def isOverlappingAnother( self, anotherBoundingLoop ): "Determine if this bounding loop is intersecting another bounding loop." if self.isRectangleMissingAnother( anotherBoundingLoop ): 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 return isLoopIntersectingLoop( anotherBoundingLoop.loop, self.loop ) #later check for intersection on only acute angles
def isOverlappingAnother( self, anotherBoundingLoop ): "Determine if this bounding loop is intersecting another bounding loop." if self.isRectangleMissingAnother( anotherBoundingLoop ): return False for point in self.loop: if euclidean.getNumberOfIntersectionsToLeft( anotherBoundingLoop.loop, point ) % 2 == 1: return True for point in anotherBoundingLoop.loop: if euclidean.getNumberOfIntersectionsToLeft( self.loop, point ) % 2 == 1: return True return isLoopIntersectingLoop( anotherBoundingLoop.loop, self.loop ) #later check for intersection on only acute angles
def getIsIntersectingWithinList( loop, loopList ): "Determine if the loop is intersecting or is within the loop list." leftPoint = euclidean.getLeftPoint( loop ) for otherLoop in loopList: if euclidean.getNumberOfIntersectionsToLeft( otherLoop, leftPoint ) % 2 == 1: return True return euclidean.isLoopIntersectingLoops( loop, loopList )
def isIntersectingWithinList( loop, loopList ): "Determine if the loop is intersecting or is within the loop list." if euclidean.isLoopIntersectingLoops( loop, loopList ): return True totalNumberOfIntersections = 0 for otherLoop in loopList: leftPoint = euclidean.getLeftPoint( otherLoop ) totalNumberOfIntersections += euclidean.getNumberOfIntersectionsToLeft( leftPoint, loop ) return totalNumberOfIntersections % 2 == 1
def isEntirelyInsideAnother( self, anotherBoundingLoop ): "Determine if this bounding loop is entirely inside another bounding loop." if self.minimum.imag < anotherBoundingLoop.minimum.imag or self.minimum.real < anotherBoundingLoop.minimum.real: return False if self.maximum.imag > anotherBoundingLoop.maximum.imag or self.maximum.real > anotherBoundingLoop.maximum.real: return False for point in self.loop: if euclidean.getNumberOfIntersectionsToLeft( anotherBoundingLoop.loop, point ) % 2 == 0: return False return not isLoopIntersectingLoop( anotherBoundingLoop.loop, self.loop ) #later check for intersection on only acute angles
def isIntersectingWithinList(loop, loopList): "Determine if the loop is intersecting or is within the loop list." if euclidean.isLoopIntersectingLoops(loop, loopList): return True totalNumberOfIntersections = 0 for otherLoop in loopList: leftPoint = euclidean.getLeftPoint(otherLoop) totalNumberOfIntersections += euclidean.getNumberOfIntersectionsToLeft( leftPoint, loop) return totalNumberOfIntersections % 2 == 1
def isEntirelyInsideAnother( self, anotherBoundingLoop ): "Determine if this bounding loop is entirely inside another bounding loop." if self.minimum.imag < anotherBoundingLoop.minimum.imag or self.minimum.real < anotherBoundingLoop.minimum.real: return False if self.maximum.imag > anotherBoundingLoop.maximum.imag or self.maximum.real > anotherBoundingLoop.maximum.real: return False for point in self.loop: if euclidean.getNumberOfIntersectionsToLeft( point, anotherBoundingLoop.loop ) % 2 == 0: return False return not isLoopIntersectingLoop( anotherBoundingLoop.loop, self.loop ) #later check for intersection on only acute angles
def getLoopsFromMesh( self, z ): "Get loops from a carve of a mesh." originalLoops = [] if self.isCorrectMesh: originalLoops = getLoopsFromCorrectMesh( self.edges, self.faces, self.vertices, z ) if len( originalLoops ) < 1: originalLoops = getLoopsFromUnprovenMesh( self.edges, self.faces, self.importRadius, self.vertices, z ) simplifiedLoops = [] for originalLoop in originalLoops: simplifiedLoops.append( euclidean.getSimplifiedLoop( originalLoop, self.importRadius ) ) loops = getLoopsInDescendingOrderOfArea( simplifiedLoops ) for loopIndex in xrange( len( loops ) ): loop = loops[ loopIndex ] leftPoint = euclidean.getLeftPoint( loop ) totalNumberOfIntersectionsToLeft = 0 for otherLoop in loops[ : loopIndex ] + loops[ loopIndex + 1 : ]: totalNumberOfIntersectionsToLeft += euclidean.getNumberOfIntersectionsToLeft( leftPoint, otherLoop ) loopIsWiddershins = euclidean.isWiddershins( loop ) isEven = totalNumberOfIntersectionsToLeft % 2 == 0 if isEven != loopIsWiddershins: loop.reverse() return loops
def getNumberOfOddIntersectionsFromLoops( leftPoint, loops ): "Get the number of odd intersections with the loops." totalNumberOfOddIntersections = 0 for loop in loops: totalNumberOfOddIntersections += int( euclidean.getNumberOfIntersectionsToLeft( loop, leftPoint ) % 2 ) return totalNumberOfOddIntersections