|
| 1 | +from collections import namedtuple |
1 | 2 | from math import prod
|
2 | 3 | from pathlib import Path
|
3 | 4 | from unittest import skipUnless
|
@@ -184,8 +185,47 @@ def test_to_mask(self):
|
184 | 185 | assert np.array_equal(mask_img.affine, np.eye(4))
|
185 | 186 |
|
186 | 187 |
|
187 |
| -class TestTriangularMeshes(TestPointsets): |
188 |
| - ... |
| 188 | +class TestTriangularMeshes: |
| 189 | + def test_init(self): |
| 190 | + # Tetrahedron |
| 191 | + coords = np.array( |
| 192 | + [ |
| 193 | + [0.0, 0.0, 0.0], |
| 194 | + [0.0, 0.0, 1.0], |
| 195 | + [0.0, 1.0, 0.0], |
| 196 | + [1.0, 0.0, 0.0], |
| 197 | + ] |
| 198 | + ) |
| 199 | + triangles = np.array( |
| 200 | + [ |
| 201 | + [0, 2, 1], |
| 202 | + [0, 3, 2], |
| 203 | + [0, 1, 3], |
| 204 | + [1, 2, 3], |
| 205 | + ] |
| 206 | + ) |
| 207 | + |
| 208 | + mesh = namedtuple('mesh', ('coordinates', 'triangles'))(coords, triangles) |
| 209 | + |
| 210 | + tm1 = ps.TriangularMesh(coords, triangles) |
| 211 | + tm2 = ps.TriangularMesh.from_tuple(mesh) |
| 212 | + tm3 = ps.TriangularMesh.from_object(mesh) |
| 213 | + |
| 214 | + assert np.allclose(tm1.affine, np.eye(4)) |
| 215 | + assert np.allclose(tm2.affine, np.eye(4)) |
| 216 | + assert np.allclose(tm3.affine, np.eye(4)) |
| 217 | + |
| 218 | + assert tm1.homogeneous is False |
| 219 | + assert tm2.homogeneous is False |
| 220 | + assert tm3.homogeneous is False |
| 221 | + |
| 222 | + assert (tm1.n_coords, tm1.dim) == (4, 3) |
| 223 | + assert (tm2.n_coords, tm2.dim) == (4, 3) |
| 224 | + assert (tm3.n_coords, tm3.dim) == (4, 3) |
| 225 | + |
| 226 | + assert tm1.n_triangles == 4 |
| 227 | + assert tm2.n_triangles == 4 |
| 228 | + assert tm3.n_triangles == 4 |
189 | 229 |
|
190 | 230 |
|
191 | 231 | class H5ArrayProxy:
|
|
0 commit comments