py4design.py3dmodel.modify module

py4design.py3dmodel.modify.occpt_2_pypt(occpt)

This function constructs a point (pypt) from an OCC point (gp_pnt).

Parameters:
occpt : OCC point (gp_pnt)

OCC point (gp_pnt) to be converted to a pypt.

Returns:
point : pypt

A pypt constructed from the OCC point (gp_pnt).

py4design.py3dmodel.modify.occpt_list_2_pyptlist(occpt_list)

This function constructs a list of points (pyptlist) from a list of OCC points (gp_pnt).

Parameters:
occpt_list : list of OCC points (gp_pnt)

list of OCC points (gp_pnt) to be converted to a pyptlist.

Returns:
list of points : pyptlist

A pyptlist constructed from the list of OCC points (gp_pnt).

py4design.py3dmodel.modify.occvertex_2_occpt(occvertex)

This function constructs an OCC point (gp_pnt) from an OCCvertex.

Parameters:
occvertex : OCCvertex

OCCvertex to be converted to a OCC point (gp_pnt).

Returns:
point : OCC point (gp_pnt)

An OCC point constructed from the OCCvertex.

py4design.py3dmodel.modify.occvertex_list_2_occpt_list(occvertex_list)

This function constructs a list of OCC points (gp_pnt) from a list of OCCvertices.

Parameters:
occvertex_list : list of OCCvertices

List of OCCvertices to be converted to a list of OCC points (gp_pnt).

Returns:
list of points : list of OCC points (gp_pnt)

A list of OCC points (gp_pnt) constructed from the list of OCCvertices.

py4design.py3dmodel.modify.gpvec_2_pyvec(gpvec)

This function construct a pyvec from a OCC vector (gp_vec).

Parameters:
gpvec : gp_vec

OCCvector to be converted.

Returns:
normalised vector : pyvec

Tuple of floats. A pyvec is a tuple that documents the xyz vector of a dir e.g. (x,y,z).

py4design.py3dmodel.modify.normalise_vec(gpvec)

This function normalises a OCC vector (gp_vec).

Parameters:
gpvec : gp_vec

OCCvector to be normalised.

Returns:
normalised vector : pyvec

Tuple of floats. A pyvec is a tuple that documents the xyz vector of a dir e.g. (x,y,z).

py4design.py3dmodel.modify.reverse_vector(pyvec)

This function reverses a vector.

Parameters:
pyvec : tuple of floats

A pyvec is a tuple that documents the xyz vector of a dir e.g. (x,y,z).

Returns:
reversed vector : pyvec

Tuple of floats. A pyvec is a tuple that documents the xyz vector of a dir e.g. (x,y,z).

py4design.py3dmodel.modify.move_pt(orig_pypt, pydir2move, magnitude)

This function moves a point.

Parameters:
orig_pypt : tuple of floats

The original point to be moved. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

pydir2move : tuple of floats

The direction to move the point. A pydir is a tuple that documents the xyz vector of a dir e.g. (x,y,z).

magnitude : float

The distance of the move.

Returns:
moved point : pypt

The moved point.

py4design.py3dmodel.modify.round_pypt(pypt, roundndigit)

This function rounds a point according to the roundndigit input.

Parameters:
pypt : tuple of floats

The point to be rounded. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z).

roundndigit : int

The number of decimal place the points will be rounded to.

Returns:
rounded point : pypt

The rounded point.

py4design.py3dmodel.modify.round_pyptlist(pyptlist, roundndigit)

This function rounds a list of points according to the roundndigit input.

Parameters:
pyptlist : a list of tuples

List of points to be rounded. 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), …]

roundndigit : int

The number of decimal place the points will be rounded to.

Returns:
list of rounded points : pyptlist

The list of rounded points.

py4design.py3dmodel.modify.rmv_duplicated_pts_by_distance(pyptlist, distance=1e-06)

This function fuses all the points within a certain distance.

Parameters:
pyptlist : a list of tuples

List of points to be fused. 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), …]

distance : float, optional

The minimal distance between two points, default = 1e-06. Any points closer than this distance will be fused.

Returns:
list of fused points : pyptlist

The list of fused points.

py4design.py3dmodel.modify.rmv_duplicated_pts(pyptlist, roundndigit=None)

This function removes duplicated points.

Parameters:
pyptlist : a list of tuples

List of points to be analysed. 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), …]

roundndigit : int, optional

The number of decimal place the points will be rounded to. Default= None

Returns:
list of fused points : pyptlist

The list of fused points.

py4design.py3dmodel.modify.rmv_duplicated_edges(occedge_list)

This function removes duplicated OCCedges.

Parameters:
occedge_list : a list of OCCedges

The list of OCCedges to be analysed.

Returns:
list of non-duplicated edges : list of OCCedges

The list of non-duplicated OCCedges.

py4design.py3dmodel.modify.trimedge(lbound, ubound, occedge)

This function trims the OCCedge according to the specified 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 trimmed.

Returns:
trimmed edge : OCCedge

The trimmed OCCedge.

py4design.py3dmodel.modify.flatten_edge_z_value(occedge, z=0)

This function flattens the Z-dimension of the OCCedge.

Parameters:
occedge : OCCedge

The edge to be flatten.

z : float, optional

The Z-value to flatten to. Default = 0.

Returns:
flatten edge : OCCedge

The flatten OCCedge.

py4design.py3dmodel.modify.fix_closed_wire(occwire, occface, tolerance=1e-06)

This function will try to closed an open wire.

Parameters:
occwire : OCCwire

The OCCwire to be fixed.

occface : OCCface

The reference OCCface used for closing the OCCwire.

tolerance : float, optional

The precision for the fix, Default = 1e-06.

Returns:
fixed wire : OCCwire

The fixed OCCwire.

py4design.py3dmodel.modify.trim_wire(occwire, pypt1, pypt2, is_periodic=False)

This function trims the wire.

Parameters:
occwire : OCCwire

The OCCwire to be fixed.

pypt1 : tuple of floats

The starting point of the trim. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

pypt2 : tuple of floats

The ending point of the trim. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

is_periodic : bool, optional

Indicates if the wire is open or close, True for close, False for open, Default = False.

Returns:
trimmed wire : OCCwire

The trimmed OCCwire.

py4design.py3dmodel.modify.wire_2_bsplinecurve_edge(occwire)

This function covnerts an OCCwire to a bspline OCCedge.

Parameters:
occwire : OCCwire

The OCCwire to be converted.

Returns:
converted bspline edge : OCCedge

The converted OCCedge.

py4design.py3dmodel.modify.resample_wire(occwire)

This function resamples an OCCwire uniformly.

Parameters:
occwire : OCCwire

The OCCwire to be resampled.

Returns:
resampled wire : OCCwire

The resampled OCCwire.

py4design.py3dmodel.modify.reverse_face(occface)

This function reverse an OCCface orientation.

Parameters:
occface : OCCface

The OCCface to be reversed.

Returns:
reversed face : OCCface

The reverse OCCface.

py4design.py3dmodel.modify.fix_face(occ_face)

This function fixes an OCCface.

Parameters:
occface : OCCface

The OCCface to be fixed.

Returns:
fixed face : OCCface

The fixed OCCface.

py4design.py3dmodel.modify.rmv_duplicated_faces(occface_list)

This function removes duplicated faces from a list of OCCfaces.

Parameters:
occface_list : list of OCCfaces

The list of OCCfaces to be analysed.

Returns:
non-duplicated list of faces : list of OCCfaces

The list of non-duplicated OCCfaces.

py4design.py3dmodel.modify.flatten_face_z_value(occface, z=0)

This function flatten the OCCface to the Z-value specified.

Parameters:
occface : OCCface

The OCCface to be flatten.

z : float, optional

The Z-value to flatten to. Default = 0.

Returns:
flatten face : OCCface

The flatten OCCface.

py4design.py3dmodel.modify.sort_face_by_xy(occface_list)

This function sorts the faces in order of the xy direction.

Parameters:
occface_list : list of OCCfaces

The list of OCCfaces to be sorted.

Returns:
sorted list of faces : list of OCCfaces

The list of sorted OCCfaces in xy direction.

py4design.py3dmodel.modify.fix_shell_orientation(occshell)

This function fixes the OCCshell orientation. The fix will orientate all the OCCfaces in the shell towards the same direction.

Parameters:
occshell : OCCshell

The OCCshell to be fixed.

Returns:
fixed shell : OCCshell

The fixed OCCshell.

py4design.py3dmodel.modify.flatten_shell_z_value(occshell, z=0)

This function flatten the OCCshell to the Z-value specified.

Parameters:
occshell : OCCshell

The OCCshell to be flattened.

z : float, optional

The Z-value to flatten to. Default = 0.

Returns:
flatten shell : OCCshell

The flatten OCCshell.

py4design.py3dmodel.modify.simplify_shell(occshell, tolerance=1e-06)

This function simplifies the OCCshell by merging all the coincidental OCCfaces in the shell into a single OCCface.

Parameters:
occshell : OCCshell

The OCCshell to be simplified.

tolerance : float, optional

The precision of the simplification, Default = 1e-06.

Returns:
simplified shell : OCCshell

The simplified OCCshell.

py4design.py3dmodel.modify.fix_close_solid(occsolid)

This function fixes an OCCsolid by making sure all the OCCfaces in the solid have an outward orientation.

Parameters:
occsolid : OCCsolid

The OCCsolid to be fixed.

Returns:
fixed solid : OCCsolid

The fixed OCCsolid. If None it means the solid is not fixed.

py4design.py3dmodel.modify.move(orig_pypt, location_pypt, occtopology)

This function moves an OCCtopology from the orig_pypt to the location_pypt.

Parameters:
orig_pypt : tuple of floats

The OCCtopology will move in reference to this point. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

location_pypt : tuple of floats

The destination of where the OCCtopology will be moved in relation to the orig_pypt. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

occtopology : OCCtopology

The OCCtopology to be moved. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
moved topology : OCCtopology (OCCshape)

The moved OCCtopology.

py4design.py3dmodel.modify.map_cs(occgp_ax3_1, occgp_ax3_2, occtopology)

This function maps an OCCtopology from one OCC coordinate sytem to another.

Parameters:
occgp_ax3_1 : gp_ax3

The destination OCC coordinate system, OCC coordinate system can be created using construct.make_gp_ax3 function.

occgp_ax3_2 : gp_ax3

The original OCC coordinate system, OCC coordinate system can be created using construct.make_gp_ax3 function.

occtopology : OCCtopology

The OCCtopology to be mapped. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
mapped topology : OCCtopology (OCCshape)

The mapped OCCtopology.

py4design.py3dmodel.modify.rotate(occtopology, rot_pypt, pyaxis, degree)

This function rotates an OCCtopology based on the rotation point, an axis and the rotation degree.

Parameters:
occtopology : OCCtopology

The OCCtopology to be rotated. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

rot_pypt : tuple of floats

The OCCtopology will rotate in reference to this point. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

pyaxis : tuple of floats

The OCCtopology will rotate along this axis. A pyaxis is a tuple that documents the xyz of a direction e.g. (x,y,z)

degree : float

The degree of rotation.

Returns:
rotated topology : OCCtopology (OCCshape)

The rotated OCCtopology.

py4design.py3dmodel.modify.uniform_scale(occtopology, tx, ty, tz, ref_pypt)

This function uniformly scales an OCCtopology based on the reference point and tx,ty,tz factors.

Parameters:
occtopology : OCCtopology

The OCCtopology to be scaled. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

tx : float

The scale factor in the X-axis.

ty : float

The scale factor in the Y-axis.

tz : float

The scale factor in the Z-axis.

ref_pypt : tuple of floats

The OCCtopology will scale in reference to this point. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

Returns:
scaled topology : OCCtopology (OCCshape)

The scaled OCCtopology.

py4design.py3dmodel.modify.scale(occtopology, scale_factor, ref_pypt)

This function uniformly scales an OCCtopology based on the reference point and the scale factor.

Parameters:
occtopology : OCCtopology

The OCCtopology to be scaled. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

scale_factor : float

The scale factor.

ref_pypt : tuple of floats

The OCCtopology will scale in reference to this point. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)

Returns:
scaled topology : OCCtopology (OCCshape)

The scaled OCCtopology.

py4design.py3dmodel.modify.fix_shape(occtopology)

This function fixes an OCCtopology.

Parameters:
occtopology : OCCtopology

The OCCtopology to be fixed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex

Returns:
fixed topology : OCCtopology (OCCshape)

The fixed OCCtopology.