def test_slicing_internal_hull(self): polygon = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4)] edge = [(0,0) , (10,0) , (10,10), (0,10) , (0,0)] sliced = GeometryTools.slicePolygon(edge , polygon) expected = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4),(2.0,4.0),(2,2)] self.assertEqual(sliced, expected)
def test_slicing_internal_hull(self): polygon = [(2, 2), (2, 1), (1, 1), (1, 5), (5, 5), (5, 4), (4, 4)] edge = [(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)] sliced = GeometryTools.slicePolygon(edge, polygon) expected = [(2, 2), (2, 1), (1, 1), (1, 5), (5, 5), (5, 4), (4, 4), (2.0, 4.0), (2, 2)] self.assertEqual(sliced, expected)
def test_slicing_bendy_line_segments(self): p0 = (0.0, 0.0) p1 = (0.0, 1.0) p2 = (1.0, 1.0) p3 = (1.0, 0.0) polygon = [p0, p1, p2, p3, p0] lp0 = (0.2, 0.5) lp1 = (0.4, 0.5) lp2 = (0.4, 0.3) line = [lp0, lp1, lp2] expected = [(0.0, 0.5), p1, p2, p3, (0.4, 0.0), lp2, lp1, lp0, (0.0, 0.5)] result = GeometryTools.slicePolygon(polygon, line) self.assertEqual(result, expected) line = [lp2, lp1, lp0] result = GeometryTools.slicePolygon(polygon, line) self.assertEqual(result, expected)
def test_slicing_same_segment(self): p0 = (0.0, 0.0) p1 = (0.0, 1.0) p2 = (1.0, 1.0) p3 = (1.0, 0.0) polygon = [p0, p1, p2, p3, p0] lp0 = (0.2, 0.5) lp1 = (0.4, 0.5) lp2 = (0.4, 0.3) lp3 = (0.2, 0.3) line = [lp0, lp1, lp2, lp3] result = GeometryTools.slicePolygon(polygon, line) expected = [(0.0, 0.5), (0.0, 0.3), lp3, lp2, lp1, lp0, (0.0, 0.5)] self.assertEqual(result, expected) line = [lp3, lp2, lp1, lp0] result = GeometryTools.slicePolygon(polygon, line) expected = [(0.0, 0.3), (0.0, 0.5), lp0, lp1, lp2, lp3, (0.0, 0.3)] self.assertEqual(result, expected)