Skip to content

Commit

Permalink
tests for converted functions bar mesh conversion
Browse files Browse the repository at this point in the history
mesh conversion will be tested indirectly by other tests- come back later for additional test
  • Loading branch information
tf17270 authored Mar 13, 2024
1 parent aed6b6d commit 3f40fd8
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lyceanem/geometry/test_geometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pytest
import numpy as np
import meshio
from . import geometry_functions_meshio as GF
def are_meshes_equal(mesh1, mesh2, rtol=1e-5):
# Check vertices
assert np.allclose(mesh1.points, mesh2.points, rtol=rtol)


# Check cells
if len(mesh1.cells) >0:

assert np.allclose(mesh1.cells[0].data, mesh2.cells[0].data)

for i in mesh1.point_data:
assert np.allclose(mesh1.point_data[i], mesh2.point_data[i])

for i in mesh1.cell_data:
assert np.allclose(mesh1.cell_data[i], mesh2.cell_data[i])


return True

def test_tri_areas():
refrence = np.load('areas.npy')
input = meshio.read('receive_horn.ply')
result = GF.tri_areas(input)
assert np.allclose(result, refrence)

def test_tri_centroids():
refrence = np.load('centroid_numpy.npy')
refrenece_mesh = meshio.read('centroid_mesh.ply')
input = meshio.read('receive_horn.ply')
result_numpy, result_mesh = GF.tri_centroids(input)
assert np.allclose(result_numpy, refrence)
assert are_meshes_equal(result_mesh, refrenece_mesh)
def test_mesh_rotate():
refrence = meshio.read('rotated_recieve.ply')
input = meshio.read('receive_horn.ply')
rotation_vector1 = np.radians(np.asarray([90.0, 0.0, 0.0]))
centre = np.array([1.0, 1.0, 1.0])


result = GF.mesh_rotate(input, rotation_vector1, centre)

assert are_meshes_equal(result, refrence)

0 comments on commit 3f40fd8

Please sign in to comment.