本文整理匯總了Python中OCC.Utils.Topology.Topo.edges_from_vertex方法的典型用法代碼示例。如果您正苦於以下問題:Python Topo.edges_from_vertex方法的具體用法?Python Topo.edges_from_vertex怎麽用?Python Topo.edges_from_vertex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OCC.Utils.Topology.Topo
的用法示例。
在下文中一共展示了Topo.edges_from_vertex方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LoopWirePairs
# 需要導入模塊: from OCC.Utils.Topology import Topo [as 別名]
# 或者: from OCC.Utils.Topology.Topo import edges_from_vertex [as 別名]
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(edges_a.next()),Edge(edges_a.next())
b1, b2 = Edge(edges_b.next()),Edge(edges_b.next())
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
示例2: TestTopology
# 需要導入模塊: from OCC.Utils.Topology import Topo [as 別名]
# 或者: from OCC.Utils.Topology.Topo import edges_from_vertex [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)