def boundary_curve_from_2_points(p1, p2): # first create an edge e0 = BRepBuilderAPI_MakeEdge(p1, p2).Edge() w0 = BRepBuilderAPI_MakeWire(e0).Wire() # boundary for filling adap = BRepAdaptor_CompCurve(w0) p0_h = BRepAdaptor_HCompCurve(adap) boundary = GeomFill_SimpleBound(p0_h.GetHandle(), 1e-6, 1e-6) return boundary.GetHandle()
def wire_to_curve(wire, tolerance=TOLERANCE, order=GeomAbs_C2, max_segment=200, max_order=12): ''' a wire can consist of many edges. these edges are merged given a tolerance and a curve @param wire: ''' adap = BRepAdaptor_CompCurve(wire) hadap = BRepAdaptor_HCompCurve(adap) from OCC.Approx import Approx_Curve3d approx = Approx_Curve3d(hadap.GetHandle(), tolerance, order, max_segment, max_order) with assert_isdone(approx, 'not able to compute approximation from wire'): return approx.Curve().GetObject()