VTK  9.7.1
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 
25 VTK_ABI_NAMESPACE_BEGIN
27 class vtkFieldData;
28 class vtkImageData;
29 class vtkStringArray;
30 
31 class VTKIOCELLGRID_EXPORT vtkCellGridIOQuery : public vtkCellGridQuery
32 {
33 public:
34  static vtkCellGridIOQuery* New();
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 
91  bool ExtractCellTypeAttributeInfo(vtkCellGrid* grid, vtkCellAttribute::CellTypeInfo& cellTypeInfo,
92  const nlohmann::json& jsonInfo, vtkStringToken cellTypeName);
93 
102  bool InsertCellTypeAttributeInfo(vtkCellGrid* grid,
103  const vtkCellAttribute::CellTypeInfo& cellTypeInfo, nlohmann::json& jsonInfo,
104  vtkStringToken cellTypeName);
105 
107  nlohmann::json& AddMetadataEntry(vtkStringToken cellTypeName);
109 
110 protected:
111  vtkCellGridIOQuery() = default;
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 
120 private:
121  vtkCellGridIOQuery(const vtkCellGridIOQuery&) = delete;
122  void operator=(const vtkCellGridIOQuery&) = delete;
123 };
124 
125 VTK_ABI_NAMESPACE_END
126 #endif
std::unordered_map< vtkAbstractArray *, vtkStringToken > & GetArrayLocations()
Return the JSON object that holds attribute data.
Perform an operation on cells in a vtkCellMetadata instance.
bool IsSerializing() const
Return true if the query is serializing cells (as opposed to deserializing).
a vtkAbstractArray subclass for strings
Serialize/deserialize vtkCellMetadata records.
const std::vector< vtkCellAttribute * > & GetAttributeList() const
Return a vector of cell-attributes that matches AttributeData.
Visualization data composed of cells of arbitrary type.
Definition: vtkCellGrid.h:48
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
Store on/off settings for data arrays, etc.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
nlohmann::json * GetData()
Return the JSON object that holds attribute data.
Represent a string by its integer hash.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
const std::unordered_map< vtkAbstractArray *, vtkStringToken > & GetArrayLocations() const
Return the map of array pointers to the names of groups which contain them.
std::vector< vtkCellAttribute * > * AttributeList
std::unordered_map< vtkAbstractArray *, vtkStringToken > ArrayLocations
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51
nlohmann::json * GetAttributeData()
Return the JSON object that holds attribute data.