Skip to content

Commit 9ab160f

Browse files
committed
feat(mesh-io): Add C++ MZ3 IO and tests
1 parent 891c5c1 commit 9ab160f

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

packages/mesh-io/CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set(WebAssemblyInterface_MeshIOModules
1919
"IOMeshSWC"
2020
"ITKIOMeshBYU"
2121
"ITKIOMeshFreeSurfer"
22+
"IOMeshMZ3"
2223
CACHE STRING
2324
"String delimited list of ITK mesh IO modules to support.")
2425

@@ -58,6 +59,10 @@ set(meshio_kebab_itkWasmMeshIO "wasm")
5859
set(meshio_id_itkWasmZstdMeshIO 9)
5960
set(meshio_kebab_itkWasmZstdMeshIO "wasm-zstd")
6061

62+
set(meshios_IOMeshMZ3 itkMZ3MeshIO)
63+
set(meshio_id_itkMZ3MeshIO 10)
64+
set(meshio_kebab_itkMZ3MeshIO "mz3")
65+
6166
set(ITK_NO_MESHIO_FACTORY_REGISTER_MANAGER 1)
6267
set(MeshIOIndex_ARRAY "")
6368
foreach(io_module ${WebAssemblyInterface_MeshIOModules} WebAssemblyInterface)
@@ -132,13 +137,25 @@ add_test(NAME byu-write-mesh-test
132137
${output_dir}/byu-write-mesh-test.could-write.json
133138
${output_dir}/byu-write-mesh-test.byu)
134139

140+
add_test(NAME mz3-read-mesh-test
141+
COMMAND mz3-read-mesh
142+
${input_dir}/11ScalarMesh.mz3
143+
${output_dir}/mz3-read-mesh-test.could-read.json
144+
${output_dir}/mz3-read-mesh-test.iwm.cbor)
145+
146+
add_test(NAME mz3-write-mesh-test
147+
COMMAND mz3-write-mesh
148+
${baseline_dir}/mz3-read-mesh-test.iwm.cbor
149+
${output_dir}/mz3-write-mesh-test.could-write.json
150+
${output_dir}/mz3-write-mesh-test.mz3)
135151

136152
# This list should be ordered from approximately most commonly to least
137153
# commonly used modules.
138154
set(WebAssemblyInterface_PointSetIOModules
139155
"ITKIOMeshVTK"
140156
"ITKIOMeshOBJ"
141157
"ITKIOMeshOFF"
158+
"IOMeshMZ3"
142159
CACHE STRING
143160
"String delimited list of ITK point set IO modules to support.")
144161

@@ -160,6 +177,10 @@ set(pointsetio_kebab_itkWasmMeshIO "wasm")
160177
set(pointsetio_id_itkWasmZstdMeshIO 4)
161178
set(pointsetio_kebab_itkWasmZstdMeshIO "wasm-zstd")
162179

180+
set(pointsetios_IOMeshMZ3 itkMZ3MeshIO)
181+
set(pointsetio_id_itkMZ3MeshIO 5)
182+
set(pointsetio_kebab_itkMZ3MeshIO "mz3")
183+
163184
set(ITK_NO_MESHIO_FACTORY_REGISTER_MANAGER 1)
164185
set(PointSetIOIndex_ARRAY "")
165186
foreach(io_module ${WebAssemblyInterface_PointSetIOModules} WebAssemblyInterface)
@@ -227,3 +248,15 @@ add_test(NAME obj-write-point-set-test
227248
${baseline_dir}/obj-read-point-set-test.iwm.cbor
228249
${output_dir}/obj-write-point-set-test.could-write.json
229250
${output_dir}/obj-write-point-set-test.obj)
251+
252+
add_test(NAME mz3-read-point-set-test
253+
COMMAND mz3-read-point-set
254+
${input_dir}/11ScalarMesh.mz3
255+
${output_dir}/mz3-read-point-set-test.could-read.json
256+
${output_dir}/mz3-read-point-set-test.iwm.cbor)
257+
258+
add_test(NAME mz3-write-point-set-test
259+
COMMAND mz3-write-point-set
260+
${baseline_dir}/mz3-read-point-set-test.iwm.cbor
261+
${output_dir}/mz3-write-point-set-test.could-write.json
262+
${output_dir}/mz3-write-point-set-test.mz3)

packages/mesh-io/read-mesh.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#elif MESH_IO_CLASS == 8
4545
#elif MESH_IO_CLASS == 9
4646
#include "itkWasmZstdMeshIO.h"
47+
#elif MESH_IO_CLASS == 10
48+
#include "itkMZ3MeshIO.h"
4749
#else
4850
#error "Unsupported MESH_IO_CLASS"
4951
#endif
@@ -119,6 +121,8 @@ int main (int argc, char * argv[])
119121
return readMesh<itk::WasmMeshIO>(inputFileName, couldRead, outputMeshIO, informationOnly);
120122
#elif MESH_IO_CLASS == 9
121123
return readMesh<itk::WasmZstdMeshIO>(inputFileName, couldRead, outputMeshIO, informationOnly);
124+
#elif MESH_IO_CLASS == 10
125+
return readMesh<itk::MZ3MeshIO>(inputFileName, couldRead, outputMeshIO, informationOnly);
122126
#else
123127
#error "Unsupported MESH_IO_CLASS"
124128
#endif

packages/mesh-io/read-point-set.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#elif MESH_IO_CLASS == 3
3535
#elif MESH_IO_CLASS == 4
3636
#include "itkWasmZstdMeshIO.h"
37+
#elif MESH_IO_CLASS == 5
38+
#include "itkMZ3MeshIO.h"
3739
#else
3840
#error "Unsupported MESH_IO_CLASS"
3941
#endif
@@ -98,6 +100,8 @@ int main (int argc, char * argv[])
98100
return readPointSet<itk::WasmMeshIO>(inputFileName, couldRead, pointSetIO, informationOnly);
99101
#elif MESH_IO_CLASS == 4
100102
return readPointSet<itk::WasmZstdMeshIO>(inputFileName, couldRead, pointSetIO, informationOnly);
103+
#elif MESH_IO_CLASS == 5
104+
return readPointSet<itk::MZ3MeshIO>(inputFileName, couldRead, pointSetIO, informationOnly);
101105
#else
102106
#error "Unsupported MESH_IO_CLASS"
103107
#endif

packages/mesh-io/write-mesh.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#elif MESH_IO_CLASS == 8
4545
#elif MESH_IO_CLASS == 9
4646
#include "itkWasmZstdMeshIO.h"
47+
#elif MESH_IO_CLASS == 10
48+
#include "itkMZ3MeshIO.h"
4749
#else
4850
#error "Unsupported MESH_IO_CLASS"
4951
#endif
@@ -190,6 +192,8 @@ int main (int argc, char * argv[])
190192
return writeMesh<itk::WasmMeshIO>(inputMeshIO, couldWrite, outputFileName, informationOnly, useCompression, binaryFileType);
191193
#elif MESH_IO_CLASS == 9
192194
return writeMesh<itk::WasmZstdMeshIO>(inputMeshIO, couldWrite, outputFileName, informationOnly, useCompression, binaryFileType);
195+
#elif MESH_IO_CLASS == 10
196+
return writeMesh<itk::MZ3MeshIO>(inputMeshIO, couldWrite, outputFileName, informationOnly, useCompression, binaryFileType);
193197
#else
194198
#error "Unsupported MESH_IO_CLASS"
195199
#endif

packages/mesh-io/write-point-set.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#elif MESH_IO_CLASS == 3
3535
#elif MESH_IO_CLASS == 4
3636
#include "itkWasmZstdMeshIO.h"
37+
#elif MESH_IO_CLASS == 5
38+
#include "itkMZ3MeshIO.h"
3739
#else
3840
#error "Unsupported MESH_IO_CLASS"
3941
#endif
@@ -147,6 +149,8 @@ int main(int argc, char *argv[])
147149
return writePointSet<itk::WasmMeshIO>(inputPointSetIO, couldWrite, outputFileName, informationOnly, useCompression, binaryFileType);
148150
#elif MESH_IO_CLASS == 4
149151
return writePointSet<itk::WasmZstdMeshIO>(inputPointSetIO, couldWrite, outputFileName, informationOnly, useCompression, binaryFileType);
152+
#elif MESH_IO_CLASS == 5
153+
return writePointSet<itk::MZ3MeshIO>(inputPointSetIO, couldWrite, outputFileName, informationOnly, useCompression, binaryFileType);
150154
#else
151155
#error "Unsupported MESH_IO_CLASS"
152156
#endif

0 commit comments

Comments
 (0)