diff --git a/include/itkImageJSON.h b/include/itkImageJSON.h index 01f086f9f..e8797bc29 100644 --- a/include/itkImageJSON.h +++ b/include/itkImageJSON.h @@ -63,8 +63,9 @@ namespace itk std::string direction; std::vector size { 0, 0 }; - MetadataJSON metadata; std::string data; + + MetadataJSON metadata; }; template diff --git a/include/itkMeshJSON.h b/include/itkMeshJSON.h index 2e16c39f4..2905ebdbc 100644 --- a/include/itkMeshJSON.h +++ b/include/itkMeshJSON.h @@ -26,6 +26,7 @@ #include "itkFloatTypesJSON.h" #include "itkPixelTypesJSON.h" #include "itkWasmMesh.h" +#include "itkMetaDataDictionaryJSON.h" #include "glaze/glaze.hpp" @@ -74,6 +75,8 @@ namespace itk size_t numberOfCellPixels{ 0 }; std::string cellData; + + MetadataJSON metadata; }; template @@ -164,6 +167,9 @@ auto meshToMeshJSON(const TMesh * mesh, const WasmMesh * wasmMesh, bool i meshJSON.cellData = "data:application/vnd.itk.path,data/cell-data.raw"; } + auto dictionary = mesh->GetMetaDataDictionary(); + metaDataDictionaryToJSON(dictionary, meshJSON.metadata); + return meshJSON; } } // end namespace itk diff --git a/include/itkMeshToWasmMeshFilter.hxx b/include/itkMeshToWasmMeshFilter.hxx index b449e3786..36fd2afae 100644 --- a/include/itkMeshToWasmMeshFilter.hxx +++ b/include/itkMeshToWasmMeshFilter.hxx @@ -18,6 +18,8 @@ #ifndef itkMeshToWasmMeshFilter_hxx #define itkMeshToWasmMeshFilter_hxx +#include "itkMetaDataDictionaryJSON.h" + #include "glaze/glaze.hpp" namespace itk diff --git a/include/itkPolyDataJSON.h b/include/itkPolyDataJSON.h index eed3b00eb..f8cd29a8a 100644 --- a/include/itkPolyDataJSON.h +++ b/include/itkPolyDataJSON.h @@ -26,6 +26,7 @@ #include "itkFloatTypesJSON.h" #include "itkPixelTypesJSON.h" #include "itkWasmPolyData.h" +#include "itkMetaDataDictionaryJSON.h" #include "glaze/glaze.hpp" @@ -79,6 +80,8 @@ namespace itk size_t numberOfCellPixels { 0 }; std::string cellData; + + MetadataJSON metadata; }; template @@ -203,6 +206,9 @@ auto polyDataToPolyDataJSON(const TPolyData * polyData, bool inMemory) -> PolyDa cellDataStream << cellDataAddress; polyDataJSON.cellData = cellDataStream.str(); + auto dictionary = polyData->GetMetaDataDictionary(); + metaDataDictionaryToJSON(dictionary, polyDataJSON.metadata); + return polyDataJSON; } } // end namespace itk diff --git a/include/itkWasmMeshToMeshFilter.hxx b/include/itkWasmMeshToMeshFilter.hxx index e0250b1c0..0ebe0220e 100644 --- a/include/itkWasmMeshToMeshFilter.hxx +++ b/include/itkWasmMeshToMeshFilter.hxx @@ -375,7 +375,7 @@ WasmMeshToMeshFilter const std::string descriptiveError = glz::format_error(deserializedAttempt, json); itkExceptionMacro("Failed to deserialize meshJSON: " << descriptiveError); } - auto meshJSON = deserializedAttempt.value(); + const auto meshJSON = deserializedAttempt.value(); const auto dimension = meshJSON.meshType.dimension; const auto numberOfPointPixels = meshJSON.numberOfPointPixels; @@ -482,6 +482,9 @@ WasmMeshToMeshFilter mesh->GetCellData()->resize(meshJSON.numberOfCellPixels); mesh->GetCellData()->assign(cellDataPtr, cellDataPtr + meshJSON.numberOfCellPixels); } + + auto dictionary = mesh->GetMetaDataDictionary(); + jsonToMetaDataDictionary(meshJSON.metadata, dictionary); } template diff --git a/include/itkWasmPolyDataToPolyDataFilter.hxx b/include/itkWasmPolyDataToPolyDataFilter.hxx index dc97dc8d6..cec90dcb7 100644 --- a/include/itkWasmPolyDataToPolyDataFilter.hxx +++ b/include/itkWasmPolyDataToPolyDataFilter.hxx @@ -251,6 +251,9 @@ WasmPolyDataToPolyDataFilter polyData->GetCellData()->resize(numberOfCellPixels * cellPixelComponents); polyData->GetCellData()->assign(cellDataPtr, cellDataPtr + numberOfCellPixels * cellPixelComponents); } + + auto dictionary = polyData->GetMetaDataDictionary(); + jsonToMetaDataDictionary(polyDataJSON.metadata, dictionary); } template