diff --git a/tests/test_gifti.py b/tests/test_gifti.py index ba758a5057952452eaf27d2651869a657c621805..ff6a9b1a3e51c96a48cd971fbe46f68d6f0e90b9 100644 --- a/tests/test_gifti.py +++ b/tests/test_gifti.py @@ -299,3 +299,23 @@ def test_GiftiMesh_multiple_vertices(): surf.vertices = expvsets[1] assert np.all(surf.vertices == TEST_VERTS * 5) + + +def test_GiftiMesh_needsFixing(): + from . import test_mesh + + verts = test_mesh.CUBE_VERTICES + idxs = test_mesh.CUBE_TRIANGLES_CW + idxs_fixed = test_mesh.CUBE_TRIANGLES_CCW + + verts = nib.gifti.GiftiDataArray(verts, intent='NIFTI_INTENT_POINTSET') + idxs = nib.gifti.GiftiDataArray(idxs, intent='NIFTI_INTENT_TRIANGLE') + gimg = nib.gifti.GiftiImage(darrays=[verts, idxs]) + + with tempdir(): + fname = op.abspath('test.gii') + gimg.to_filename(fname) + + surf = gifti.GiftiMesh(fname, fixWinding=True) + + assert np.all(np.isclose(surf.indices, idxs_fixed)) diff --git a/tests/test_mesh.py b/tests/test_mesh.py index 97f2c9b2f3eb63b02a2c06fec81c508e53f5e713..8b97bfa1c180cd301af462a2f067aff02c04e4b1 100644 --- a/tests/test_mesh.py +++ b/tests/test_mesh.py @@ -248,9 +248,11 @@ def test_needsFixing(): fnormals = np.array(CUBE_CCW_VERTEX_NORMALS) blo = verts.min(axis=0) bhi = verts.max(axis=0) + mesh = fslmesh.Mesh(tris_cw, vertices=verts, fixWinding=True) assert not fslmesh.needsFixing(verts, tris_ccw, fnormals, blo, bhi) assert fslmesh.needsFixing(verts, tris_cw, -fnormals, blo, bhi) + assert np.all(np.isclose(mesh.indices, tris_ccw)) def test_trimesh_no_trimesh():