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 addCoolOrbits(self, remainingOrbitTime): 'Add the minimum radius cool orbits.' if len(self.boundaryLayer.loops) < 1: return insetBoundaryLoops = intercircle.getInsetLoopsFromLoops( self.perimeterWidth, self.boundaryLayer.loops) if len(insetBoundaryLoops) < 1: insetBoundaryLoops = self.boundaryLayer.loops largestLoop = euclidean.getLargestLoop(insetBoundaryLoops) loopArea = euclidean.getAreaLoopAbsolute(largestLoop) if loopArea < self.minimumArea: center = 0.5 * (euclidean.getMaximumByComplexPath(largestLoop) + euclidean.getMinimumByComplexPath(largestLoop)) centerXBounded = max(center.real, self.boundingRectangle.cornerMinimum.real) centerXBounded = min(centerXBounded, self.boundingRectangle.cornerMaximum.real) centerYBounded = max(center.imag, self.boundingRectangle.cornerMinimum.imag) centerYBounded = min(centerYBounded, self.boundingRectangle.cornerMaximum.imag) center = complex(centerXBounded, centerYBounded) maximumCorner = center + self.halfCorner minimumCorner = center - self.halfCorner largestLoop = euclidean.getSquareLoopWiddershins( minimumCorner, maximumCorner) pointComplex = euclidean.getXYComplexFromVector3(self.oldLocation) if pointComplex != None: largestLoop = euclidean.getLoopStartingNearest( self.perimeterWidth, pointComplex, largestLoop) intercircle.addOrbitsIfLarge(self.distanceFeedRate, largestLoop, self.orbitalFeedRatePerSecond, remainingOrbitTime, self.highestZ)
def addCoolOrbits(self, remainingOrbitTime): 'Add the minimum radius cool orbits.' if len(self.boundaryLayer.loops) < 1: return insetBoundaryLoops = self.boundaryLayer.loops if abs(self.repository.orbitalOutset.value) > 0.1 * abs(self.edgeWidth): insetBoundaryLoops = intercircle.getInsetLoopsFromLoops(self.boundaryLayer.loops, -self.repository.orbitalOutset.value) if len(insetBoundaryLoops) < 1: insetBoundaryLoops = self.boundaryLayer.loops largestLoop = euclidean.getLargestLoop(insetBoundaryLoops) loopArea = euclidean.getAreaLoopAbsolute(largestLoop) if loopArea < self.minimumArea: center = 0.5 * (euclidean.getMaximumByComplexPath(largestLoop) + euclidean.getMinimumByComplexPath(largestLoop)) centerXBounded = max(center.real, self.boundingRectangle.cornerMinimum.real) centerXBounded = min(centerXBounded, self.boundingRectangle.cornerMaximum.real) centerYBounded = max(center.imag, self.boundingRectangle.cornerMinimum.imag) centerYBounded = min(centerYBounded, self.boundingRectangle.cornerMaximum.imag) center = complex(centerXBounded, centerYBounded) maximumCorner = center + self.halfCorner minimumCorner = center - self.halfCorner largestLoop = euclidean.getSquareLoopWiddershins(minimumCorner, maximumCorner) pointComplex = euclidean.getXYComplexFromVector3(self.oldLocation) if pointComplex != None: largestLoop = euclidean.getLoopStartingClosest(self.edgeWidth, pointComplex, largestLoop) intercircle.addOrbitsIfLarge( self.distanceFeedRate, largestLoop, self.orbitalFeedRatePerSecond, remainingOrbitTime, self.highestZ)
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 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 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 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 getBridgeDirection(belowLoops, layerLoops, radius): 'Get span direction for the majority of the overhanging extrusion perimeter, if any.' if len(belowLoops) < 1: return None belowOutsetLoops = intercircle.getInsetLoopsFromLoops(belowLoops, -radius) bridgeRotation = complex() for loop in layerLoops: for pointIndex, point in enumerate(loop): previousIndex = (pointIndex + len(loop) - 1) % len(loop) bridgeRotation += getOverhangDirection(belowOutsetLoops, loop[previousIndex], point) if abs(bridgeRotation) < 0.75 * radius: return None else: return cmath.sqrt(bridgeRotation / abs(bridgeRotation))
def getBridgeDirection(belowLoops, layerLoops, radius): 'Get span direction for the majority of the overhanging extrusion edge, if any.' if len(belowLoops) < 1: return None belowOutsetLoops = intercircle.getInsetLoopsFromLoops(belowLoops, -radius) bridgeRotation = complex() for loop in layerLoops: for pointIndex, point in enumerate(loop): previousIndex = (pointIndex + len(loop) - 1) % len(loop) bridgeRotation += getOverhangDirection(belowOutsetLoops, loop[previousIndex], point) if abs(bridgeRotation) < 0.75 * radius: return None else: return cmath.sqrt(bridgeRotation / abs(bridgeRotation))
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, 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 addCoolOrbits( self, remainingOrbitTime ): "Add the minimum radius cool orbits." if len( self.boundaryLayer.loops ) < 1: return insetBoundaryLoops = intercircle.getInsetLoopsFromLoops( self.perimeterWidth, self.boundaryLayer.loops ) if len( insetBoundaryLoops ) < 1: insetBoundaryLoops = self.boundaryLayer.loops largestLoop = euclidean.getLargestLoop( insetBoundaryLoops ) loopArea = abs( euclidean.getPolygonArea( largestLoop ) ) if loopArea < self.minimumArea: center = 0.5 * ( euclidean.getMaximumFromPoints( largestLoop ) + euclidean.getMinimumFromPoints( largestLoop ) ) centerXBounded = max( center.real, self.boundingRectangle.cornerMinimum.real ) centerXBounded = min( centerXBounded, self.boundingRectangle.cornerMaximum.real ) centerYBounded = max( center.imag, self.boundingRectangle.cornerMinimum.imag ) centerYBounded = min( centerYBounded, self.boundingRectangle.cornerMaximum.imag ) center = complex( centerXBounded, centerYBounded ) maximumCorner = center + self.halfCorner minimumCorner = center - self.halfCorner largestLoop = euclidean.getSquareLoop( minimumCorner, maximumCorner ) pointComplex = euclidean.getXYComplexFromVector3( self.oldLocation ) if pointComplex != None: largestLoop = euclidean.getLoopStartingNearest( self.perimeterWidth, pointComplex, largestLoop ) intercircle.addOrbitsIfLarge( self.distanceFeedRate, largestLoop, self.orbitalFeedRatePerSecond, remainingOrbitTime, self.highestZ )
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 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 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)