Exemplo n.º 1
0
    def test_construction(self):
        polyline = Polyline(name="test line")

        with self.assertRaises(IndexError):
            polyline.isClosed()

        self.assertEqual(polyline.getName(), "test line")

        self.assertEqual(len(polyline), 0)

        polyline.addPoint(0, 0, 0)
        self.assertEqual(len(polyline), 1)

        polyline.addPoint(1, 1, 0)
        self.assertEqual(len(polyline), 2)

        polyline.addPoint(1, 1.5)
        self.assertEqual(len(polyline), 3)

        self.assertEqual(polyline[0], (0, 0, 0))
        self.assertEqual(polyline[1], (1, 1, 0))
        self.assertEqual(polyline[2], (1, 1.5))

        polyline.addPoint(0, 1, 0)
        self.assertFalse(polyline.isClosed())

        polyline.addPoint(0, 0, 0)
        self.assertTrue(polyline.isClosed())
Exemplo n.º 2
0
    def test_construction(self):
        polyline = Polyline(name="test line")

        with self.assertRaises(IndexError):
            polyline.isClosed()

        self.assertEqual(polyline.getName(), "test line")

        self.assertEqual(len(polyline), 0)

        polyline.addPoint(0, 0, 0)
        self.assertEqual(len(polyline), 1)

        polyline.addPoint(1, 1, 0)
        self.assertEqual(len(polyline), 2)

        polyline.addPoint(1, 1.5)
        self.assertEqual(len(polyline), 3)

        self.assertEqual(polyline[0], (0, 0, 0))
        self.assertEqual(polyline[1], (1, 1, 0))
        self.assertEqual(polyline[2], (1, 1.5))

        polyline.addPoint(0, 1, 0)
        self.assertFalse(polyline.isClosed())

        polyline.addPoint(0, 0, 0)
        self.assertTrue(polyline.isClosed())
Exemplo n.º 3
0
    def get_edge_polygon(self):
        x_list = DoubleVector()
        y_list = DoubleVector()
        cell_list = IntVector()

        self._trace_edge(x_list, y_list, cell_list)
        p = Polyline()
        for (x, y) in zip(x_list, y_list):
            p.addPoint(x, y)
        return p
Exemplo n.º 4
0
    def get_edge_polygon(self):
        x_list = DoubleVector()
        y_list = DoubleVector()
        cell_list = IntVector()

        self._trace_edge(x_list, y_list, cell_list)
        p = Polyline()
        for (x,y) in zip(x_list, y_list):
            p.addPoint(x,y)
        return p
Exemplo n.º 5
0
    def test_iteration(self):
        values = [(0, 0, 0), (1, 0, 0), (1, 1, 0), (1, 1, 1)]

        polyline = Polyline(name="iteration line")

        for p in values:
            polyline.addPoint(*p)

        for index, point in enumerate(polyline):
            self.assertEqual(point, values[index])
Exemplo n.º 6
0
    def test_closed(self):
        pl = Polyline(init_points=[(1, 0), (1, 1), (0, 2)])
        self.assertFalse(pl.isClosed())
        pl.addPoint(1, 0)
        self.assertEqual(4, len(pl))
        self.assertTrue(pl.isClosed())

        pl = Polyline(init_points=[(1, 0), (1, 1), (0, 2)])
        self.assertFalse(pl.isClosed())
        pl.assertClosed()
        self.assertEqual(4, len(pl))
        self.assertTrue(pl.isClosed())
Exemplo n.º 7
0
    def test_closed(self):
        pl = Polyline( init_points = [(1,0) , (1,1) , (0,2)])
        self.assertFalse( pl.isClosed() )
        pl.addPoint( 1,0 )
        self.assertEqual( 4 , len(pl) ) 
        self.assertTrue( pl.isClosed() )

        pl = Polyline( init_points = [(1,0) , (1,1) , (0,2)])
        self.assertFalse( pl.isClosed() )
        pl.assertClosed( )
        self.assertEqual( 4 , len(pl) ) 
        self.assertTrue( pl.isClosed() )
Exemplo n.º 8
0
    def test_iteration(self):
        values = [(0, 0, 0),
                  (1, 0, 0),
                  (1, 1, 0),
                  (1, 1, 1)]

        polyline = Polyline(name="iteration line")

        for p in values:
            polyline.addPoint(*p)

        for index, point in enumerate(polyline):
            self.assertEqual(point, values[index])