def addPathBetween(self, betweenFirst, betweenSecond, loopFirst): "Add a path between the perimeter and the fill." clockwisePath = [betweenFirst] widdershinsPath = [betweenFirst] nearestFirstDistanceIndex = euclidean.getNearestDistanceSquaredIndex( betweenFirst, loopFirst) nearestSecondDistanceIndex = euclidean.getNearestDistanceSquaredIndex( betweenSecond, loopFirst) firstBeginIndex = (int(nearestFirstDistanceIndex.imag) + 1) % len(loopFirst) secondBeginIndex = (int(nearestSecondDistanceIndex.imag) + 1) % len(loopFirst) widdershinsLoop = euclidean.getAroundLoop(firstBeginIndex, secondBeginIndex, loopFirst) widdershinsPath += widdershinsLoop clockwiseLoop = euclidean.getAroundLoop(secondBeginIndex, firstBeginIndex, loopFirst) clockwiseLoop.reverse() clockwisePath += clockwiseLoop clockwisePath.append(betweenSecond) widdershinsPath.append(betweenSecond) if euclidean.getPathLength(widdershinsPath) > euclidean.getPathLength( clockwisePath): widdershinsPath = clockwisePath widdershinsPath = euclidean.getAwayPath(widdershinsPath, 0.2 * self.layerFillInset) for point in widdershinsPath: self.addGcodeMovement(point)
def addPathBetween( self, betweenFirst, betweenSecond, loopFirst ): "Add a path between the perimeter and the fill." clockwisePath = [ betweenFirst ] widdershinsPath = [ betweenFirst ] nearestFirstDistanceIndex = euclidean.getNearestDistanceSquaredIndex( betweenFirst, loopFirst ) nearestSecondDistanceIndex = euclidean.getNearestDistanceSquaredIndex( betweenSecond, loopFirst ) firstBeginIndex = ( int( nearestFirstDistanceIndex.imag ) + 1 ) % len( loopFirst ) secondBeginIndex = ( int( nearestSecondDistanceIndex.imag ) + 1 ) % len( loopFirst ) widdershinsLoop = euclidean.getAroundLoop( firstBeginIndex, secondBeginIndex, loopFirst ) widdershinsPath += widdershinsLoop clockwiseLoop = euclidean.getAroundLoop( secondBeginIndex, firstBeginIndex, loopFirst ) clockwiseLoop.reverse() clockwisePath += clockwiseLoop clockwisePath.append( betweenSecond ) widdershinsPath.append( betweenSecond ) if euclidean.getPathLength( widdershinsPath ) > euclidean.getPathLength( clockwisePath ): widdershinsPath = clockwisePath widdershinsPath = euclidean.getAwayPath( widdershinsPath, 0.2 * self.layerFillInset ) for point in widdershinsPath: self.addGcodeMovement( point )
def getWithLeastLength(path, point): "Insert a point into a path, at the index at which the path would be shortest." shortestPointIndex = None shortestPathLength = 999999999999999999.0 for pointIndex in range(len(path) + 1): concatenation = path[:] concatenation.insert(pointIndex, point) concatenationLength = euclidean.getPathLength(concatenation) if concatenationLength < shortestPathLength: shortestPathLength = concatenationLength shortestPointIndex = pointIndex return shortestPointIndex
def getWithLeastLength( path, point ): "Insert a point into a path, at the index at which the path would be shortest." shortestPointIndex = None shortestPathLength = 999999999999999999.0 for pointIndex in range( len( path ) + 1 ): concatenation = path[ : ] concatenation.insert( pointIndex, point ) concatenationLength = euclidean.getPathLength( concatenation ) if concatenationLength < shortestPathLength: shortestPathLength = concatenationLength shortestPointIndex = pointIndex return shortestPointIndex