py4design.py3dmodel.calculate module¶
-
py4design.py3dmodel.calculate.
point_in_face
(pypt, occface, tolerance=0.0001)¶ This function checks if a point is inside an OCCface.
Parameters: - pypt : tuple of floats
Check if this point is inside the OCCface. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
- occface : OCCface
Check if the point is inside this OCCface.
- tolerance : float, optional
The minimum distance between the point and the face to determine if the point is inside the face. Default = 1e-04.
Returns: - True or False : bool
If True means the point is in the face, if False the point is not in the face.
-
py4design.py3dmodel.calculate.
point_in_solid
(pypt, occsolid)¶ This function checks if a point is inside an OCCsolid.
Parameters: - pypt : tuple of floats
Check if this point is inside the OCCsolid. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
- occsolid : OCCsolid
Check if the point is inside this OCCsolid.
Returns: - True, False, None : True, False, None
If True means the point is in the solid, if False the point is not in the solid, if None means the point is on the solid.
-
py4design.py3dmodel.calculate.
project_point_on_infedge
(pypt, occedge)¶ This function projects a point towards the OCCedge. The edge is treated as a vector and it stretched through infinity.
Parameters: - pypt : tuple of floats
The point to be projected. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
- occedge : OCCedge
The edge to be projected on.
Returns: - Projected point : pypt
The projected point on the edge.
-
py4design.py3dmodel.calculate.
project_point_on_faceplane
(pypt, occface)¶ This function projects a point towards the OCCface. The face is treated as a plane and it stretched through infinity.
Parameters: - pypt : tuple of floats
The point to be projected. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
- occface : OCCface
The face to be projected on.
Returns: - Projected point : pypt
The projected point on the face.
-
py4design.py3dmodel.calculate.
angle_bw_2_vecs_w_ref
(pyvec1, pyvec2, ref_pyvec)¶ This function measures the angle between two vectors regards to a reference vector. The reference vector must be perpendicular to both the vectors. The angle is measured in counter-clockwise direction.
Parameters: - pyvec1 : tuple of floats
The first vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
- pyvec2 : tuple of floats
The second vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
- ref_pyvec : tuple of floats
- The reference vector must be perpendicular to pyvec1 and pyvec2.
A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
Returns: - angle : float
The measured angle between pyvec1 and pyvec2 regards to ref_pyvec, the angle is measured in counter-clockwise direction.
-
py4design.py3dmodel.calculate.
angle_bw_2_vecs
(pyvec1, pyvec2)¶ This function measures the angle between two vectors.
Parameters: - pyvec1 : tuple of floats
The first vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
- pyvec2 : tuple of floats
The second vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
Returns: - angle : float
The measured angle between pyvec1 and pyvec2.
-
py4design.py3dmodel.calculate.
cross_product
(pyvec1, pyvec2)¶ This function measures the angle between two vectors.
Parameters: - pyvec1 : tuple of floats
The first vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
- pyvec2 : tuple of floats
The second vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
Returns: - cross product : pyvec
The cross product.
-
py4design.py3dmodel.calculate.
dot_product
(pyvec1, pyvec2)¶ This function measures the angle between two vectors.
Parameters: - pyvec1 : tuple of floats
The first vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
- pyvec2 : tuple of floats
The second vector to be measured. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
Returns: - dot product : float
The dot product.
-
py4design.py3dmodel.calculate.
distance_between_2_pts
(pypt1, pypt2)¶ This function measures the distance between two points.
Parameters: - pypt1 : tuple of floats
The first point to be measured. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
- pypt2 : tuple of floats
The second point to be measured. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
Returns: - angle : float
The measured distance between pypt1 and pypt2.
-
py4design.py3dmodel.calculate.
points_mean
(pyptlist)¶ This function calculates the mean of all points.
Parameters: - pyptlist : a list of tuples
The list of points to be checked. List of points to be converted. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
Returns: - midpt : pypt
The mean of all the points.
-
py4design.py3dmodel.calculate.
is_anticlockwise
(pyptlist, ref_pyvec)¶ This function checks if the list of points are arranged anticlockwise in regards to the ref_pyvec. The ref_pyvec must be perpendicular to the points.
Parameters: - pyptlist : a list of tuples
The list of points to be checked. List of points to be converted. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
- ref_pyvec : tuple of floats
The reference vector must be perpendicular to the list of points. A pyvec is a tuple that documents the xyz direction of a vector e.g. (x,y,z)
Returns: - True or False : bool
If True the list of points are arranged in anticlockwise manner, if False they are not.
-
py4design.py3dmodel.calculate.
is_collinear
(pyptlist)¶ This function checks if the list of points are collinear.
Parameters: - pyptlist : a list of tuples
The list of points to be checked. List of points to be converted. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
Returns: - True or False : bool
If True the list of points are collinear.
-
py4design.py3dmodel.calculate.
is_coplanar
(pyptlist)¶ This function checks if the list of points are coplanar.
Parameters: - pyptlist : a list of tuples
The list of points to be checked. List of points to be converted. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z), thus a pyptlist is a list of tuples e.g. [(x1,y1,z1), (x2,y2,z2), …]
Returns: - True or False : bool
If True the list of points are coplanar.
-
py4design.py3dmodel.calculate.
edge_midpt
(occedge)¶ This function calcuates the midpoint of an OCCedge.
Parameters: - occedge : OCCedge
The edge to be analysed.
Returns: - midpoint : pypt
The midpoint of the edge.
-
py4design.py3dmodel.calculate.
project_edge_on_face
(occedge, occface)¶ This function projects an OCCedge towards the OCCface. #TODO: figure out if it is a faceplane or just the face.
Parameters: - occedge : OCCedge
The edge to be projected.
- occface : OCCface
The face to be projected on.
Returns: - Projected edge : OCCedge
The projected edge on the face.
-
py4design.py3dmodel.calculate.
intersect_edge_with_edge
(occedge1, occedge2, tolerance=1e-06)¶ This function intersects two OCCedges and obtain a list of intersection points.
Parameters: - occedge1 : OCCedge
The first edge to be intersected.
- occedge2 : OCCedge
The second edge to be intersected.
- tolerance : float, optional
The minimum distance between the two edges to determine if the edges are intersecting, Default = 1e-06.
Returns: - list of intersection points : pyptlist
The list of points where the two edges intersect.
-
py4design.py3dmodel.calculate.
edge_common_vertex
(occedge1, occedge2)¶ This function checks if two OCCedges have common vertices.
Parameters: - occedge1 : OCCedge
The first edge to be analysed.
- occedge2 : OCCedge
The second edge to be analysed.
Returns: - list of common points : pyptlist
The list of common points between the two edges.
-
py4design.py3dmodel.calculate.
intersect_edge_with_face
(occedge, occface, tolerance=0.01)¶ This function intersects an OCCedge with an OCCface and obtain a list of intersection points.
Parameters: - occedge : OCCedge
The edge to be intersected.
- occface : OCCface
The face to be intersected.
- tolerance : float, optional
The minimum distance between the edge and face to determine if the they are intersecting, Default = 1e-02.
Returns: - list of intersection points : pyptlist
The list of points where the two topologies intersect.
-
py4design.py3dmodel.calculate.
pt2edgeparameter
(pypt, occedge)¶ This function calculates the parameter of the OCCedge from the given point. The length of the edge can be calculated by specifying two parameters in the edgelength function.
Parameters: - pypt : tuple of floats
The point on the OCCedge to be converted to the parameter. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z).
- occedge : OCCedge
The edge to be analysed.
Returns: - parameter : float
The parameter of the point on the OCCedge.
-
py4design.py3dmodel.calculate.
edgeparameter2pt
(parameter, occedge)¶ This function calculates the point on the OCCedge from the given parameter.
Parameters: - parameter : float
The parameter of the OCCedge.
- occedge : OCCedge
The edge to be analysed.
Returns: - point on edge : pypt
The point on the edge based on the parameter.
-
py4design.py3dmodel.calculate.
edgelength
(lbound, ubound, occedge)¶ This function calculates the length of the OCCedge between the lower and upper bound.
Parameters: - lbound : float
The lower bound of the OCCedge.
- ubound : float
The upper bound of the OCCedge.
- occedge : OCCedge
The edge to be analysed.
Returns: - length : float
The length of the edge between the upper and lower bound.
-
py4design.py3dmodel.calculate.
are_same_edges
(occedge1, occedge2)¶ This function checks if the two OCCedges are the same.
Parameters: - occedge1 : OCCedge
The first edge to be analysed.
- occedge2 : OCCedge
The second edge to be analysed.
Returns: - True or False : bool
If True the two edges are the same, if False the two edges are not the same.
-
py4design.py3dmodel.calculate.
sort_edges_into_order
(occedge_list, isclosed=False)¶ This function creates a list of ordered OCCedges from a list of loose OCCedges. The edges does not need to form a close face.
Parameters: - occedge_list : list of OCCedges
The list of OCCedges to be sorted.
- isclosed : bool, optional
True or False, is the resultant wires suppose to be closed or opened, Default = False.
Returns: - list of sorted edges : list of OCCedges
A list of ordered OCCedges.
-
py4design.py3dmodel.calculate.
identify_open_close_wires_frm_loose_edges
(occedge_list)¶ This function rearranged the list of OCCedges and categorise them into two lists of open and closed OCCwires.
Parameters: - occedge_list : list of OCCedges
The list of OCCedges to be sorted.
Returns: - list of closed wires : list of OCCwires
A list of closed OCCwires from the loose OCCedges.
- list of opened wires : list of OCCwires
A list of opened OCCwires from the loose OCCedges.
-
py4design.py3dmodel.calculate.
is_wire_closed
(occwire)¶ This function checks if an OCCwire is closed.
Parameters: - occwire : OCCwire
The OCCwire to be checked.
Returns: - True or False : bool
If True wire is closed, if False wire is opened.
-
py4design.py3dmodel.calculate.
wirelength
(occwire)¶ This function measures the length of the OCCwire.
Parameters: - occwire : OCCwire
The OCCwire to be measured.
Returns: - length of wire : float
The lenght of the wire.
-
py4design.py3dmodel.calculate.
face_normal
(occface)¶ This function calculates the normal of the OCCface.
Parameters: - occface : OCCface
The OCCface to be analysed.
Returns: - face normal : pydirection
The normal of the face. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)
-
py4design.py3dmodel.calculate.
face_area
(occface)¶ This function calculates the area of the OCCface.
Parameters: - occface : OCCface
The OCCface to be analysed.
Returns: - face area : float
The area of the face.
-
py4design.py3dmodel.calculate.
face_midpt
(occface)¶ This function calculates the mid point of the OCCface.
Parameters: - occface : OCCface
The OCCface to be analysed.
Returns: - face mid point : pypt
The mid point of the face.
-
py4design.py3dmodel.calculate.
is_face_planar
(occface, tolerance=1e-06)¶ This function calculates if the OCCface is planar.
Parameters: - occface : OCCface
The OCCface to be analysed.
- tolerance : float, optional
The precision for checking the planarity, Default = 1e-06.
Returns: - True or False : bool
If True face is planar, if False face is not planar.
-
py4design.py3dmodel.calculate.
face_is_inside
(occface, boundary_occface)¶ This function calculates if OCCface is inside boundary OCCface.
Parameters: - occface : OCCface
The OCCface to be analysed.
- boundary_occface : OCCface
Check if occface is inside the boundary_occface.
Returns: - True or False : bool
If True face is inside boundary face, if False face is not inside boundary face.
-
py4design.py3dmodel.calculate.
project_face_on_faceplane
(occface2projon, occface2proj)¶ This function projects the OCCface onto another OCCface plane. The plane stretches through infinity.
Parameters: - occface2projon : OCCface
The OCCface to be projected on.
- occface2proj : OCCface
The OCCface to be projected.
Returns: - list of points : pyptlist
The list of projected points.
-
py4design.py3dmodel.calculate.
srf_nrml_facing_solid_inward
(occface, occsolid)¶ This function checks if the OCCface is facing the inside of the OCCsolid.
Parameters: - occface : OCCface
The OCCface to be checked.
- occsolid : OCCsolid
The OCCsolid.
Returns: - True or False : bool
If True the face is facing the inside of the solid, if False the face is not facing inwards.
-
py4design.py3dmodel.calculate.
are_same_faces
(occface1, occface2)¶ This function checks if the two OCCfaces are the same.
Parameters: - occface1 : OCCface
The first OCCface to be checked.
- occface2 : OCCface
The second OCCface to be checked.
Returns: - True or False : bool
If True the faces are the same, if False the faces are not the same.
-
py4design.py3dmodel.calculate.
face_normal_as_edges
(occface_list, normal_magnitude=1)¶ This function calculates the normals of the list of OCCfaces and construct a list of OCCedges from it.
Parameters: - occface_list : list of OCCfaces
The list of OCCfaces to be analysed.
- normal_magnitude : float, optional
The length of the normal OCCedges, Default = 1.
Returns: - list of normals : list of OCCedges
List of OCCedges.
-
py4design.py3dmodel.calculate.
grp_faces_acc2normals
(occface_list)¶ This function groups the list of OCCfaces according to their normals.
Parameters: - occface_list : list of OCCfaces
The list of OCCfaces to be analysed.
Returns: - dictionary of faces according to their normals : dictionary of OCCfaces
The normals are the keys of the dictionary. e.g. to obtain all the OCCfaces that have normals (0,0,1), dictionar[ (0,0,1)]
-
py4design.py3dmodel.calculate.
is_shell_closed
(occshell)¶ This function calculates if the OCCshell is closed.
Parameters: - occshell : OCCshell
The OCCshell to be analysed.
Returns: - True or False : bool
If True OCCshell is closed, if False OCCshell is not closed.
-
py4design.py3dmodel.calculate.
solid_volume
(occsolid)¶ This function calculates the volume of the OCCsolid.
Parameters: - occsolid : OCCsolid
The OCCsolid to be analysed.
Returns: - volume : float
The volume of the solid.
-
py4design.py3dmodel.calculate.
check_solid_inward
(occsolid)¶ This function checks if all the OCCfaces of the OCCsolids is facing inwards.
Parameters: - occsolid : OCCsolid
The OCCsolid to be analysed.
Returns: - True or False : bool
If True OCCsolid is facing inwards, if False OCCsolid is not facing inwards.
-
py4design.py3dmodel.calculate.
get_bounding_box
(occtopology)¶ This function calculates the bounding box of the OCCtopology.
Parameters: - occtopology : OCCtopology
The OCCtopology to be analysed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
Returns: - xmin : float
Minimum X-coordinate
- ymin : float
Minimum Y-coordinate
- zmin : float
Minimum Z-coordinate
- xmax : float
Maximum X-coordinate
- ymax : float
Maximum Y-coordinate
- zmax : float
Maximum Z-coordinate
-
py4design.py3dmodel.calculate.
get_centre_bbox
(occtopology)¶ This function calculates the centre of the bounding box of the OCCtopology.
Parameters: - occtopology : OCCtopology
The OCCtopology to be analysed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
Returns: - centre point : pypt
The centre point of the OCCtopology’s bounding box.
-
py4design.py3dmodel.calculate.
minimum_distance
(occtopology1, occtopology2)¶ This function calculates the minimum distance between the two OCCtopologies.
Parameters: - occtopology1 : OCCtopology
The OCCtopology to be analysed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- occtopology2 : OCCtopology
The OCCtopology to be analysed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
Returns: - minimum distance : float
The minimum distance between the two topologies.
-
py4design.py3dmodel.calculate.
project_shape_on_shape
(occtopo_proj, occtopo_projon, tolerance=1e-06)¶ This function project the occtopoproj (OCCtopology) onto the occtopoprojon (OCCtopology), and returns the list of projected points.
Parameters: - occtopo_proj : OCCtopology
The OCCtopology to to project. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- occtopo_projon : OCCtopology
The OCCtopology to be projected on. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- tolerance : float, optional
The precision of the projection, Default = 1e-06.
Returns: - list of projected points : pyptlist
The list of projected points.
-
py4design.py3dmodel.calculate.
intersect_shape_with_ptdir
(occtopology, pypt, pydir)¶ This function projects a point in a direction and calculates the at which point does the point intersects the OCCtopology.
Parameters: - occtopology : OCCtopology
The OCCtopology to be projected on. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex
- pypt : tuple of floats
The point to be projected. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
- pydir : tuple of floats
The direction of the point to be projected. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z)
Returns: - intersection point : pypt
The point in which the projected point intersect the OCCtopology. If None means there is no intersection.
- intersection face : OCCface
The OCCface in which the projected point hits. If None means there is no intersection.
-
py4design.py3dmodel.calculate.
cs_transformation
(occ_gpax3_1, occ_gpax3_2)¶ This function maps a OCC coordinate system (occ_gpax3) to another OCC coordinate system (occ_gpax3).
Parameters: - occ_gpax3_1 : gp_Ax3
The coordinate system to be mapped.
- occ_gpax3_2 : gp_Ax3
The coordinate system to be mapped onto.
Returns: - transformation : gp_Trsf
The transformation for the mapping.