예제 #1
0
 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)
예제 #2
0
 def getOutloopLocation(self, point):
     "Get location outside of loop."
     if str(point) not in self.pointTable:
         return point
     closestBetween = None
     closestDistanceSquaredIndex = complex(999999999999999999.0, -1)
     for between in self.getBetweens():
         distanceSquaredIndex = euclidean.getNearestDistanceSquaredIndex(
             point, between)
         if distanceSquaredIndex.real < closestDistanceSquaredIndex.real:
             closestBetween = between
             closestDistanceSquaredIndex = distanceSquaredIndex
     if closestBetween == None:
         print >> sys.stderr, (
             'This should never happen, closestBetween should always exist.'
         )
         return point
     closestIndex = int(round(closestDistanceSquaredIndex.imag))
     segmentBegin = closestBetween[closestIndex]
     segmentEnd = closestBetween[(closestIndex + 1) % len(closestBetween)]
     nearestPoint = euclidean.getNearestPointOnSegment(
         segmentBegin, segmentEnd, point)
     distanceToNearestPoint = point.distance(nearestPoint)
     nearestMinusOld = nearestPoint.minus(point)
     nearestMinusOld.scale(1.5)
     return point.plus(nearestMinusOld)
예제 #3
0
	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 )
예제 #4
0
	def getOutloopLocation( self, point ):
		"Get location outside of loop."
		if str( point ) not in self.pointTable:
			return point
		closestBetween = None
		closestDistanceSquaredIndex = complex( 999999999999999999.0, - 1 )
		for between in self.getBetweens():
			distanceSquaredIndex = euclidean.getNearestDistanceSquaredIndex( point, between )
			if distanceSquaredIndex.real < closestDistanceSquaredIndex.real:
				closestBetween = between
				closestDistanceSquaredIndex = distanceSquaredIndex
		if closestBetween == None:
			print >> sys.stderr, ( 'This should never happen, closestBetween should always exist.' )
			return point
		closestIndex = int( round( closestDistanceSquaredIndex.imag ) )
		segmentBegin = closestBetween[ closestIndex ]
		segmentEnd = closestBetween[ ( closestIndex + 1 ) % len( closestBetween ) ]
		nearestPoint = euclidean.getNearestPointOnSegment( segmentBegin, segmentEnd, point )
		distanceToNearestPoint = point.distance( nearestPoint )
		nearestMinusOld = nearestPoint.minus( point )
		nearestMinusOld.scale( 1.5 )
		return point.plus( nearestMinusOld )