def addRunningJumpPath( self, end, loop, pathAround ): "Get the running jump path from the perimeter to the intersection or running jump space." if self.combRepository.runningJumpSpaceOverPerimeterWidth.value < 1.0: return if len( pathAround ) < 2: return loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loop, self.combInset ) penultimatePoint = pathAround[ - 2 ] lastPoint = pathAround[ - 1 ] nearestEndDistanceIndex = euclidean.getNearestDistanceIndex( end, loop ) nearestEndIndex = ( nearestEndDistanceIndex.index + 1 ) % len( loop ) nearestEnd = euclidean.getNearestPointOnSegment( loop[ nearestEndDistanceIndex.index ], loop[ nearestEndIndex ], end ) nearestEndMinusLast = nearestEnd - lastPoint nearestEndMinusLastLength = abs( nearestEndMinusLast ) if nearestEndMinusLastLength <= 0.0: return nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength betweens = self.getBetweens() if self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, self.runningJumpSpace ): return doubleCombInset = 2.0 * self.combInset shortJumpSpace = 0.5 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return if self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace ): return shortJumpSpace = 0.25 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace )
def addGcodeFromRemainingLoop( self, loop, radius, z ): "Add the remainder of the loop." boundary = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loop, radius ) euclidean.addSurroundingLoopBeginning( self.distanceFeedRate, boundary, z ) self.distanceFeedRate.addPerimeterBlock( loop, z ) self.distanceFeedRate.addLine( '(</boundaryPerimeter>)' ) self.distanceFeedRate.addLine( '(</surroundingLoop>)' )
def addGcodeFromRemainingLoop( self, loop, loopLists, radius, z ): "Add the remainder of the loop which does not overlap the alreadyFilledArounds loops." boundary = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loop, - radius ) euclidean.addSurroundingLoopBeginning( self.distanceFeedRate, boundary, z ) self.addGcodePerimeterBlockFromRemainingLoop( loop, loopLists, radius, z ) self.distanceFeedRate.addLine( '(</boundaryPerimeter>)' ) self.distanceFeedRate.addLine( '(</surroundingLoop>)' )
def addGcodeFromRemainingLoop(self, loop, radius, z): "Add the remainder of the loop." boundary = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loop, radius) euclidean.addSurroundingLoopBeginning(self.distanceFeedRate, boundary, z) self.distanceFeedRate.addPerimeterBlock(loop, z) self.distanceFeedRate.addLine('(</boundaryPerimeter>)') self.distanceFeedRate.addLine('(</surroundingLoop>)')
def getPathBetween(self, betweenFirst, betweenSecond, isLeavingPerimeter, loopFirst): "Add a path between the perimeter and the fill." loopFirst = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loopFirst, self.combInset) nearestFirstDistanceIndex = euclidean.getNearestDistanceIndex( betweenFirst, loopFirst) nearestSecondDistanceIndex = euclidean.getNearestDistanceIndex( betweenSecond, loopFirst) firstBeginIndex = (nearestFirstDistanceIndex.index + 1) % len(loopFirst) secondBeginIndex = (nearestSecondDistanceIndex.index + 1) % len(loopFirst) nearestFirst = euclidean.getNearestPointOnSegment( loopFirst[nearestFirstDistanceIndex.index], loopFirst[firstBeginIndex], betweenFirst) nearestSecond = euclidean.getNearestPointOnSegment( loopFirst[nearestSecondDistanceIndex.index], loopFirst[secondBeginIndex], betweenSecond) clockwisePath = [nearestFirst] widdershinsPath = [nearestFirst] loopBeforeLeaving = euclidean.getAroundLoop(firstBeginIndex, firstBeginIndex, loopFirst) if nearestFirstDistanceIndex.index == nearestSecondDistanceIndex.index: if euclidean.getPathLength( widdershinsPath) < self.minimumDepartureDistance: widdershinsPath = [nearestFirst] + loopBeforeLeaving reversedLoop = loopBeforeLeaving[:] reversedLoop.reverse() clockwisePath = [nearestFirst] + reversedLoop else: widdershinsLoop = euclidean.getAroundLoop(firstBeginIndex, secondBeginIndex, loopFirst) widdershinsPath += widdershinsLoop clockwiseLoop = euclidean.getAroundLoop(secondBeginIndex, firstBeginIndex, loopFirst) clockwiseLoop.reverse() clockwisePath += clockwiseLoop clockwisePath.append(nearestSecond) widdershinsPath.append(nearestSecond) if euclidean.getPathLength(widdershinsPath) > euclidean.getPathLength( clockwisePath): loopBeforeLeaving.reverse() widdershinsPath = clockwisePath if isLeavingPerimeter: totalDistance = euclidean.getPathLength(widdershinsPath) loopLength = euclidean.getPolygonLength(loopBeforeLeaving) while totalDistance < self.minimumDepartureDistance: widdershinsPath = [nearestFirst ] + loopBeforeLeaving + widdershinsPath[1:] totalDistance += loopLength return widdershinsPath
def getRunningJumpPath(self, end, loop, pathAround): "Get the running jump path from the perimeter to the intersection or running jump space." if self.combPreferences.runningJumpSpaceOverPerimeterWidth.value < 1.0: return pathAround loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat(loop, self.combInset) lastPoint = pathAround[-1] nearestEndDistanceIndex = euclidean.getNearestDistanceIndex(end, loop) nearestEndIndex = (nearestEndDistanceIndex.index + 1) % len(loop) nearestEnd = euclidean.getNearestPointOnSegment(loop[nearestEndDistanceIndex.index], loop[nearestEndIndex], end) nearestEndMinusLast = nearestEnd - lastPoint nearestEndMinusLastLength = abs(nearestEndMinusLast) if nearestEndMinusLastLength <= 0.0: return pathAround nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength beginRun = self.getCorneredTruncatedJumpSpacePath(lastPoint, -nearestEndMinusLastSegment) endRun = self.getCorneredTruncatedJumpSpacePath(nearestEnd, nearestEndMinusLastSegment) endRun.reverse() pathAround += beginRun + endRun return pathAround
def getPathBetween(self, betweenFirst, betweenSecond, isLeavingPerimeter, loopFirst): "Add a path between the perimeter and the fill." loopFirst = intercircle.getLargestInsetLoopFromLoopNoMatterWhat(loopFirst, self.combInset) nearestFirstDistanceIndex = euclidean.getNearestDistanceIndex(betweenFirst, loopFirst) nearestSecondDistanceIndex = euclidean.getNearestDistanceIndex(betweenSecond, loopFirst) firstBeginIndex = (nearestFirstDistanceIndex.index + 1) % len(loopFirst) secondBeginIndex = (nearestSecondDistanceIndex.index + 1) % len(loopFirst) nearestFirst = euclidean.getNearestPointOnSegment( loopFirst[nearestFirstDistanceIndex.index], loopFirst[firstBeginIndex], betweenFirst ) nearestSecond = euclidean.getNearestPointOnSegment( loopFirst[nearestSecondDistanceIndex.index], loopFirst[secondBeginIndex], betweenSecond ) clockwisePath = [nearestFirst] widdershinsPath = [nearestFirst] loopBeforeLeaving = euclidean.getAroundLoop(firstBeginIndex, firstBeginIndex, loopFirst) if nearestFirstDistanceIndex.index == nearestSecondDistanceIndex.index: if euclidean.getPathLength(widdershinsPath) < self.minimumDepartureDistance: widdershinsPath = [nearestFirst] + loopBeforeLeaving reversedLoop = loopBeforeLeaving[:] reversedLoop.reverse() clockwisePath = [nearestFirst] + reversedLoop else: widdershinsLoop = euclidean.getAroundLoop(firstBeginIndex, secondBeginIndex, loopFirst) widdershinsPath += widdershinsLoop clockwiseLoop = euclidean.getAroundLoop(secondBeginIndex, firstBeginIndex, loopFirst) clockwiseLoop.reverse() clockwisePath += clockwiseLoop clockwisePath.append(nearestSecond) widdershinsPath.append(nearestSecond) if euclidean.getPathLength(widdershinsPath) > euclidean.getPathLength(clockwisePath): loopBeforeLeaving.reverse() widdershinsPath = clockwisePath if isLeavingPerimeter: totalDistance = euclidean.getPathLength(widdershinsPath) loopLength = euclidean.getPolygonLength(loopBeforeLeaving) while totalDistance < self.minimumDepartureDistance: widdershinsPath = [nearestFirst] + loopBeforeLeaving + widdershinsPath[1:] totalDistance += loopLength return widdershinsPath
def addRunningJumpPath(self, end, loop, pathAround): "Get the running jump path from the perimeter to the intersection or running jump space." if self.combRepository.runningJumpSpaceOverPerimeterWidth.value < 1.0: return if len(pathAround) < 2: return loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loop, self.combInset) penultimatePoint = pathAround[-2] lastPoint = pathAround[-1] nearestEndDistanceIndex = euclidean.getNearestDistanceIndex(end, loop) nearestEndIndex = (nearestEndDistanceIndex.index + 1) % len(loop) nearestEnd = euclidean.getNearestPointOnSegment( loop[nearestEndDistanceIndex.index], loop[nearestEndIndex], end) nearestEndMinusLast = nearestEnd - lastPoint nearestEndMinusLastLength = abs(nearestEndMinusLast) if nearestEndMinusLastLength <= 0.0: return nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength betweens = self.getBetweens() if self.getIsRunningJumpPathAdded(betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, self.runningJumpSpace): return doubleCombInset = 2.0 * self.combInset shortJumpSpace = 0.5 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return if self.getIsRunningJumpPathAdded(betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace): return shortJumpSpace = 0.25 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return self.getIsRunningJumpPathAdded(betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace)