Пример #1
0
	def insertPathsBetween( self, nextBeginning, pathEnd ):
		"Insert paths between the perimeter and the fill."
		betweenX = []
		switchX = []
		segment = nextBeginning.minus( pathEnd )
		segment.normalize()
		segmentXY = segment.dropAxis( 2 )
		segmentYMirror = complex( segment.x, - segment.y )
		pathEndRotated = euclidean.getRoundZAxisByPlaneAngle( segmentYMirror, pathEnd )
		nextBeginningRotated = euclidean.getRoundZAxisByPlaneAngle( segmentYMirror, nextBeginning )
		y = pathEndRotated.y
		z = pathEndRotated.z
		for betweenIndex in range( len( self.getBetweens() ) ):
			between = self.getBetweens()[ betweenIndex ]
			betweenRotated = euclidean.getPathRoundZAxisByPlaneAngle( segmentYMirror, between )
			euclidean.addXIntersections( betweenRotated, betweenIndex, switchX, y )
		switchX.sort( euclidean.compareSolidXByX )
		maximumX = max( pathEndRotated.x, nextBeginningRotated.x )
		minimumX = min( pathEndRotated.x, nextBeginningRotated.x )
		for xIntersection in switchX:
			if xIntersection.real > minimumX and xIntersection.real < maximumX:
				betweenX.append( xIntersection )
		betweenXIndex = 0
		while betweenXIndex < len( betweenX ) - 1:
			betweenXFirst = betweenX[ betweenXIndex ]
			betweenXSecond = betweenX[ betweenXIndex + 1 ]
			if betweenXSecond.imag == betweenXFirst.imag:
				betweenXIndex += 1
				betweenFirst = euclidean.getRoundZAxisByPlaneAngle( segmentXY, Vec3( betweenXFirst.real, y, z ) )
				betweenSecond = euclidean.getRoundZAxisByPlaneAngle( segmentXY, Vec3( betweenXSecond.real, y, z ) )
				loopFirst = self.getBetweens()[ int( betweenXFirst.imag ) ]
				self.addPathBetween( betweenFirst, betweenSecond, loopFirst )
			betweenXIndex += 1
Пример #2
0
def getHorizontalSegments( fillLoops, alreadyFilledArounds, y ):
	"Get horizontal segments inside loops."
	solidXIntersectionList = []
	euclidean.addXIntersectionsFromLoops( fillLoops, - 1, solidXIntersectionList, y )
	for alreadyFilledAroundIndex in range( len( alreadyFilledArounds ) ):
		alreadyFilledLoops = alreadyFilledArounds[ alreadyFilledAroundIndex ]
		for alreadyFilledLoopIndex in range( len( alreadyFilledLoops ) ):
			alreadyFilledLoop = alreadyFilledLoops[ alreadyFilledLoopIndex ]
			euclidean.addXIntersections( alreadyFilledLoop, alreadyFilledAroundIndex, solidXIntersectionList, y )
	return euclidean.getSegmentsFromIntersections( solidXIntersectionList, y, fillLoops[ 0 ][ 0 ].z )
Пример #3
0
def getHorizontalSegments(fillLoops, alreadyFilledArounds, y):
    "Get horizontal segments inside loops."
    solidXIntersectionList = []
    euclidean.addXIntersectionsFromLoops(fillLoops, -1, solidXIntersectionList,
                                         y)
    for alreadyFilledAroundIndex in range(len(alreadyFilledArounds)):
        alreadyFilledLoops = alreadyFilledArounds[alreadyFilledAroundIndex]
        for alreadyFilledLoopIndex in range(len(alreadyFilledLoops)):
            alreadyFilledLoop = alreadyFilledLoops[alreadyFilledLoopIndex]
            euclidean.addXIntersections(alreadyFilledLoop,
                                        alreadyFilledAroundIndex,
                                        solidXIntersectionList, y)
    return euclidean.getSegmentsFromIntersections(solidXIntersectionList, y,
                                                  fillLoops[0][0].z)
Пример #4
0
def getOverhangDirection( belowOutsetLoops, segmentBegin, segmentEnd ):
	"Add to span direction from the endpoint segments which overhang the layer below."
	segment = segmentEnd.minus( segmentBegin )
	normalizedSegment = complex( segment.x, segment.y )
	normalizedSegment /= abs( normalizedSegment )
	segmentYMirror = complex( normalizedSegment.real, - normalizedSegment.imag )
	segmentBegin = euclidean.getRoundZAxisByPlaneAngle( segmentYMirror, segmentBegin )
	segmentEnd = euclidean.getRoundZAxisByPlaneAngle( segmentYMirror, segmentEnd )
	solidXIntersectionList = []
	y = segmentBegin.y
	solidXIntersectionList.append( complex( segmentBegin.x, - 1.0 ) )
	solidXIntersectionList.append( complex( segmentEnd.x, - 1.0 ) )
	for belowLoopIndex in range( len( belowOutsetLoops ) ):
		belowLoop = belowOutsetLoops[ belowLoopIndex ]
		rotatedOutset = euclidean.getPathRoundZAxisByPlaneAngle( segmentYMirror, belowLoop )
		euclidean.addXIntersections( rotatedOutset, belowLoopIndex, solidXIntersectionList, y )
	overhangingSegments = euclidean.getSegmentsFromIntersections( solidXIntersectionList, y, segmentBegin.z )
	overhangDirection = complex()
	for overhangingSegment in overhangingSegments:
		overhangDirection += getDoubledRoundZ( overhangingSegment, normalizedSegment )
	return overhangDirection
Пример #5
0
 def insertPathsBetween(self, nextBeginning, pathEnd):
     "Insert paths between the perimeter and the fill."
     betweenX = []
     switchX = []
     segment = nextBeginning.minus(pathEnd)
     segment.normalize()
     segmentXY = segment.dropAxis(2)
     segmentYMirror = complex(segment.x, -segment.y)
     pathEndRotated = euclidean.getRoundZAxisByPlaneAngle(
         segmentYMirror, pathEnd)
     nextBeginningRotated = euclidean.getRoundZAxisByPlaneAngle(
         segmentYMirror, nextBeginning)
     y = pathEndRotated.y
     z = pathEndRotated.z
     for betweenIndex in range(len(self.getBetweens())):
         between = self.getBetweens()[betweenIndex]
         betweenRotated = euclidean.getPathRoundZAxisByPlaneAngle(
             segmentYMirror, between)
         euclidean.addXIntersections(betweenRotated, betweenIndex, switchX,
                                     y)
     switchX.sort(euclidean.compareSolidXByX)
     maximumX = max(pathEndRotated.x, nextBeginningRotated.x)
     minimumX = min(pathEndRotated.x, nextBeginningRotated.x)
     for xIntersection in switchX:
         if xIntersection.real > minimumX and xIntersection.real < maximumX:
             betweenX.append(xIntersection)
     betweenXIndex = 0
     while betweenXIndex < len(betweenX) - 1:
         betweenXFirst = betweenX[betweenXIndex]
         betweenXSecond = betweenX[betweenXIndex + 1]
         if betweenXSecond.imag == betweenXFirst.imag:
             betweenXIndex += 1
             betweenFirst = euclidean.getRoundZAxisByPlaneAngle(
                 segmentXY, Vec3(betweenXFirst.real, y, z))
             betweenSecond = euclidean.getRoundZAxisByPlaneAngle(
                 segmentXY, Vec3(betweenXSecond.real, y, z))
             loopFirst = self.getBetweens()[int(betweenXFirst.imag)]
             self.addPathBetween(betweenFirst, betweenSecond, loopFirst)
         betweenXIndex += 1