Beispiel #1
0
 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
Beispiel #2
0
 def addPathBetween(self, aroundBetweenPath, betweenFirst, betweenSecond,
                    isLeavingPerimeter, loopFirst):
     "Add a path between the perimeter and the fill."
     clockwisePath = [betweenFirst]
     widdershinsPath = [betweenFirst]
     nearestFirstDistanceIndex = euclidean.getNearestDistanceIndex(
         betweenFirst, loopFirst)
     nearestSecondDistanceIndex = euclidean.getNearestDistanceIndex(
         betweenSecond, loopFirst)
     firstBeginIndex = (nearestFirstDistanceIndex.index +
                        1) % len(loopFirst)
     secondBeginIndex = (nearestSecondDistanceIndex.index +
                         1) % len(loopFirst)
     loopBeforeLeaving = euclidean.getAroundLoop(firstBeginIndex,
                                                 firstBeginIndex, loopFirst)
     if nearestFirstDistanceIndex.index == nearestSecondDistanceIndex.index:
         nearestPoint = euclidean.getNearestPointOnSegment(
             loopFirst[nearestSecondDistanceIndex.index],
             loopFirst[secondBeginIndex], betweenSecond)
         widdershinsPath += [nearestPoint]
         clockwisePath += [nearestPoint]
         if euclidean.getPathLength(
                 widdershinsPath) < self.minimumPerimeterDepartureDistance:
             widdershinsPath = [betweenFirst
                                ] + loopBeforeLeaving + [nearestPoint]
             reversedLoop = loopBeforeLeaving[:]
             reversedLoop.reverse()
             clockwisePath = [betweenFirst] + reversedLoop + [nearestPoint]
     else:
         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):
         loopBeforeLeaving.reverse()
         widdershinsPath = clockwisePath
     if isLeavingPerimeter:
         totalDistance = euclidean.getPathLength(widdershinsPath)
         loopLength = euclidean.getPolygonLength(loopBeforeLeaving)
         while totalDistance < self.minimumPerimeterDepartureDistance:
             widdershinsPath = [betweenFirst
                                ] + loopBeforeLeaving + widdershinsPath[1:]
             totalDistance += loopLength
     aroundBetweenPath += widdershinsPath
Beispiel #3
0
 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
Beispiel #4
0
	def addPathBetween( self, aroundBetweenPath, betweenFirst, betweenSecond, isLeavingPerimeter, loopFirst ):
		"Add a path between the perimeter and the fill."
		clockwisePath = [ betweenFirst ]
		widdershinsPath = [ betweenFirst ]
		nearestFirstDistanceIndex = euclidean.getNearestDistanceIndex( betweenFirst, loopFirst )
		nearestSecondDistanceIndex = euclidean.getNearestDistanceIndex( betweenSecond, loopFirst )
		firstBeginIndex = ( nearestFirstDistanceIndex.index + 1 ) % len( loopFirst )
		secondBeginIndex = ( nearestSecondDistanceIndex.index + 1 ) % len( loopFirst )
		loopBeforeLeaving = euclidean.getAroundLoop( firstBeginIndex, firstBeginIndex, loopFirst )
		if nearestFirstDistanceIndex.index == nearestSecondDistanceIndex.index:
			nearestPoint = euclidean.getNearestPointOnSegment( loopFirst[ nearestSecondDistanceIndex.index ], loopFirst[ secondBeginIndex ], betweenSecond )
			widdershinsPath += [ nearestPoint ]
			clockwisePath += [ nearestPoint ]
			if euclidean.getPathLength( widdershinsPath ) < self.minimumPerimeterDepartureDistance:
				widdershinsPath = [ betweenFirst ] + loopBeforeLeaving + [ nearestPoint ]
				reversedLoop = loopBeforeLeaving[ : ]
				reversedLoop.reverse()
				clockwisePath = [ betweenFirst ] + reversedLoop + [ nearestPoint ]
		else:
			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 ):
			loopBeforeLeaving.reverse()
			widdershinsPath = clockwisePath
		if isLeavingPerimeter:
			totalDistance = euclidean.getPathLength( widdershinsPath )
			loopLength = euclidean.getPolygonLength( loopBeforeLeaving )
			while totalDistance < self.minimumPerimeterDepartureDistance:
				widdershinsPath = [ betweenFirst ] + loopBeforeLeaving + widdershinsPath[ 1 : ]
				totalDistance += loopLength
		aroundBetweenPath += widdershinsPath
Beispiel #5
0
 def addGcodeFromPerimeterPaths(self, isIntersectingSelf, loop, loopLists,
                                radius, z):
     "Add the perimeter paths to the output."
     segments = []
     outlines = []
     thickOutlines = []
     allLoopLists = loopLists[:] + [thickOutlines]
     aroundLists = loopLists
     for pointIndex in xrange(len(loop)):
         pointBegin = loop[pointIndex]
         pointEnd = loop[(pointIndex + 1) % len(loop)]
         if isIntersectingSelf:
             if euclidean.isLineIntersectingLoops(outlines, pointBegin,
                                                  pointEnd):
                 segments += getSegmentsFromLoopListsPoints(
                     allLoopLists, pointBegin, pointEnd)
             else:
                 segments += getSegmentsFromLoopListsPoints(
                     loopLists, pointBegin, pointEnd)
             addSegmentOutline(False, outlines, pointBegin, pointEnd,
                               self.overlapRemovalWidth)
             addSegmentOutline(True, thickOutlines, pointBegin, pointEnd,
                               self.overlapRemovalWidth)
         else:
             segments += getSegmentsFromLoopListsPoints(
                 loopLists, pointBegin, pointEnd)
     perimeterPaths = []
     path = []
     muchSmallerThanRadius = 0.1 * radius
     for segment in segments:
         pointBegin = segment[0].point
         if not isCloseToLast(perimeterPaths, pointBegin,
                              muchSmallerThanRadius):
             path = [pointBegin]
             perimeterPaths.append(path)
         path.append(segment[1].point)
     if len(perimeterPaths) > 1:
         firstPath = perimeterPaths[0]
         lastPath = perimeterPaths[-1]
         if abs(lastPath[-1] - firstPath[0]) < 0.1 * muchSmallerThanRadius:
             connectedBeginning = lastPath[:-1] + firstPath
             perimeterPaths[0] = connectedBeginning
             perimeterPaths.remove(lastPath)
     muchGreaterThanRadius = 6.0 * radius
     for perimeterPath in perimeterPaths:
         if euclidean.getPathLength(perimeterPath) > muchGreaterThanRadius:
             self.distanceFeedRate.addGcodeFromThreadZ(perimeterPath, z)
Beispiel #6
0
	def addGcodeFromPerimeterPaths( self, isIntersectingSelf, loop, loopLists, radius, z ):
		"Add the perimeter paths to the output."
		segments = []
		outlines = []
		thickOutlines = []
		allLoopLists = loopLists[ : ] + [ thickOutlines ]
		aroundLists = loopLists
		for pointIndex in xrange( len( loop ) ):
			pointBegin = loop[ pointIndex ]
			pointEnd = loop[ ( pointIndex + 1 ) % len( loop ) ]
			if isIntersectingSelf:
				if euclidean.isLineIntersectingLoops( outlines, pointBegin, pointEnd ):
					segments += getSegmentsFromLoopListsPoints( allLoopLists, pointBegin, pointEnd )
				else:
					segments += getSegmentsFromLoopListsPoints( loopLists, pointBegin, pointEnd )
				addSegmentOutline( False, outlines, pointBegin, pointEnd, self.overlapRemovalWidth )
				addSegmentOutline( True, thickOutlines, pointBegin, pointEnd, self.overlapRemovalWidth )
			else:
				segments += getSegmentsFromLoopListsPoints( loopLists, pointBegin, pointEnd )
		perimeterPaths = []
		path = []
		muchSmallerThanRadius = 0.1 * radius
		for segment in segments:
			pointBegin = segment[ 0 ].point
			if not isCloseToLast( perimeterPaths, pointBegin, muchSmallerThanRadius ):
				path = [ pointBegin ]
				perimeterPaths.append( path )
			path.append( segment[ 1 ].point )
		if len( perimeterPaths ) > 1:
			firstPath = perimeterPaths[ 0 ]
			lastPath = perimeterPaths[ - 1 ]
			if abs( lastPath[ - 1 ] - firstPath[ 0 ] ) < 0.1 * muchSmallerThanRadius:
				connectedBeginning = lastPath[ : - 1 ] + firstPath
				perimeterPaths[ 0 ] = connectedBeginning
				perimeterPaths.remove( lastPath )
		muchGreaterThanRadius = 6.0 * radius
		for perimeterPath in perimeterPaths:
			if euclidean.getPathLength( perimeterPath ) > muchGreaterThanRadius:
				self.distanceFeedRate.addGcodeFromThreadZ( perimeterPath, z )