Esempio n. 1
0
def trouve_inclusions_diviser(polygones):
    results = [-1] * len(polygones)
    rectangle = Quadrant.empty_quadrant(2)
    for polygone in polygones:
        rectangle.update(polygone.bounding_quadrant())
    trouve_inclusions_rec(polygones, results, rectangle)
    return results
Esempio n. 2
0
 def bounding_quadrant(self):
     """
     return min quadrant containing self.
     """
     quadrant = Quadrant.empty_quadrant(2)
     for point in self.endpoints:
         quadrant.add_point(point)
     return quadrant
Esempio n. 3
0
 def bounding_quadrant(self):
     """
     return min quadrant containing underlying objects.
     """
     quadrant = Quadrant.empty_quadrant(2)
     for point in self.vertices:
         quadrant.add_point(point)
     return quadrant
Esempio n. 4
0
 def bounding_quadrant(self):
     """
     min quadrant containing polygon.
     """
     box = Quadrant.empty_quadrant(2)
     for point in self.points:
         box.add_point(point)
     return box
def main():
    q = Quadrant((50, 50), (100, 100))
    c = q.empty_quadrant(2)
    print(c.max_coordinates, c.min_coordinates)
    # q.add_point(Point([20, 60]))
    # print(q.min_coordinates, q.max_coordinates)
    # q.update(Quadrant((60,60),(180,180)))
    # print(q.min_coordinates, q.max_coordinates)
    # l = q.limits(0)
    # print(l)
    # print(q.get_arrays())
    q.inflate(10)
    print(q.max_coordinates, q.min_coordinates)
Esempio n. 6
0
def compute_displays(things):
    """
    compute bounding quadrant and svg strings for all things to display.
    """
    quadrant = Quadrant.empty_quadrant(2)
    strings = []
    for color, thing in zip(cycle(iter(Displayer.svg_colors)), things):
        strings.append('<g fill="{}" stroke="{}">\n'.format(color, color))
        inner_quadrant, inner_strings = compute_display(thing)
        quadrant.update(inner_quadrant)
        strings.extend(inner_strings)
        strings.append('</g>\n')

    return (quadrant, strings)
Esempio n. 7
0
def compute_display(thing):
    """
    return bounding quadrant and svg strings for one thing (and all it's content)
    """
    quadrant = Quadrant.empty_quadrant(2)
    strings = []
    try:
        iterator = iter(thing)
        for subthing in iterator:
            inner_quadrant, inner_strings = compute_display(subthing)
            strings.extend(inner_strings)
            quadrant.update(inner_quadrant)

    except TypeError:
        # we cannot iterate on it
        strings.append(thing.svg_content())
        quadrant.update(thing.bounding_quadrant())

    return quadrant, strings