Esempio n. 1
0
def test_SimpleWithConvex_non_intersecting():
    for i in range(10000):

        # Generate nonintersecting polygons
        subject, target = generate_non_intersecting()

        # Do the clipping
        result = clip.simple_with_convex(flex.vec2_double(subject),
                                         flex.vec2_double(target))

        # Ensure we no vertices
        assert len(result) == 0
Esempio n. 2
0
def test_SimpleWithConvex_intersecting():
    for i in range(10000):

        # Generate intersecting polygons
        subject, target = generate_intersecting()

        # Do the clipping
        result = clip.simple_with_convex(flex.vec2_double(subject),
                                         flex.vec2_double(target))

        # Ensure we have roughly valid number of vertices
        assert len(result) >= 3
        assert len(result) >= min([len(subject), len(target)])
Esempio n. 3
0
    def test_non_intersecting(self):
        from dials.algorithms.polygon import clip
        from scitbx.array_family import flex

        for i in range(10000):

            # Generate nonintersecting polygons
            subject, target = generate_non_intersecting()

            # Do the clipping
            result = clip.simple_with_convex(flex.vec2_double(subject),
                                             flex.vec2_double(target))

            # Ensure we no vertices
            assert (len(result) == 0)
Esempio n. 4
0
    def test_intersecting(self):
        from dials.algorithms.polygon import clip
        from scitbx.array_family import flex
        for i in range(10000):

            # Generate intersecting polygons
            subject, target = generate_intersecting()

            # Do the clipping
            result = clip.simple_with_convex(flex.vec2_double(subject),
                                             flex.vec2_double(target))

            # Ensure we have roughly valid number of vertices
            assert (len(result) >= 3)
            assert (len(result) >= min([len(subject), len(target)]))
Esempio n. 5
0
  def tst_non_intersecting(self):
    from dials.algorithms.polygon import clip
    from scitbx.array_family import flex

    for i in range(10000):

      # Generate nonintersecting polygons
      subject, target = generate_non_intersecting()

      # Do the clipping
      result = clip.simple_with_convex(
          flex.vec2_double(subject),
          flex.vec2_double(target))

      # Ensure we no vertices
      assert(len(result) == 0)

    print 'OK'
Esempio n. 6
0
  def tst_intersecting(self):
    from dials.algorithms.polygon import clip
    from scitbx.array_family import flex
    for i in range(10000):

      # Generate intersecting polygons
      subject, target = generate_intersecting()

      # Do the clipping
      result = clip.simple_with_convex(
          flex.vec2_double(subject),
          flex.vec2_double(target))

      # Ensure we have roughly valid number of vertices
      assert(len(result) >= 3)
      assert(len(result) >= min([len(subject), len(target)]))

#            for v in result:
#                assert(point_in_polygon(v, clip))

    print 'OK'
Esempio n. 7
0

from dials.algorithms.polygon import clip
from scitbx.array_family import flex
from time import time

bx = (aabb[0][0], aabb[1][0], aabb[1][0], aabb[0][0])
by = (aabb[0][1], aabb[0][1], aabb[1][1], aabb[1][1])
convex = zip(bx, by)
poly1 = flex.vec2_double(quad)
poly2 = flex.vec2_double(convex)
rect = aabb

st = time()
for i in range(10000):
    result1 = clip.simple_with_convex(poly1, poly2)
print(time() - st)

st = time()
for i in range(10000):
    #    result2 = sutherland_hodgman(quad, aabb)
    result2 = clip.simple_with_rect(poly1, rect)
print(time() - st)

print(list(result1))
print(list(result2))

# poly = sutherland_hodgman(quad, aabb)
# print poly
# display(poly, quad, aabb)
Esempio n. 8
0

from dials.algorithms.polygon import clip
from scitbx.array_family import flex
from time import time

bx = (aabb[0][0], aabb[1][0], aabb[1][0], aabb[0][0])
by = (aabb[0][1], aabb[0][1], aabb[1][1], aabb[1][1])
convex = zip(bx, by)
poly1 = flex.vec2_double(quad)
poly2 = flex.vec2_double(convex)
rect = aabb

st = time()
for i in range(10000):
  result1 = clip.simple_with_convex(poly1, poly2)
print time() - st

st = time()
for i in range(10000):
#    result2 = sutherland_hodgman(quad, aabb)
  result2 = clip.simple_with_rect(poly1, rect)
print time() - st

print list(result1)
print list(result2)

#poly = sutherland_hodgman(quad, aabb)
#print poly
#display(poly, quad, aabb)