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 addAlreadyFilledArounds( alreadyFilledArounds, loop, radius ): "Add already filled loops around loop to alreadyFilledArounds." radius = abs( radius ) alreadyFilledLoop = [] slightlyGreaterThanRadius = 1.01 * radius muchGreaterThanRadius = 2.5 * radius circleNodes = intercircle.getCircleNodesFromLoop( loop, slightlyGreaterThanRadius ) centers = intercircle.getCentersFromCircleNodes( circleNodes ) for center in centers: alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, radius ) if euclidean.isLarge( alreadyFilledInset, muchGreaterThanRadius ) or euclidean.isWiddershins( alreadyFilledInset ): alreadyFilledLoop.append( alreadyFilledInset ) if len( alreadyFilledLoop ) > 0: alreadyFilledArounds.append( alreadyFilledLoop )
def getBridgeLoops( layerThickness, loop ): "Get the inset bridge loops from the loop." halfWidth = 1.5 * layerThickness slightlyGreaterThanHalfWidth = 1.1 * halfWidth muchGreaterThanHalfWIdth = 2.5 * halfWidth extrudateLoops = [] circleNodes = intercircle.getCircleNodesFromLoop( loop, slightlyGreaterThanHalfWidth ) centers = intercircle.getCentersFromCircleNodes( circleNodes ) for center in centers: extrudateLoop = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfWidth ) if euclidean.isLargeSameDirection( extrudateLoop, center, muchGreaterThanHalfWIdth ): if euclidean.isPathInsideLoop( loop, extrudateLoop ) == euclidean.isWiddershins( loop ): extrudateLoop.reverse() extrudateLoops.append( extrudateLoop ) return extrudateLoops
def addAlreadyFilledArounds(alreadyFilledArounds, loop, radius): "Add already filled loops around loop to alreadyFilledArounds." radius = abs(radius) alreadyFilledLoop = [] slightlyGreaterThanRadius = 1.01 * radius muchGreaterThanRadius = 2.5 * radius circleNodes = intercircle.getCircleNodesFromLoop( loop, slightlyGreaterThanRadius) centers = intercircle.getCentersFromCircleNodes(circleNodes) for center in centers: alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, radius) if euclidean.isLarge(alreadyFilledInset, muchGreaterThanRadius ) or euclidean.isWiddershins(alreadyFilledInset): alreadyFilledLoop.append(alreadyFilledInset) if len(alreadyFilledLoop) > 0: alreadyFilledArounds.append(alreadyFilledLoop)
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