-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/mesh-io/python/itkwasm-mesh-io-wasi/tests/test_swc.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,38 @@ | ||
from pathlib import Path | ||
|
||
from itkwasm import FloatTypes, IntTypes, PixelTypes | ||
|
||
from itkwasm_mesh_io_wasi import swc_read_mesh, swc_write_mesh | ||
|
||
from .common import test_input_path, test_output_path | ||
|
||
test_input_file_path = test_input_path / "11706c2.CNG.swc" | ||
test_output_file_path = test_output_path / "swc-test-11706c2.CNG.swc" | ||
|
||
def verify_mesh(mesh): | ||
assert mesh.meshType.dimension == 3 | ||
assert mesh.meshType.pointComponentType == FloatTypes.Float32 | ||
assert mesh.meshType.cellComponentType == IntTypes.UInt32 | ||
assert mesh.meshType.pointPixelType == PixelTypes.Scalar | ||
assert mesh.meshType.cellPixelType == PixelTypes.Scalar | ||
assert mesh.numberOfPoints == 1534 | ||
assert mesh.numberOfPointPixels == 1534 | ||
assert mesh.numberOfCells == 1533 | ||
assert mesh.cellBufferSize == 6132 | ||
|
||
def test_swc_read_mesh(): | ||
could_read, mesh = swc_read_mesh(test_input_file_path) | ||
assert could_read | ||
verify_mesh(mesh) | ||
|
||
def test_swc_write_mesh(): | ||
could_read, mesh = swc_read_mesh(test_input_file_path) | ||
assert could_read | ||
|
||
use_compression = False | ||
could_write = swc_write_mesh(mesh, test_output_file_path, use_compression=use_compression) | ||
assert could_write | ||
|
||
could_read, mesh = swc_read_mesh(test_output_file_path) | ||
assert could_read | ||
verify_mesh(mesh) |