-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(mesh-io): add dispatch test_vtk_poly_data
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
42 changes: 42 additions & 0 deletions
42
packages/mesh-io/python/itkwasm-mesh-io/tests/test_vtk_poly_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from pathlib import Path | ||
|
||
from itkwasm import FloatTypes, IntTypes | ||
import numpy as np | ||
|
||
from itkwasm_mesh_io import vtk_poly_data_read_mesh, vtk_poly_data_write_mesh | ||
|
||
from .common import test_input_path, test_output_path | ||
|
||
test_input_file_path = test_input_path / "cow.vtk" | ||
test_output_file_path = test_output_path / "vtk-test-cow.vtk" | ||
|
||
def verify_mesh(mesh): | ||
assert mesh.meshType.dimension == 3 | ||
assert mesh.meshType.pointComponentType == FloatTypes.Float32 | ||
assert mesh.meshType.pointPixelComponentType == IntTypes.Int8 | ||
assert mesh.numberOfPoints == 2903 | ||
assert np.allclose(mesh.points.ravel()[0], 3.71636) | ||
assert np.allclose(mesh.points.ravel()[1], 2.34339) | ||
print(mesh.points.shape) | ||
assert mesh.numberOfCells == 3263 | ||
assert mesh.cellBufferSize == 18856 | ||
assert mesh.cells[0] == 4 | ||
assert mesh.cells[1] == 4 | ||
assert mesh.cells[2] == 250 | ||
|
||
def test_vtk_read_mesh(): | ||
could_read, mesh = vtk_poly_data_read_mesh(test_input_file_path) | ||
assert could_read | ||
verify_mesh(mesh) | ||
|
||
def test_vtk_write_mesh(): | ||
could_read, mesh = vtk_poly_data_read_mesh(test_input_file_path) | ||
assert could_read | ||
|
||
use_compression = False | ||
could_write = vtk_poly_data_write_mesh(mesh, test_output_file_path, use_compression=use_compression) | ||
assert could_write | ||
|
||
could_read, mesh = vtk_poly_data_read_mesh(test_output_file_path) | ||
assert could_read | ||
verify_mesh(mesh) |