def test_export_to_x3d(self): """3rd test : export a sphere to X3D file format""" a_sphere = BRepPrimAPI_MakeSphere(10.0).Shape() tess = ShapeTesselator(a_sphere) tess.Compute() tess.ExportShapeToX3D(os.path.join("test_io", "sphere.x3d")) self.assertTrue(os.path.exists(os.path.join("test_io", "sphere.x3d")))
def test_x3d_file_is_valid_xml(self): """use ElementTree to parse X3D output""" another_torus = BRepPrimAPI_MakeTorus(10, 4).Shape() torus_tess = ShapeTesselator(another_torus) torus_tess.Compute() output_x3d_filename = os.path.join("test_io", "torus.x3d") torus_tess.ExportShapeToX3D(output_x3d_filename) self.assertTrue(os.path.exists(output_x3d_filename)) with open(output_x3d_filename, "r") as x3d_file: x3d_content = x3d_file.read() ET.fromstring(x3d_content) # raise an exception if not valid xml