예제 #1
0
    def test_flateSegmentLeft(self):
        '''
        A curve with center c.

        X    c
        X
        X
         x
          XXX
        '''
        segment = TFSSilhouette._flateSegmentLeft(
            TFSSegment(TFSPoint(0, 3), TFSPoint(0, 2), TFSPoint(2, 0),
                       TFSPoint(3, 0)), 0.5)
        self.assertIsNotNone(segment)
        self.assertEqual(len(segment), 4)
        segment = TFSSilhouette._flateSegmentLeft(
            TFSSegment(TFSPoint(0, 3), TFSPoint(0, 2), TFSPoint(2, 0),
                       TFSPoint(3, 0)), 2.5)
        self.assertIsNotNone(segment)
        self.assertEqual(len(segment), 4)

        segment = TFSSilhouette._flateSegmentLeft(
            TFSSegment(TFSPoint(0, 3), TFSPoint(0, 2), TFSPoint(2, 0),
                       TFSPoint(3, 0)), 3)
        self.assertIsNone(segment)

        segment = TFSSilhouette._flateSegmentLeft(
            TFSSegment(TFSPoint(0, 3), TFSPoint(0, 2), TFSPoint(2, 0),
                       TFSPoint(3, 0)), 3.5)
        self.assertIsNone(segment)
예제 #2
0
    def test_flateSegmentLeft(self):
        '''
        A curve with center c.

        X    c
        X
        X
         x
          XXX
        '''
        segment = TFSSilhouette._flateSegmentLeft(TFSSegment(TFSPoint(0, 3),
                                                             TFSPoint(0, 2),
                                                             TFSPoint(2, 0),
                                                             TFSPoint(3, 0)), 0.5)
        self.assertIsNotNone(segment)
        self.assertEqual(len(segment), 4)
        segment = TFSSilhouette._flateSegmentLeft(TFSSegment(TFSPoint(0, 3),
                                                             TFSPoint(0, 2),
                                                             TFSPoint(2, 0),
                                                             TFSPoint(3, 0)), 2.5)
        self.assertIsNotNone(segment)
        self.assertEqual(len(segment), 4)

        segment = TFSSilhouette._flateSegmentLeft(TFSSegment(TFSPoint(0, 3),
                                                             TFSPoint(0, 2),
                                                             TFSPoint(2, 0),
                                                             TFSPoint(3, 0)), 3)
        self.assertIsNone(segment)

        segment = TFSSilhouette._flateSegmentLeft(TFSSegment(TFSPoint(0, 3),
                                                             TFSPoint(0, 2),
                                                             TFSPoint(2, 0),
                                                             TFSPoint(3, 0)), 3.5)
        self.assertIsNone(segment)
예제 #3
0
    def test_inflatePaths_inflateDeflateSquare(self):
        '''
        XXXX (clockwise)
        X  X
        X  X
        XXXX
        '''
        paths = TFSSilhouette.inflatePaths((polygonWithPoints(
            TFSPoint(0, 0), TFSPoint(0, 3), TFSPoint(3, 3), TFSPoint(3, 0)), ),
                                           1)
        self.assertIsNotNone(paths)
        self.assertEqual(len(paths), 1)
        path = paths[0]
        self.assertEqual(len(path), 8)
        #        debugPath('inflateDeflateSquare.1', path)

        paths = TFSSilhouette.deflatePaths(paths, 1)
        self.assertIsNotNone(paths)
        self.assertEqual(len(paths), 1)
        path = paths[0]
        #        debugPath('inflateDeflateSquare.2', path)
        self.assertEqual(len(path), 4)
예제 #4
0
 def test_flatePathLeft_deflateSquare(self):
     '''
     XXXX (counter-clockwise)
     X  X
     X  X
     XXXX
     '''
     paths = TFSSilhouette._flatePathLeft(
         polygonWithPoints(TFSPoint(0, 0), TFSPoint(0, 3), TFSPoint(3, 3),
                           TFSPoint(3, 0)).reverse(), 1)
     self.assertIsNotNone(paths)
     self.assertEqual(len(paths), 1)
     path = paths[0]
     self.assertEqual(len(path), 4)
예제 #5
0
    def test_inflatePaths_inflateDeflateSquare(self):
        '''
        XXXX (clockwise)
        X  X
        X  X
        XXXX
        '''
        paths = TFSSilhouette.inflatePaths( ( polygonWithPoints(TFSPoint(0, 0),
                                                                TFSPoint(0, 3),
                                                                TFSPoint(3, 3),
                                                                TFSPoint(3, 0)),
                                             ), 1)
        self.assertIsNotNone(paths)
        self.assertEqual(len(paths), 1)
        path = paths[0]
        self.assertEqual(len(path), 8)
#        debugPath('inflateDeflateSquare.1', path)

        paths = TFSSilhouette.deflatePaths(paths, 1)
        self.assertIsNotNone(paths)
        self.assertEqual(len(paths), 1)
        path = paths[0]
#        debugPath('inflateDeflateSquare.2', path)
        self.assertEqual(len(path), 4)
예제 #6
0
 def test_flatePathLeft_deflateSquare(self):
     '''
     XXXX (counter-clockwise)
     X  X
     X  X
     XXXX
     '''
     paths = TFSSilhouette._flatePathLeft(polygonWithPoints(TFSPoint(0, 0),
                                                            TFSPoint(0, 3),
                                                            TFSPoint(3, 3),
                                                            TFSPoint(3, 0)).reverse(), 1)
     self.assertIsNotNone(paths)
     self.assertEqual(len(paths), 1)
     path = paths[0]
     self.assertEqual(len(path), 4)
예제 #7
0
    def test_inflatePaths_inflateOverlappingSquares(self):
        '''
        (clockwise)

             XXXX
             X  X
        XXXX X  X
        X  X XXXX
        X  X
        XXXX
        '''
        paths = TFSSilhouette.inflatePaths((
            polygonWithPoints(TFSPoint(0, 0), TFSPoint(0, 3), TFSPoint(3, 3),
                              TFSPoint(3, 0)),
            polygonWithPoints(TFSPoint(4, 2), TFSPoint(4, 5), TFSPoint(7, 5),
                              TFSPoint(7, 2)),
        ), 1)
        self.assertIsNotNone(paths)
        self.assertEqual(len(paths), 1)
        path = paths[0]
        self.assertEqual(len(path), 14)
예제 #8
0
    def test_inflatePaths_inflateOverlappingSquares(self):
        '''
        (clockwise)

             XXXX
             X  X
        XXXX X  X
        X  X XXXX
        X  X
        XXXX
        '''
        paths = TFSSilhouette.inflatePaths( ( polygonWithPoints(TFSPoint(0, 0),
                                                              TFSPoint(0, 3),
                                                              TFSPoint(3, 3),
                                                              TFSPoint(3, 0)),
                                              polygonWithPoints(TFSPoint(4, 2),
                                                              TFSPoint(4, 5),
                                                              TFSPoint(7, 5),
                                                              TFSPoint(7, 2)),
                                             ), 1)
        self.assertIsNotNone(paths)
        self.assertEqual(len(paths), 1)
        path = paths[0]
        self.assertEqual(len(path), 14)