def addPathBeforeEnd( self, aroundBetweenPath, location, loop ): "Add the path before the end of the loop." halfFillInset = 0.5 * self.fillInset if self.arrivalInsetFollowDistance < halfFillInset: return locationComplex = location.dropAxis( 2 ) closestInset = None closestDistanceIndex = euclidean.DistanceIndex( 999999999999999999.0, - 1 ) loop = euclidean.getAwayPoints( loop, self.extrusionWidth ) circleNodes = intercircle.getCircleNodesFromLoop( loop, self.fillInset ) centers = [] centers = intercircle.getCentersFromCircleNodes( circleNodes ) for center in centers: inset = intercircle.getInsetFromClockwiseLoop( center, halfFillInset ) if euclidean.isLargeSameDirection( inset, center, self.fillInset ): if euclidean.isPathInsideLoop( loop, inset ) == euclidean.isWiddershins( loop ): distanceIndex = euclidean.getNearestDistanceIndex( locationComplex, inset ) if distanceIndex.distance < closestDistanceIndex.distance: closestInset = inset closestDistanceIndex = distanceIndex if closestInset == None: return extrusionHalfWidth = 0.5 * self.extrusionWidth closestInset = euclidean.getLoopStartingNearest( extrusionHalfWidth, locationComplex, closestInset ) if euclidean.getPolygonLength( closestInset ) < 0.2 * self.arrivalInsetFollowDistance: return closestInset.append( closestInset[ 0 ] ) closestInset = euclidean.getSimplifiedPath( closestInset, self.extrusionWidth ) closestInset.reverse() pathBeforeArrival = euclidean.getClippedAtEndLoopPath( self.arrivalInsetFollowDistance, closestInset ) pointBeforeArrival = pathBeforeArrival[ - 1 ] aroundBetweenPath.append( pointBeforeArrival ) if self.arrivalInsetFollowDistance <= halfFillInset: return aroundBetweenPath += euclidean.getClippedAtEndLoopPath( halfFillInset, closestInset )[ len( pathBeforeArrival ) - 1 : ]
def getBridgeLoops( layerThickness, loop ): "Get the inset bridge loops from the loop." halfWidth = 1.5 * layerThickness slightlyGreaterThanHalfWidth = 1.1 * halfWidth extrudateLoops = [] centers = intercircle.getCentersFromLoop( loop, slightlyGreaterThanHalfWidth ) for center in centers: extrudateLoop = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfWidth ) if intercircle.isLargeSameDirection( extrudateLoop, center, halfWidth ): if euclidean.isPathInsideLoop( loop, extrudateLoop ) == euclidean.isWiddershins( loop ): extrudateLoop.reverse() extrudateLoops.append( extrudateLoop ) return extrudateLoops
def getInsetLoopsFromLoop( inset, loop ): "Get the inset loops from a loop." absoluteInset = abs( inset ) insetLoops = [] slightlyGreaterThanInset = 1.1 * absoluteInset muchGreaterThanLayerInset = 2.5 * absoluteInset isInInsetDirection = euclidean.isWiddershins( loop ) if inset < 0.0: isInInsetDirection = not isInInsetDirection centers = getCentersFromLoopDirection( not isInInsetDirection, loop, slightlyGreaterThanInset ) for center in centers: insetLoop = getSimplifiedInsetFromClockwiseLoop( center, absoluteInset ) if euclidean.isLargeSameDirection( insetLoop, center, muchGreaterThanLayerInset ): if euclidean.isPathInsideLoop( loop, insetLoop ) == isInInsetDirection: if inset > 0.0: insetLoop.reverse() insetLoops.append( insetLoop ) return insetLoops
def getBetweens( self ): "Set betweens for the layer." if self.layerZ in self.betweenTable: return self.betweenTable[ self.layerZ ] if self.layerZ not in self.layerTable: return [] halfFillInset = 0.5 * self.fillInset betweens = [] for boundaryLoop in self.layerTable[ self.layerZ ]: circleNodes = intercircle.getCircleNodesFromLoop( boundaryLoop, self.fillInset ) centers = intercircle.getCentersFromCircleNodes( circleNodes ) for center in centers: inset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfFillInset ) if euclidean.isLargeSameDirection( inset, center, self.fillInset ): if euclidean.isPathInsideLoop( boundaryLoop, inset ) == euclidean.isWiddershins( boundaryLoop ): betweens.append( inset ) self.betweenTable[ self.layerZ ] = betweens return betweens
def addPathBeforeEnd(self, aroundBetweenPath, location, loop): "Add the path before the end of the loop." halfFillInset = 0.5 * self.fillInset if self.arrivalInsetFollowDistance < halfFillInset: return locationComplex = location.dropAxis(2) closestInset = None closestDistanceIndex = euclidean.DistanceIndex(999999999999999999.0, -1) loop = euclidean.getAwayPoints(loop, self.extrusionWidth) circleNodes = intercircle.getCircleNodesFromLoop(loop, self.fillInset) centers = [] centers = intercircle.getCentersFromCircleNodes(circleNodes) for center in centers: inset = intercircle.getInsetFromClockwiseLoop( center, halfFillInset) if euclidean.isLargeSameDirection(inset, center, self.fillInset): if euclidean.isPathInsideLoop( loop, inset) == euclidean.isWiddershins(loop): distanceIndex = euclidean.getNearestDistanceIndex( locationComplex, inset) if distanceIndex.distance < closestDistanceIndex.distance: closestInset = inset closestDistanceIndex = distanceIndex if closestInset == None: return extrusionHalfWidth = 0.5 * self.extrusionWidth closestInset = euclidean.getLoopStartingNearest( extrusionHalfWidth, locationComplex, closestInset) if euclidean.getPolygonLength( closestInset) < 0.2 * self.arrivalInsetFollowDistance: return closestInset.append(closestInset[0]) closestInset = euclidean.getSimplifiedPath(closestInset, self.extrusionWidth) closestInset.reverse() pathBeforeArrival = euclidean.getClippedAtEndLoopPath( self.arrivalInsetFollowDistance, closestInset) pointBeforeArrival = pathBeforeArrival[-1] aroundBetweenPath.append(pointBeforeArrival) if self.arrivalInsetFollowDistance <= halfFillInset: return aroundBetweenPath += euclidean.getClippedAtEndLoopPath( halfFillInset, closestInset)[len(pathBeforeArrival) - 1:]
def getBetweens(self): "Set betweens for the layer." if self.layerZ in self.betweenTable: return self.betweenTable[self.layerZ] if self.layerZ not in self.layerTable: return [] halfFillInset = 0.5 * self.fillInset betweens = [] for boundaryLoop in self.layerTable[self.layerZ]: circleNodes = intercircle.getCircleNodesFromLoop( boundaryLoop, self.fillInset) centers = intercircle.getCentersFromCircleNodes(circleNodes) for center in centers: inset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfFillInset) if euclidean.isLargeSameDirection(inset, center, self.fillInset): if euclidean.isPathInsideLoop( boundaryLoop, inset) == euclidean.isWiddershins(boundaryLoop): betweens.append(inset) self.betweenTable[self.layerZ] = betweens return betweens
def getIsIntersectingWithinLoop(loop, otherLoop, outsetLoop): "Determine if the loop is intersecting or is within the other loop." if euclidean.isLoopIntersectingLoop(loop, otherLoop): return True return euclidean.isPathInsideLoop( otherLoop, loop) != euclidean.isPathInsideLoop(otherLoop, outsetLoop)
def getIsIntersectingWithinLoop( loop, otherLoop, outsetLoop ): "Determine if the loop is intersecting or is within the other loop." if euclidean.isLoopIntersectingLoop( loop, otherLoop ): return True return euclidean.isPathInsideLoop( otherLoop, loop ) != euclidean.isPathInsideLoop( otherLoop, outsetLoop )