def 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. """ gppnt1 = construct.make_gppnt(pypt1) gppnt2 = construct.make_gppnt(pypt2) trimmed = Construct.trim_wire(occwire, gppnt1, gppnt2, periodic= is_periodic ) return trimmed
def 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. """ gppnt1 = construct.make_gppnt(pypt1) gppnt2 = construct.make_gppnt(pypt2) trimmed = Construct.trim_wire(occwire, gppnt1, gppnt2, periodic=is_periodic) return trimmed
def 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. """ xform = gp_Trsf() gp_pnt = construct.make_gppnt(ref_pypt) xform.SetScale(gp_pnt, scale_factor) brep = BRepBuilderAPI_Transform(xform) brep.Perform(occtopology, True) trsfshape = brep.Shape() return trsfshape
def 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. """ occutil_edge = edge.Edge(occedge) gppt = construct.make_gppnt(pypt) parameter, nearest_gppt = occutil_edge.project_vertex(gppt) return parameter
def pt2edgeparameter(pypt, occedge): occutil_edge = edge.Edge(occedge) gppt = construct.make_gppnt(pypt) parameter, nearest_gppt = occutil_edge.project_vertex(gppt) return parameter