def getInclusiveLoops( allPoints, corners, importRadius, isInteriorWanted = True ): "Get loops which include most of the points." circleNodes = intercircle.getCircleNodesFromPoints( allPoints, importRadius ) centers = intercircle.getCentersFromCircleNodes( circleNodes ) clockwiseLoops = [] inclusiveLoops = [] tinyRadius = 0.03 * importRadius for loop in centers: if len( loop ) > 2: insetPoint = getInsetPoint( loop, tinyRadius ) if getNumberOfOddIntersectionsFromLoops( insetPoint, centers ) % 4 == 0: inclusiveLoops.append( loop ) else: clockwiseLoops.append( loop ) pointTable = {} for inclusiveLoop in inclusiveLoops: addLoopToPointTable( inclusiveLoop, pointTable ) if not isInteriorWanted: return getLoopsWithCorners( corners, importRadius, inclusiveLoops, pointTable ) clockwiseLoops = getLoopsInOrderOfArea( compareAreaDescending, clockwiseLoops ) for clockwiseLoop in clockwiseLoops: if getOverlapRatio( clockwiseLoop, pointTable ) < 0.1: inclusiveLoops.append( clockwiseLoop ) addLoopToPointTable( clockwiseLoop, pointTable ) return getLoopsWithCorners( corners, importRadius, inclusiveLoops, pointTable )
def getInclusiveLoops( allPoints, corners, importRadius, isInteriorWanted ): "Get loops which include most of the points." circleNodes = intercircle.getCircleNodesFromPoints( allPoints, importRadius ) centers = intercircle.getCentersFromCircleNodes( circleNodes ) loops = intercircle.getLoopsFromLoopsDirection( True, centers ) pointTable = {} for loop in loops: addLoopToPointTable( loop, pointTable ) if not isInteriorWanted: return getLoopsWithCorners( corners, importRadius, loops, pointTable ) clockwiseLoops = getLoopsInDescendingOrderOfArea( intercircle.getLoopsFromLoopsDirection( False, centers ) ) clockwiseLoops.reverse() for clockwiseLoop in clockwiseLoops: if len( clockwiseLoop ) > 2 and euclidean.getMaximumSpan( clockwiseLoop ) > 2.5 * importRadius: if getOverlapRatio( clockwiseLoop, pointTable ) < 0.45: loops.append( clockwiseLoop ) addLoopToPointTable( clockwiseLoop, pointTable ) return getLoopsWithCorners( corners, importRadius, loops, pointTable )