Exemplo n.º 1
0
 def test_precision(self):
     pface = Polyface(precision=3)
     pface.add_vertex( (1.0001, 1.0, 1.0) )
     pface.add_vertex( (1.0002, 1.0, 1.0) )
     self.assertEqual(len(pface.vertices), 1)
     pface.add_vertex( (1.001, 1.0, 1.0) )
     self.assertEqual(len(pface.vertices), 2)
Exemplo n.º 2
0
 def test_precision(self):
     pface = Polyface(precision=3)
     pface.add_vertex((1.0001, 1.0, 1.0))
     pface.add_vertex((1.0002, 1.0, 1.0))
     self.assertEqual(len(pface.vertices), 1)
     pface.add_vertex((1.001, 1.0, 1.0))
     self.assertEqual(len(pface.vertices), 2)
Exemplo n.º 3
0
    def test_cube_of_polyfaces(self):
        pface = Polyface()
        # cube corner points
        p1 = pface.add_vertex( (0,0,0) )
        p2 = pface.add_vertex( (0,0,1) )
        p3 = pface.add_vertex( (0,1,0) )
        p4 = pface.add_vertex( (0,1,1) )
        p5 = pface.add_vertex( (1,0,0) )
        p6 = pface.add_vertex( (1,0,1) )
        p7 = pface.add_vertex( (1,1,0) )
        p8 = pface.add_vertex( (1,1,1) )

        # define the 6 cube faces
        # look into -x direction
        pface.add_face_by_indices([p1, p5, p7, p3]) # base
        pface.add_face_by_indices([p1, p5, p6, p2]) # left
        pface.add_face_by_indices([p5, p7, p8, p6]) # front
        pface.add_face_by_indices([p7, p8, p4, p3]) # right
        pface.add_face_by_indices([p1, p3, p4, p2]) # back
        pface.add_face_by_indices([p2, p6, p8, p4]) # top

        vt = "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n1.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n1.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n1.0\n 30\n1.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n0.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n0.0\n 30\n1.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n1.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n1.0\n 30\n1.0\n 70\n192\n"

        vtf_prefix = "  0\nVERTEX\n 62\n0\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n0.0\n 70\n128\n"
        vtf =  vtf_prefix + " 71\n1\n 72\n5\n 73\n7\n 74\n3\n" + \
               vtf_prefix + " 71\n1\n 72\n5\n 73\n6\n 74\n2\n" + \
               vtf_prefix + " 71\n5\n 72\n7\n 73\n8\n 74\n6\n" + \
               vtf_prefix + " 71\n7\n 72\n8\n 73\n4\n 74\n3\n" + \
               vtf_prefix + " 71\n1\n 72\n3\n 73\n4\n 74\n2\n" + \
               vtf_prefix + " 71\n2\n 72\n6\n 73\n8\n 74\n4\n"

        expected = "  0\nPOLYLINE\n  8\n0\n 66\n1\n" \
                   " 70\n64\n 71\n8\n 72\n6\n" + vt + vtf + "  0\nSEQEND\n"
        self.assertEqual(dxfstr(pface), expected)
Exemplo n.º 4
0
    def test_cube_of_polyfaces(self):
        pface = Polyface()
        # cube corner points
        p1 = pface.add_vertex((0, 0, 0))
        p2 = pface.add_vertex((0, 0, 1))
        p3 = pface.add_vertex((0, 1, 0))
        p4 = pface.add_vertex((0, 1, 1))
        p5 = pface.add_vertex((1, 0, 0))
        p6 = pface.add_vertex((1, 0, 1))
        p7 = pface.add_vertex((1, 1, 0))
        p8 = pface.add_vertex((1, 1, 1))

        # define the 6 cube faces
        # look into -x direction
        pface.add_face_by_indices([p1, p5, p7, p3])  # base
        pface.add_face_by_indices([p1, p5, p6, p2])  # left
        pface.add_face_by_indices([p5, p7, p8, p6])  # front
        pface.add_face_by_indices([p7, p8, p4, p3])  # right
        pface.add_face_by_indices([p1, p3, p4, p2])  # back
        pface.add_face_by_indices([p2, p6, p8, p4])  # top

        vt = "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n1.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n1.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n0.0\n 20\n1.0\n 30\n1.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n0.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n0.0\n 30\n1.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n1.0\n 30\n0.0\n 70\n192\n" + \
             "  0\nVERTEX\n  8\n0\n 10\n1.0\n 20\n1.0\n 30\n1.0\n 70\n192\n"

        vtf_prefix = "  0\nVERTEX\n 62\n0\n  8\n0\n 10\n0.0\n 20\n0.0\n 30\n0.0\n 70\n128\n"
        vtf =  vtf_prefix + " 71\n1\n 72\n5\n 73\n7\n 74\n3\n" + \
               vtf_prefix + " 71\n1\n 72\n5\n 73\n6\n 74\n2\n" + \
               vtf_prefix + " 71\n5\n 72\n7\n 73\n8\n 74\n6\n" + \
               vtf_prefix + " 71\n7\n 72\n8\n 73\n4\n 74\n3\n" + \
               vtf_prefix + " 71\n1\n 72\n3\n 73\n4\n 74\n2\n" + \
               vtf_prefix + " 71\n2\n 72\n6\n 73\n8\n 74\n4\n"

        expected = "  0\nPOLYLINE\n  8\n0\n 66\n1\n" \
                   " 70\n64\n 71\n8\n 72\n6\n" + vt + vtf + "  0\nSEQEND\n"
        self.assertEqual(dxfstr(pface), expected)