当前位置: 首页>>代码示例>>Python>>正文


Python Topo.number_of_edges方法代码示例

本文整理汇总了Python中OCC.Utils.Topology.Topo.number_of_edges方法的典型用法代码示例。如果您正苦于以下问题:Python Topo.number_of_edges方法的具体用法?Python Topo.number_of_edges怎么用?Python Topo.number_of_edges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCC.Utils.Topology.Topo的用法示例。


在下文中一共展示了Topo.number_of_edges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_change_selection

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import number_of_edges [as 别名]
 def on_change_selection(self):
     new_id = self.edge_id
     input = self.input
     label = self.label
     
     if not all((input, label)): return
     
     input_shape = input.shape
     
     sel_label = self.label.FindChild(4)
     selector = TNaming.TNaming_Selector(sel_label)
     
     self.selector = selector
     
     topo = Topo(input_shape)
     self._n_edges = topo.number_of_edges()
     for i,edge in enumerate(topo.edges()):
         if i==new_id:
             selector.Select(edge, input_shape)
             print "got selection!"
             break
     else:
         print "no selection"
         
     self.modified = False
     self.modified = True
开发者ID:mortbauer,项目名称:pythonocc,代码行数:28,代码来源:occ_model.py

示例2: execute

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import number_of_edges [as 别名]
 def execute(self):
     input_shape = self.input.shape
     
     topo = Topo(input_shape)
     self._n_edges = topo.number_of_edges()
     
     builder = BRepFilletAPI.BRepFilletAPI_MakeChamfer(input_shape)
     
     Map = TDF.TDF_LabelMap()
     itr = TDF.TDF_ChildIterator(self.parent_label, True)
     while itr.More():
         sub_label = itr.Value()
         Map.Add(sub_label)
         itr.Next()
         
     selector = self.selector
     ret = selector.Solve(Map)
     
     if not ret:
         raise Exception("Failed to solve for edge")
         #print "Failed to solve for edge"
     
     nt = TNaming.TNaming_Tool()
     selected_shape = nt.CurrentShape(selector.NamedShape())
     
     selected_edge = TopoDS.TopoDS().Edge(selected_shape)
     
     try:
         face = Topo(input_shape).faces_from_edge(selected_edge).next()
     except RuntimeError:
         raise #not sure how to handle this
     size = self.size
     builder.Add(size, size, selected_edge, face)
     
     self.update_naming(builder)
     return builder.Shape()
开发者ID:mortbauer,项目名称:pythonocc,代码行数:38,代码来源:occ_model.py

示例3: TestTopology

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import number_of_edges [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)
开发者ID:imclab,项目名称:pythonocc,代码行数:95,代码来源:topology_unittest.py


注:本文中的OCC.Utils.Topology.Topo.number_of_edges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。