def getIsInsetPointInsideLoops( inside, loops, pointBegin, pointCenter, pointEnd, radius ): "Determine if the inset point is inside the loops." centerMinusBegin = euclidean.getNormalized( pointCenter - pointBegin ) centerMinusBeginWiddershins = complex( - centerMinusBegin.imag, centerMinusBegin.real ) endMinusCenter = euclidean.getNormalized( pointEnd - pointCenter ) endMinusCenterWiddershins = complex( - endMinusCenter.imag, endMinusCenter.real ) widdershinsNormalized = euclidean.getNormalized( centerMinusBeginWiddershins + endMinusCenterWiddershins ) * radius return euclidean.isPointInsideLoopsZone( loops, pointCenter + widdershinsNormalized ) == inside
def flipDirectLayer(self, rotatedLoopLayer): "Flip the y coordinate of the layer and direct the loops." for loop in rotatedLoopLayer.loops: for pointIndex, point in enumerate(loop): loop[pointIndex] = complex(point.real, -point.imag) rotatedLoopLayer.loops = trianglemesh.getLoopsInOrderOfArea(trianglemesh.compareAreaDescending, rotatedLoopLayer.loops) for loopIndex, loop in enumerate(rotatedLoopLayer.loops): isInsideLoops = euclidean.isPointInsideLoopsZone(rotatedLoopLayer.loops[: loopIndex], euclidean.getLeftPoint(loop)) booleansolid.directLoop((not isInsideLoops), loop)
def getIsInsetPointInsideLoops(inside, loops, pointBegin, pointCenter, pointEnd, radius): "Determine if the inset point is inside the loops." centerMinusBegin = euclidean.getNormalized(pointCenter - pointBegin) centerMinusBeginWiddershins = complex(-centerMinusBegin.imag, centerMinusBegin.real) endMinusCenter = euclidean.getNormalized(pointEnd - pointCenter) endMinusCenterWiddershins = complex(-endMinusCenter.imag, endMinusCenter.real) widdershinsNormalized = euclidean.getNormalized( centerMinusBeginWiddershins + endMinusCenterWiddershins) * radius return euclidean.isPointInsideLoopsZone( loops, pointCenter + widdershinsNormalized) == inside
def getConnectionIsCloseWithoutOverlap(self, location, path): "Determine if the connection is close enough and does not overlap another thread." if len(path) < 1: return False locationComplex = location.dropAxis(2) segment = locationComplex - path[-1] segmentLength = abs(segment) if segmentLength <= 0.0: return True if segmentLength > self.maximumConnectionDistance: return False segment /= segmentLength distance = self.connectingStepLength segmentEndLength = segmentLength - self.connectingStepLength while distance < segmentEndLength: alongPoint = distance * segment + path[-1] if not euclidean.isPointInsideLoopsZone(self.boundaryLoops, alongPoint): return False distance += self.connectingStepLength # removedLayerPixelTable = self.layerPixelTable.copy() # if self.oldLocation in self.maskPixelTableTable: # euclidean.removePixelTableFromPixelTable( self.maskPixelTableTable[ self.oldLocation ], removedLayerPixelTable ) # euclidean.addPathToPixelTable( path[ : - 2 ], removedLayerPixelTable, None, self.layerPixelWidth ) segmentTable = {} euclidean.addSegmentToPixelTable(path[-1], locationComplex, segmentTable, 2.0, 2.0, self.layerPixelWidth) # euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth ) # euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth ) # maskPixelTable = {} # if location in self.maskPixelTableTable: # maskPixelTable = self.maskPixelTableTable[ location ] if euclidean.isPixelTableIntersecting(self.layerPixelTable, segmentTable, {}): # if euclidean.isPixelTableIntersecting( removedLayerPixelTable, segmentTable, {} ): return False euclidean.addValueSegmentToPixelTable(path[-1], locationComplex, self.layerPixelTable, None, self.layerPixelWidth) # euclidean.addPixelTableToPixelTable( segmentTable, self.layerPixelTable ) return True
def getConnectionIsCloseWithoutOverlap( self, location, path ): "Determine if the connection is close enough and does not overlap another thread." if len( path ) < 1: return False locationComplex = location.dropAxis( 2 ) segment = locationComplex - path[ - 1 ] segmentLength = abs( segment ) if segmentLength <= 0.0: return True if segmentLength > self.maximumConnectionDistance: return False segment /= segmentLength distance = self.connectingStepLength segmentEndLength = segmentLength - self.connectingStepLength while distance < segmentEndLength: alongPoint = distance * segment + path[ - 1 ] if not euclidean.isPointInsideLoopsZone( self.boundaryLoops, alongPoint ): return False distance += self.connectingStepLength # removedLayerPixelTable = self.layerPixelTable.copy() # if self.oldLocation in self.maskPixelTableTable: # euclidean.removePixelTableFromPixelTable( self.maskPixelTableTable[ self.oldLocation ], removedLayerPixelTable ) # euclidean.addPathToPixelTable( path[ : - 2 ], removedLayerPixelTable, None, self.layerPixelWidth ) segmentTable = {} euclidean.addSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, 2.0, 2.0, self.layerPixelWidth ) # euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth ) # euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth ) # maskPixelTable = {} # if location in self.maskPixelTableTable: # maskPixelTable = self.maskPixelTableTable[ location ] if euclidean.isPixelTableIntersecting( self.layerPixelTable, segmentTable, {} ): # if euclidean.isPixelTableIntersecting( removedLayerPixelTable, segmentTable, {} ): return False euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, self.layerPixelTable, None, self.layerPixelWidth ) # euclidean.addPixelTableToPixelTable( segmentTable, self.layerPixelTable ) return True