VTK  9.1.0
vtkAMRInformation.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAMRInformation.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
31#ifndef vtkAMRInformation_h
32#define vtkAMRInformation_h
33
34#include "vtkAMRBox.h" //for storing AMR Boxes
35#include "vtkCommonDataModelModule.h" // For export macro
36#include "vtkObject.h"
37#include "vtkSmartPointer.h" //for ivars
38#include <vector> //for storing AMR Boxes
39
40typedef std::vector<vtkAMRBox> vtkAMRBoxList;
41
43class vtkIntArray;
44class vtkDoubleArray;
45class vtkAMRIndexIterator;
46
47class VTKCOMMONDATAMODEL_EXPORT vtkAMRInformation : public vtkObject
48{
49public:
52
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
55 bool operator==(const vtkAMRInformation& other);
56
62 void Initialize(int numLevels, const int* blocksPerLevel);
63
65
68 vtkGetMacro(GridDescription, int);
69 void SetGridDescription(int description);
71
73
77 void GetOrigin(double origin[3]);
78 double* GetOrigin();
79 void SetOrigin(const double* origin);
81
85 unsigned int GetNumberOfLevels() const
86 {
87 return static_cast<unsigned int>(this->NumBlocks.size() - 1);
88 }
89
93 unsigned int GetNumberOfDataSets(unsigned int level) const;
94
98 unsigned int GetTotalNumberOfBlocks() { return this->NumBlocks.back(); }
99
103 int GetIndex(unsigned int level, unsigned int id) const { return this->NumBlocks[level] + id; }
104
108 void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id);
109
113 const double* GetBounds();
114
118 void GetBounds(unsigned int level, unsigned int id, double* bb);
119
123 bool GetOrigin(unsigned int level, unsigned int id, double* origin);
124
128 void GetSpacing(unsigned int level, double spacing[3]);
129
130 bool HasSpacing(unsigned int level);
131
133
136 void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
137 const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
139
143 bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
144
146
151 void SetAMRBlockSourceIndex(int index, int sourceId);
153
165
171
176 void SetRefinementRatio(unsigned int level, int ratio);
177
181 int GetRefinementRatio(unsigned int level) const;
182
186 void SetSpacing(unsigned int level, const double* h);
187
192
198 unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
199
205 unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
206
210 void PrintParentChildInfo(unsigned int level, unsigned int index);
211
217
221 bool Audit();
222
228 bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
229
233 bool FindGrid(double q[3], int level, unsigned int& gridId);
234
238 bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
239
243 const std::vector<int>& GetNumBlocks() const { return this->NumBlocks; }
244
245 std::vector<std::vector<unsigned int>>& GetChildrenAtLevel(unsigned int i)
246 {
247 return this->AllChildren[i];
248 }
249
251
252private:
254 ~vtkAMRInformation() override;
255 vtkAMRInformation(const vtkAMRInformation&) = delete;
256 void operator=(const vtkAMRInformation&) = delete;
257
258 bool HasValidOrigin();
259 bool HasValidBounds();
260 void UpdateBounds(const int level, const int id);
261 void AllocateBoxes(unsigned int n);
262 void GenerateBlockLevel();
263 void CalculateParentChildRelationShip(unsigned int level,
264 std::vector<std::vector<unsigned int>>& children,
265 std::vector<std::vector<unsigned int>>& parents);
266
267 //-------------------------------------------------------------------------
268 // Essential information that determines an AMR structure. Must be copied
269 //-------------------------------------------------------------------------
270 int GridDescription; // example: VTK_XYZ_GRID
271 double Origin[3]; // the origin of the whole data set
272 vtkAMRBoxList Boxes; // vtkAMRBoxes, one per data set
273 std::vector<int>
274 NumBlocks; // NumBlocks[i] stores the total number of blocks from level 0 to level i-1
275
277 SourceIndex; // Typically, this maps to a file block index used by the reader
278 vtkSmartPointer<vtkDoubleArray> Spacing; // The grid spacing for all levels
279 double Bounds[6]; // the bounds of the entire domain
280
281 //-------------------------------------------------------------------------
282 // Auxiliary information that be computed
283 //-------------------------------------------------------------------------
284 vtkSmartPointer<vtkIntArray> Refinement; // refinement ratio between two adjacent levels
285 vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; // only necessary if need to call
286 // ComputeIndexPair
287
288 // parent child information
289 std::vector<std::vector<std::vector<unsigned int>>> AllChildren;
290 std::vector<std::vector<std::vector<unsigned int>>> AllParents;
291};
292
293#endif
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:73
Meta data that describes the structure of an AMR data set.
const std::vector< int > & GetNumBlocks() const
Returns internal arrays.
void GenerateRefinementRatio()
This method computes the refinement ratio at each level.
bool FindGrid(double q[3], int level, unsigned int &gridId)
find the grid that contains the point q at the specified level
int GetAMRBlockSourceIndex(int index)
Get/Set the SourceIndex of a block.
unsigned int GetNumberOfLevels() const
Return the number of levels.
bool Audit()
Checks whether the meta data is internally consistent.
unsigned int GetNumberOfDataSets(unsigned int level) const
Returns the number of datasets at the given levelx.
static vtkAMRInformation * New()
bool operator==(const vtkAMRInformation &other)
bool HasSpacing(unsigned int level)
void SetRefinementRatio(unsigned int level, int ratio)
Set the refinement ratio at a level.
int GetIndex(unsigned int level, unsigned int id) const
Returns the single index from a pair of indices.
void SetAMRBlockSourceIndex(int index, int sourceId)
Get/Set the SourceIndex of a block.
double * GetOrigin()
Get the AMR dataset origin The origin is essentially the minimum of all the grids.
void ComputeIndexPair(unsigned int index, unsigned int &level, unsigned int &id)
Returns the an index pair given a single index.
unsigned int * GetParents(unsigned int level, unsigned int index, unsigned int &numParents)
Return a pointer to Parents of a block.
void SetGridDescription(int description)
returns the value of vtkUniformGrid::GridDescription() of any block
void Initialize(int numLevels, const int *blocksPerLevel)
Initialize the meta information numLevels is the number of levels blocksPerLevel[i] is the number of ...
bool HasChildrenInformation()
Return whether parent child information has been generated.
void DeepCopy(vtkAMRInformation *other)
const vtkAMRBox & GetAMRBox(unsigned int level, unsigned int id) const
Methods to set and get the AMR box at a given position.
void PrintParentChildInfo(unsigned int level, unsigned int index)
Prints the parents and children of a requested block (Debug Routine)
bool HasRefinementRatio()
Returns whether refinement ratio has been set (either by calling GenerateRefinementRatio() or by call...
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
unsigned int * GetChildren(unsigned int level, unsigned int index, unsigned int &numChildren)
Return a pointer to Children of a block.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetOrigin(double origin[3])
Get the AMR dataset origin The origin is essentially the minimum of all the grids.
void GetBounds(unsigned int level, unsigned int id, double *bb)
Returns the bounding box of a given box.
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).
void GetSpacing(unsigned int level, double spacing[3])
Return the spacing at the given fiven.
const double * GetBounds()
Returns the bounds of the entire domain.
bool FindGrid(double q[3], unsigned int &level, unsigned int &gridId)
Given a point q, find the highest level grid that contains it.
int GetRefinementRatio(unsigned int level) const
Returns the refinement of a given level.
bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box) const
return the amr box coarsened to the previous level
unsigned int GetTotalNumberOfBlocks()
Returns total number of datasets.
void GenerateParentChildInformation()
Generate the parent/child relationships - needed to be called before GetParents or GetChildren can be...
void SetOrigin(const double *origin)
Get the AMR dataset origin The origin is essentially the minimum of all the grids.
void SetSpacing(unsigned int level, const double *h)
Set the spacing at a given level.
bool GetOrigin(unsigned int level, unsigned int id, double *origin)
Returns the origin of the grid at (level,id)
void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox &box)
Methods to set and get the AMR box at a given position.
dynamic, self-adjusting array of double
vtkFrustumSelector is a vtkSelector that selects elements based on whether they are inside or interse...
a simple class to control print indentation
Definition: vtkIndent.h:113
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:149
abstract base class for most VTK objects
Definition: vtkObject.h:82
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned int
std::vector< vtkAMRBox > vtkAMRBoxList