py4design.py3dmodel.utility module¶
-
py4design.py3dmodel.utility.
generate_falsecolour_bar
(minval, maxval, unit_str, bar_length, description_str=None, bar_pos=(0, 0, 0))¶ This function constructs a falsecolour diagram.
Parameters: - minval : float
The minimum value of the falsecolour bar.
- maxval : float
The maximum value of the falsecolour bar.
- unit_str : str
The string of the unit to be displayed on the bar.
- bar_length : float
The length of the falsecolour bar.
- description_str : str, optional
Description for the falsecolour bar, Default = None.
- bar_pos : tuple of floats, optional
The position of the bar, Default = (0,0,0).
Returns: - falsecolour bar : list of OCCfaces
The falsecolor bar which is a list of OCCfaces.
- bar colour : list of tuple of floats
Each tuple is a r,g,b that is specifying the colour of the bar.
- geometries of text: OCCcompound
The geometries of the text.
- str_colour_list : list of tuple of floats
Each tuple is a r,g,b that is specifying the colour of the string.
- value of each falsecolour : list of floats
The value of each falsecolour.
-
py4design.py3dmodel.utility.
pseudocolor
(val, minval, maxval)¶ This function converts a value into a rgb value with reference to the minimum and maximum value.
Parameters: - val : float
The value to be converted into rgb.
- minval : float
The minimum value of the falsecolour rgb.
- maxval : float
The maximum value of the falsecolour rgb.
Returns: - rgb value : tuple of floats
The converted rgb value.
-
py4design.py3dmodel.utility.
falsecolour
(vals, minval, maxval)¶ This function converts a list of values into a list of rgb values with reference to the minimum and maximum value.
Parameters: - vals : list of float
A list of values to be converted into rgb.
- minval : float
The minimum value of the falsecolour rgb.
- maxval : float
The maximum value of the falsecolour rgb.
Returns: - rgb value : list of tuple of floats
The converted list of rgb value.
-
py4design.py3dmodel.utility.
rgb2val
(rgb, minval, maxval)¶ This function converts a rgb of value into its original value with reference to the minimum and maximum value.
Parameters: - rgb : tuple of floats
The rgb value to be converted.
- minval : float
The minimum value of the falsecolour rgb.
- maxval : float
The maximum value of the falsecolour rgb.
Returns: - original value : float
The orignal float value.
-
py4design.py3dmodel.utility.
visualise_falsecolour_topo
(occtopo_list, results, other_occtopo_2dlist=None, other_colour_list=None, minval=None, maxval=None, backend='qt-pyqt5')¶ This function visualise a falsecolour 3D model using the PythonOCC viewer.
Parameters: - occtopo_list : list of OCCtopologies
The geometries to be visualised with the results. The list of geometries must correspond to the list of results. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- results : list of floats
The results to be visualised. The list of results must correspond to the occtopo_list.
- other_occtopo_2dlist : 2d list of OCCtopologies, optional
Other geometries to be visualised together with the results, Default = None.
- other_colour_list : list of str, optional
The colours of the other_topo2dlist, Default = None. The colour strings include: “WHITE”, “BLUE”, “RED”, “GREEN”, “YELLOW”, “CYAN”, “BLACK”, “ORANGE”. The number of colours must correspond to the number of list in the other_topo2dlist.
- minval : float, optional
The minimum value of the falsecolour rgb, Default = None. If None the maximum value is equal to the maximum value from the results.
- maxval : float, optional
The maximum value of the falsecolour rgb, Default = None. If None the maximum value is equal to the minimum value from the results.
- backend : str, optional
The graphic interface to use for visualisation, Default = qt-pyqt5. Other options include:”qt-pyqt4”, “qt-pyside”, “wx”
Returns: - None : None
A qt window pops up displaying the geometries.
-
py4design.py3dmodel.utility.
visualise
(occtopo_2dlist, colour_list=None, backend='qt-pyqt5')¶ This function visualise a 3D model using the PythonOCC viewer.
Parameters: - occtopo_2dlist : 2d list of OCCtopologies
Geometries to be visualised together with the results. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- colour_list : list of str, optional
The colours of the occtopo_2dlist, Default = None. If None all the geometries are displayed in white. The colour strings include: “WHITE”, “BLUE”, “RED”, “GREEN”, “YELLOW”, “CYAN”, “BLACK”, “ORANGE”. The number of colours must correspond to the number of list in the other_topo2dlist.
- backend : str, optional
The graphic interface to use for visualisation, Default = qt-pyqt5. Other options include:”qt-pyqt4”, “qt-pyside”, “wx”
Returns: - None : None
A qt window pops up displaying the geometries.
-
py4design.py3dmodel.utility.
write_2_stl
(occtopology, stl_filepath, linear_deflection=0.8, angle_deflection=0.5)¶ This function writes a 3D model into STL format.
Parameters: - occtopology : OCCtopology
Geometries to be written into STL. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- stl_filepath : str
The file path of the STL file.
- mesh_incremental_float : float, optional
Default = 0.8.
Returns: - None : None
The geometries are written to a STL file.
-
py4design.py3dmodel.utility.
write_2_stl2
(occtopology, stl_filepath, is_meshed=True, linear_deflection=0.8, angle_deflection=0.5)¶ This function writes a 3D model into STL format. This is different from write2stl as it uses the numpy-stl library.
Parameters: - occtopology : OCCtopology
Geometries to be written into STL. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- stl_filepath : str
The file path of the STL file.
- mesh_incremental_float : float, optional
Default = 0.8.
Returns: - None : None
The geometries are written to a STL file.
-
py4design.py3dmodel.utility.
read_stl
(stl_filepath)¶ This function reads STL format.
Parameters: - stl_filepath : str
The file path of the STL file.
Returns: - occtopology : OCCtopology
The geometries from an STL file.
-
py4design.py3dmodel.utility.
write_brep
(occtopology, brep_filepath)¶ This function writes a 3D model into brep format.
Parameters: - occtopology : OCCtopology
Geometries to be written into STL. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- brep_filepath : str
The file path of the brep file.
Returns: - None : None
The geometries are written to a brep file.
-
py4design.py3dmodel.utility.
read_brep
(brep_filepath)¶ This function writes a 3D model into brep format.
Parameters: - brep_filepath : str
The file path of the brep file.
Returns: - occtopology : OCCtopology
Geometries read from the brep. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
-
py4design.py3dmodel.utility.
write_2_stl_gmsh
(occtopology, stl_filepath, mesh_dim=2, min_length=1, max_length=5, gmsh_location='C:\\gmsh\\gmsh.exe')¶ This function mesh an occtopology using gmsh http://gmsh.info/.
Parameters: - occtopology : OCCtopology
Geometries to be written into STL. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- stl_filepath : str
The file path of the STL file.
- mesh_dim : int, optional
Perform 1D, 2D or 3D mesh generation.
- min_length : float, optional
The minimum edge length of the mesh.
- max_length : float, optional
The max edge length of the mesh.
- gmsh_location : str
The location where the gmsh program is located. We assumed it is isntalled in C:gmshgmsh.exe
Returns: - None : None
The geometries are meshed and written to a stl file.