Skip to content

Commit a8fdda0

Browse files
committed
feat(Mesh,PolyData): add metadata member in C++
1 parent 55dc91e commit a8fdda0

File tree

6 files changed

+23
-2
lines changed

6 files changed

+23
-2
lines changed

include/itkImageJSON.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ namespace itk
6363
std::string direction;
6464
std::vector<size_t> size { 0, 0 };
6565

66-
MetadataJSON metadata;
6766
std::string data;
67+
68+
MetadataJSON metadata;
6869
};
6970

7071
template<typename TImage>

include/itkMeshJSON.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "itkFloatTypesJSON.h"
2727
#include "itkPixelTypesJSON.h"
2828
#include "itkWasmMesh.h"
29+
#include "itkMetaDataDictionaryJSON.h"
2930

3031
#include "glaze/glaze.hpp"
3132

@@ -74,6 +75,8 @@ namespace itk
7475

7576
size_t numberOfCellPixels{ 0 };
7677
std::string cellData;
78+
79+
MetadataJSON metadata;
7780
};
7881

7982
template<typename TMesh>
@@ -164,6 +167,9 @@ auto meshToMeshJSON(const TMesh * mesh, const WasmMesh<TMesh> * wasmMesh, bool i
164167
meshJSON.cellData = "data:application/vnd.itk.path,data/cell-data.raw";
165168
}
166169

170+
auto dictionary = mesh->GetMetaDataDictionary();
171+
metaDataDictionaryToJSON(dictionary, meshJSON.metadata);
172+
167173
return meshJSON;
168174
}
169175
} // end namespace itk

include/itkMeshToWasmMeshFilter.hxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#ifndef itkMeshToWasmMeshFilter_hxx
1919
#define itkMeshToWasmMeshFilter_hxx
2020

21+
#include "itkMetaDataDictionaryJSON.h"
22+
2123
#include "glaze/glaze.hpp"
2224

2325
namespace itk

include/itkPolyDataJSON.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "itkFloatTypesJSON.h"
2727
#include "itkPixelTypesJSON.h"
2828
#include "itkWasmPolyData.h"
29+
#include "itkMetaDataDictionaryJSON.h"
2930

3031
#include "glaze/glaze.hpp"
3132

@@ -79,6 +80,8 @@ namespace itk
7980

8081
size_t numberOfCellPixels { 0 };
8182
std::string cellData;
83+
84+
MetadataJSON metadata;
8285
};
8386

8487
template<typename TPolyData>
@@ -203,6 +206,9 @@ auto polyDataToPolyDataJSON(const TPolyData * polyData, bool inMemory) -> PolyDa
203206
cellDataStream << cellDataAddress;
204207
polyDataJSON.cellData = cellDataStream.str();
205208

209+
auto dictionary = polyData->GetMetaDataDictionary();
210+
metaDataDictionaryToJSON(dictionary, polyDataJSON.metadata);
211+
206212
return polyDataJSON;
207213
}
208214
} // end namespace itk

include/itkWasmMeshToMeshFilter.hxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ WasmMeshToMeshFilter<TMesh>
375375
const std::string descriptiveError = glz::format_error(deserializedAttempt, json);
376376
itkExceptionMacro("Failed to deserialize meshJSON: " << descriptiveError);
377377
}
378-
auto meshJSON = deserializedAttempt.value();
378+
const auto meshJSON = deserializedAttempt.value();
379379

380380
const auto dimension = meshJSON.meshType.dimension;
381381
const auto numberOfPointPixels = meshJSON.numberOfPointPixels;
@@ -482,6 +482,9 @@ WasmMeshToMeshFilter<TMesh>
482482
mesh->GetCellData()->resize(meshJSON.numberOfCellPixels);
483483
mesh->GetCellData()->assign(cellDataPtr, cellDataPtr + meshJSON.numberOfCellPixels);
484484
}
485+
486+
auto dictionary = mesh->GetMetaDataDictionary();
487+
jsonToMetaDataDictionary(meshJSON.metadata, dictionary);
485488
}
486489

487490
template <typename TMesh>

include/itkWasmPolyDataToPolyDataFilter.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ WasmPolyDataToPolyDataFilter<TPolyData>
251251
polyData->GetCellData()->resize(numberOfCellPixels * cellPixelComponents);
252252
polyData->GetCellData()->assign(cellDataPtr, cellDataPtr + numberOfCellPixels * cellPixelComponents);
253253
}
254+
255+
auto dictionary = polyData->GetMetaDataDictionary();
256+
jsonToMetaDataDictionary(polyDataJSON.metadata, dictionary);
254257
}
255258

256259
template <typename TPolyData>

0 commit comments

Comments
 (0)