def getBridgeDirection( self, layerLoops ): "Get span direction for the majority of the overhanging extrusion perimeter, if any." if not self.slicePreferences.infillDirectionBridge.value: return None if self.belowLoops == None: return None belowOutsetLoops = [] overhangInset = 1.25 * self.extrusionWidth greaterThanOverhang = 1.1 * overhangInset for loop in self.belowLoops: centers = intercircle.getCentersFromLoopDirection( euclidean.isWiddershins( loop ), loop, greaterThanOverhang ) # centers = intercircle.getCentersFromOutside( not euclidean.isWiddershins( loop ), loop, greaterThanOverhang ) for center in centers: outset = intercircle.getInsetFromClockwiseLoop( center, overhangInset ) if euclidean.isWiddershins( center ) == euclidean.isWiddershins( outset ): if euclidean.getMaximumSpan( outset ) > self.extrusionWidth: belowOutsetLoops.append( outset ) bridgeDirection = complex() for loop in layerLoops: for pointIndex in range( len( loop ) ): previousIndex = ( pointIndex + len( loop ) - 1 ) % len( loop ) bridgeDirection += getOverhangDirection( belowOutsetLoops, loop[ previousIndex ], loop[ pointIndex ] ) if abs( bridgeDirection ) < self.halfExtrusionWidth: return None else: bridgeDirection /= abs( bridgeDirection ) return cmath.sqrt( bridgeDirection )
def getOutsetBoundingLoop( self, outsetDistance ): "Outset the bounding rectangle and loop by a distance." outsetBoundingLoop = BoundingLoop() outsetBoundingLoop.maximum = self.maximum + complex( outsetDistance, outsetDistance ) outsetBoundingLoop.minimum = self.minimum - complex( outsetDistance, outsetDistance ) greaterThanOutsetDistance = 1.1 * outsetDistance centers = intercircle.getCentersFromLoopDirection( True, self.loop, greaterThanOutsetDistance ) outsetBoundingLoop.loop = intercircle.getInsetFromClockwiseLoop( centers[ 0 ], outsetDistance ) return outsetBoundingLoop
def getOutsetBoundingLoop(self, outsetDistance): "Outset the bounding rectangle and loop by a distance." outsetBoundingLoop = BoundingLoop() outsetBoundingLoop.maximum = self.maximum + complex( outsetDistance, outsetDistance) outsetBoundingLoop.minimum = self.minimum - complex( outsetDistance, outsetDistance) greaterThanOutsetDistance = 1.1 * outsetDistance centers = intercircle.getCentersFromLoopDirection( True, self.loop, greaterThanOutsetDistance) outsetBoundingLoop.loop = intercircle.getInsetFromClockwiseLoop( centers[0], outsetDistance) return outsetBoundingLoop