Beispiel #1
0
	def getIsAsFarAndNotIntersecting( self, begin, end ):
		"Determine if the point on the line is at least as far from the loop as the center point."
		if begin == end:
			print( 'this should never happen but it does not really matter, begin == end in getIsAsFarAndNotIntersecting in comb.' )
			print( begin )
			return True
		return not euclidean.isLineIntersectingLoops( self.getBetweens(), begin, end )
Beispiel #2
0
	def getIsRunningJumpPathAdded( self, betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, runningJumpSpace ):
		"Add a running jump path if possible, and return if it was added."
		jumpStartPoint = lastPoint - nearestEndMinusLastSegment * runningJumpSpace
		if euclidean.isLineIntersectingLoops( betweens, penultimatePoint, jumpStartPoint ):
			return False
		pathAround[ - 1 ] = jumpStartPoint
		return True
Beispiel #3
0
def isIntersectingItself(loop, width):
    "Determine if the loop is intersecting itself."
    outlines = []
    for pointIndex in xrange(len(loop)):
        pointBegin = loop[pointIndex]
        pointEnd = loop[(pointIndex + 1) % len(loop)]
        if euclidean.isLineIntersectingLoops(outlines, pointBegin, pointEnd):
            return True
        addSegmentOutline(False, outlines, pointBegin, pointEnd, width)
    return False
Beispiel #4
0
def isIntersectingItself( loop, width ):
	"Determine if the loop is intersecting itself."
	outlines = []
	for pointIndex in xrange( len( loop ) ):
		pointBegin = loop[ pointIndex ]
		pointEnd = loop[ ( pointIndex + 1 ) % len( loop ) ]
		if euclidean.isLineIntersectingLoops( outlines, pointBegin, pointEnd ):
			return True
		addSegmentOutline( False, outlines, pointBegin, pointEnd, width )
	return False
Beispiel #5
0
 def getIsRunningJumpPathAdded(self, betweens, end, lastPoint,
                               nearestEndMinusLastSegment, pathAround,
                               penultimatePoint, runningJumpSpace):
     "Add a running jump path if possible, and return if it was added."
     jumpStartPoint = lastPoint - nearestEndMinusLastSegment * runningJumpSpace
     if euclidean.isLineIntersectingLoops(betweens, penultimatePoint,
                                          jumpStartPoint):
         return False
     pathAround[-1] = jumpStartPoint
     return True
Beispiel #6
0
 def getIsAsFarAndNotIntersecting(self, begin, end):
     "Determine if the point on the line is at least as far from the loop as the center point."
     if begin == end:
         print(
             'this should never happen but it does not really matter, begin == end in getIsAsFarAndNotIntersecting in comb.'
         )
         print(begin)
         return True
     return not euclidean.isLineIntersectingLoops(self.getBetweens(), begin,
                                                  end)
Beispiel #7
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 #8
0
 def getIsAsFarAndNotIntersecting(self, begin, center, end, loop):
     "Determine if the point on the line is at least as far from the loop as the center point."
     if begin == end:
         print(
             "this should never happen but it does not really matter, begin == end in getIsAsFarAndNotIntersecting in comb."
         )
         print(begin)
         return True
     centerMinusEnd = center - end
     centerMinusEndLength = abs(centerMinusEnd)
     if centerMinusEndLength <= 0.0:
         return True
     segment = euclidean.getNormalized(begin - end)
     segmentCenterMinusEnd = segment * centerMinusEndLength + end
     nearestCenterDistanceIndex = euclidean.getNearestDistanceIndex(center, loop)
     nearestCenterMinusEndDistanceIndex = euclidean.getNearestDistanceIndex(segmentCenterMinusEnd, loop)
     if nearestCenterMinusEndDistanceIndex.distance < nearestCenterDistanceIndex.distance:
         return False
     return not euclidean.isLineIntersectingLoops(self.getBetweens(), begin, end)
Beispiel #9
0
	def addGcodeFromPerimeterPaths( self, isIntersectingSelf, loop, loopLists, radius, z ):
		"Add the perimeter paths to the output."
		segments = []
		outlines = []
		thickOutlines = []
		allLoopLists = loopLists[ : ] + [ thickOutlines ]
		aroundLists = loopLists
#		if euclidean.isWiddershins( loop ):
#			aroundLists = []
		for pointIndex in xrange( len( loop ) ):
			pointBegin = loop[ pointIndex ]
			pointEnd = loop[ ( pointIndex + 1 ) % len( loop ) ]
			if isIntersectingSelf:
				if euclidean.isLineIntersectingLoops( outlines, pointBegin, pointEnd ):
					segments += getSegmentsFromPoints( [], allLoopLists, pointBegin, pointEnd )
				else:
					segments += getSegmentsFromPoints( [], loopLists, pointBegin, pointEnd )
				addSegmentOutline( False, outlines, pointBegin, pointEnd, self.extrusionWidth )
				addSegmentOutline( True, thickOutlines, pointBegin, pointEnd, self.extrusionWidth )
			else:
				segments += getSegmentsFromPoints( aroundLists, 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 )
		for perimeterPath in perimeterPaths:
			self.addGcodeFromThreadZ( perimeterPath, z )