diff --git a/wasm/CMakeLists.txt b/wasm/CMakeLists.txt index f5bb092..dbcf950 100644 --- a/wasm/CMakeLists.txt +++ b/wasm/CMakeLists.txt @@ -122,5 +122,5 @@ add_test(NAME write-parameter-files-multiple-test add_test(NAME default-parameter-map-test COMMAND default-parameter-map affine - ${CMAKE_CURRENT_BINARY_DIR}/affine_default_parameters.json + ${CMAKE_CURRENT_BINARY_DIR}/affine_default_parameters.toml ) diff --git a/wasm/default-parameter-map.cxx b/wasm/default-parameter-map.cxx index 55d3d47..b073fe6 100644 --- a/wasm/default-parameter-map.cxx +++ b/wasm/default-parameter-map.cxx @@ -18,10 +18,7 @@ #include "elxParameterObject.h" #include "itkPipeline.h" #include "itkOutputTextStream.h" - -#include "rapidjson/document.h" -#include "rapidjson/prettywriter.h" -#include "rapidjson/stringbuffer.h" +#include "Install/elxConversion.h" int main(int argc, char * argv[]) @@ -44,10 +41,10 @@ main(int argc, char * argv[]) finalGridSpacingInPhysicalUnits, "Final grid spacing in physical units for bspline transforms."); - itk::wasm::OutputTextStream parameterMapJson; - pipeline.add_option("parameter-map", parameterMapJson, "Elastix parameter map representation") + itk::wasm::OutputTextStream outputTextStream; + pipeline.add_option("parameter-map", outputTextStream, "Elastix parameter map representation") ->required() - ->type_name("OUTPUT_JSON"); + ->type_name("OUTPUT_TEXT_STREAM"); ITK_WASM_PARSE(pipeline); @@ -55,27 +52,7 @@ main(int argc, char * argv[]) auto parameterMap = ParameterObjectType::GetDefaultParameterMap(transformName, numberOfResolutions, finalGridSpacingInPhysicalUnits); - rapidjson::Document document; - document.SetObject(); - rapidjson::Document::AllocatorType & allocator = document.GetAllocator(); - - for (const auto & parameter : parameterMap) - { - const auto & key = parameter.first; - const auto & value = parameter.second; - rapidjson::Value valueJson(rapidjson::kArrayType); - for (const auto & valueElement : value) - { - valueJson.PushBack(rapidjson::Value(valueElement.c_str(), allocator).Move(), allocator); - } - document.AddMember(rapidjson::Value(key.c_str(), allocator).Move(), valueJson, allocator); - } - - rapidjson::StringBuffer buffer; - rapidjson::PrettyWriter writer(buffer); - document.Accept(writer); - - parameterMapJson.Get() << buffer.GetString(); - + outputTextStream.Get() << elastix::Conversion::ParameterMapToString(parameterMap, + elastix::ParameterMapStringFormat::Toml); return EXIT_SUCCESS; } \ No newline at end of file