def isIntersectingAnother( self, anotherBoundingLoop ): "Determine if this bounding loop is intersecting another bounding loop." if self.maximum.imag < anotherBoundingLoop.minimum.imag or self.maximum.real < anotherBoundingLoop.minimum.real: return False if self.minimum.imag > anotherBoundingLoop.maximum.imag or self.minimum.real > anotherBoundingLoop.maximum.real: return False for point in self.loop: if euclidean.getNumberOfIntersectionsToLeft( point, anotherBoundingLoop.loop ) % 2 == 1: return True for point in anotherBoundingLoop.loop: if euclidean.getNumberOfIntersectionsToLeft( point, self.loop ) % 2 == 1: return True if isLoopIntersectingLoop( anotherBoundingLoop.loop, self.loop ): return True return False #later check for intersection on only acute angles
def isPathAlwaysOutsideLoops(loops, path): "Determine if all points in a path are outside another loop in a list." for loop in loops: for point in path: if euclidean.getNumberOfIntersectionsToLeft(point, loop) % 2 == 1: return False return True
def isPathAlwaysOutsideLoops( loops, path ): "Determine if all points in a path are outside another loop in a list." for loop in loops: for point in path: if euclidean.getNumberOfIntersectionsToLeft( point, loop ) % 2 == 1: return False return True
def isIntersectingAnother(self, anotherBoundingLoop): "Determine if this bounding loop is intersecting another bounding loop." if self.maximum.imag < anotherBoundingLoop.minimum.imag or self.maximum.real < anotherBoundingLoop.minimum.real: return False if self.minimum.imag > anotherBoundingLoop.maximum.imag or self.minimum.real > anotherBoundingLoop.maximum.real: return False for point in self.loop: if euclidean.getNumberOfIntersectionsToLeft( point, anotherBoundingLoop.loop) % 2 == 1: return True for point in anotherBoundingLoop.loop: if euclidean.getNumberOfIntersectionsToLeft(point, self.loop) % 2 == 1: return True if isLoopIntersectingLoop(anotherBoundingLoop.loop, self.loop): return True return False #later check for intersection on only acute angles
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 isPathAlwaysInsideLoop(loop, path): "Determine if all points of a path are inside another loop." for point in path: if euclidean.getNumberOfIntersectionsToLeft(point, loop) % 2 == 0: return False return True
def isPathAlwaysInsideLoop( loop, path ): "Determine if all points of a path are inside another loop." for point in path: if euclidean.getNumberOfIntersectionsToLeft( point, loop ) % 2 == 0: return False return True