def test_SimpleWithRect_intersecting(): for i in range(10000): # Generate intersecting polygons subject, target = generate_intersecting(target_size=2) rect = ((0, 0), (10, 10)) # Do the clipping result = clip.simple_with_rect(flex.vec2_double(subject), rect) # Ensure we have roughly valid number of vertices assert len(result) >= 3 assert len(result) >= min([len(subject), 4])
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(target_size=2) rect = ((0, 0), (10, 10)) # Do the clipping result = clip.simple_with_rect(flex.vec2_double(subject), rect) # Ensure we have roughly valid number of vertices assert (len(result) >= 3) assert (len(result) >= min([len(subject), 4]))
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(target_size=2) rect = ((0, 0), (10, 10)) # Do the clipping result = clip.simple_with_rect( flex.vec2_double(subject), rect) # Ensure we have roughly valid number of vertices assert(len(result) >= 3) assert(len(result) >= min([len(subject), 4])) # for v in result: # assert(point_in_polygon(v, clip)) print 'OK'
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)
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)