def getSegmentsFromPoints( aroundLists, loopLists, pointBegin, pointEnd ): "Get endpoint segments from the beginning and end of a line segment." normalizedSegment = pointEnd - pointBegin normalizedSegmentLength = abs( normalizedSegment ) if normalizedSegmentLength == 0.0: return normalizedSegment /= normalizedSegmentLength segmentYMirror = complex( normalizedSegment.real, - normalizedSegment.imag ) pointBeginRotated = segmentYMirror * pointBegin pointEndRotated = segmentYMirror * pointEnd rotatedLoopLists = [] for loopList in loopLists: rotatedLoopList = [] rotatedLoopLists.append( rotatedLoopList ) for loop in loopList: rotatedLoop = euclidean.getPointsRoundZAxis( segmentYMirror, loop ) rotatedLoopList.append( rotatedLoop ) xIntersectionIndexList = [] xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointBeginRotated.real ) ) xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointEndRotated.real ) ) euclidean.addXIntersectionIndexesFromLoopLists( rotatedLoopLists, xIntersectionIndexList, pointBeginRotated.imag ) segments = euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, pointBeginRotated.imag ) insideSegments = [] for segment in segments: insideSegment = euclidean.getSegmentFromPoints( normalizedSegment * segment[ 0 ].point, normalizedSegment * segment[ 1 ].point ) if len( aroundLists ) < 1: insideSegments.append( insideSegment ) elif isSegmentInsideAround( aroundLists, insideSegment ): insideSegments.append( insideSegment ) return insideSegments
def getSegmentsFromPoints(loops, pointBegin, pointEnd): "Get endpoint segments from the beginning and end of a line segment." normalizedSegment = pointEnd - pointBegin normalizedSegmentLength = abs(normalizedSegment) if normalizedSegmentLength == 0.0: return [] normalizedSegment /= normalizedSegmentLength segmentYMirror = complex(normalizedSegment.real, -normalizedSegment.imag) pointBeginRotated = segmentYMirror * pointBegin pointEndRotated = segmentYMirror * pointEnd xIntersectionIndexList = [] xIntersectionIndexList.append( euclidean.XIntersectionIndex(-1, pointBeginRotated.real)) xIntersectionIndexList.append( euclidean.XIntersectionIndex(-1, pointEndRotated.real)) for loopIndex in xrange(len(loops)): rotatedLoop = euclidean.getPointsRoundZAxis(segmentYMirror, loops[loopIndex]) euclidean.addXIntersectionIndexesFromLoopY(rotatedLoop, loopIndex, xIntersectionIndexList, pointBeginRotated.imag) segments = euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, pointBeginRotated.imag) for segment in segments: for endpoint in segment: endpoint.point *= normalizedSegment return segments
def getSegmentsFromLoopListsPoints( loopLists, pointBegin, pointEnd ): "Get endpoint segments from the beginning and end of a line segment." normalizedSegment = pointEnd - pointBegin normalizedSegmentLength = abs( normalizedSegment ) if normalizedSegmentLength == 0.0: return [] normalizedSegment /= normalizedSegmentLength segmentYMirror = complex( normalizedSegment.real, - normalizedSegment.imag ) pointBeginRotated = segmentYMirror * pointBegin pointEndRotated = segmentYMirror * pointEnd rotatedLoopLists = [] for loopList in loopLists: rotatedLoopList = [] rotatedLoopLists.append( rotatedLoopList ) for loop in loopList: rotatedLoop = euclidean.getPointsRoundZAxis( segmentYMirror, loop ) rotatedLoopList.append( rotatedLoop ) xIntersectionIndexList = [] xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointBeginRotated.real ) ) xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointEndRotated.real ) ) euclidean.addXIntersectionIndexesFromLoopListsY( rotatedLoopLists, xIntersectionIndexList, pointBeginRotated.imag ) segments = euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, pointBeginRotated.imag ) for segment in segments: for endpoint in segment: endpoint.point *= normalizedSegment return segments
def subtractFill( fillXIntersectionIndexTable, supportSegmentLayerTable ): "Subtract fill from the support layer table." supportSegmentLayerTableKeys = supportSegmentLayerTable.keys() supportSegmentLayerTableKeys.sort() if len( supportSegmentLayerTableKeys ) < 1: return for supportSegmentLayerTableKey in supportSegmentLayerTableKeys: xIntersectionIndexList = [] addXIntersectionsFromSegments( - 1, supportSegmentLayerTable[ supportSegmentLayerTableKey ], xIntersectionIndexList ) if supportSegmentLayerTableKey in fillXIntersectionIndexTable: addXIntersectionsFromSegments( 0, fillXIntersectionIndexTable[ supportSegmentLayerTableKey ], xIntersectionIndexList ) lineSegments = euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, supportSegmentLayerTableKey ) if len( lineSegments ) > 0: supportSegmentLayerTable[ supportSegmentLayerTableKey ] = lineSegments else: del supportSegmentLayerTable[ supportSegmentLayerTableKey ]
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
def getSegmentsFromPoints(aroundLists, loopLists, pointBegin, pointEnd): "Get endpoint segments from the beginning and end of a line segment." normalizedSegment = pointEnd - pointBegin normalizedSegmentLength = abs(normalizedSegment) if normalizedSegmentLength == 0.0: return normalizedSegment /= normalizedSegmentLength segmentYMirror = complex(normalizedSegment.real, -normalizedSegment.imag) pointBeginRotated = segmentYMirror * pointBegin pointEndRotated = segmentYMirror * pointEnd rotatedLoopLists = [] for loopList in loopLists: rotatedLoopList = [] rotatedLoopLists.append(rotatedLoopList) for loop in loopList: rotatedLoop = euclidean.getPointsRoundZAxis(segmentYMirror, loop) rotatedLoopList.append(rotatedLoop) xIntersectionIndexList = [] xIntersectionIndexList.append( euclidean.XIntersectionIndex(-1, pointBeginRotated.real)) xIntersectionIndexList.append( euclidean.XIntersectionIndex(-1, pointEndRotated.real)) euclidean.addXIntersectionIndexesFromLoopLists(rotatedLoopLists, xIntersectionIndexList, pointBeginRotated.imag) segments = euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, pointBeginRotated.imag) insideSegments = [] for segment in segments: insideSegment = euclidean.getSegmentFromPoints( normalizedSegment * segment[0].point, normalizedSegment * segment[1].point) if len(aroundLists) < 1: insideSegments.append(insideSegment) elif isSegmentInsideAround(aroundLists, insideSegment): insideSegments.append(insideSegment) return insideSegments
def getHorizontalSegments( fillLoops, alreadyFilledArounds, y ): "Get horizontal segments inside loops." xIntersectionIndexList = [] euclidean.addXIntersectionIndexesFromLoops( fillLoops, - 1, xIntersectionIndexList, y ) euclidean.addXIntersectionIndexesFromLoops( alreadyFilledArounds, 0, xIntersectionIndexList, y ) return euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, y )