Skip to content

Commit 4466da6

Browse files
committed
test(core): add transform-read-write-pipeline
1 parent 4d5b0e9 commit 4466da6

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

packages/core/typescript/itk-wasm/test/pipelines/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ add_subdirectory("input-output-files-pipeline")
66
add_subdirectory("input-output-json-pipeline")
77
add_subdirectory("median-filter-pipeline")
88
add_subdirectory("mesh-read-write-pipeline")
9+
add_subdirectory("transform-read-write-pipeline")
910
add_subdirectory("read-image")
1011
add_subdirectory("stdout-stderr-pipeline")
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(transform-read-write-test)
3+
4+
set(CMAKE_CXX_STANDARD 20)
5+
6+
set(io_components)
7+
if(NOT EMSCRIPTEN)
8+
set(io_components ITKIOTransformHDF5)
9+
endif()
10+
find_package(ITK REQUIRED
11+
COMPONENTS
12+
${io_components}
13+
WebAssemblyInterface
14+
)
15+
include(${ITK_USE_FILE})
16+
17+
add_executable(transform-read-write-test transform-read-write-test.cxx)
18+
target_link_libraries(transform-read-write-test PUBLIC ${ITK_LIBRARIES})
19+
20+
enable_testing()
21+
add_test(NAME transform-read-write-test
22+
COMMAND transform-read-write-test ${CMAKE_CURRENT_SOURCE_DIR}/LinearTransform.h5
23+
${CMAKE_CURRENT_BINARY_DIR}/LinearTransform.written.h5
24+
)
25+
26+
add_test(NAME transformReadWriteWasmTest
27+
COMMAND transform-read-write-test ${CMAKE_CURRENT_SOURCE_DIR}/LinearTransform.h5
28+
${CMAKE_CURRENT_BINARY_DIR}/LinearTransform.iwt
29+
)
30+
31+
add_test(NAME transformReadWriteWasmCBORTest
32+
COMMAND transform-read-write-test ${CMAKE_CURRENT_SOURCE_DIR}/LinearTransform.h5
33+
${CMAKE_CURRENT_BINARY_DIR}/LinearTransform.iwt.cbor
34+
)
35+
36+
add_test(NAME transformReadWriteWasmInputTest
37+
COMMAND transform-read-write-test ${CMAKE_CURRENT_BINARY_DIR}/LinearTransform.iwt
38+
${CMAKE_CURRENT_BINARY_DIR}/LinearTransform.out.iwt
39+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*=========================================================================
2+
*
3+
* Copyright NumFOCUS
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
#include "itkAffineTransform.h"
19+
#include "itkInputTransform.h"
20+
#include "itkOutputTransform.h"
21+
#include "itkPipeline.h"
22+
23+
int main( int argc, char * argv[] )
24+
{
25+
itk::wasm::Pipeline pipeline("transform-read-write-test", "A test for reading and writing transforms", argc, argv);
26+
27+
using ParametersValueType = double;
28+
constexpr unsigned int Dimension = 3;
29+
using TransformType = itk::AffineTransform< ParametersValueType, Dimension >;
30+
31+
using InputTransformType = itk::wasm::InputTransform<TransformType>;
32+
InputTransformType inputTransform;
33+
pipeline.add_option("input-transform", inputTransform, "The input transform")->required()->type_name("INPUT_TRANSFORM");
34+
35+
using OutputTransformType = itk::wasm::OutputTransform<TransformType>;
36+
OutputTransformType outputTransform;
37+
pipeline.add_option("output-transform", outputTransform, "The output transform")->required()->type_name("OUTPUT_TRANSFORM");
38+
39+
ITK_WASM_PARSE(pipeline);
40+
41+
outputTransform.Set(inputTransform.Get());
42+
43+
return EXIT_SUCCESS;
44+
}

0 commit comments

Comments
 (0)