예제 #1
0
 def insertPathsBetween(self, aroundBetweenPath, nextBeginning, pathEnd):
     "Insert paths between the perimeter and the fill."
     betweenX = []
     switchX = []
     segment = euclidean.getNormalized(nextBeginning - pathEnd)
     segmentYMirror = complex(segment.real, -segment.imag)
     pathEndRotated = segmentYMirror * pathEnd
     nextBeginningRotated = segmentYMirror * nextBeginning
     y = pathEndRotated.imag
     for betweenIndex in xrange(len(self.getBetweens())):
         between = self.getBetweens()[betweenIndex]
         betweenRotated = euclidean.getPointsRoundZAxis(
             segmentYMirror, between)
         euclidean.addXIntersectionIndexes(betweenRotated, betweenIndex,
                                           switchX, y)
     switchX.sort()
     maximumX = max(pathEndRotated.real, nextBeginningRotated.real)
     minimumX = min(pathEndRotated.real, nextBeginningRotated.real)
     for xIntersection in switchX:
         if xIntersection.x > minimumX and xIntersection.x < maximumX:
             betweenX.append(xIntersection)
     betweenXIndex = self.getStartIndex(betweenX)
     while betweenXIndex < len(betweenX) - 1:
         betweenXFirst = betweenX[betweenXIndex]
         betweenXSecond = betweenX[betweenXIndex + 1]
         loopFirst = self.getBetweens()[betweenXFirst.index]
         betweenFirst = segment * complex(betweenXFirst.x, y)
         betweenSecond = segment * complex(betweenXSecond.x, y)
         isLeavingPerimeter = False
         if betweenXSecond.index != betweenXFirst.index:
             isLeavingPerimeter = True
         self.addPathBetween(aroundBetweenPath, betweenFirst, betweenSecond,
                             isLeavingPerimeter, loopFirst)
         betweenXIndex += 2
예제 #2
0
파일: comb.py 프로젝트: D1plo1d/ReplicatorG
	def insertPathsBetween( self, aroundBetweenPath, nextBeginning, pathEnd ):
		"Insert paths between the perimeter and the fill."
		betweenX = []
		switchX = []
		segment = euclidean.getNormalized( nextBeginning - pathEnd )
		segmentYMirror = complex( segment.real, - segment.imag )
		pathEndRotated = segmentYMirror * pathEnd
		nextBeginningRotated = segmentYMirror * nextBeginning
		y = pathEndRotated.imag
		for betweenIndex in xrange( len( self.getBetweens() ) ):
			between = self.getBetweens()[ betweenIndex ]
			betweenRotated = euclidean.getPointsRoundZAxis( segmentYMirror, between )
			euclidean.addXIntersectionIndexes( betweenRotated, betweenIndex, switchX, y )
		switchX.sort()
		maximumX = max( pathEndRotated.real, nextBeginningRotated.real )
		minimumX = min( pathEndRotated.real, nextBeginningRotated.real )
		for xIntersection in switchX:
			if xIntersection.x > minimumX and xIntersection.x < maximumX:
				betweenX.append( xIntersection )
		betweenXIndex = self.getStartIndex( betweenX )
		while betweenXIndex < len( betweenX ) - 1:
			betweenXFirst = betweenX[ betweenXIndex ]
			betweenXSecond = betweenX[ betweenXIndex + 1 ]
			loopFirst = self.getBetweens()[ betweenXFirst.index ]
			betweenFirst = segment * complex( betweenXFirst.x, y )
			betweenSecond = segment * complex( betweenXSecond.x, y )
			isLeavingPerimeter = False
			if betweenXSecond.index != betweenXFirst.index:
				isLeavingPerimeter = True
			self.addPathBetween( aroundBetweenPath, betweenFirst, betweenSecond, isLeavingPerimeter, loopFirst )
			betweenXIndex += 2
예제 #3
0
def getOverhangDirection( belowOutsetLoops, segmentBegin, segmentEnd ):
	"Add to span direction from the endpoint segments which overhang the layer below."
	segment = segmentEnd - segmentBegin
	normalizedSegment = euclidean.getNormalized( complex( segment.real, segment.imag ) )
	segmentYMirror = complex( normalizedSegment.real, - normalizedSegment.imag )
	segmentBegin = segmentYMirror * segmentBegin
	segmentEnd = segmentYMirror * segmentEnd
	solidXIntersectionList = []
	y = segmentBegin.imag
	solidXIntersectionList.append( euclidean.XIntersectionIndex( - 1.0, segmentBegin.real ) )
	solidXIntersectionList.append( euclidean.XIntersectionIndex( - 1.0, segmentEnd.real ) )
	for belowLoopIndex in xrange( len( belowOutsetLoops ) ):
		belowLoop = belowOutsetLoops[ belowLoopIndex ]
		rotatedOutset = euclidean.getPointsRoundZAxis( segmentYMirror, belowLoop )
		euclidean.addXIntersectionIndexes( rotatedOutset, belowLoopIndex, solidXIntersectionList, y )
	overhangingSegments = euclidean.getSegmentsFromXIntersectionIndexes( solidXIntersectionList, y )
	overhangDirection = complex()
	for overhangingSegment in overhangingSegments:
		overhangDirection += getDoubledRoundZ( overhangingSegment, normalizedSegment )
	return overhangDirection