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 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)