Example #1
0
def getPathsByIntersectedLoop(begin, end, loop):
    "Get both paths along the loop from the point closest to the begin to the point closest to the end."
    closestBeginDistanceIndex = euclidean.getClosestDistanceIndexToLine(begin, loop)
    closestEndDistanceIndex = euclidean.getClosestDistanceIndexToLine(end, loop)
    beginIndex = (closestBeginDistanceIndex.index + 1) % len(loop)
    endIndex = (closestEndDistanceIndex.index + 1) % len(loop)
    closestBegin = euclidean.getClosestPointOnSegment(loop[closestBeginDistanceIndex.index], loop[beginIndex], begin)
    closestEnd = euclidean.getClosestPointOnSegment(loop[closestEndDistanceIndex.index], loop[endIndex], end)
    clockwisePath = [closestBegin]
    widdershinsPath = [closestBegin]
    if closestBeginDistanceIndex.index != closestEndDistanceIndex.index:
        widdershinsPath += euclidean.getAroundLoop(beginIndex, endIndex, loop)
        clockwisePath += euclidean.getAroundLoop(endIndex, beginIndex, loop)[::-1]
    clockwisePath.append(closestEnd)
    widdershinsPath.append(closestEnd)
    return [clockwisePath, widdershinsPath]
Example #2
0
 def getTransferClosestNestedRingLines(self, oldOrderedLocation,
                                       remainingNestedRings):
     "Get and transfer the closest remaining nested ring."
     if len(remainingNestedRings) > 0:
         oldOrderedLocation.z = remainingNestedRings[0].z
     closestDistance = 999999999987654321.0
     closestNestedRing = None
     for remainingNestedRing in remainingNestedRings:
         distance = euclidean.getClosestDistanceIndexToLine(
             oldOrderedLocation.dropAxis(),
             remainingNestedRing.boundary).distance
         if distance < closestDistance:
             closestDistance = distance
             closestNestedRing = remainingNestedRing
     remainingNestedRings.remove(closestNestedRing)
     hasTravelledHighRoad = False
     for line in closestNestedRing.lines:
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if firstWord == 'G1':
             location = gcodec.getLocationFromSplitLine(
                 self.oldLocation, splitLine)
             if not hasTravelledHighRoad:
                 hasTravelledHighRoad = True
                 self.addHighThread(location)
             if location.z > self.highestZ:
                 self.highestZ = location.z
             self.oldLocation = location
         self.distanceFeedRate.addLine(line)
     return closestNestedRing
Example #3
0
	def getTransferClosestNestedRingLines( self, oldOrderedLocation, remainingNestedRings ):
		"Get and transfer the closest remaining nested ring."
		if len( remainingNestedRings ) > 0:
			oldOrderedLocation.z = remainingNestedRings[0].z
		closestDistance = 999999999987654321.0
		closestNestedRing = None
		for remainingNestedRing in remainingNestedRings:
			distance = euclidean.getClosestDistanceIndexToLine(oldOrderedLocation.dropAxis(), remainingNestedRing.boundary).distance
			if distance < closestDistance:
				closestDistance = distance
				closestNestedRing = remainingNestedRing
		remainingNestedRings.remove(closestNestedRing)
		hasTravelledHighRoad = False
		for line in closestNestedRing.lines:
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
			firstWord = gcodec.getFirstWord(splitLine)
			if firstWord == 'G1':
				location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
				if not hasTravelledHighRoad:
					hasTravelledHighRoad = True
					self.addHighThread(location)
				if location.z > self.highestZ:
					self.highestZ = location.z
				self.oldLocation = location
			self.distanceFeedRate.addLine(line)
		return closestNestedRing
Example #4
0
def getJumpPointIfInside(boundary, otherPoint, perimeterWidth, runningJumpSpace):
	'Get the jump point if it is inside the boundary, otherwise return None.'
	insetBoundary = intercircle.getSimplifiedInsetFromClockwiseLoop(boundary, -perimeterWidth)
	closestJumpDistanceIndex = euclidean.getClosestDistanceIndexToLine(otherPoint, insetBoundary)
	jumpIndex = (closestJumpDistanceIndex.index + 1) % len(insetBoundary)
	jumpPoint = euclidean.getClosestPointOnSegment(insetBoundary[closestJumpDistanceIndex.index], insetBoundary[jumpIndex], otherPoint)
	jumpPoint = getJumpPoint(jumpPoint, otherPoint, boundary, runningJumpSpace)
	if euclidean.isPointInsideLoop(boundary, jumpPoint):
		return jumpPoint
	return None
Example #5
0
def getPathsByIntersectedLoop(begin, end, loop):
    'Get both paths along the loop from the point closest to the begin to the point closest to the end.'
    closestBeginDistanceIndex = euclidean.getClosestDistanceIndexToLine(
        begin, loop)
    closestEndDistanceIndex = euclidean.getClosestDistanceIndexToLine(
        end, loop)
    beginIndex = (closestBeginDistanceIndex.index + 1) % len(loop)
    endIndex = (closestEndDistanceIndex.index + 1) % len(loop)
    closestBegin = euclidean.getClosestPointOnSegment(
        loop[closestBeginDistanceIndex.index], loop[beginIndex], begin)
    closestEnd = euclidean.getClosestPointOnSegment(
        loop[closestEndDistanceIndex.index], loop[endIndex], end)
    clockwisePath = [closestBegin]
    widdershinsPath = [closestBegin]
    if closestBeginDistanceIndex.index != closestEndDistanceIndex.index:
        widdershinsPath += euclidean.getAroundLoop(beginIndex, endIndex, loop)
        clockwisePath += euclidean.getAroundLoop(endIndex, beginIndex,
                                                 loop)[::-1]
    clockwisePath.append(closestEnd)
    widdershinsPath.append(closestEnd)
    return [clockwisePath, widdershinsPath]
Example #6
0
def getJumpPointIfInside(boundary, otherPoint, edgeWidth, runningJumpSpace):
    'Get the jump point if it is inside the boundary, otherwise return None.'
    insetBoundary = intercircle.getSimplifiedInsetFromClockwiseLoop(
        boundary, -edgeWidth)
    closestJumpDistanceIndex = euclidean.getClosestDistanceIndexToLine(
        otherPoint, insetBoundary)
    jumpIndex = (closestJumpDistanceIndex.index + 1) % len(insetBoundary)
    jumpPoint = euclidean.getClosestPointOnSegment(
        insetBoundary[closestJumpDistanceIndex.index],
        insetBoundary[jumpIndex], otherPoint)
    jumpPoint = getJumpPoint(jumpPoint, otherPoint, boundary, runningJumpSpace)
    if euclidean.isPointInsideLoop(boundary, jumpPoint):
        return jumpPoint
    return None