MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / test_cube_refine

Method test_cube_refine

python/pymesh/tests/test_tetgen.py:31–74  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

29 self.assertAlmostEqual(1.0, np.sum(volumes))
30
31 def test_cube_refine(self):
32 vertices = np.array([
33 [0.0, 0.0, 0.0],
34 [1.0, 0.0, 0.0],
35 [1.0, 1.0, 0.0],
36 [0.0, 1.0, 0.0],
37 [0.0, 0.0, 1.0],
38 [1.0, 0.0, 1.0],
39 [1.0, 1.0, 1.0],
40 [0.0, 1.0, 1.0] ])
41 # A cube can be splitted into 5 tets or 6 tets without adding steiner
42 # points. We start with 5 tets and see if tetgen can refine it to the 6
43 # tet configuration.
44 tets = np.array([
45 [0, 1, 2, 5],
46 [0, 2, 3, 7],
47 [4, 7, 5, 0],
48 [5, 7, 6, 2],
49 [0, 5, 2, 7]
50 ], dtype=int)
51 mesh = pymesh.form_mesh(vertices, np.array([]), tets)
52 mesh.add_attribute("voxel_volume")
53 volumes = mesh.get_attribute("voxel_volume")
54 self.assertAlmostEqual(1.0, np.sum(volumes))
55
56 tetgen = pymesh.tetgen()
57 tetgen.points = mesh.vertices
58 tetgen.triangles = mesh.faces
59 tetgen.tetrahedra = mesh.voxels
60 tetgen.max_tet_volume = 0.17
61 tetgen.max_num_steiner_points = 0
62 tetgen.split_boundary = False
63 tetgen.verbosity = 0
64 tetgen.run()
65
66 mesh = tetgen.mesh
67 mesh.add_attribute("voxel_volume")
68 volumes = mesh.get_attribute("voxel_volume")
69 self.assertAlmostEqual(1.0, np.sum(volumes))
70
71 # No tetgen cannot recover the 6 tet configuration...
72 # So tet_volume constaint is actually not satisfied by the result.
73 self.assertEqual(8, len(tetgen.vertices))
74 self.assertEqual(5, len(tetgen.voxels))
75
76 def test_volume_constraint(self):
77 tetgen = pymesh.tetgen()

Callers

nothing calls this directly

Calls 4

form_meshMethod · 0.45
add_attributeMethod · 0.45
get_attributeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected