Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Mesh,PolyData): add metadata member in C++ #1183

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/itkImageJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ namespace itk
std::string direction;
std::vector<size_t> size { 0, 0 };

MetadataJSON metadata;
std::string data;

MetadataJSON metadata;
};

template<typename TImage>
Expand Down
6 changes: 6 additions & 0 deletions include/itkMeshJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "itkFloatTypesJSON.h"
#include "itkPixelTypesJSON.h"
#include "itkWasmMesh.h"
#include "itkMetaDataDictionaryJSON.h"

#include "glaze/glaze.hpp"

Expand Down Expand Up @@ -74,6 +75,8 @@ namespace itk

size_t numberOfCellPixels{ 0 };
std::string cellData;

MetadataJSON metadata;
};

template<typename TMesh>
Expand Down Expand Up @@ -164,6 +167,9 @@ auto meshToMeshJSON(const TMesh * mesh, const WasmMesh<TMesh> * 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
Expand Down
2 changes: 2 additions & 0 deletions include/itkMeshToWasmMeshFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef itkMeshToWasmMeshFilter_hxx
#define itkMeshToWasmMeshFilter_hxx

#include "itkMetaDataDictionaryJSON.h"

#include "glaze/glaze.hpp"

namespace itk
Expand Down
6 changes: 6 additions & 0 deletions include/itkPolyDataJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "itkFloatTypesJSON.h"
#include "itkPixelTypesJSON.h"
#include "itkWasmPolyData.h"
#include "itkMetaDataDictionaryJSON.h"

#include "glaze/glaze.hpp"

Expand Down Expand Up @@ -79,6 +80,8 @@ namespace itk

size_t numberOfCellPixels { 0 };
std::string cellData;

MetadataJSON metadata;
};

template<typename TPolyData>
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion include/itkWasmMeshToMeshFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ WasmMeshToMeshFilter<TMesh>
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;
Expand Down Expand Up @@ -482,6 +482,9 @@ WasmMeshToMeshFilter<TMesh>
mesh->GetCellData()->resize(meshJSON.numberOfCellPixels);
mesh->GetCellData()->assign(cellDataPtr, cellDataPtr + meshJSON.numberOfCellPixels);
}

auto dictionary = mesh->GetMetaDataDictionary();
jsonToMetaDataDictionary(meshJSON.metadata, dictionary);
}

template <typename TMesh>
Expand Down
3 changes: 3 additions & 0 deletions include/itkWasmPolyDataToPolyDataFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ WasmPolyDataToPolyDataFilter<TPolyData>
polyData->GetCellData()->resize(numberOfCellPixels * cellPixelComponents);
polyData->GetCellData()->assign(cellDataPtr, cellDataPtr + numberOfCellPixels * cellPixelComponents);
}

auto dictionary = polyData->GetMetaDataDictionary();
jsonToMetaDataDictionary(polyDataJSON.metadata, dictionary);
}

template <typename TPolyData>
Expand Down
Loading