コード例 #1
0
    def test_x3d(self):

        f = open(data_path("ref/073985f1c3e2f26c5be4a01073de42d3"), "r")
        as_json = f.read()
        f.close()

        blockmodel = BlockModel.from_json(as_json)
        x3d = blockmodel.x3d

        f = open(data_path("made/x3d_ref.x3d"), "w")
        f.write(x3d)
        f.close()

        f = open(data_path("ref/x3d_ref.x3d"), "r")
        refx3d = f.read()
        f.close()

        self.maxDiff = None
        # self.assertMultiLineEqual(refx3d, x3d)

        f = open(data_path("ref/x3d-3.2.xsd"), "rb")
        xmlschema_doc = etree.parse(f)
        f.close()
        xmlschema = etree.XMLSchema(xmlschema_doc)

        f = open(data_path("made/x3d_ref.x3d"), "r")
        x3dxml = etree.parse(f)
        f.close()
        xmlschema.validate(x3dxml)
コード例 #2
0
    def test_collada(self):

        f = open(data_path("ref/073985f1c3e2f26c5be4a01073de42d3"), "r")
        as_json = f.read()
        f.close()

        blockmodel = BlockModel.from_json(as_json)
        col = blockmodel.collada

        f = open(data_path("made/col_ref.dae"), "w")
        f.write(col)
        f.close()

        f = open(data_path("ref/col_ref.dae"), "r")
        refcol = f.read()
        f.close()

        self.maxDiff = None
        # self.assertMultiLineEqual(refcol, col)

        f = open(data_path("ref/collada_schema_1_4_1.xsd"), "rb")
        col_str = f.read()
        xmlschema_doc = etree.fromstring(col_str)
        f.close()
        xmlschema = etree.XMLSchema(xmlschema_doc)

        f = open(data_path("made/col_ref.dae"), "r")
        colxml = etree.parse(f)
        f.close()
        xmlschema.validate(colxml)
コード例 #3
0
    def test_x3d(self):

        f = open(data_path("ref/073985f1c3e2f26c5be4a01073de42d3"), "r")
        as_json = f.read()
        f.close()

        blockmodel = BlockModel.from_json(as_json)
        x3d = blockmodel.x3d

        f = open(data_path("made/x3d_ref.x3d"), "w")
        f.write(x3d)
        f.close()

        f = open(data_path("ref/x3d_ref.x3d"), "r")
        refx3d = f.read()
        f.close()

        self.maxDiff = None
        # self.assertMultiLineEqual(refx3d, x3d)

        f = open(data_path("ref/x3d-3.2.xsd"), "rb")
        xmlschema_doc = etree.parse(f)
        f.close()
        xmlschema = etree.XMLSchema(xmlschema_doc)

        f = open(data_path("made/x3d_ref.x3d"), "r")
        x3dxml = etree.parse(f)
        f.close()
        xmlschema.validate(x3dxml)
コード例 #4
0
    def test_collada(self):

        f = open(data_path("ref/073985f1c3e2f26c5be4a01073de42d3"), "r")
        as_json = f.read()
        f.close()

        blockmodel = BlockModel.from_json(as_json)
        col = blockmodel.collada

        f = open(data_path("made/col_ref.dae"), "w")
        f.write(col)
        f.close()

        f = open(data_path("ref/col_ref.dae"), "r")
        refcol = f.read()
        f.close()

        self.maxDiff = None
        # self.assertMultiLineEqual(refcol, col)

        f = open(data_path("ref/collada_schema_1_4_1.xsd"), "rb")
        col_str = f.read()
        xmlschema_doc = etree.fromstring(col_str)
        f.close()
        xmlschema = etree.XMLSchema(xmlschema_doc)

        f = open(data_path("made/col_ref.dae"), "r")
        colxml = etree.parse(f)
        f.close()
        xmlschema.validate(colxml)
コード例 #5
0
    def test_save_collada_from_json(self):
        earth_json ="""[
            [[[3,0],[3,0],[3,0]],[[3,0],[3,0],[3,0]],[[2,0],[2,0],[2,0]]],
            [[[3,0],[3,0],[3,0]],[[0,0],[56,0],[3,0]],[[2,0],[2,0],[2,0]]],
            [[[3,0],[3,0],[3,0]],[[0,0],[0,0],[3,0]],[[2,0],[2,0],[2,0]]]
            ]
            """

        model = BlockModel.from_json(earth_json)
        made_file_path = data_path("made/earth.dae")
        model.save_as_collada(made_file_path)
        self.assertTrue(os.path.exists(data_path("made/earth_dae/earth.dae")))
コード例 #6
0
    def test_save_collada_from_json(self):
        earth_json = """[
            [[[3,0],[3,0],[3,0]],[[3,0],[3,0],[3,0]],[[2,0],[2,0],[2,0]]],
            [[[3,0],[3,0],[3,0]],[[0,0],[56,0],[3,0]],[[2,0],[2,0],[2,0]]],
            [[[3,0],[3,0],[3,0]],[[0,0],[0,0],[3,0]],[[2,0],[2,0],[2,0]]]
            ]
            """

        model = BlockModel.from_json(earth_json)
        made_file_path = data_path("made/earth.dae")
        model.save_as_collada(made_file_path)
        self.assertTrue(os.path.exists(data_path("made/earth_dae/earth.dae")))
コード例 #7
0
    def test_stl(self):
      
        f = open(data_path("ref/073985f1c3e2f26c5be4a01073de42d3"), "r")
        as_json = f.read()
        f.close()
        
        blockmodel = BlockModel.from_json(as_json)

        stl = blockmodel.stl
        
        f = open(data_path("made/stl_ref.stl"), "wb")
        f.write(stl)
        f.close()
        
        f = open(data_path("ref/stl_ref.stl"), "rb")
        refstl = f.read()
        f.close()

        self.maxDiff = None
        self.assertEqual(refstl, stl)
コード例 #8
0
    def test_stl(self):

        f = open(data_path("ref/073985f1c3e2f26c5be4a01073de42d3"), "r")
        as_json = f.read()
        f.close()

        blockmodel = BlockModel.from_json(as_json)

        stl = blockmodel.stl

        f = open(data_path("made/stl_ref.stl"), "wb")
        f.write(stl)
        f.close()

        f = open(data_path("ref/stl_ref.stl"), "rb")
        refstl = f.read()
        f.close()

        self.maxDiff = None
        self.assertEqual(refstl, stl)