def pipe(): # the bspline path, must be a wire array2 = TColgp_Array1OfPnt(1, 3) array2.SetValue(1, gp_Pnt(0, 0, 0)) array2.SetValue(2, gp_Pnt(0, 1, 2)) array2.SetValue(3, gp_Pnt(0, 2, 3)) bspline2 = GeomAPI_PointsToBSpline(array2).Curve() path_edge = BRepBuilderAPI_MakeEdge(bspline2).Edge() path_wire = BRepBuilderAPI_MakeWire(path_edge).Wire() # the bspline profile. Profile mist be a wire array = TColgp_Array1OfPnt(1, 5) array.SetValue(1, gp_Pnt(0, 0, 0)) array.SetValue(2, gp_Pnt(1, 2, 0)) array.SetValue(3, gp_Pnt(2, 3, 0)) array.SetValue(4, gp_Pnt(4, 3, 0)) array.SetValue(5, gp_Pnt(5, 5, 0)) bspline = GeomAPI_PointsToBSpline(array).Curve() profile_edge = BRepBuilderAPI_MakeEdge(bspline).Edge() # pipe pipe = BRepOffsetAPI_MakePipe(path_wire, profile_edge).Shape() display.DisplayShape(profile_edge, color='WHITE', update=False) display.DisplayShape(path_wire, color='BLUE', update=False) display.DisplayShape(pipe, update=True)
def create_shape(self): data = self.element.attrib.get('d') shapes = [] path = None for cmd, params in self.parse_path(data): if cmd == 'M': if path is not None: shapes.append(path.Wire()) path = BRepBuilderAPI_MakeWire() last_pnt = gp_Pnt(params[0], params[1], 0) start_pnt = last_pnt elif cmd in ['L', 'H', 'V']: pnt = gp_Pnt(params[0], params[1], 0) path.Add(BRepBuilderAPI_MakeEdge(last_pnt, pnt).Edge()) last_pnt = pnt elif cmd == 'Q': # Quadratic Bezier pts = TColgp_Array1OfPnt(1, 3) pts.SetValue(1, last_pnt) pts.SetValue(2, gp_Pnt(params[0], params[1], 0)) last_pnt = gp_Pnt(params[2], params[3], 0) pts.SetValue(3, last_pnt) curve = Geom_BezierCurve(pts) path.Add(BRepBuilderAPI_MakeEdge(curve.GetHandle()).Edge()) elif cmd == 'C': # Cubic Bezier pts = TColgp_Array1OfPnt(1, 4) pts.SetValue(1, last_pnt) pts.SetValue(2, gp_Pnt(params[0], params[1], 0)) pts.SetValue(3, gp_Pnt(params[2], params[3], 0)) last_pnt = gp_Pnt(params[4], params[5], 0) pts.SetValue(4, last_pnt) curve = Geom_BezierCurve(pts) path.Add(BRepBuilderAPI_MakeEdge(curve.GetHandle()).Edge()) elif cmd == 'A': # Warning: Play at your own risk! x1, y1 = last_pnt.X(), last_pnt.Y() rx, ry, phi, large_arc_flag, sweep_flag, x2, y2 = params phi = radians(phi) pnt = gp_Pnt(x2, y2, 0) cx, cy, rx, ry = compute_arc_center( x1, y1, rx, ry, phi, large_arc_flag, sweep_flag, x2, y2) z_dir = Z_DIR if sweep_flag else NEG_Z_DIR # sweep_flag c = make_ellipse((cx, cy, 0), rx, ry, phi, z_dir) curve = GC_MakeArcOfEllipse(c, last_pnt, pnt, True).Value() path.Add(BRepBuilderAPI_MakeEdge(curve).Edge()) last_pnt = pnt elif cmd == 'Z': path.Add(BRepBuilderAPI_MakeEdge(last_pnt, start_pnt).Edge()) shapes.append(path.Wire()) path = None # Close path last_pnt = start_pnt if path is not None: shapes.append(path.Wire()) return shapes
def prism(): # the bspline profile array = TColgp_Array1OfPnt(1, 5) array.SetValue(1, gp_Pnt(0, 0, 0)) array.SetValue(2, gp_Pnt(1, 2, 0)) array.SetValue(3, gp_Pnt(2, 3, 0)) array.SetValue(4, gp_Pnt(4, 3, 0)) array.SetValue(5, gp_Pnt(5, 5, 0)) bspline = GeomAPI_PointsToBSpline(array).Curve() profile = BRepBuilderAPI_MakeEdge(bspline).Edge() # the linear path starting_point = gp_Pnt(0., 0., 0.) end_point = gp_Pnt(0., 0., 6.) vec = gp_Vec(starting_point, end_point) path = BRepBuilderAPI_MakeEdge(starting_point, end_point).Edge() # extrusion prism = BRepPrimAPI_MakePrism(profile, vec).Shape() display.DisplayShape(profile, update=False) display.DisplayShape(starting_point, update=False) display.DisplayShape(end_point, update=False) display.DisplayShape(path, update=False) display.DisplayShape(prism, update=True)
def DisplayG01Line(coor1, coor2): array = TColgp_Array1OfPnt(1, 2) array.SetValue(1, gp_Pnt(coor1[0], coor1[1], coor1[2])) array.SetValue(2, gp_Pnt(coor2[0], coor2[1], coor2[2])) bspline2 = GeomAPI_PointsToBSpline(array).Curve() path_edge = BRepBuilderAPI_MakeEdge(bspline2).Edge() display.DisplayColoredShape(path_edge, 'GREEN')
def add_to_wire(self, points, wire): array=TColgp_Array1OfPnt(1, len(points)) for i in range(len(points)): array.SetValue(i+1, points[i]) curve = Geom_BezierCurve(array) me = BRepBuilderAPI_MakeEdge(curve.GetHandle()) wire.Add(me.Edge())
def create_shape(self): d = self.declaration pts = TColgp_Array1OfPnt(1, len(d.points)) set_value = pts.SetValue # TODO: Support weights for i, p in enumerate(d.points): set_value(i + 1, gp_Pnt(*p)) self.shape = Geom_BezierCurve(pts)
def make_bspline_edge(pyptlist, mindegree=3, maxdegree=8): array = TColgp_Array1OfPnt(1, len(pyptlist)) pcnt = 1 for pypt in pyptlist: gppt = make_gppnt(pypt) array.SetValue(pcnt, gppt) pcnt += 1 bcurve = GeomAPI_PointsToBSpline(array, mindegree, maxdegree).Curve() curve_edge = BRepBuilderAPI_MakeEdge(bcurve) return curve_edge.Edge()
def DisplayG02Arc(coor1, coor2, ARCCMD): f = G02EXE(coor1, coor2, ARCCMD) print(f) pty = f[0] center = f[1] radius = f[2] startA = f[3] endA = f[4] if endA - startA >= 0: endA = -2 * math.pi + endA dis = endA - startA dis = dis / 30 array = TColgp_Array1OfPnt(1, 30) if pty == 'xy': for i in range(29): array.SetValue( i + 1, gp_Pnt(radius * math.cos(startA + dis * i) + center[0], radius * math.sin(startA + dis * i) + center[1], coor1[2])) array.SetValue( 30, gp_Pnt(radius * math.cos(endA) + center[0], radius * math.sin(endA) + center[1], coor1[2])) elif pty == 'zx': for i in range(29): array.SetValue( i + 1, gp_Pnt(radius * math.sin(startA + dis * i) + center[1], coor1[1], radiud * math.cos(startA + dis * i) + center[0])) array.SetValue( 30, gp_Pnt(radius * math.sin(endA) + center[1], coor1[1], radiud * math.cos(endA) + center[0])) elif pty == 'yz': for i in range(29): array.SetValue( i + 1, gp_Pnt(coor1[0], radiud * math.cos(startA + dis * i) + center[0], radius * math.sin(startA + dis * i) + center[1])) array.SetValue( 30, gp_Pnt(coor1[0], radiud * math.cos(endA) + center[0], radius * math.sin(endA) + center[1])) bspline2 = GeomAPI_PointsToBSpline(array).Curve() path_edge = BRepBuilderAPI_MakeEdge(bspline2).Edge() display.DisplayColoredShape(path_edge, 'RED')
def create_shape(self): d = self.declaration if not d.points: raise ValueError("Must have at least two points") # Poles and weights pts = TColgp_Array1OfPnt(1, len(d.points)) set_value = pts.SetValue # TODO: Support weights for i, p in enumerate(d.points): set_value(i + 1, gp_Pnt(*p)) self.shape = GeomAPI_PointsToBSpline(pts).Curve().GetObject()
def DisplayG00Line(coor1, coor2): coors = [ coor1, [coor2[0], coor1[1], coor1[2]], [coor2[0], coor2[1], coor1[2]], coor2 ] for i in range(3): array = TColgp_Array1OfPnt(1, 2) array.SetValue(1, gp_Pnt(coors[i][0], coors[i][1], coors[i][2])) array.SetValue( 2, gp_Pnt(coors[i + 1][0], coors[i + 1][1], coors[i + 1][2])) bspline2 = GeomAPI_PointsToBSpline(array).Curve() path_edge = BRepBuilderAPI_MakeEdge(bspline2).Edge() display.DisplayColoredShape(path_edge, 'YELLOW')
def makeSpline(cls, listOfVector): """ Interpolate a spline through the provided points. :param cls: :param listOfVector: a list of Vectors that represent the points :return: an Edge """ pnts = TColgp_Array1OfPnt(0, len(listOfVector) - 1) for ix, v in enumerate(listOfVector): pnts.SetValue(ix, v.toPnt()) spline_geom = GeomAPI_PointsToBSpline(pnts).Curve() return cls(BRepBuilderAPI_MakeEdge(spline_geom).Edge())
def edge(event=None): # The blud edge BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80, -50, -20), gp_Pnt(-30, -60, -60)) V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20, 10, -30)) V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10, 7, -25)) YellowEdge = BRepBuilderAPI_MakeEdge(V1.Vertex(), V2.Vertex()) #The white edge line = gp_Lin(gp_Ax1(gp_Pnt(10, 10, 10), gp_Dir(1, 0, 0))) WhiteEdge = BRepBuilderAPI_MakeEdge(line, -20, 10) #The red edge Elips = gp_Elips(gp_Ax2(gp_Pnt(10, 0, 0), gp_Dir(1, 1, 1)), 60, 30) RedEdge = BRepBuilderAPI_MakeEdge(Elips, 0, math.pi / 2) # The green edge and the both extreme vertex P1 = gp_Pnt(-15, 200, 10) P2 = gp_Pnt(5, 204, 0) P3 = gp_Pnt(15, 200, 0) P4 = gp_Pnt(-15, 20, 15) P5 = gp_Pnt(-5, 20, 0) P6 = gp_Pnt(15, 20, 0) P7 = gp_Pnt(24, 120, 0) P8 = gp_Pnt(-24, 120, 12.5) array = TColgp_Array1OfPnt(1, 8) array.SetValue(1, P1) array.SetValue(2, P2) array.SetValue(3, P3) array.SetValue(4, P4) array.SetValue(5, P5) array.SetValue(6, P6) array.SetValue(7, P7) array.SetValue(8, P8) curve = Geom_BezierCurve(array) ME = BRepBuilderAPI_MakeEdge(curve.GetHandle()) GreenEdge = ME V3 = ME.Vertex1() V4 = ME.Vertex2() display.DisplayColoredShape(BlueEdge.Edge(), 'BLUE') display.DisplayShape(V1.Vertex()) display.DisplayShape(V2.Vertex()) display.DisplayColoredShape(WhiteEdge.Edge(), 'WHITE') display.DisplayColoredShape(YellowEdge.Edge(), 'YELLOW') display.DisplayColoredShape(RedEdge.Edge(), 'RED') display.DisplayColoredShape(GreenEdge.Edge(), 'GREEN') display.DisplayShape(V3) display.DisplayShape(V4, update=True)
def edge(event=None): # The blud edge blue_edge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80, -50, -20), gp_Pnt(-30, -60, -60)) v1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20, 10, -30)) v2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10, 7, -25)) yellow_edge = BRepBuilderAPI_MakeEdge(v1.Vertex(), v2.Vertex()) # The white edge line = gp_Lin(gp_Ax1(gp_Pnt(10, 10, 10), gp_Dir(1, 0, 0))) white_edge = BRepBuilderAPI_MakeEdge(line, -20, 10) # The red edge elips = gp_Elips(gp_Ax2(gp_Pnt(10, 0, 0), gp_Dir(1, 1, 1)), 60, 30) red_edge = BRepBuilderAPI_MakeEdge(elips, 0, math.pi / 2) # The green edge and the both extreme vertex p1 = gp_Pnt(-15, 200, 10) p2 = gp_Pnt(5, 204, 0) p3 = gp_Pnt(15, 200, 0) p4 = gp_Pnt(-15, 20, 15) p5 = gp_Pnt(-5, 20, 0) p6 = gp_Pnt(15, 20, 0) p7 = gp_Pnt(24, 120, 0) p8 = gp_Pnt(-24, 120, 12.5) array = TColgp_Array1OfPnt(1, 8) array.SetValue(1, p1) array.SetValue(2, p2) array.SetValue(3, p3) array.SetValue(4, p4) array.SetValue(5, p5) array.SetValue(6, p6) array.SetValue(7, p7) array.SetValue(8, p8) curve = Geom_BezierCurve(array) make_edge = BRepBuilderAPI_MakeEdge(curve.GetHandle()) green_edge = make_edge v3 = make_edge.Vertex1() v4 = make_edge.Vertex2() display.DisplayColoredShape(blue_edge.Edge(), 'BLUE') display.DisplayShape(v1.Vertex()) display.DisplayShape(v2.Vertex()) display.DisplayColoredShape(white_edge.Edge(), 'WHITE') display.DisplayColoredShape(yellow_edge.Edge(), 'YELLOW') display.DisplayColoredShape(red_edge.Edge(), 'RED') display.DisplayColoredShape(green_edge.Edge(), 'GREEN') display.DisplayShape(v3) display.DisplayShape(v4, update=True)
def __init__(self, knotVector=[], controlPoints=[], degree=3, center=False, axis=2): uniqueKnots = unique(knotVector) frequency = [ knotVector.count(knot) for knot in uniqueKnots ] knots = TColStd_Array1OfReal(0, len(uniqueKnots)-1) for i in range(len(uniqueKnots)): knots.SetValue(i, uniqueKnots[i]) mults = TColStd_Array1OfInteger(0, len(frequency)-1) for i in range(len(frequency)): mults.SetValue(i,frequency[i]) poles = TColgp_Array1OfPnt(0, len(controlPoints)-1) for i in range(len(controlPoints)): p = controlPoints[i] poles.SetValue(i, gp_Pnt(p[0],p[1],p[2])) poles2d = TColgp_Array1OfPnt2d(0, len(controlPoints)-1) plane = get_principal_plane(controlPoints) for i in range(len(controlPoints)): p = controlPoints[i] if plane == 0: poles2d.SetValue(i, gp_Pnt2d(p[1],p[2])) elif plane == 1: poles2d.SetValue(i, gp_Pnt2d(p[0],p[2])) elif plane == 2: poles2d.SetValue(i, gp_Pnt2d(p[0],p[1])) curve2d = Geom2d_BSplineCurve(poles2d, knots, mults, degree) if is_self_intersecting(curve2d.GetHandle()): from cadmium import CadmiumException raise CadmiumException('Self intersecting BSpline not allowed') curve = Geom_BSplineCurve(poles, knots, mults, degree) h_curve = Handle_Geom_BSplineCurve(curve) axes = [ gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1,0,0)), gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,1,0)), gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,0,1)), ] self.instance = BRepPrimAPI_MakeRevolution(axes[axis], h_curve) Solid.__init__(self, self.instance.Shape(), center=center)
def fit_spline(points, degree_min=3, degree_max=8, continuity='C2', tol=1e-3): """Approximates a set of points on the plane with a B-spline. Parameters ---------- points : ndarray 2D ndarray with N>=2 rows and 2 columns, representing the points on the plane, ordered from one end point to the other. The first column gives the x, the second column gives the the y coordinates of the points. degree_min : int, optional Minimum degree of the spline. The default is 3. degree_max : int, optional Maximum degree of the spline. The default is 8. continuity : {'C0', 'G1', 'C1', 'G2', 'C2', 'C3', 'CN'}, optional The continuity of the spline will be at least `continuity`. The default is 'C2'. For their meanings, consult with https://www.opencascade.com/doc/occt-7.4.0/refman/html/_geom_abs___shape_8hxx.html tol : float, optional The distance from the points to the spline will be lower than `tol`. The default is 1e-3. Returns ------- spline : Geom_BSplineCurve For details on the resulting spline, see the OpenCASCADE documentation: https://www.opencascade.com/doc/occt-7.4.0/refman/html/class_geom___b_spline_curve.html Raises ------ ValueError If the minimum degree of the B-spline to be constructed is greater than its maximum degree. """ if degree_min > degree_max: raise ValueError( 'Minimum degree must not be lower than the maximum degree.') # Create points from the input array that OCCT understands n_point = np.size(points, 0) pts = TColgp_Array1OfPnt(0, n_point - 1) for i in range(n_point): pts.SetValue(i, gp_Pnt(float(points[i][0]), float(points[i][1]), 0)) # Construct the spline continuity = _spline_continuity_enum(continuity) spline = GeomAPI_PointsToBSpline(pts, degree_min, degree_max, continuity, tol).Curve() return spline
def revolved_cut(base): # Define 7 points face_points = TColgp_Array1OfPnt(1, 7) face_inner_radius = 0.6 pts = [ gp_Pnt(face_inner_radius - 0.05, 0.0, -0.05), gp_Pnt(face_inner_radius - 0.10, 0.0, -0.025), gp_Pnt(face_inner_radius - 0.10, 0.0, 0.025), gp_Pnt(face_inner_radius + 0.10, 0.0, 0.025), gp_Pnt(face_inner_radius + 0.10, 0.0, -0.025), gp_Pnt(face_inner_radius + 0.05, 0.0, -0.05), gp_Pnt(face_inner_radius - 0.05, 0.0, -0.05), ] for n, i in enumerate(pts): face_points.SetValue(n + 1, i) # Use these points to create edges and add these edges to a wire hexwire = BRepBuilderAPI_MakeWire() for i in range(1, 7): hexedge = BRepBuilderAPI_MakeEdge(face_points.Value(i), face_points.Value(i + 1)).Edge() hexwire.Add(hexedge) # Turn the wire into a 6 sided face hexface = BRepBuilderAPI_MakeFace(hexwire.Wire()).Face() # Revolve the face around an axis revolve_axis = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)) revolved_shape = BRepPrimAPI_MakeRevol(hexface, revolve_axis).Shape() # Move the generated shape move = gp_Trsf() move.SetTranslation(gp_Pnt(0, 0, 0), gp_Pnt(0, 0, sin(0.5))) moved_shape = BRepBuilderAPI_Transform(revolved_shape, move, False).Shape() # Remove the revolved shape cut = BRepAlgoAPI_Cut(base, moved_shape).Shape() return cut
def __init__(self, knotVector=[], controlPoints=[], degree=3, thickness=10, axis=0, center=False): self.thickness = thickness wire = BRepBuilderAPI_MakeWire() uniqueKnots = unique(knotVector) frequency = [knotVector.count(knot) for knot in uniqueKnots] knots = TColStd_Array1OfReal(0, len(uniqueKnots) - 1) for i in range(len(uniqueKnots)): knots.SetValue(i, uniqueKnots[i]) mults = TColStd_Array1OfInteger(0, len(frequency) - 1) for i in range(len(frequency)): mults.SetValue(i, frequency[i]) poles = TColgp_Array1OfPnt(0, len(controlPoints) - 1) for i in range(len(controlPoints)): p = controlPoints[i] poles.SetValue(i, gp_Pnt(p[0], p[1], p[2])) poles2d = TColgp_Array1OfPnt2d(0, len(controlPoints) - 1) plane = get_principal_plane(controlPoints) for i in range(len(controlPoints)): p = controlPoints[i] if plane == 0: poles2d.SetValue(i, gp_Pnt2d(p[1], p[2])) elif plane == 1: poles2d.SetValue(i, gp_Pnt2d(p[0], p[2])) elif plane == 2: poles2d.SetValue(i, gp_Pnt2d(p[0], p[1])) curve2d = Geom2d_BSplineCurve(poles2d, knots, mults, degree) if is_self_intersecting(curve2d.GetHandle()): from cadmium import CadmiumException raise CadmiumException('Self intersecting BSpline not allowed') curve = Geom_BSplineCurve(poles, knots, mults, degree) me = BRepBuilderAPI_MakeEdge(curve.GetHandle()) wire.Add(me.Edge()) first = controlPoints[0] first = gp_Pnt(first[0], first[1], first[2]) last = controlPoints[-1] last = gp_Pnt(last[0], last[1], last[2]) if not first.IsEqual(last, 1.0e-9): closer = BRepBuilderAPI_MakeEdge( gp_Lin(first, gp_Dir(gp_Vec(first, last))), first, last) wire.Add(closer.Edge()) face = BRepBuilderAPI_MakeFace(wire.Wire()) if axis == 0: extrusion_vector = gp_Vec(self.thickness, 0, 0) elif axis == 1: extrusion_vector = gp_Vec(0, self.thickness, 0) elif axis == 2: extrusion_vector = gp_Vec(0, 0, self.thickness) self.instance = BRepPrimAPI_MakePrism(face.Shape(), extrusion_vector) Solid.__init__(self, self.instance.Shape(), center=center)
def points_to_bspline(pnts): pts = TColgp_Array1OfPnt(0, len(pnts) - 1) for n, i in enumerate(pnts): pts.SetValue(n, i) crv = GeomAPI_PointsToBSpline(pts) return crv.Curve()
def point_list_to_TColgp_Array1OfPnt(li): pts = TColgp_Array1OfPnt(0, len(li) - 1) for n, i in enumerate(li): pts.SetValue(n, i) return pts
p.append(gp_Pnt(point[i]['r'], 0, point[i]['z'])) edge = BRepBuilderAPI_MakeEdge(p[0], p[1]).Edge() return edge datadir = trim_dir('../../../Data/') with open(datadir + 'occ_input.json', 'r') as f: data = json.load(f) loop, cs, pf, nTF = data['p'], data['section'], data['pf'], data['nTF'] color = data['color'] PFsupport, CSsupport = data['PFsupport'], data['CSsupport'] Gsupport, OISsupport = data['Gsupport'], data['OISsupport'] w = [] for segment in loop: Pnt = TColgp_Array1OfPnt(1, 4) for i in range(4): point = segment['p{:d}'.format(i)] Pnt.SetValue(i + 1, gp_Pnt(point['r'], 0, point['z'])) curve = Geom_BezierCurve(Pnt) w.append(BRepBuilderAPI_MakeEdge(curve.GetHandle()).Edge()) inner_edge = add_line([loop[3]['p3'], loop[0]['p0']]) inner_curve = BRepBuilderAPI_MakeWire(inner_edge) upper_curve = BRepBuilderAPI_MakeWire(w[0]) lower_curve = BRepBuilderAPI_MakeWire(w[3]) # outboard loop dflat = (loop[1]['p3']['r']-loop[2]['p0']['r'])**2+\ (loop[1]['p3']['z']-loop[2]['p0']['z'])**2 if dflat > 1e-3:
def parse_face(topo_face): """ Method to parse a single Face (a single patch nurbs surface). It returns a matrix with all the coordinates of control points of the Face and a second list with all the control points related to the Edges of the Face. :param topo_face: the input Face :return: mesh_points_face: it is a `n_points`-by-3 matrix containing the coordinates of the control points of the Face (a nurbs surface) :return: mesh_points_edge: it is a list of `n_points`-by-3 matrix :rtype: tuple(numpy.ndarray, list) """ # get some Face - Edge - Vertex data map information mesh_points_edge = [] face_exp_wire = TopExp_Explorer(topo_face, TopAbs_WIRE) # loop on wires per face while face_exp_wire.More(): twire = topods_Wire(face_exp_wire.Current()) wire_exp_edge = TopExp_Explorer(twire, TopAbs_EDGE) # loop on edges per wire while wire_exp_edge.More(): edge = topods_Edge(wire_exp_edge.Current()) bspline_converter = BRepBuilderAPI_NurbsConvert(edge) bspline_converter.Perform(edge) bspline_tshape_edge = bspline_converter.Shape() h_geom_edge = BRep_Tool_Curve( topods_Edge(bspline_tshape_edge))[0] h_bspline_edge = geomconvert_CurveToBSplineCurve(h_geom_edge) bspline_geom_edge = h_bspline_edge.GetObject() nb_poles = bspline_geom_edge.NbPoles() # Edge geometric properties edge_ctrlpts = TColgp_Array1OfPnt(1, nb_poles) bspline_geom_edge.Poles(edge_ctrlpts) points_single_edge = np.zeros((0, 3)) for i in range(1, nb_poles + 1): ctrlpt = edge_ctrlpts.Value(i) ctrlpt_position = np.array( [[ctrlpt.Coord(1), ctrlpt.Coord(2), ctrlpt.Coord(3)]]) points_single_edge = np.append(points_single_edge, ctrlpt_position, axis=0) mesh_points_edge.append(points_single_edge) wire_exp_edge.Next() face_exp_wire.Next() # extract mesh points (control points) on Face mesh_points_face = np.zeros((0, 3)) # convert Face to Geom B-spline Face nurbs_converter = BRepBuilderAPI_NurbsConvert(topo_face) nurbs_converter.Perform(topo_face) nurbs_face = nurbs_converter.Shape() h_geomsurface = BRep_Tool.Surface(topods.Face(nurbs_face)) h_bsurface = geomconvert_SurfaceToBSplineSurface(h_geomsurface) bsurface = h_bsurface.GetObject() # get access to control points (poles) nb_u = bsurface.NbUPoles() nb_v = bsurface.NbVPoles() ctrlpts = TColgp_Array2OfPnt(1, nb_u, 1, nb_v) bsurface.Poles(ctrlpts) for indice_u_direction in range(1, nb_u + 1): for indice_v_direction in range(1, nb_v + 1): ctrlpt = ctrlpts.Value(indice_u_direction, indice_v_direction) ctrlpt_position = np.array( [[ctrlpt.Coord(1), ctrlpt.Coord(2), ctrlpt.Coord(3)]]) mesh_points_face = np.append(mesh_points_face, ctrlpt_position, axis=0) return mesh_points_face, mesh_points_edge