def testOffsetReferences(): #f = TestObjects.makeHeartFace(); #f must be a face with one outer and one inner wire f = TestObjects.makeSquareWithRoundHole(); wires = OCCUtil.wireListFromFace(f); outer = wires[0]; inner = wires[1]; display.DisplayColoredShape(outer,'GREEN'); display.DisplayColoredShape(inner,'WHITE'); #add wires to offset. bo = BRepOffsetAPI.BRepOffsetAPI_MakeOffset(); bo.AddWire(outer); bo.AddWire(inner); bo.Perform(-0.2,0.0); #do an offset shape = bo.Shape(); for w in Topo(shape).wires(): display.DisplayColoredShape(OCCUtil.cast(shape),'YELLOW'); for e in Topo(outer).edges(): print "Outer Edge %d has %d generated shapes" % ( e.__hash__(), len(OCCUtil.listFromTopToolsListOfShape(bo.Generated(e) )) ); for e in Topo(inner).edges(): print "Inner Edge %d has %d generated shapes" % ( e.__hash__(), len(OCCUtil.listFromTopToolsListOfShape(bo.Generated(e) )) ); display.FitAll();
def testOffsetReferences(): #f = TestObjects.makeHeartFace(); #f must be a face with one outer and one inner wire f = TestObjects.makeSquareWithRoundHole() wires = OCCUtil.wireListFromFace(f) outer = wires[0] inner = wires[1] display.DisplayColoredShape(outer, 'GREEN') display.DisplayColoredShape(inner, 'WHITE') #add wires to offset. bo = BRepOffsetAPI.BRepOffsetAPI_MakeOffset() bo.AddWire(outer) bo.AddWire(inner) bo.Perform(-0.2, 0.0) #do an offset shape = bo.Shape() for w in Topo(shape).wires(): display.DisplayColoredShape(OCCUtil.cast(shape), 'YELLOW') for e in Topo(outer).edges(): print "Outer Edge %d has %d generated shapes" % ( e.__hash__(), len(OCCUtil.listFromTopToolsListOfShape(bo.Generated(e)))) for e in Topo(inner).edges(): print "Inner Edge %d has %d generated shapes" % ( e.__hash__(), len(OCCUtil.listFromTopToolsListOfShape(bo.Generated(e)))) display.FitAll()
def testOffsetMapBasic(): #tests whether the offestting works f = TestObjects.makeSquareWithRoundHole(); #face that will have odd offsets om = OffsetMap(f); om.offsetOnce(-0.2); display.DisplayColoredShape(om.originalWires,'GREEN'); display.DisplayColoredShape(om.otherWires,'RED');
def testOffsetMapBasic(): #tests whether the offestting works f = TestObjects.makeSquareWithRoundHole() #face that will have odd offsets om = OffsetMap(f) om.offsetOnce(-0.2) display.DisplayColoredShape(om.originalWires, 'GREEN') display.DisplayColoredShape(om.otherWires, 'RED')
def testOffsetMapDecendants(): #test that we can find the edge, vertex, and wire from a given edge f = TestObjects.makeSquareWithRoundHole(); #face that will have odd offsets om = OffsetMap(f); om.offsetOnce(-0.2); #display each edge and its decendant edge. #each original edge and vertex is checked #in each case the result should be the edge that was created from the one in green, #and the blue point should be the vertex of that edge closest to the green vertex for w in om.originalWires: for e in Topo(w).edges(): for v in Topo(e).vertices(): display.EraseAll(); display.DisplayColoredShape(v,'GREEN'); display.DisplayColoredShape(e,'GREEN'); (nv,ne,nw) = om.getNextEdge(e,v); display.DisplayColoredShape(nw,'YELLOW'); display.DisplayColoredShape(ne,'RED'); display.DisplayColoredShape(nv,'BLUE'); time.sleep(5);
def testOffsetMapDecendants(): #test that we can find the edge, vertex, and wire from a given edge f = TestObjects.makeSquareWithRoundHole() #face that will have odd offsets om = OffsetMap(f) om.offsetOnce(-0.2) #display each edge and its decendant edge. #each original edge and vertex is checked #in each case the result should be the edge that was created from the one in green, #and the blue point should be the vertex of that edge closest to the green vertex for w in om.originalWires: for e in Topo(w).edges(): for v in Topo(e).vertices(): display.EraseAll() display.DisplayColoredShape(v, 'GREEN') display.DisplayColoredShape(e, 'GREEN') (nv, ne, nw) = om.getNextEdge(e, v) display.DisplayColoredShape(nw, 'YELLOW') display.DisplayColoredShape(ne, 'RED') display.DisplayColoredShape(nv, 'BLUE') time.sleep(5)