本文整理汇总了Python中OCC.Utils.Topology.Topo.number_of_vertices方法的典型用法代码示例。如果您正苦于以下问题:Python Topo.number_of_vertices方法的具体用法?Python Topo.number_of_vertices怎么用?Python Topo.number_of_vertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCC.Utils.Topology.Topo
的用法示例。
在下文中一共展示了Topo.number_of_vertices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import number_of_vertices [as 别名]
def __init__(self, file_path, id=None):
self.file = file_path.encode("utf-8")
self.id = id
self.shapes_simples = []
self.main_product=None
basename = os.path.basename(self.file)
self.fileName = os.path.splitext(basename)[0]
self.STEPReader = STEPCAFControl_Reader()
if self.STEPReader.ReadFile(self.file) != 1:
raise OCCReadingStepError
self.h_doc = TDocStd.Handle_TDocStd_Document()
self.app = XCAFApp.GetApplication().GetObject()
self.app.NewDocument(TCollection_ExtendedString("MDTV-XCAF"), self.h_doc)
self.STEPReader.Transfer(self.h_doc)
self.doc = self.h_doc.GetObject()
self.h_shape_tool = XCAFDoc.XCAFDoc_DocumentTool_ShapeTool(self.doc.Main())
self.h_colors_tool = XCAFDoc.XCAFDoc_DocumentTool_ColorTool(self.doc.Main())
self.shape_tool = self.h_shape_tool.GetObject()
self.color_tool=self.h_colors_tool.GetObject()
self.shapes = TDF_LabelSequence()
self.shape_tool.GetShapes(self.shapes)
for i in range(self.shapes.Length()):
shape = self.shapes.Value(i+1)
if self.shape_tool.IsSimpleShape(shape):
compShape = self.shape_tool.GetShape(shape)
t = Topo(compShape)
if t.number_of_vertices() > 0:
label = get_label_name(shape)
color = find_color(shape, self.color_tool, self.shape_tool)
self.shapes_simples.append(SimpleShape(label, compShape, color))
roots = TDF_LabelSequence()
self.shape_tool.GetFreeShapes(roots)
self.thumbnail_valid = False
if roots.Length() == 1:
shape = self.shape_tool.GetShape(roots.Value(1))
t = Topo(shape)
if t.number_of_vertices() > 0:
bbox = Bnd_Box()
gap = 0
bbox.SetGap(gap)
BRepMesh_Mesh(shape, get_mesh_precision(shape, 1))
faces_iterator = Topo(shape).faces()
for F in faces_iterator:
face_location = TopLoc_Location()
BRep_Tool_Triangulation(F, face_location)
BRepBndLib_Add(shape, bbox)
x_min, y_min, z_min, x_max, y_max, z_max = bbox.Get()
diagonal = max(x_max - x_min, y_max - y_min, z_max - z_min)
if diagonal > 0:
self.scale = 200. / diagonal
self.trans = ((x_max - x_min) / 2. - x_max,
(y_max - y_min) / 2. - y_max,
(z_max - z_min) / 2. - z_max)
self.thumbnail_valid = True
ws = self.STEPReader.Reader().WS().GetObject()
model = ws.Model().GetObject()
model.Clear()
示例2: TestTopology
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import number_of_vertices [as 别名]
class TestTopology(unittest.TestCase):
def setUp(self):
self.topo = Topo(BRepPrimAPI_MakeBox(10., 10., 10).Shape())
def test_nested_iteration(self):
'''check nested looping'''
for f in self.topo.faces():
for e in self.topo.edges():
self.assert_(isinstance(f, TopoDS_Face))
self.assert_(isinstance(e, TopoDS_Edge))
def test_kept_reference(self):
'''did we keep a reference after looping several time through a list
of topological entities?'''
_tmp = []
_faces = [i for i in self.topo.faces()]
for f in _faces:
_tmp.append(0 == f.IsNull())
for f in _faces:
_tmp.append(0 == f.IsNull())
self.assert_(all(_tmp))
def test_number_of_topological_entities(self):
self.assert_(self.topo.number_of_vertices() == 8)
self.assert_(self.topo.number_of_edges() == 12)
self.assert_(self.topo.number_of_wires() == 6)
self.assert_(self.topo.number_of_faces() == 6)
self.assert_(self.topo.number_of_solids() == 1)
self.assert_(self.topo.number_of_comp_solids() == 0)
self.assert_(self.topo.number_of_compounds() == 0)
def test_edge_face(self):
edg = self.topo.edges().next()
face = self.topo.faces().next()
faces_from_edge = [i for i in self.topo.faces_from_edge(edg)]
self.assert_(len(faces_from_edge) == self.topo.number_of_faces_from_edge(edg))
edges_from_face = [i for i in self.topo.edges_from_face(face)]
self.assert_(len(edges_from_face) == self.topo.number_of_edges_from_face(face))
def test_edge_wire(self):
edg = self.topo.edges().next()
wire = self.topo.wires().next()
wires_from_edge = [i for i in self.topo.wires_from_edge(edg)]
self.assert_(len(wires_from_edge) == self.topo.number_of_wires_from_edge(edg))
edges_from_wire = [i for i in self.topo.edges_from_wire(wire)]
self.assert_(len(edges_from_wire) == self.topo.number_of_edges_from_wire(wire))
def test_vertex_edge(self):
vert = self.topo.vertices().next()
verts_from_edge = [i for i in self.topo.vertices_from_edge(vert)]
self.assert_(len(verts_from_edge) == self.topo.number_of_vertices_from_edge(vert))
edges_from_vert = [ i for i in self.topo.edges_from_vertex(vert)]
self.assert_(len(edges_from_vert) == self.topo.number_of_edges_from_vertex(vert))
def test_vertex_face(self):
vert = self.topo.vertices().next()
face = self.topo.faces().next()
faces_from_vertex = [i for i in self.topo.faces_from_vertex(vert)]
self.assert_(len(faces_from_vertex) == self.topo.number_of_faces_from_vertex(vert))
verts_from_face = [i for i in self.topo.vertices_from_face(face)]
self.assert_(len(verts_from_face) == self.topo.number_of_vertices_from_face(face))
def test_face_solid(self):
face = self.topo.faces().next()
solid = self.topo.solids().next()
faces_from_solid = [i for i in self.topo.faces_from_solids(solid)]
self.assert_(len(faces_from_solid) == self.topo.number_of_faces_from_solids(solid))
solids_from_face = [i for i in self.topo.solids_from_face(face)]
self.assert_(len(solids_from_face) == self.topo.number_of_solids_from_face(face))
def test_wire_face(self):
wire = self.topo.wires().next()
face = self.topo.faces().next()
faces_from_wire = [i for i in self.topo.faces_from_wire(wire)]
self.assert_(len(faces_from_wire) == self.topo.number_of_faces_from_wires(wire))
wires_from_face = [i for i in self.topo.wires_from_face(face)]
self.assert_(len(wires_from_face) == self.topo.number_of_wires_from_face(face))
def test_edges_out_of_scope(self):
face = self.topo.faces().next()
_edges = []
for edg in Topo(face).edges():
_edges.append(edg)
for edg in _edges:
self.assert_(edg.IsNull() == False)
def test_wires_out_of_scope(self):
face = self.topo.wires().next()
_edges = []
for edg in WireExplorer(face).ordered_edges():
_edges.append(edg)
for edg in _edges:
self.assert_(edg.IsNull() == False)