예제 #1
0
 def test_intersecting_segbelt_and_dseg(self):
     sb = SegmentedBelt()
     SOL.add(sb.corner(0) == Point2D(0, 0))
     SOL.add(sb.corner(1) == Point2D(10, 0))
     SOL.add(sb.sink() == Point2D(20, 0))
     SOL.add(sb.num_segs >= 2)
     ds = Segment(Point2D(), Point2D(), is_diag=True)
     SOL.add(ds.p1 == Point2D(12, 0))
     SOL.add(ds.p2 == Point2D(15, 3))
     SOL.add(non_intersecting_seg_belt_diag_seg(sb, ds))
     d = None
     for d in SOL.shrinker_loop(sb.num_segs):
         pass
     self.assertEqual(4, d)
예제 #2
0
    def test_seg_belt_enumerate(self):
        sb = SegmentedBelt()
        SOL.add(sb.source() == (0,0))
        SOL.add(sb.sink() == (5,5))
        SOL.add(sb.num_segs < 5)
        ln = sb.len(5)

        for d in SOL.shrinker_loop(ln):
            pass

        self.assertEqual(11, d)

        p0 = None
        for p in sb.enumerate_points():
            if p0:
                dx = p.x - p0.x
                dy = p.y - p0.y
                self.assertTrue(dx == 0 and dy == 1 or dx == 1 and dy == 0)
            p0 = p