VTK  9.7.1
vtkOverlappingAMRMetaData.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
24 #ifndef vtkOverlappingAMRMetaData_h
25 #define vtkOverlappingAMRMetaData_h
26 
27 #include "vtkAMRBox.h" //for storing AMR Boxes
28 #include "vtkAMRMetaData.h"
29 #include "vtkBoundingBox.h" //for storing AMR Bounding boxes
30 #include "vtkCommonDataModelModule.h" // For export macro
31 #include "vtkSmartPointer.h" //for ivars
32 
33 VTK_ABI_NAMESPACE_BEGIN
34 class vtkIntArray;
35 class vtkDoubleArray;
36 class VTKCOMMONDATAMODEL_EXPORT vtkOverlappingAMRMetaData : public vtkAMRMetaData
37 {
38 public:
41 
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43  bool operator==(const vtkOverlappingAMRMetaData& other) const;
44  bool operator!=(const vtkOverlappingAMRMetaData& other) const { return !(*this == other); }
45 
46  // VTK_DEPRECATED_IN_9_6_0
47  // Remove once the deprecated Initialize method in parent class is removed
49 
54  void Initialize(const std::vector<unsigned int>& blocksPerLevel) override;
55 
57 
61  void GetOrigin(double origin[3]);
62  [[nodiscard]] double* GetOrigin();
63  void SetOrigin(const double* origin);
65 
69  [[nodiscard]] const double* GetBounds();
70 
76  void GetBounds(unsigned int level, unsigned int id, double* bb);
77 
83  void SetBounds(unsigned int level, unsigned int id, double* bb);
84 
90  bool GetOrigin(unsigned int level, unsigned int id, double* origin);
91 
96  void GetSpacing(unsigned int level, double spacing[3]);
97 
101  [[nodiscard]] bool HasSpacing(unsigned int level) const;
102 
106  [[nodiscard]] bool HasSpacing() const;
107 
111  [[nodiscard]] bool HasBlockBounds(unsigned int index) const;
112 
116  [[nodiscard]] bool HasBlockBounds() const;
117 
119 
122  void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
123  [[nodiscard]] const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
124  bool GetAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
126 
132  bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box);
133 
135 
139  [[nodiscard]] int GetAMRBlockSourceIndex(int index);
140  void SetAMRBlockSourceIndex(int index, int sourceId);
142 
154  bool GenerateRefinementRatio();
155 
161  [[nodiscard]] bool HasRefinementRatio() const;
162 
167  void SetRefinementRatio(unsigned int level, int ratio);
168 
174  [[nodiscard]] int GetRefinementRatio(unsigned int level) const;
175 
179  void SetSpacing(unsigned int level, const double* h);
180 
184  [[nodiscard]] bool HasChildrenInformation() const;
185 
191  unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
192 
198  unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
199 
203  void PrintParentChildInfo(unsigned int level, unsigned int index);
204 
212  void GenerateParentChildInformation();
213 
217  [[nodiscard]] bool CheckValidity();
218 
225  bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
226 
231  bool FindGrid(double q[3], int level, unsigned int& gridId);
232 
237  bool FindGrids(double q[3], unsigned int level, std::vector<unsigned int>& gridIds);
238 
244  bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
245 
250  [[nodiscard]] std::vector<std::vector<unsigned int>>& GetChildrenAtLevel(unsigned int i)
251  {
252  return this->AllChildren[i];
253  }
254 
256 
259  [[nodiscard]] vtkGetMacro(GridType, unsigned int);
260  vtkSetMacro(GridType, unsigned int);
262 
267  void DeepCopy(vtkAMRMetaData* other) override;
268 
269 protected:
271  ~vtkOverlappingAMRMetaData() override;
272 
273 private:
275  void operator=(const vtkOverlappingAMRMetaData&) = delete;
276 
277  bool HasValidOrigin() const;
278  bool HasValidBounds() const;
279  void UpdateBounds(int level, int id);
280  void AllocateBoxes(unsigned int n);
281  void AllocateBlockBounds(unsigned int n);
282  void CalculateParentChildRelationShip(unsigned int level,
283  std::vector<std::vector<unsigned int>>& children,
284  std::vector<std::vector<unsigned int>>& parents);
285 
286  //-------------------------------------------------------------------------
287  // Essential information that determines an AMR structure. Must be copied
288  //-------------------------------------------------------------------------
289  unsigned int GridType = VTK_DATA_SET;
290 
291  // the origin of the whole data set
292  double Origin[3] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX };
293 
294  // vtkAMRBoxes, one per block
295  std::vector<vtkAMRBox> Boxes;
296 
297  // BoundingBoxes, one per block if used
298  std::vector<vtkBoundingBox> BlockBounds;
299 
300  // Typically, this maps to a file block index used by the reader
301  vtkSmartPointer<vtkIntArray> SourceIndex;
302 
303  // The grid spacing for all levels
304  vtkNew<vtkDoubleArray> Spacing;
305 
306  // the bounds of the entire domain
308  VTK_DOUBLE_MAX, VTK_DOUBLE_MIN };
309 
310  //-------------------------------------------------------------------------
311  // Auxiliary information that be computed
312  //-------------------------------------------------------------------------
313 
314  // refinement ratio between two adjacent levels
315  vtkNew<vtkIntArray> Refinement;
316 
317  // parent child information
318  std::vector<std::vector<std::vector<unsigned int>>> AllChildren;
319  std::vector<std::vector<std::vector<unsigned int>>> AllParents;
320 };
321 
322 VTK_ABI_NAMESPACE_END
323 #endif
void GetBounds(T a, double bds[6])
bool operator==(const vtkAMRMetaData &other) const
#define VTK_DOUBLE_MAX
Definition: vtkType.h:202
bool operator!=(const vtkOverlappingAMRMetaData &other) const
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:29
dynamic, self-adjusting array of double
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
virtual void Initialize(const std::vector< unsigned int > &blocksPerLevel)
Initialize the meta information blocksPerLevel is the number of blocks for each levels.
a simple class to control print indentation
Definition: vtkIndent.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Print members.
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
Get children at a specific level HasChildrenInformation is NOT checked by this method.
Meta data that describes the structure of an overlapping AMR data set.
#define VTK_DOUBLE_MIN
Definition: vtkType.h:201
Meta data that describes the structure of a generic AMR data set.
virtual void DeepCopy(vtkAMRMetaData *other)
Copy internal fields from other into this.
static vtkAMRMetaData * New()