Esempio n. 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
Esempio n. 2
0
	def addRunningJumpPath( self, end, loop, pathAround ):
		"Get the running jump path from the perimeter to the intersection or running jump space."
		if self.combRepository.runningJumpSpaceOverPerimeterWidth.value < 1.0:
			return
		if len( pathAround ) < 2:
			return
		loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loop, self.combInset )
		penultimatePoint = pathAround[ - 2 ]
		lastPoint = pathAround[ - 1 ]
		nearestEndDistanceIndex = euclidean.getNearestDistanceIndex( end, loop )
		nearestEndIndex = ( nearestEndDistanceIndex.index + 1 ) % len( loop )
		nearestEnd = euclidean.getNearestPointOnSegment( loop[ nearestEndDistanceIndex.index ], loop[ nearestEndIndex ], end )
		nearestEndMinusLast = nearestEnd - lastPoint
		nearestEndMinusLastLength = abs( nearestEndMinusLast )
		if nearestEndMinusLastLength <= 0.0:
			return
		nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength
		betweens = self.getBetweens()
		if self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, self.runningJumpSpace ):
			return
		doubleCombInset = 2.0 * self.combInset
		shortJumpSpace = 0.5 * self.runningJumpSpace
		if shortJumpSpace < doubleCombInset:
			return
		if self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace ):
			return
		shortJumpSpace = 0.25 * self.runningJumpSpace
		if shortJumpSpace < doubleCombInset:
			return
		self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace )
Esempio n. 3
0
 def getOutloopLocation(self, point):
     "Get location outside of loop."
     pointComplex = point.dropAxis(2)
     if str(point) not in self.pointTable:
         return pointComplex
     closestBetween = None
     closestDistanceIndex = euclidean.DistanceIndex(999999999999999999.0,
                                                    -1)
     for between in self.getBetweens():
         distanceIndex = euclidean.getNearestDistanceIndex(
             pointComplex, between)
         if distanceIndex.distance < closestDistanceIndex.distance:
             closestBetween = between
             closestDistanceIndex = distanceIndex
     if closestBetween == None:
         print(
             'This should never happen, closestBetween should always exist.'
         )
         print(point)
         print(self.getBetweens())
         return pointComplex
     closestIndex = closestDistanceIndex.index
     segmentBegin = closestBetween[closestIndex]
     segmentEnd = closestBetween[(closestIndex + 1) % len(closestBetween)]
     nearestPoint = euclidean.getNearestPointOnSegment(
         segmentBegin, segmentEnd, pointComplex)
     distanceToNearestPoint = abs(pointComplex - nearestPoint)
     nearestMinusOld = 1.5 * (nearestPoint - pointComplex)
     return pointComplex + nearestMinusOld
Esempio n. 4
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
Esempio n. 5
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
Esempio n. 6
0
 def getRunningJumpPath(self, end, loop, pathAround):
     "Get the running jump path from the perimeter to the intersection or running jump space."
     if self.combPreferences.runningJumpSpaceOverPerimeterWidth.value < 1.0:
         return pathAround
     loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat(loop, self.combInset)
     lastPoint = pathAround[-1]
     nearestEndDistanceIndex = euclidean.getNearestDistanceIndex(end, loop)
     nearestEndIndex = (nearestEndDistanceIndex.index + 1) % len(loop)
     nearestEnd = euclidean.getNearestPointOnSegment(loop[nearestEndDistanceIndex.index], loop[nearestEndIndex], end)
     nearestEndMinusLast = nearestEnd - lastPoint
     nearestEndMinusLastLength = abs(nearestEndMinusLast)
     if nearestEndMinusLastLength <= 0.0:
         return pathAround
     nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength
     beginRun = self.getCorneredTruncatedJumpSpacePath(lastPoint, -nearestEndMinusLastSegment)
     endRun = self.getCorneredTruncatedJumpSpacePath(nearestEnd, nearestEndMinusLastSegment)
     endRun.reverse()
     pathAround += beginRun + endRun
     return pathAround
Esempio n. 7
0
 def addRunningJumpPath(self, end, loop, pathAround):
     "Get the running jump path from the perimeter to the intersection or running jump space."
     if self.combRepository.runningJumpSpaceOverPerimeterWidth.value < 1.0:
         return
     if len(pathAround) < 2:
         return
     loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat(
         loop, self.combInset)
     penultimatePoint = pathAround[-2]
     lastPoint = pathAround[-1]
     nearestEndDistanceIndex = euclidean.getNearestDistanceIndex(end, loop)
     nearestEndIndex = (nearestEndDistanceIndex.index + 1) % len(loop)
     nearestEnd = euclidean.getNearestPointOnSegment(
         loop[nearestEndDistanceIndex.index], loop[nearestEndIndex], end)
     nearestEndMinusLast = nearestEnd - lastPoint
     nearestEndMinusLastLength = abs(nearestEndMinusLast)
     if nearestEndMinusLastLength <= 0.0:
         return
     nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength
     betweens = self.getBetweens()
     if self.getIsRunningJumpPathAdded(betweens, end, lastPoint,
                                       nearestEndMinusLastSegment,
                                       pathAround, penultimatePoint,
                                       self.runningJumpSpace):
         return
     doubleCombInset = 2.0 * self.combInset
     shortJumpSpace = 0.5 * self.runningJumpSpace
     if shortJumpSpace < doubleCombInset:
         return
     if self.getIsRunningJumpPathAdded(betweens, end, lastPoint,
                                       nearestEndMinusLastSegment,
                                       pathAround, penultimatePoint,
                                       shortJumpSpace):
         return
     shortJumpSpace = 0.25 * self.runningJumpSpace
     if shortJumpSpace < doubleCombInset:
         return
     self.getIsRunningJumpPathAdded(betweens, end, lastPoint,
                                    nearestEndMinusLastSegment, pathAround,
                                    penultimatePoint, shortJumpSpace)
Esempio n. 8
0
	def getOutloopLocation( self, point ):
		"Get location outside of loop."
		pointComplex = point.dropAxis( 2 )
		if str( point ) not in self.pointTable:
			return pointComplex
		closestBetween = None
		closestDistanceIndex = euclidean.DistanceIndex( 999999999999999999.0, - 1 )
		for between in self.getBetweens():
			distanceIndex = euclidean.getNearestDistanceIndex( pointComplex, between )
			if distanceIndex.distance < closestDistanceIndex.distance:
				closestBetween = between
				closestDistanceIndex = distanceIndex
		if closestBetween == None:
			print( 'This should never happen, closestBetween should always exist.' )
			print( point )
			print( self.getBetweens() )
			return pointComplex
		closestIndex = closestDistanceIndex.index
		segmentBegin = closestBetween[ closestIndex ]
		segmentEnd = closestBetween[ ( closestIndex + 1 ) % len( closestBetween ) ]
		nearestPoint = euclidean.getNearestPointOnSegment( segmentBegin, segmentEnd, pointComplex )
		distanceToNearestPoint = abs( pointComplex - nearestPoint )
		nearestMinusOld = 1.5 * ( nearestPoint - pointComplex )
		return pointComplex + nearestMinusOld
Esempio n. 9
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