def addInset( self, rotatedBoundaryLayer ): "Add inset to the layer." alreadyFilledArounds = [] halfWidth = self.halfPerimeterWidth if rotatedBoundaryLayer.rotation != None: halfWidth *= self.repository.bridgeWidthMultiplier.value self.distanceFeedRate.addTagBracketedLine('bridgeRotation', rotatedBoundaryLayer.rotation ) extrudateLoops = intercircle.getInsetLoopsFromLoops( halfWidth, rotatedBoundaryLayer.loops ) if self.repository.loopOrderAscendingArea.value: extrudateLoops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaAscending, extrudateLoops ) else: extrudateLoops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaDescending, extrudateLoops ) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop( extrudateLoop, alreadyFilledArounds, halfWidth, rotatedBoundaryLayer.z )
def addWiden(self, rotatedBoundaryLayer): "Add widen to the layer." loops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaAscending, rotatedBoundaryLayer.loops) widdershinsLoops = [] clockwiseInsetLoops = [] for loopIndex in xrange(len(loops)): loop = loops[loopIndex] if euclidean.isWiddershins(loop): otherLoops = loops[:loopIndex] + loops[loopIndex + 1:] leftPoint = euclidean.getLeftPoint(loop) if getIsPointInsideALoop(otherLoops, leftPoint): self.distanceFeedRate.addGcodeFromLoop( loop, rotatedBoundaryLayer.z) else: widdershinsLoops.append(loop) else: clockwiseInsetLoops += intercircle.getInsetLoopsFromLoop( self.doublePerimeterWidth, loop) self.distanceFeedRate.addGcodeFromLoop(loop, rotatedBoundaryLayer.z) for widdershinsLoop in widdershinsLoops: outsetLoop = intercircle.getLargestInsetLoopFromLoop( widdershinsLoop, -self.doublePerimeterWidth) widenedLoop = getWidenedLoop(widdershinsLoop, clockwiseInsetLoops, outsetLoop, self.perimeterWidth) self.distanceFeedRate.addGcodeFromLoop(widenedLoop, rotatedBoundaryLayer.z)
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) rotatedLoopLayer.loops = trianglemesh.getLoopsInOrderOfArea(trianglemesh.compareAreaDescending, rotatedLoopLayer.loops) for loopIndex, loop in enumerate(rotatedLoopLayer.loops): isInsideLoops = euclidean.getIsInFilledRegion(rotatedLoopLayer.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) rotatedLoopLayer.loops = trianglemesh.getLoopsInOrderOfArea(trianglemesh.compareAreaDescending, rotatedLoopLayer.loops) for loopIndex, loop in enumerate(rotatedLoopLayer.loops): isInsideLoops = euclidean.getIsInFilledRegion(rotatedLoopLayer.loops[: loopIndex], euclidean.getLeftPoint(loop)) intercircle.directLoop((not isInsideLoops), loop)
def addOutset(self, rotatedBoundaryLayer): "Add outset to the layer." extrudateLoops = intercircle.getInsetLoopsFromLoops( -self.absoluteHalfPerimeterWidth, rotatedBoundaryLayer.loops) sortedLoops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaAscending, extrudateLoops) for sortedLoop in sortedLoops: self.addGcodeFromRemainingLoop(sortedLoop, self.absoluteHalfPerimeterWidth, rotatedBoundaryLayer.z)
def addInset(self, rotatedBoundaryLayer): "Add inset to the layer." alreadyFilledArounds = [] halfWidth = self.halfPerimeterWidth if rotatedBoundaryLayer.rotation != None: halfWidth *= self.repository.bridgeWidthMultiplier.value self.distanceFeedRate.addTagBracketedLine( 'bridgeRotation', rotatedBoundaryLayer.rotation) extrudateLoops = intercircle.getInsetLoopsFromLoops( halfWidth, rotatedBoundaryLayer.loops) if self.repository.loopOrderAscendingArea.value: extrudateLoops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaAscending, extrudateLoops) else: extrudateLoops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaDescending, extrudateLoops) for extrudateLoop in extrudateLoops: self.addGcodeFromRemainingLoop(extrudateLoop, alreadyFilledArounds, halfWidth, rotatedBoundaryLayer.z)
def addWiden( self, rotatedBoundaryLayer ): "Add widen to the layer." loops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaAscending, rotatedBoundaryLayer.loops ) widdershinsLoops = [] clockwiseInsetLoops = [] for loopIndex in xrange( len(loops) ): loop = loops[loopIndex] if euclidean.isWiddershins(loop): otherLoops = loops[ : loopIndex ] + loops[loopIndex + 1 :] leftPoint = euclidean.getLeftPoint(loop) if getIsPointInsideALoop( otherLoops, leftPoint ): self.distanceFeedRate.addGcodeFromLoop( loop, rotatedBoundaryLayer.z ) else: widdershinsLoops.append(loop) else: clockwiseInsetLoops += intercircle.getInsetLoopsFromLoop( self.doublePerimeterWidth, loop ) self.distanceFeedRate.addGcodeFromLoop( loop, rotatedBoundaryLayer.z ) for widdershinsLoop in widdershinsLoops: outsetLoop = intercircle.getLargestInsetLoopFromLoop( widdershinsLoop, - self.doublePerimeterWidth ) widenedLoop = getWidenedLoop( widdershinsLoop, clockwiseInsetLoops, outsetLoop, self.perimeterWidth ) self.distanceFeedRate.addGcodeFromLoop( widenedLoop, rotatedBoundaryLayer.z )
def addOutset( self, rotatedBoundaryLayer ): "Add outset to the layer." extrudateLoops = intercircle.getInsetLoopsFromLoops( - self.absoluteHalfPerimeterWidth, rotatedBoundaryLayer.loops ) sortedLoops = trianglemesh.getLoopsInOrderOfArea( trianglemesh.compareAreaAscending, extrudateLoops ) for sortedLoop in sortedLoops: self.addGcodeFromRemainingLoop( sortedLoop, self.absoluteHalfPerimeterWidth, rotatedBoundaryLayer.z )