def test_export_to_x3d_TriangleSet(self):
     """ 3rd test : export a sphere to an X3D TriangleSet triangle mesh """
     a_sphere = BRepPrimAPI_MakeBox(10., 10., 10.).Shape()
     sphere_tess = ShapeTesselator(a_sphere)
     sphere_tess.Compute()
     sphere_triangle_set_string = sphere_tess.ExportShapeToX3DTriangleSet()
     self.assertTrue(sphere_triangle_set_string.startswith("<TriangleSet"))
     self.assertTrue("0 10 0" in sphere_triangle_set_string)  # a vertex
     self.assertTrue("0 0 1" in sphere_triangle_set_string)  # a normal
예제 #2
0
 def compute(self):
     shape_tesselator = ShapeTesselator(self._shape)
     shape_tesselator.Compute(compute_edges=self._export_edges,
                              mesh_quality=self._mesh_quality,
                              parallel=True)
     self._triangle_sets.append(
         shape_tesselator.ExportShapeToX3DTriangleSet())
     # then process edges
     if self._export_edges:
         # get number of edges
         nbr_edges = shape_tesselator.ObjGetEdgeCount()
         for i_edge in range(nbr_edges):
             edge_point_set = []
             nbr_vertices = shape_tesselator.ObjEdgeGetVertexCount(i_edge)
             for i_vert in range(nbr_vertices):
                 edge_point_set.append(
                     shape_tesselator.GetEdgeVertex(i_edge, i_vert))
             ils = export_edge_to_indexed_lineset(edge_point_set)
             self._line_sets.append(ils)