VTK  9.4.20241031
vtkCellGridIOQuery.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
15#ifndef vtkCellGridIOQuery_h
16#define vtkCellGridIOQuery_h
17
18#include "vtkCellAttribute.h" // For vtkCellAttribute::CellTypeInfo
19#include "vtkCellGridQuery.h"
20#include "vtkIOCellGridModule.h" // For export macro
21
22#include <vtk_nlohmannjson.h> // For API.
23#include VTK_NLOHMANN_JSON(json.hpp) // For API.
24
25VTK_ABI_NAMESPACE_BEGIN
27class vtkFieldData;
28class vtkImageData;
29class vtkStringArray;
30
31class VTKIOCELLGRID_EXPORT vtkCellGridIOQuery : public vtkCellGridQuery
32{
33public:
36 void PrintSelf(ostream& os, vtkIndent indent) override;
37
40
47 void PrepareToDeserialize(const nlohmann::json& sourceData, const nlohmann::json& attributeData,
48 std::vector<vtkCellAttribute*>& attributeList);
50
53
56 void PrepareToSerialize(nlohmann::json& destination, nlohmann::json& attributeData,
57 const std::unordered_map<vtkAbstractArray*, vtkStringToken>& arrayLocations);
59
63 nlohmann::json* GetData() { return this->Data; }
64
66 nlohmann::json* GetAttributeData() { return this->AttributeData; }
67
69 const std::unordered_map<vtkAbstractArray*, vtkStringToken>& GetArrayLocations() const
70 {
71 return this->ArrayLocations;
72 }
73 std::unordered_map<vtkAbstractArray*, vtkStringToken>& GetArrayLocations()
74 {
75 return this->ArrayLocations;
76 }
77
79 const std::vector<vtkCellAttribute*>& GetAttributeList() const { return *this->AttributeList; }
80
82 bool IsSerializing() const { return this->Serializing; }
83
92 const nlohmann::json& jsonInfo, vtkStringToken cellTypeName);
93
103 const vtkCellAttribute::CellTypeInfo& cellTypeInfo, nlohmann::json& jsonInfo,
104 vtkStringToken cellTypeName);
105
107 nlohmann::json& AddMetadataEntry(vtkStringToken cellTypeName);
109
110protected:
112 ~vtkCellGridIOQuery() override = default;
113
114 nlohmann::json* Data{ nullptr };
115 nlohmann::json* AttributeData{ nullptr };
116 std::vector<vtkCellAttribute*>* AttributeList;
117 std::unordered_map<vtkAbstractArray*, vtkStringToken> ArrayLocations;
118 bool Serializing{ true };
119
120private:
121 vtkCellGridIOQuery(const vtkCellGridIOQuery&) = delete;
122 void operator=(const vtkCellGridIOQuery&) = delete;
123};
124
125VTK_ABI_NAMESPACE_END
126#endif
Serialize/deserialize vtkCellMetadata records.
nlohmann::json * GetData()
Return the JSON object that holds attribute data.
static vtkCellGridIOQuery * New()
bool InsertCellTypeAttributeInfo(vtkCellGrid *grid, const vtkCellAttribute::CellTypeInfo &cellTypeInfo, nlohmann::json &jsonInfo, vtkStringToken cellTypeName)
Insert vtkCellAttribute::CellTypeInfo into the given jsonInfo object for the given cellTypeName.
std::unordered_map< vtkAbstractArray *, vtkStringToken > ArrayLocations
const std::vector< vtkCellAttribute * > & GetAttributeList() const
Return a vector of cell-attributes that matches AttributeData.
nlohmann::json * GetAttributeData()
Return the JSON object that holds attribute data.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void PrepareToDeserialize(const nlohmann::json &sourceData, const nlohmann::json &attributeData, std::vector< vtkCellAttribute * > &attributeList)
Prepare to deserialize cell metadata from the given sourceData JSON object.
nlohmann::json & AddMetadataEntry(vtkStringToken cellTypeName)
Add a metadata entry for cellTypeName to the output.
void PrepareToSerialize(nlohmann::json &destination, nlohmann::json &attributeData, const std::unordered_map< vtkAbstractArray *, vtkStringToken > &arrayLocations)
Prepare to serialize cell metadata to the given parent JSON object.
const std::unordered_map< vtkAbstractArray *, vtkStringToken > & GetArrayLocations() const
Return the map of array pointers to the names of groups which contain them.
std::unordered_map< vtkAbstractArray *, vtkStringToken > & GetArrayLocations()
Return the JSON object that holds attribute data.
~vtkCellGridIOQuery() override=default
std::vector< vtkCellAttribute * > * AttributeList
bool ExtractCellTypeAttributeInfo(vtkCellGrid *grid, vtkCellAttribute::CellTypeInfo &cellTypeInfo, const nlohmann::json &jsonInfo, vtkStringToken cellTypeName)
Extract JSON array information into vtkCellAttribute::CellTypeInfo.
bool IsSerializing() const
Return true if the query is serializing cells (as opposed to deserializing).
vtkCellGridIOQuery()=default
Perform an operation on cells in a vtkCellMetadata instance.
Visualization data composed of cells of arbitrary type.
Definition vtkCellGrid.h:49
Store on/off settings for data arrays, etc.
represent and manipulate fields of data
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:108
a vtkAbstractArray subclass for strings
Represent a string by its integer hash.