本文整理汇总了Python中OCC.Utils.Topology.Topo.edges方法的典型用法代码示例。如果您正苦于以下问题:Python Topo.edges方法的具体用法?Python Topo.edges怎么用?Python Topo.edges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCC.Utils.Topology.Topo
的用法示例。
在下文中一共展示了Topo.edges方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_change_selection
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import 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
示例2: makeSection2
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import edges [as 别名]
def makeSection2(self, cuttingPlane, shapeToSection, zLevel):
"""
Uses BrepSection Algo. this generally returns a list of wires, not a face
"""
# section is certainly faster, but produces only edges.
# those have to be re-organized into wires, probably
# using ShapeAnalysis_WireOrder
face = BRepBuilderAPI.BRepBuilderAPI_MakeFace(cuttingPlane).Shape()
# Computes Shape/Plane intersection
section = BRepAlgoAPI.BRepAlgoAPI_Section(self.solid.shape, face)
# section = BRepAlgo.BRepAlgo_Section(self.solid.shape,face);
section.Build()
if section.IsDone():
# Topology.dumpTopology(section.Shape());
# what we got back was a compound of edges
t = Topo(section.Shape())
wb = OCCUtil.MultiWireBuilder()
for e in t.edges():
wb.addEdge(e)
wires = wb.getWires()
print wires
for w in wires:
Topology.dumpTopology(w)
return wires
else:
raise Exception("Could not compute Section!")
示例3: offsetOnce
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import edges [as 别名]
def offsetOnce(self,distance):
bo = BRepOffsetAPI.BRepOffsetAPI_MakeOffset();
map(bo.AddWire, self.lastWires);
print "%d wires to offset at step 1, distance = %0.3f" % ( len(self.lastWires),distance);
bo.Perform(distance,0.0);
result1 = Topo(bo.Shape());
#now offset back outwards
bo2 = BRepOffsetAPI.BRepOffsetAPI_MakeOffset();
for w in result1.wires():
bo2.AddWire(w);
print "Offsetting %0.3f" % ( (-0.5)*distance);
bo2.Perform((-0.5)*distance, 0.0);
result2 = Topo(bo2.Shape());
returnList= [];
#compound result can be a compound of edges and/or wires. weird weird
for c in OCCUtil.childShapes(bo2.Shape() ):
#display.DisplayColoredShape(c,'BLUE')
if c.ShapeType() == TopAbs.TopAbs_WIRE:
returnList.append(c); #these are actually the wires we want to keep
self.otherWires.append(c);
elif c.ShapeType() == TopAbs.TopAbs_EDGE:
w = OCCUtil.wireFromEdges([c])
returnList.append(w);
self.otherWires.append(w);
else:
print "Warning: compound resulting from offset i am confused about-- not an edge or a wire."
if len(returnList) == 0:
return returnList; #do nothing further if the offset computed no curves
else:
print "2nd step yielded %d wires" % len(returnList)
#for each original edge, compute its descendant edges
#self.edgeMap will contain entries with the original edges, pointing to the generated
#edges and the corresponding wire:
# e1 --> [ (e2, w2 ), (e3 , w3 ) ];
for w in self.lastWires:
originalWire = Topo(w);
for oe in originalWire.edges():
self.edgeMap[oe.__hash__()] = [];
#find generated values from first transformation
generatedStep1 = OCCUtil.listFromTopToolsListOfShape(bo.Generated(oe));
for ne in generatedStep1:
#find edges generated from that original edge
generatedStep2 = OCCUtil.listFromTopToolsListOfShape(bo2.Generated(ne));
for ge in generatedStep2:
#get wire this belongs to this returns a list but how could there ever be more than one?
gwires = []
for g in result2.wires_from_edge(ge):
gwires.append(g);
self.edgeMap[oe.__hash__()].append ( (ge,gwires[0] ));
self.lastWires = returnList;
return returnList;
示例4: build_curve_network
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import edges [as 别名]
def build_curve_network(event=None):
'''
mimic the curve network surfacing command from rhino
'''
print 'Importing IGES file...',
pth = os.path.dirname(os.path.abspath(__file__))
pth = os.path.abspath(os.path.join(pth, '../../data/IGES/curve_geom_plate.igs'))
iges = IGESImporter(pth)
iges.read_file()
print 'done.'
# GetShapes returns 36 TopoDS_Shape, while the TopoDS_Compound contains
# just the 6 curves I made in rhino... hmmm...
print 'Building geomplate...',
topo = Topo(iges.get_compound())
edges_list = list(topo.edges())
face = build_geom_plate(edges_list)
print 'done.'
print 'Cutting out of edges...',
# Make a wire from outer edges
_edges = [edges_list[2], edges_list[3], edges_list[4], edges_list[5]]
outer_wire = make_wire(_edges)
示例5: build_curve_network
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import edges [as 别名]
def build_curve_network(event=None):
'''
mimic the curve network surfacing command from rhino
'''
print 'Importing IGES file...',
pth = os.path.dirname(os.path.abspath(__file__))
pth = os.path.abspath(os.path.join(pth, '../../data/IGES/curve_geom_plate.igs'))
iges = IGESImporter(pth)
iges.read_file()
print 'done.'
print 'Building geomplate...',
topo = Topo(iges.get_compound())
edges_list = list(topo.edges())
face = build_geom_plate(edges_list)
print 'done.'
display.EraseAll()
display.DisplayShape(edges_list)
display.FitAll()
print 'Cutting out of edges...',
# Make a wire from outer edges
_edges = [edges_list[2], edges_list[3], edges_list[4], edges_list[5]]
outer_wire = make_wire(_edges)
示例6: Topo
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import edges [as 别名]
ts = TDF.TDF_TagSource()
box = BRepPrimAPI.BRepPrimAPI_MakeBox(20.0,20.0,20.0).Shape()
box_label = ts.NewChild(root)
ns_builder = TNaming.TNaming_Builder(box_label)
ns_builder.Generated(box)
topo = Topo(box)
##
##Name all the subshape we *might* want to refer to later
##
for edge in topo.edges():
sub_label = ts.NewChild(box_label)
ns_builder = TNaming.TNaming_Builder(sub_label)
ns_builder.Generated(edge)
#
#Find and Name an edge
#
an_edge = topo.edges().next()
s_label = ts.NewChild(root)
selector = TNaming.TNaming_Selector(s_label)
ret = selector.Select(an_edge, box)
print "selected", ret
#
示例7: make_closed_polygon
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import edges [as 别名]
pl2 = make_closed_polygon(gp_Pnt(0,-10,-10),
gp_Pnt(0,10,-10),
gp_Pnt(0,10,10),
gp_Pnt(0,-10,10),
)
f1 = make_face(pl1)
f2 = make_face(pl2)
spl = Partition_Spliter()
spl.AddShape(f1)
spl.AddTool(f2)
spl.Compute(TopAbs_SHAPE)
shp = spl.Shape()
shp = translate_topods_from_vector(shp, gp_Vec(30,0,0))
disp = Display()
tp = Topo(shp)
for i in tp.edges():
disp(i)
disp((pl1,pl2))
print spl
示例8: TestTopology
# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import 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)