def __init__(self): plotocc.__init__(self) self.b1 = gen_ellipsoid(axs=gp_Ax3( gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), rxyz=[100, 100, 105]) self.b2 = gen_ellipsoid(axs=gp_Ax3( gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), rxyz=[210, 210, 210]) self.base = BRepAlgoAPI_Cut(self.b2, self.b1).Shape() self.beam = gp_Ax3(gp_Pnt(0, 150, 0), gp_Dir(1, 1.5, 0)) print(self.b1) top = Topo(self.base) print(top.number_of_faces())
def get_vertices(shape, length): bt = BRep.BRep_Tool() t = Topo(shape) vertices = t.vertices() vert = [] for vertex in vertices: vert.append([ correctLengt(bt.Pnt(vertex).Coord()[0], length, None), correctLengt(bt.Pnt(vertex).Coord()[1], length, None), correctLengt(bt.Pnt(vertex).Coord()[2], length, None) ]) return vert
class LoopWirePairs(object): """ for looping through consequtive wires assures that the returned edge pairs are ordered """ def __init__(self, wireA, wireB): self.wireA = wireA self.wireB = wireB self.we_A = WireExplorer(self.wireA) self.we_B = WireExplorer(self.wireB) self.tp_A = Topo(self.wireA) self.tp_B = Topo(self.wireB) self.bt = BRep_Tool() self.vertsA = [v for v in self.we_A.ordered_vertices()] self.vertsB = [v for v in self.we_B.ordered_vertices()] self.edgesA = [v for v in WireExplorer(wireA).ordered_edges()] self.edgesB = [v for v in WireExplorer(wireB).ordered_edges()] self.pntsB = [self.bt.Pnt(v) for v in self.vertsB] self.number_of_vertices = len(self.vertsA) self.index = 0 def closest_point(self, vertexFromWireA): pt = self.bt.Pnt(vertexFromWireA) distances = [pt.Distance(i) for i in self.pntsB] indx_max_dist = distances.index(min(distances)) return self.vertsB[indx_max_dist] def next(self): if self.index == self.number_of_vertices: raise StopIteration vert = self.vertsA[self.index] closest = self.closest_point(vert) edges_a = self.tp_A.edges_from_vertex(vert) edges_b = self.tp_B.edges_from_vertex(closest) a1, a2 = Edge(next(edges_a)), Edge(next(edges_a)) b1, b2 = Edge(next(edges_b)), Edge(next(edges_b)) mpA = a1.mid_point() self.index += 1 if mpA.Distance(b1.mid_point()) < mpA.Distance(b2.mid_point()): return iter([a1, a2]), iter([b1, b2]) else: return iter([a1, a2]), iter([b2, b1]) def __iter__(self): return self
class LoopWirePairs(object): ''' for looping through consequtive wires assures that the returned edge pairs are ordered ''' def __init__(self, wireA, wireB): self.wireA = wireA self.wireB = wireB self.we_A = WireExplorer(self.wireA) self.we_B = WireExplorer(self.wireB) self.tp_A = Topo(self.wireA) self.tp_B = Topo(self.wireB) self.bt = BRep_Tool() self.vertsA = [v for v in self.we_A.ordered_vertices()] self.vertsB = [v for v in self.we_B.ordered_vertices()] self.edgesA = [v for v in WireExplorer(wireA).ordered_edges()] self.edgesB = [v for v in WireExplorer(wireB).ordered_edges()] self.pntsB = [self.bt.Pnt(v) for v in self.vertsB] self.number_of_vertices = len(self.vertsA) self.index = 0 def closest_point(self, vertexFromWireA): pt = self.bt.Pnt(vertexFromWireA) distances = [pt.Distance(i) for i in self.pntsB] indx_max_dist = distances.index(min(distances)) return self.vertsB[indx_max_dist] def next(self): if self.index == self.number_of_vertices: raise StopIteration vert = self.vertsA[self.index] closest = self.closest_point(vert) edges_a = self.tp_A.edges_from_vertex(vert) edges_b = self.tp_B.edges_from_vertex(closest) a1, a2 = Edge(next(edges_a)), Edge(next(edges_a)) b1, b2 = Edge(next(edges_b)), Edge(next(edges_b)) mpA = a1.mid_point() self.index += 1 if mpA.Distance(b1.mid_point()) < mpA.Distance(b2.mid_point()): return iter([a1, a2]), iter([b1, b2]) else: return iter([a1, a2]), iter([b2, b1]) def __iter__(self): return self
def display(topo): #http://www.opencascade.org/org/forum/thread_18374/ #http://adl.serveftp.org/lab/opencascade/pdf/visu.pdf #shape = displays[curr_tab].DisplayShape(topo, update=False).GetObject() #shape.SetDisplayMode(0) #displays[curr_tab].DisplayColoredShape(topo, 'BLUE', False) mat = Graphic3d_MaterialAspect(Graphic3d_NOM_SILVER) displays[curr_tab].DisplayShape(topo, material=mat, update=False) t = Topo(topo) wires = t.wires() for w in wires: #print w #displays[curr_tab].DisplayColoredShape(w, 'BLACK', False) edges.append(w)
def make_EllipWire(self, rxy=[1.0, 1.0], shft=0.0, skin=None, axs=gp_Ax3()): rx, ry = rxy if rx > ry: major_radi = rx minor_radi = ry axis = gp_Ax2() axis.SetXDirection(axis.XDirection()) else: major_radi = ry minor_radi = rx axis = gp_Ax2() axis.SetXDirection(axis.YDirection()) axis.Rotate(axis.Axis(), np.deg2rad(shft)) elip = make_edge(gp_Elips(axis, major_radi, minor_radi)) poly = make_wire(elip) poly.Location(set_loc(gp_Ax3(), axs)) if skin == None: return poly else: n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) n_sided.Build() face = n_sided.Face() if skin == 0: return face else: solid = BRepOffset_MakeOffset(face, skin, 1.0E-5, BRepOffset_Skin, False, True, GeomAbs_Arc, True, True) return solid.Shape()
def make_StarWire(self, num=5, radi=[2.0, 1.0], shft=0.0, axs=gp_Ax3(), skin=None): lxy = radi pnts = [] angl = 360 / num for i in range(num): a_thet = np.deg2rad(i * angl) + np.deg2rad(shft) ax, ay = radi[0] * np.sin(a_thet), radi[0] * np.cos(a_thet) pnts.append(gp_Pnt(ax, ay, 0)) b_thet = a_thet + np.deg2rad(angl) / 2 bx, by = radi[1] * np.sin(b_thet), radi[1] * np.cos(b_thet) pnts.append(gp_Pnt(bx, by, 0)) pnts.append(pnts[0]) poly = make_polygon(pnts) poly.Location(set_loc(gp_Ax3(), axs)) n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) n_sided.Build() face = n_sided.Face() if skin == None: return poly elif skin == 0: return face else: solid = BRepOffset_MakeOffset(face, skin, 1.0E-5, BRepOffset_Skin, False, True, GeomAbs_Arc, True, True) return solid.Shape()
def __init__(self, wireA, wireB): self.wireA = wireA self.wireB = wireB self.we_A = WireExplorer(self.wireA) self.we_B = WireExplorer(self.wireB) self.tp_A = Topo(self.wireA) self.tp_B = Topo(self.wireB) self.bt = BRep_Tool() self.vertsA = [v for v in self.we_A.ordered_vertices()] self.vertsB = [v for v in self.we_B.ordered_vertices()] self.edgesA = [v for v in WireExplorer(wireA).ordered_edges()] self.edgesB = [v for v in WireExplorer(wireB).ordered_edges()] self.pntsB = [self.bt.Pnt(v) for v in self.vertsB] self.number_of_vertices = len(self.vertsA) self.index = 0
def set_surface(filename): if os.path.exists(filename): shp = read_step_file(filename) for face in Topo(shp).faces(): surf = face else: surf = make_plane() return surf
def analyse(self): """ :return: """ ss = ShapeAnalysis_Shell(self) if ss.HasFreeEdges(): bad_edges = [e for e in Topo(ss.BadEdges()).edges()] return bad_edges
def build_curve_network(event=None): ''' mimic the curve network surfacing command from rhino ''' print('Importing IGES file...', end='') iges = IGESImporter('./curve_geom_plate.igs') iges.read_file() iges_cpd = iges.get_compound() print('done.') print('Building geomplate...', end='') topo = Topo(iges_cpd) edges_list = list(topo.edges()) face = build_geom_plate(edges_list) print('done.') display.EraseAll() display.DisplayShape(edges_list) display.DisplayShape(face) display.FitAll() print('Cutting out of edges...')
def geom_plate(event=None): display.EraseAll() p1 = gp_Pnt(0, 0, 0) p2 = gp_Pnt(0, 10, 0) p3 = gp_Pnt(0, 10, 10) p4 = gp_Pnt(0, 0, 10) p5 = gp_Pnt(5, 5, 5) poly = make_closed_polygon([p1, p2, p3, p4]) edges = [i for i in Topo(poly).edges()] face = make_n_sided(edges, [p5]) display.DisplayShape(edges) display.DisplayShape(make_vertex(p5)) display.DisplayShape(face, update=True)
def test_step_exporter_overwrite(box_shape): r"""Happy path with a subclass of TopoDS_Shape""" filename = path_from_file(__file__, "./models_out/box.stp") exporter = StepExporter(filename) solid = shape_to_topology(box_shape) assert isinstance(solid, TopoDS.TopoDS_Solid) exporter.add_shape(solid) exporter.write_file() initial_timestamp = os.path.getmtime(filename) assert os.path.isfile(filename) # read the written box.stp importer = StepImporter(filename) topo_compound = Topo(importer.compound) assert topo_compound.number_of_faces() == 6 assert len([i for i in topo_compound.faces()]) == 6 assert topo_compound.number_of_edges() == 12 # add a sphere and write again with same exporter sphere = BRepPrimAPI.BRepPrimAPI_MakeSphere(10) exporter.add_shape(sphere.Shape()) exporter.write_file() # this creates a file with a box and a sphere intermediate_timestamp = os.path.getmtime(filename) assert intermediate_timestamp >= initial_timestamp # check that the file contains the box and the sphere importer = StepImporter(filename) assert len([i for i in Topo(importer.compound).faces()]) == 7 # 6 from box + 1 from sphere assert len([i for i in Topo(importer.compound).solids()]) == 2 # create a new exporter and overwrite with a box only filename = path_from_file(__file__, "./models_out/box.stp") exporter = StepExporter(filename) solid = shape_to_topology(box_shape) exporter.add_shape(solid) exporter.write_file() assert os.path.isfile(filename) last_timestamp = os.path.getmtime(filename) assert last_timestamp >= intermediate_timestamp # check the file only contains a box importer = StepImporter(filename) assert len([i for i in Topo(importer.compound).faces()]) == 6 # 6 from box assert len([i for i in Topo(importer.compound).solids()]) == 1
def test_iges_exporter_overwrite(box_shape): r"""Happy path with a subclass of TopoDS_Shape""" filename = path_from_file(__file__, "./models_out/box.igs") exporter = IgesExporter(filename) solid = shape_to_topology(box_shape) assert isinstance(solid, TopoDS.TopoDS_Solid) exporter.add_shape(solid) exporter.write_file() assert os.path.isfile(filename) # read the written box.igs importer = IgesImporter(filename) topo_compound = Topo(importer.compound) assert topo_compound.number_of_faces() == 6 assert topo_compound.number_of_edges() == 24 # add a sphere and write again with same exporter sphere = BRepPrimAPI.BRepPrimAPI_MakeSphere(10) exporter.add_shape(sphere.Shape()) exporter.write_file() # this creates a file with a box and a sphere # check that the file contains the box and the sphere importer = IgesImporter(filename) topo_compound = Topo(importer.compound) assert topo_compound.number_of_faces() == 7 # 6 from box + 1 from sphere # create a new exporter and overwrite with a box only filename = path_from_file(__file__, "./models_out/box.igs") exporter = IgesExporter(filename) solid = shape_to_topology(box_shape) exporter.add_shape(solid) exporter.write_file() assert os.path.isfile(filename) # check the file only contains a box importer = IgesImporter(filename) topo_compound = Topo(importer.compound) assert topo_compound.number_of_faces() == 6 # 6 from box
def corners(house): d = {} iface = -1 topo = Topo(house['volume']) house['boundaries'] = {'walls': [], 'windows': [], 'heats': []} house['faces'] = [] for f in topo.wires(): iface += 1 key = 'face' + str(iface) print 'new_face' edges = [] d[key] = [] topof = Topo(f) for e in topof.edges(): vts = Topo(e) print 'edge' edge = [] for i, v in enumerate(vts.vertices()): brt = BRep_Tool() pnt = brt.Pnt(topods_Vertex(v)) edge.append([pnt.X(), pnt.Y(), pnt.Z()]) edges.append(edge) print len(edges) first_edge = edges.pop(0) point_array = [first_edge[0], first_edge[1]] print 'edges :' for e in edges: print e print '-------' while len(edges) > 0: for i, e in enumerate(edges): if point_array[-1] in e: ed = edges.pop(i) print point_array[-1] if ed[0] == point_array[-1]: point_array.append(ed[1]) elif ed[1] == point_array[-1]: point_array.append(ed[0]) break d[key] = point_array house['faces'].append(point_array) return d
def test_stl_exporter_overwrite(box_shape): r"""Happy path with a subclass of TopoDS_Shape""" filename = path_from_file(__file__, "./models_out/box.stl") exporter = StlExporter(filename) solid = shape_to_topology(box_shape) assert isinstance(solid, TopoDS.TopoDS_Solid) exporter.set_shape(solid) exporter.write_file() assert os.path.isfile(filename) # read the written box.stl importer = StlImporter(filename) topo = Topo(importer.shape) assert topo.number_of_shells() == 1 # set a sphere and write again with same exporter sphere = BRepPrimAPI.BRepPrimAPI_MakeSphere(10) exporter.set_shape(sphere.Shape()) exporter.write_file( ) # this creates a file with a sphere only, this is STL specific # check that the file contains the sphere only importer = StlImporter(filename) topo = Topo(importer.shape) assert topo.number_of_shells() == 1 # create a new exporter and overwrite with a box only filename = path_from_file(__file__, "./models_out/box.stl") exporter = StlExporter(filename) solid = shape_to_topology(box_shape) exporter.set_shape(solid) exporter.write_file() assert os.path.isfile(filename) # check the file only contains a box importer = StlImporter(filename) topo = Topo(importer.shape) assert topo.number_of_shells() == 1
def __init__(self): plotocc.__init__(self) print(gxyz.shape) for i, xyz in enumerate(gxyz): print(i, *xyz) self.display.DisplayShape(gp_Pnt(*xyz)) e_array = [] for e in xyz_max: x, y, z = e e = gp_Pnt(float(x), float(y), float(z)) e_array.append(e) e_array.append(e_array[0]) poly = make_polygon(e_array) n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) for pt in gxyz: x, y, z = pt if (x < xmax) and (x > xmin) and (y < ymax) and (y > ymin) and ( z < zmax) and (z > zmin): n_sided.Add(gp_Pnt(x, y, z)) n_sided.Build() face = n_sided.Face() #face = make_n_sided(edges, p_array) # THICKEN SURFACE thickness = 0.15 solid = BRepOffset_MakeOffset(face, thickness, 1.0E-5, BRepOffset_Skin, False, False, GeomAbs_Intersection, True) # The last True is important to make solid # solid.MakeOffsetShape() # solid.MakeThickSolid() #aShape = solid.Shape() self.display.DisplayShape(poly) self.display.DisplayShape(face) #display.DisplayShape(aShape, update=True) #write_step_file(aShape, "./tmp/gyroid.stp") self.export_stp(solid.Shape())
def export_rim_2d(self, rimfile="pln1.rim", name="pln1-rim"): rim_2d = dispocc.proj_rim_pln(self, self.rim, self.pln, self.axs) fp = open(rimfile, "w") fp.write(' {:s}\n'.format(name)) fp.write('{:12d}{:12d}{:12d}\n'.format(1, 1, 1)) rim_tmp = gp_Pnt() for i, e in enumerate(Topo(rim_2d).edges()): e_curve, u0, u1 = BRep_Tool.Curve(e) print(i, e, u0, u1) if i != 0 and rim_tmp == e_curve.Value(u0): u_range = np.linspace(u0, u1, 50) rim_tmp = e_curve.Value(u1) p = e_curve.Value(u0) p.Transform(set_trf(self.axs, gp_Ax3())) data = [p.X(), p.Y()] print(0, p, u_range[0], u_range[-1]) elif i != 0 and rim_tmp == e_curve.Value(u1): u_range = np.linspace(u1, u0, 50) rim_tmp = e_curve.Value(u0) p = e_curve.Value(u1) p.Transform(set_trf(self.axs, gp_Ax3())) data = [p.X(), p.Y()] print(1, p, u_range[0], u_range[-1]) else: u_range = np.linspace(u0, u1, 50) rim_tmp = e_curve.Value(u1) p = e_curve.Value(u0) p.Transform(set_trf(self.axs, gp_Ax3())) data = [p.X(), p.Y()] print(2, p, u_range[0], u_range[-1]) fp.write(''.join([float_to_string(val) for val in data]) + '\n') for u in u_range[1:]: p = e_curve.Value(u) p.Transform(set_trf(self.axs, gp_Ax3())) data = [p.X(), p.Y()] fp.write(''.join([float_to_string(val) for val in data]) + '\n') fp.close()
def test_check_shape(): r"""check_shape() tests""" # Null shapes should raise a ValueError with pytest.raises(ValueError): check_shape(TopoDS.TopoDS_Shape()) with pytest.raises(ValueError): check_shape(TopoDS.TopoDS_Shell()) builderapi_makeedge = BRepBuilderAPI.BRepBuilderAPI_MakeEdge( gp.gp_Pnt(), gp.gp_Pnt(10, 10, 10)) shape = builderapi_makeedge.Shape() # a ValueError should be raised is check_shape() is not give a TopoDS_Shape or subclass with pytest.raises(ValueError): check_shape(gp.gp_Pnt()) with pytest.raises(ValueError): check_shape(builderapi_makeedge) # a TopoDS_Shape should pass the check without raising any exception check_shape(shape) # a subclass of shape should not raise any exception check_shape(next(Topo(shape).edges()))
def fit_plane_through_face_vertices(_face): """ :param _face: OCC.KBE.face.Face instance :return: Geom_Plane """ from OCC.Core.GeomPlate import GeomPlate_BuildAveragePlane uvs_from_vertices = [ _face.project_vertex(vertex2pnt(i)) for i in Topo(_face).vertices() ] normals = [ gp_Vec(_face.DiffGeom.normal(*uv[0])) for uv in uvs_from_vertices ] points = [i[1] for i in uvs_from_vertices] NORMALS = TColgp_SequenceOfVec() [NORMALS.Append(i) for i in normals] POINTS = to_tcol_(points, TColgp_HArray1OfPnt) pl = GeomPlate_BuildAveragePlane(NORMALS, POINTS).Plane().GetObject() vec = gp_Vec(pl.Location(), _face.GlobalProperties.centre()) pt = (pl.Location().as_vec() + vec).as_pnt() pl.SetLocation(pt) return pl
def make_FaceByOrder(self, pts=[]): pnt = [] for p in pts: pnt.append([p.X(), p.Y(), p.Z()]) pnt = np.array(pnt) cov = ConvexHull(pnt, qhull_options='QJ') #pts_ord = [] # print(cov) # print(cov.simplices) # print(cov.vertices) # for idx in cov.vertices: # print(idx, pnt[idx]) # pts_ord.append(gp_Pnt(*pnt[idx])) #poly = make_polygon(pts_ord) poly = make_polygon(pts) n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) n_sided.Build() face = n_sided.Face() return face
def test_stl_importer_happy_topology(): r"""import iges file containing a box and test topology""" # binary STL importer = StlImporter(path_from_file(__file__, "./models_in/box_binary.stl")) topo = Topo(importer.shape) # assert len(topo.solids()) == 1 assert len([i for i in topo.shells()]) == 1 assert next(topo.shells()).Closed() is True # direct method on TopoDS_Shell assert len([i for i in topo.faces()]) == 108 assert len([i for i in topo.edges()]) == 162 # ascii STL importer = StlImporter(path_from_file(__file__, "./models_in/box_ascii.stl")) topo = Topo(importer.shape) # assert len(topo.solids) == 1 assert len([i for i in topo.shells()]) == 1 assert next(topo.shells()).Closed() is True assert len([i for i in topo.faces()]) == 108 assert len([i for i in topo.edges()]) == 162
""" sae = ShapeAnalysis_Edge() return sae.IsSeam(self, face) def is_edge_on_face(self, face): '''checks whether curve lies on a surface or a face ''' return ShapeAnalysis_Edge().HasPCurve(self, face) #=========================================================================== # Curve.graphic #=========================================================================== def show(self): ''' poles, knots, should render all slightly different. here's how... http://www.opencascade.org/org/forum/thread_1125/ ''' super(Edge, self).show() if __name__ == '__main__': from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox from OCCUtils.Topology import Topo b = BRepPrimAPI_MakeBox(10, 20, 30).Shape() t = Topo(b) ed = next(t.edges()) my_e = Edge(ed) print(my_e.tolerance)
def max_counter(self, facesS_2): section_edges = list(Topo(facesS_2).edges()) # print(len(section_edges)) if len(section_edges) > 0: Wire_c = BRepBuilderAPI_MakeWire() prep_list = [] Wire_c.Add(section_edges[0]) prep_list.append(section_edges[0]) ex = TopExp_Explorer(section_edges[0], TopAbs_VERTEX) # no need for a loop since we know for a fact that # the edge has only one start and one end c = ex.Current() cv = topods_Vertex(c) v0 = BRep_Tool_Pnt(cv) ex.Next() c = ex.Current() cv = topods_Vertex(c) v1 = BRep_Tool_Pnt(cv) section_edges.pop(0) flag = 0 wires = [] while len(section_edges) > 0: new_list = [] for edges in section_edges: # Wire_c.Add(edges) ex = TopExp_Explorer(edges, TopAbs_VERTEX) c = ex.Current() cv = topods_Vertex(c) End_1 = BRep_Tool_Pnt(cv) ex.Next() c = ex.Current() cv = topods_Vertex(c) End_2 = BRep_Tool_Pnt(cv) if End_1.X() == v0.X() and End_1.Y() == v0.Y() and End_1.Z( ) == v0.Z(): Wire_c.Add(edges) v0 = End_2 flag = 0 elif End_1.X() == v1.X() and End_1.Y() == v1.Y( ) and End_1.Z() == v1.Z(): Wire_c.Add(edges) v1 = End_2 flag = 0 elif End_2.X() == v0.X() and End_2.Y() == v0.Y( ) and End_2.Z() == v0.Z(): Wire_c.Add(edges) v0 = End_1 flag = 0 elif End_2.X() == v1.X() and End_2.Y() == v1.Y( ) and End_2.Z() == v1.Z(): Wire_c.Add(edges) v1 = End_1 flag = 0 else: new_list.append(edges) flag += 1 section_edges = new_list if flag >= 5: # print('number_ostalos', len(section_edges)) wires.append(Wire_c.Wire()) Wire_c = BRepBuilderAPI_MakeWire() Wire_c.Add(section_edges[0]) ex = TopExp_Explorer(section_edges[0], TopAbs_VERTEX) # no need for a loop since we know for a fact that # the edge has only one start and one end c = ex.Current() cv = topods_Vertex(c) v0 = BRep_Tool_Pnt(cv) ex.Next() c = ex.Current() cv = topods_Vertex(c) v1 = BRep_Tool_Pnt(cv) section_edges.pop(0) flag = 0 wires.append(Wire_c.Wire()) areas = [] props = GProp_GProps() for wire in wires: brown_face = BRepBuilderAPI_MakeFace(wire) brown_face = brown_face.Face() # props = GProp_GProps() brepgprop_SurfaceProperties(brown_face, props) areas.append(props.Mass()) return max(areas) else: return 0
""" sae = ShapeAnalysis_Edge() return sae.IsSeam(self, face) def is_edge_on_face(self, face): '''checks whether curve lies on a surface or a face ''' return ShapeAnalysis_Edge().HasPCurve(self, face) #=========================================================================== # Curve.graphic #=========================================================================== def show(self): ''' poles, knots, should render all slightly different. here's how... http://www.opencascade.org/org/forum/thread_1125/ ''' super(Edge, self).show() if __name__ == '__main__': from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox from OCCUtils.Topology import Topo b = BRepPrimAPI_MakeBox(10, 20, 30).Shape() t = Topo(b) ed = next(t.edges()) my_e = Edge(ed) print(my_e.tolerance)
def Edges(self): return Topo(self, True).edges()
def Wires(self): """ :return: """ return Topo(self, True).wires()
def Faces(self): """ :return: """ return Topo(self, True).faces()
def shells(self): return (Shell(sh) for sh in Topo(self))
def get_face(self, sol): top_api = Topo(sol) print(top_api.number_of_faces()) for face in top_api.faces(): sol_face = face return sol_face
def topo(self): if self._topo is not None: return self._topo else: self._topo = Topo(self) return self._topo
def test_stl_importer_2_boxes(): r"""Import an iges file containing 2 distinct boxes and test topology Notes ----- This shows the current limitations of the IgesImporter as 2 boxes cannot be distinguished from one another """ # binary STL importer = StlImporter(path_from_file(__file__, "./models_in/2_boxes_binary.stl")) topo = Topo(importer.shape) assert len([i for i in topo.shells()]) == 2 assert next(topo.shells()).Closed() is True assert [i for i in topo.shells()][1].Closed() is True assert topo.number_of_faces() == 108 * 2 assert topo.number_of_edges() == 162 * 2 # ascii STL importer = StlImporter(path_from_file(__file__, "./models_in/2_boxes_ascii.stl")) topo = Topo(importer.shape) assert len([i for i in topo.shells()]) == 2 assert next(topo.shells()).Closed() is True assert [i for i in topo.shells()][1].Closed() is True assert topo.number_of_faces() == 108 * 2 assert topo.number_of_edges() == 162 * 2