Skip to content
Snippets Groups Projects
Commit e66d14db authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: Check gifti/mesh handling one triangle

parent 72c14d23
No related branches found
No related tags found
No related merge requests found
......@@ -381,3 +381,21 @@ def test_GiftiMesh_needsFixing():
surf = gifti.GiftiMesh(fname, fixWinding=True)
assert np.all(np.isclose(surf.indices, idxs_fixed))
def test_loadGiftiMesh_onetriangle():
verts = np.array([[0, 0, 0], [1, 1, 1], [0, 1, 0]])
idxs = np.array([[0, 1, 2]])
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)
gimg, tris, verts, _ = gifti.loadGiftiMesh('test.gii')
verts = verts[0]
assert verts.shape == (3, 3)
assert tris.shape == (1, 3)
......@@ -234,6 +234,13 @@ def test_normals():
-fnormals, fslmesh.calcFaceNormals(verts, triangles_cw)))
assert np.all(np.isclose(
fnormals, fslmesh.calcFaceNormals(verts, triangles_ccw)))
# Make sure result is (1, 3) for input of (1, 3)
onetri = np.atleast_2d(triangles_ccw[0, :])
result = fslmesh.calcFaceNormals(verts, onetri)
assert result.shape == (1, 3)
assert np.all(np.isclose(fnormals[0, :], result))
assert np.all(np.isclose(
-vnormals, fslmesh.calcVertexNormals(verts, triangles_cw, -fnormals)))
assert np.all(np.isclose(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment