VTK  9.5.20250810
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
20#ifndef vtkOverlappingAMRMetaData_h
21#define vtkOverlappingAMRMetaData_h
22
23#include "vtkAMRBox.h" //for storing AMR Boxes
24#include "vtkAMRMetaData.h"
25#include "vtkCommonDataModelModule.h" // For export macro
26#include "vtkSmartPointer.h" //for ivars
27
28VTK_ABI_NAMESPACE_BEGIN
29class vtkIntArray;
30class vtkDoubleArray;
31class VTKCOMMONDATAMODEL_EXPORT vtkOverlappingAMRMetaData : public vtkAMRMetaData
32{
33public:
36
37 void PrintSelf(ostream& os, vtkIndent indent) override;
38 bool operator==(const vtkOverlappingAMRMetaData& other) const;
39 bool operator!=(const vtkOverlappingAMRMetaData& other) const { return !(*this == other); }
40
41 // VTK_DEPRECATED_IN_9_6_0
42 // Remove once the deprecated Initialize method in parent class is removed
44
49 void Initialize(const std::vector<unsigned int>& blocksPerLevel) override;
50
52
56 void GetOrigin(double origin[3]);
57 [[nodiscard]] double* GetOrigin();
58 void SetOrigin(const double* origin);
60
64 [[nodiscard]] const double* GetBounds();
65
69 void GetBounds(unsigned int level, unsigned int id, double* bb);
70
75 bool GetOrigin(unsigned int level, unsigned int id, double* origin);
76
80 void GetSpacing(unsigned int level, double spacing[3]);
81
85 [[nodiscard]] bool HasSpacing(unsigned int level);
86
88
91 void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
92 [[nodiscard]] const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
94
98 bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
99
101
105 [[nodiscard]] int GetAMRBlockSourceIndex(int index);
106 void SetAMRBlockSourceIndex(int index, int sourceId);
108
119
124 [[nodiscard]] bool HasRefinementRatio();
125
130 void SetRefinementRatio(unsigned int level, int ratio);
131
136 [[nodiscard]] int GetRefinementRatio(unsigned int level) const;
137
141 void SetSpacing(unsigned int level, const double* h);
142
146 [[nodiscard]] bool HasChildrenInformation();
147
153 unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
154
160 unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
161
165 void PrintParentChildInfo(unsigned int level, unsigned int index);
166
172
176 [[nodiscard]] bool CheckValidity();
177
183 bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
184
188 bool FindGrid(double q[3], int level, unsigned int& gridId);
189
193 bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
194
198 [[nodiscard]] std::vector<std::vector<unsigned int>>& GetChildrenAtLevel(unsigned int i)
199 {
200 return this->AllChildren[i];
201 }
202
207 void DeepCopy(vtkAMRMetaData* other) override;
208
209protected:
212
213private:
215 void operator=(const vtkOverlappingAMRMetaData&) = delete;
216
217 bool HasValidOrigin();
218 bool HasValidBounds();
219 void UpdateBounds(int level, int id);
220 void AllocateBoxes(unsigned int n);
221 void CalculateParentChildRelationShip(unsigned int level,
222 std::vector<std::vector<unsigned int>>& children,
223 std::vector<std::vector<unsigned int>>& parents);
224
225 //-------------------------------------------------------------------------
226 // Essential information that determines an AMR structure. Must be copied
227 //-------------------------------------------------------------------------
228
229 // the origin of the whole data set
230 double Origin[3] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX };
231
232 // vtkAMRBoxes, one per data set
233 std::vector<vtkAMRBox> Boxes;
234
235 // Typically, this maps to a file block index used by the reader
237
238 // The grid spacing for all levels
240
241 // the bounds of the entire domain
244
245 //-------------------------------------------------------------------------
246 // Auxiliary information that be computed
247 //-------------------------------------------------------------------------
248
249 // refinement ratio between two adjacent levels
250 vtkNew<vtkIntArray> Refinement;
251
252 // parent child information
253 std::vector<std::vector<std::vector<unsigned int>>> AllChildren;
254 std::vector<std::vector<std::vector<unsigned int>>> AllParents;
255};
256
257VTK_ABI_NAMESPACE_END
258#endif
Encloses a rectangular region of voxel like cells.
Definition vtkAMRBox.h:69
Meta data that describes the structure of a generic AMR data set.
virtual void Initialize(const std::vector< unsigned int > &blocksPerLevel)
Initialize the meta information blocksPerLevel is the number of blocks for each levels.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
dynamic, self-adjusting array of int
Allocate and hold a VTK object.
Definition vtkNew.h:167
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)
Generate if needed and prints the parents and children of a requested block (Debug Routine)
void Initialize(const std::vector< unsigned int > &blocksPerLevel) override
Initialize the meta information blocksPerLevels is the number of blocks for each level.
void GetOrigin(double origin[3])
Get the AMR block 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 block 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
bool operator!=(const vtkOverlappingAMRMetaData &other) const
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.
void DeepCopy(vtkAMRMetaData *other) override
Check it is an vtkOverlappingAMRMetaData and copy internal fields from other into this.
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 block origin as a 3 sized array The origin is essentially the minimum of all the grids.
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.
#define VTK_DOUBLE_MIN
Definition vtkType.h:170
#define VTK_DOUBLE_MAX
Definition vtkType.h:171