VTK  9.5.20250625
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
17#ifndef vtkOverlappingAMRMetaData_h
18#define vtkOverlappingAMRMetaData_h
19
20#include "vtkAMRBox.h" //for storing AMR Boxes
21#include "vtkAMRMetaData.h"
22#include "vtkCommonDataModelModule.h" // For export macro
23#include "vtkSmartPointer.h" //for ivars
24
25VTK_ABI_NAMESPACE_BEGIN
26class vtkIntArray;
27class vtkDoubleArray;
28class VTKCOMMONDATAMODEL_EXPORT vtkOverlappingAMRMetaData : public vtkAMRMetaData
29{
30public:
33
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35 bool operator==(const vtkOverlappingAMRMetaData& other) const;
36
42 void Initialize(int numLevels, const int* blocksPerLevel) override;
43
45
49 void GetOrigin(double origin[3]);
50 [[nodiscard]] double* GetOrigin();
51 void SetOrigin(const double* origin);
53
57 [[nodiscard]] const double* GetBounds();
58
62 void GetBounds(unsigned int level, unsigned int id, double* bb);
63
68 bool GetOrigin(unsigned int level, unsigned int id, double* origin);
69
73 void GetSpacing(unsigned int level, double spacing[3]);
74
78 [[nodiscard]] bool HasSpacing(unsigned int level);
79
81
84 void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
85 [[nodiscard]] const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
87
91 bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
92
94
98 [[nodiscard]] int GetAMRBlockSourceIndex(int index);
99 void SetAMRBlockSourceIndex(int index, int sourceId);
101
112
117 [[nodiscard]] bool HasRefinementRatio();
118
123 void SetRefinementRatio(unsigned int level, int ratio);
124
128 [[nodiscard]] int GetRefinementRatio(unsigned int level) const;
129
133 void SetSpacing(unsigned int level, const double* h);
134
138 [[nodiscard]] bool HasChildrenInformation();
139
145 unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
146
152 unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
153
157 void PrintParentChildInfo(unsigned int level, unsigned int index);
158
164
168 [[nodiscard]] bool CheckValidity();
169
175 bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
176
180 bool FindGrid(double q[3], int level, unsigned int& gridId);
181
185 bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
186
190 [[nodiscard]] std::vector<std::vector<unsigned int>>& GetChildrenAtLevel(unsigned int i)
191 {
192 return this->AllChildren[i];
193 }
194
200
201protected:
204
205private:
207 void operator=(const vtkOverlappingAMRMetaData&) = delete;
208
209 bool HasValidOrigin();
210 bool HasValidBounds();
211 void UpdateBounds(int level, int id);
212 void AllocateBoxes(unsigned int n);
213 void CalculateParentChildRelationShip(unsigned int level,
214 std::vector<std::vector<unsigned int>>& children,
215 std::vector<std::vector<unsigned int>>& parents);
216
217 //-------------------------------------------------------------------------
218 // Essential information that determines an AMR structure. Must be copied
219 //-------------------------------------------------------------------------
220 double Origin[3]; // the origin of the whole data set
221
222 std::vector<vtkAMRBox> Boxes; // vtkAMRBoxes, one per data set
223
225 SourceIndex; // Typically, this maps to a file block index used by the reader
226 vtkSmartPointer<vtkDoubleArray> Spacing; // The grid spacing for all levels
227 double Bounds[6]; // the bounds of the entire domain
228
229 //-------------------------------------------------------------------------
230 // Auxiliary information that be computed
231 //-------------------------------------------------------------------------
232 vtkSmartPointer<vtkIntArray> Refinement; // refinement ratio between two adjacent levels
233
234 // parent child information
235 std::vector<std::vector<std::vector<unsigned int>>> AllChildren;
236 std::vector<std::vector<std::vector<unsigned int>>> AllParents;
237};
238
239VTK_ABI_NAMESPACE_END
240#endif
Encloses a rectangular region of voxel like cells.
Definition vtkAMRBox.h:68
Meta data that describes the structure of a generic AMR data set.
virtual void DeepCopy(vtkAMRMetaData *other)
Copy internal fields from other into this.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
dynamic, self-adjusting array of int
Meta data that describes the structure of an overlapping AMR data set.
void SetAMRBlockSourceIndex(int index, int sourceId)
Get/Set the SourceIndex of a block.
const double * GetBounds()
Returns the bounds of the entire domain as a 6 sized array.
int GetRefinementRatio(unsigned int level) const
Returns the refinement of a given level.
void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox &box)
Methods to set and get the AMR box at a given position.
bool CheckValidity()
Checks whether the meta data is internally consistent.
void SetSpacing(unsigned int level, const double *h)
Set the spacing at a given level.
bool FindGrid(double q[3], int level, unsigned int &gridId)
find the grid that contains the point q at the specified level
bool HasSpacing(unsigned int level)
Return if a specific level has spacing.
unsigned int * GetParents(unsigned int level, unsigned int index, unsigned int &numParents)
Return a pointer to Parents of a block.
void PrintParentChildInfo(unsigned int level, unsigned int index)
Prints the parents and children of a requested block (Debug Routine)
void GetOrigin(double origin[3])
Get the AMR dataset origin as a 3 sized array The origin is essentially the minimum of all the grids.
unsigned int * GetChildren(unsigned int level, unsigned int index, unsigned int &numChildren)
Return a pointer to Children of a block.
void SetRefinementRatio(unsigned int level, int ratio)
Set the refinement ratio at a level.
double * GetOrigin()
Get the AMR dataset origin as a 3 sized array The origin is essentially the minimum of all the grids.
bool FindGrid(double q[3], unsigned int &level, unsigned int &gridId)
Given a point q, find the highest level grid that contains it.
static vtkOverlappingAMRMetaData * New()
bool operator==(const vtkOverlappingAMRMetaData &other) const
void DeepCopy(vtkOverlappingAMRMetaData *other)
Copy internal fields from other into this.
bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box) const
return the amr box coarsened to the previous level
void GetSpacing(unsigned int level, double spacing[3])
Return the spacing at the given fiven.
bool FindCell(double q[3], unsigned int level, unsigned int index, int &cellIdx)
Given a point q, find whether q is bounded by the data set at (level,index).
bool HasChildrenInformation()
Return whether parent child information has been generated.
void PrintSelf(ostream &os, vtkIndent indent) override
Print members.
void GetBounds(unsigned int level, unsigned int id, double *bb)
Returns the bounding box of a given box.
void GenerateRefinementRatio()
This method computes the refinement ratio at each level.
void GenerateParentChildInformation()
Generate the parent/child relationships - needed to be called before GetParents or GetChildren can be...
const vtkAMRBox & GetAMRBox(unsigned int level, unsigned int id) const
Methods to set and get the AMR box at a given position.
~vtkOverlappingAMRMetaData() override
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
Get children at a specific level.
bool GetOrigin(unsigned int level, unsigned int id, double *origin)
Recover the origin of the grid at (level,id).
int GetAMRBlockSourceIndex(int index)
Get/Set the SourceIndex of a block.
bool HasRefinementRatio()
Returns whether refinement ratio has been set (either by calling GenerateRefinementRatio() or by call...
void SetOrigin(const double *origin)
Get the AMR dataset origin as a 3 sized array The origin is essentially the minimum of all the grids.
void Initialize(int numLevels, const int *blocksPerLevel) override
Initialize the meta information numLevels is the number of levels blocksPerLevel[i] is the number of ...
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.