def getInsetFromClockwiseLoop( loop, radius ): "Get loop inset from clockwise loop, out from widdershins loop." insetLoop = [] for pointIndex in range( len( loop ) ): behindAbsolute = loop[ ( pointIndex + len( loop ) - 1 ) % len( loop ) ] center = loop[ pointIndex ] aheadAbsolute = loop[ ( pointIndex + 1 ) % len( loop ) ] insetLoop.append( getInsetFromClockwiseTriple( aheadAbsolute, behindAbsolute, center, radius ) ) return euclidean.getSimplifiedLoop( insetLoop, radius )
def getInsetFromClockwiseLoop(loop, radius): "Get loop inset from clockwise loop, out from widdershins loop." insetLoop = [] for pointIndex in range(len(loop)): behindAbsolute = loop[(pointIndex + len(loop) - 1) % len(loop)] center = loop[pointIndex] aheadAbsolute = loop[(pointIndex + 1) % len(loop)] insetLoop.append( getInsetFromClockwiseTriple(aheadAbsolute, behindAbsolute, center, radius)) return euclidean.getSimplifiedLoop(insetLoop, radius)
def getLoopsFromMesh( self, z ): "Get loops from a slice of a mesh." loops = [] originalLoops = [] if self.slicePreferences.correct.value: originalLoops = getLoopsFromCorrectMesh( self.triangleMesh.edges, self.triangleMesh.faces, self.triangleMesh.vertices, z ) if len( originalLoops ) < 1: originalLoops = getLoopsFromUnprovenMesh( self.triangleMesh.edges, self.extrusionWidth, self.triangleMesh.faces, self.triangleMesh.vertices, self.slicePreferences, z ) for original in originalLoops: loops.append( euclidean.getSimplifiedLoop( original, self.extrusionWidth ) ) for pathIndex in range( len( loops ) ): loop = loops[ pathIndex ] leftPoint = euclidean.getLeftPoint( loop ) totalNumberOfIntersectionsToLeft = 0 for otherLoop in loops[ : pathIndex ] + loops[ pathIndex + 1 : ]: totalNumberOfIntersectionsToLeft += euclidean.getNumberOfIntersectionsToLeft( leftPoint, otherLoop ) loopIsWiddershins = euclidean.isWiddershins( loop ) isEven = totalNumberOfIntersectionsToLeft % 2 == 0 if isEven != loopIsWiddershins: loop.reverse() return loops
def addPath(extrusionWidth, fill, path, rotationPlaneAngle): "Add simplified path to fill." planeRotated = euclidean.getPathRoundZAxisByPlaneAngle( rotationPlaneAngle, euclidean.getSimplifiedLoop(path, extrusionWidth)) fill.append(planeRotated)
def addPath( extrusionWidth, fill, path, rotationPlaneAngle ): "Add simplified path to fill." planeRotated = euclidean.getPathRoundZAxisByPlaneAngle( rotationPlaneAngle, euclidean.getSimplifiedLoop( path, extrusionWidth ) ) fill.append( planeRotated )