def addInset(self, nestedRing, halfWidth, alreadyFilledArounds): "Add inset to the layer." # Note: inner nested rings have to come first so the intersecting check below does not give a false positive for innerNestedRing in nestedRing.innerNestedRings: self.addInset(innerNestedRing, halfWidth, alreadyFilledArounds) boundary = [nestedRing.getXYBoundaries()] insetBoundaryPerimeter = intercircle.getInsetLoopsFromLoops(halfWidth, boundary) triangle_mesh.sortLoopsInOrderOfArea(not self.loopOrderAscendingArea, insetBoundaryPerimeter) for loop in insetBoundaryPerimeter: centerOutset = intercircle.getLargestCenterOutsetLoopFromLoopRegardless(loop, halfWidth) "Add the perimeter block remainder of the loop which does not overlap the alreadyFilledArounds loops." if self.overlapRemovalWidthOverPerimeterWidth < 0.1: nestedRing.perimeter.addPath(centerOutset.center + [centerOutset.center[0]]) break isIntersectingSelf = isIntersectingItself(centerOutset.center, self.overlapRemovalWidth) if isIntersectingWithinLists(centerOutset.center, alreadyFilledArounds) or isIntersectingSelf: self.addGcodeFromPerimeterPaths( nestedRing, isIntersectingSelf, centerOutset.center, alreadyFilledArounds, halfWidth, boundary ) else: nestedRing.perimeter.addPath(centerOutset.center + [centerOutset.center[0]]) addAlreadyFilledArounds(alreadyFilledArounds, centerOutset.center, self.overlapRemovalWidth)
def addWiden(self, loopLayer): 'Add widen to the layer.' triangle_mesh.sortLoopsInOrderOfArea(False, loopLayer.loops) widdershinsLoops = [] clockwiseInsetLoops = [] for loopIndex in xrange(len(loopLayer.loops)): loop = loopLayer.loops[loopIndex] if euclidean.isWiddershins(loop): otherLoops = loopLayer.loops[:loopIndex] + loopLayer.loops[ loopIndex + 1:] leftPoint = euclidean.getLeftPoint(loop) if getIsPointInsideALoop(otherLoops, leftPoint): self.distanceFeedRate.addGcodeFromLoop(loop, loopLayer.z) else: widdershinsLoops.append(loop) else: # clockwiseInsetLoop = intercircle.getLargestInsetLoopFromLoop(loop, self.widenEdgeWidth) # clockwiseInsetLoop.reverse() # clockwiseInsetLoops.append(clockwiseInsetLoop) clockwiseInsetLoops += intercircle.getInsetLoopsFromLoop( loop, self.widenEdgeWidth) self.distanceFeedRate.addGcodeFromLoop(loop, loopLayer.z) for widdershinsLoop in widdershinsLoops: outsetLoop = intercircle.getLargestInsetLoopFromLoop( widdershinsLoop, -self.widenEdgeWidth) for widenedLoop in getWidenedLoops(widdershinsLoop, clockwiseInsetLoops, outsetLoop, self.lessThanHalfEdgeWidth): self.distanceFeedRate.addGcodeFromLoop(widenedLoop, loopLayer.z)
def addOutset(self, loopLayer): 'Add outset to the layer.' extrudateLoops = intercircle.getInsetLoopsFromLoops( loopLayer.loops, -self.absoluteHalfPerimeterWidth) triangle_mesh.sortLoopsInOrderOfArea(False, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop(extrudateLoop, self.absoluteHalfPerimeterWidth, loopLayer.z)
def flipDirectLayer(self, loopLayer): "Flip the y coordinate of the layer and direct the loops." for loop in loopLayer.loops: for pointIndex, point in enumerate(loop): loop[pointIndex] = complex(point.real, -point.imag) triangle_mesh.sortLoopsInOrderOfArea(True, loopLayer.loops) for loopIndex, loop in enumerate(loopLayer.loops): isInsideLoops = euclidean.getIsInFilledRegion(loopLayer.loops[: loopIndex], euclidean.getLeftPoint(loop)) intercircle.directLoop((not isInsideLoops), loop)
def flipDirectLayer(self, rotatedLoopLayer): "Flip the y coordinate of the layer and direct the loops." for loop in rotatedLoopLayer.loops: for pointIndex, point in enumerate(loop): loop[pointIndex] = complex(point.real, -point.imag) triangle_mesh.sortLoopsInOrderOfArea(True, rotatedLoopLayer.loops) for loopIndex, loop in enumerate(rotatedLoopLayer.loops): isInsideLoops = euclidean.getIsInFilledRegion(rotatedLoopLayer.loops[: loopIndex], euclidean.getLeftPoint(loop)) intercircle.directLoop((not isInsideLoops), loop)
def addInset( self, rotatedLoopLayer ): "Add inset to the layer." alreadyFilledArounds = [] halfWidth = self.halfPerimeterWidth if rotatedLoopLayer.rotation != None: halfWidth *= self.repository.bridgeWidthMultiplier.value self.distanceFeedRate.addTagBracketedLine('bridgeRotation', rotatedLoopLayer.rotation ) extrudateLoops = intercircle.getInsetLoopsFromLoops( halfWidth, rotatedLoopLayer.loops ) triangle_mesh.sortLoopsInOrderOfArea(not self.repository.loopOrderAscendingArea.value, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop( extrudateLoop, alreadyFilledArounds, halfWidth, rotatedLoopLayer.z )
def addInset(self, rotatedLoopLayer): "Add inset to the layer." alreadyFilledArounds = [] halfWidth = self.halfPerimeterWidth if rotatedLoopLayer.rotation != None: halfWidth *= self.repository.bridgeWidthMultiplier.value self.distanceFeedRate.addTagBracketedLine('bridgeRotation', rotatedLoopLayer.rotation) extrudateLoops = intercircle.getInsetLoopsFromLoops(halfWidth, rotatedLoopLayer.loops) triangle_mesh.sortLoopsInOrderOfArea(not self.repository.loopOrderAscendingArea.value, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop(extrudateLoop, alreadyFilledArounds, halfWidth, rotatedLoopLayer)
def addInset(self, loopLayer): "Add inset to the layer." alreadyFilledArounds = [] extrudateLoops = intercircle.getInsetLoopsFromLoops(loopLayer.loops, self.halfEdgeWidth) if self.repository.infillInDirectionOfBridge.value: bridgeRotation = getBridgeDirection(self.belowLoops, extrudateLoops, self.halfEdgeWidth) if bridgeRotation != None: self.distanceFeedRate.addTagBracketedLine('bridgeRotation', bridgeRotation) self.belowLoops = loopLayer.loops triangle_mesh.sortLoopsInOrderOfArea(not self.repository.loopOrderAscendingArea.value, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop(extrudateLoop, loopLayer, alreadyFilledArounds, self.halfEdgeWidth)
def addInset(self, loopLayer): "Add inset to the layer." alreadyFilledArounds = [] extrudateLoops = intercircle.getInsetLoopsFromLoops(loopLayer.loops, self.halfPerimeterWidth) if self.repository.infillInDirectionOfBridge.value: self.halfBridgeWidth = self.repository.bridgeWidthMultiplier.value * self.halfPerimeterWidth #* (self.nozzleXsection / self.extrusionXsection) bridgeRotation = getBridgeDirection(self.belowLoops, extrudateLoops, self.halfBridgeWidth ) if bridgeRotation is not None: self.distanceFeedRate.addTagBracketedLine('bridgeRotation', bridgeRotation) # print 'bridge' , self.layerCount self.belowLoops = loopLayer.loops triangle_mesh.sortLoopsInOrderOfArea(not self.repository.loopOrderAscendingArea.value, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop(extrudateLoop, loopLayer, alreadyFilledArounds, self.halfPerimeterWidth)
def addInset(self, loopLayer): "Add inset to the layer." alreadyFilledArounds = [] extrudateLoops = intercircle.getInsetLoopsFromLoops( loopLayer.loops, self.halfEdgeWidth) if self.repository.infillInDirectionOfBridge.value: bridgeRotation = getBridgeDirection(self.belowLoops, extrudateLoops, self.halfEdgeWidth) if bridgeRotation != None: self.distanceFeedRate.addTagBracketedLine( 'bridgeRotation', bridgeRotation) self.belowLoops = loopLayer.loops triangle_mesh.sortLoopsInOrderOfArea( not self.repository.loopOrderAscendingArea.value, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop(extrudateLoop, loopLayer, alreadyFilledArounds, self.halfEdgeWidth)
def addOutset(self, rotatedLoopLayer): "Add outset to the layer." extrudateLoops = intercircle.getInsetLoopsFromLoops( -self.absoluteHalfPerimeterWidth, rotatedLoopLayer.loops) sortedLoops = triangle_mesh.sortLoopsInOrderOfArea( False, extrudateLoops) for sortedLoop in sortedLoops: self.addGcodeFromRemainingLoop(sortedLoop, self.absoluteHalfPerimeterWidth, rotatedLoopLayer.z)
def parseBoundaries(self): 'Parse the boundaries and add them to the boundary layers.' boundaryLoop = None boundaryLayer = None for line in self.lines[self.lineIndex :]: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == '(</boundaryPerimeter>)': boundaryLoop = None elif firstWord == '(<boundaryPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) if boundaryLoop == None: boundaryLoop = [] boundaryLayer.loops.append(boundaryLoop) boundaryLoop.append(location.dropAxis()) elif firstWord == '(<layer>': boundaryLayer = euclidean.LoopLayer(float(splitLine[1])) self.boundaryLayers.append(boundaryLayer) for boundaryLayer in self.boundaryLayers: triangle_mesh.sortLoopsInOrderOfArea(False, boundaryLayer.loops)
def addInset(self, nestedRing, halfWidth, alreadyFilledArounds): "Add inset to the layer." # Note: inner nested rings have to come first so the intersecting check below does not give a false positive for innerNestedRing in nestedRing.innerNestedRings: self.addInset(innerNestedRing, halfWidth, alreadyFilledArounds) boundary = [nestedRing.getXYBoundaries()] insetBoundaryPerimeter = intercircle.getInsetLoopsFromLoops( halfWidth, boundary) triangle_mesh.sortLoopsInOrderOfArea(not self.loopOrderAscendingArea, insetBoundaryPerimeter) for loop in insetBoundaryPerimeter: centerOutset = intercircle.getLargestCenterOutsetLoopFromLoopRegardless( loop, halfWidth) "Add the perimeter block remainder of the loop which does not overlap the alreadyFilledArounds loops." if self.overlapRemovalWidthOverPerimeterWidth < 0.1: nestedRing.perimeter.addPath(centerOutset.center + [centerOutset.center[0]]) break isIntersectingSelf = isIntersectingItself(centerOutset.center, self.overlapRemovalWidth) if isIntersectingWithinLists( centerOutset.center, alreadyFilledArounds) or isIntersectingSelf: self.addGcodeFromPerimeterPaths(nestedRing, isIntersectingSelf, centerOutset.center, alreadyFilledArounds, halfWidth, boundary) else: nestedRing.perimeter.addPath(centerOutset.center + [centerOutset.center[0]]) addAlreadyFilledArounds(alreadyFilledArounds, centerOutset.center, self.overlapRemovalWidth)
def addWiden(self, rotatedLoopLayer): 'Add widen to the layer.' triangle_mesh.sortLoopsInOrderOfArea(False, rotatedLoopLayer.loops) widdershinsLoops = [] clockwiseInsetLoops = [] for loopIndex in xrange(len(rotatedLoopLayer.loops)): loop = rotatedLoopLayer.loops[loopIndex] if euclidean.isWiddershins(loop): otherLoops = rotatedLoopLayer.loops[: loopIndex] + rotatedLoopLayer.loops[loopIndex + 1 :] leftPoint = euclidean.getLeftPoint(loop) if getIsPointInsideALoop(otherLoops, leftPoint): self.distanceFeedRate.addGcodeFromLoop(loop, rotatedLoopLayer.z) else: widdershinsLoops.append(loop) else: # clockwiseInsetLoop = intercircle.getLargestInsetLoopFromLoop(loop, self.doublePerimeterWidth) # clockwiseInsetLoop.reverse() # clockwiseInsetLoops.append(clockwiseInsetLoop) clockwiseInsetLoops += intercircle.getInsetLoopsFromLoop(loop, self.doublePerimeterWidth) self.distanceFeedRate.addGcodeFromLoop(loop, rotatedLoopLayer.z) for widdershinsLoop in widdershinsLoops: outsetLoop = intercircle.getLargestInsetLoopFromLoop(widdershinsLoop, -self.doublePerimeterWidth) widenedLoop = getWidenedLoop(widdershinsLoop, clockwiseInsetLoops, outsetLoop, self.perimeterWidth) self.distanceFeedRate.addGcodeFromLoop(widenedLoop, rotatedLoopLayer.z)
def addOutset(self, rotatedLoopLayer): "Add outset to the layer." extrudateLoops = intercircle.getInsetLoopsFromLoops(-self.absoluteHalfPerimeterWidth, rotatedLoopLayer.loops) sortedLoops = triangle_mesh.sortLoopsInOrderOfArea(False, extrudateLoops) for sortedLoop in sortedLoops: self.addGcodeFromRemainingLoop(sortedLoop, self.absoluteHalfPerimeterWidth, rotatedLoopLayer.z)
def addOutset(self, loopLayer): 'Add outset to the layer.' extrudateLoops = intercircle.getInsetLoopsFromLoops(loopLayer.loops, -self.absoluteHalfPerimeterWidth) triangle_mesh.sortLoopsInOrderOfArea(False, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop(extrudateLoop, self.absoluteHalfPerimeterWidth, loopLayer.z)