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 __init__(self, face): self.face = face self.originalWires = OCCUtil.wireListFromFace(face) self.edgeMap = {} self.otherWires = [] self.lastWires = self.originalWires self.display = None self.outputWires = []
def __init__(self,face): self.face= face; self.originalWires = OCCUtil.wireListFromFace(face); self.edgeMap = {}; self.otherWires = []; self.lastWires = self.originalWires; self.display = None; self.outputWires = [];
def testBasicFaceOffset(): f = TestObjects.makeHeartFaceNoHole() startWires = OCCUtil.wireListFromFace(f) display.DisplayColoredShape(startWires, 'GREEN') cw = startWires for i in range(3): w = OCCUtil.offsetWireList(cw, -0.2) display.DisplayColoredShape(w, 'RED') cw = w
def testBasicFaceOffset(): f = TestObjects.makeHeartFaceNoHole(); startWires = OCCUtil.wireListFromFace(f); display.DisplayColoredShape(startWires,'GREEN'); cw = startWires; for i in range(3): w = OCCUtil.offsetWireList(cw,-0.2); display.DisplayColoredShape(w,'RED'); cw = w;
def _fillSlice(self, slice): #how many shells do we need? #attempt to create the number of shells requested by the user, plus one additional for infill for f in slice.faces: numShells = (int)(self.options.fillingWallThickness / self.extruder.trackWidth()) + 1 numShells = max(2, numShells) faceWires = OCCUtil.wireListFromFace(f.face) #regardless, the last successfully created offset is used for hatch infill shells = [] for i in range(1, numShells): #compute offset inwards by one track width offset = (-1) * i * self.extruder.trackWidth() innerEdge = OCCUtil.offsetWireList(faceWires, offset) if len(innerEdge) == 0: #performance: dont offset if there were already no wires continue pathCenter = OCCUtil.offsetWireList( innerEdge, self.extruder.trackWidth() / 2) if len(pathCenter) > 0: shells.append(pathCenter) if len(shells) > 1: #use last one for filling. print "%d shells were available for Hatching" % len(shells) lastShell = shells.pop() s = self.solid h = hatchlib.Hatcher(lastShell, zLevel, (s.xMin, s.yMin, s.xMax, s.yMax), self.extruder.trackWidth(), cSlice.fillAngle) h.hatch() ww = h.getWires() print "Hatching complete: %d fillWires created" % len(ww) f.fillWires = ww else: print "WARNING: not filling this layer, too few shells were computable" #add shells for s in shells: for ss in s: f.shellWires.append(ss)
def _fillSlice(self, slice): # how many shells do we need? # attempt to create the number of shells requested by the user, plus one additional for infill for f in slice.faces: numShells = (int)(self.options.fillingWallThickness / self.extruder.trackWidth()) + 1 numShells = max(2, numShells) faceWires = OCCUtil.wireListFromFace(f.face) # regardless, the last successfully created offset is used for hatch infill shells = [] for i in range(1, numShells): # compute offset inwards by one track width offset = (-1) * i * self.extruder.trackWidth() innerEdge = OCCUtil.offsetWireList(faceWires, offset) if len(innerEdge) == 0: # performance: dont offset if there were already no wires continue pathCenter = OCCUtil.offsetWireList(innerEdge, self.extruder.trackWidth() / 2) if len(pathCenter) > 0: shells.append(pathCenter) if len(shells) > 1: # use last one for filling. print "%d shells were available for Hatching" % len(shells) lastShell = shells.pop() s = self.solid h = hatchlib.Hatcher( lastShell, zLevel, (s.xMin, s.yMin, s.xMax, s.yMax), self.extruder.trackWidth(), cSlice.fillAngle ) h.hatch() ww = h.getWires() print "Hatching complete: %d fillWires created" % len(ww) f.fillWires = ww else: print "WARNING: not filling this layer, too few shells were computable" # add shells for s in shells: for ss in s: f.shellWires.append(ss)