-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest_remeshing.py
55 lines (48 loc) · 1.39 KB
/
test_remeshing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pytest
import trimesh
import numpy as np
import pynanoinstantmeshes as PyNIM
@pytest.fixture
def mesh():
# Just use a trimesh primitive (Capsule)
yield trimesh.primitives.Capsule(radius=1, height=2).to_mesh()
@pytest.mark.parametrize(
"rosy, posy, expected_vertex_dim",
[
(2, 4, 4),
(4, 4, 4),
],
)
@pytest.mark.parametrize("vertex_count", [100, 200])
@pytest.mark.parametrize("creaseAngle", [0.0, 10.0, 20.0])
@pytest.mark.parametrize("align_to_boundaries", [True, False])
@pytest.mark.parametrize("smooth_iter", [0, 2, 4])
class TestRemeshing:
def test_mesh_valid(
self,
mesh,
rosy,
posy,
expected_vertex_dim,
vertex_count,
creaseAngle,
align_to_boundaries,
smooth_iter,
):
vertices = np.asarray(mesh.vertices)
faces = np.asarray(mesh.faces)
new_verts, new_faces = PyNIM.remesh(
vertices,
faces,
vertex_count,
rosy=rosy,
posy=posy,
creaseAngle=creaseAngle,
align_to_boundaries=align_to_boundaries,
smooth_iter=smooth_iter,
)
assert new_verts.shape[-1] == 3
if new_verts.shape[0] - 1 != new_faces.max():
# Skip test as the meshing failed
pytest.skip("Meshing failed")
assert new_faces.shape[-1] == expected_vertex_dim