VTK
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 "vtkCommonDataModelModule.h" // For export macro
35 #include "vtkObject.h"
36 #include "vtkAMRBox.h" //for storing AMR Boxes
37 #include "vtkSmartPointer.h" //for ivars
38 #include <vector> //for storing AMR Boxes
39 
40 
41 typedef std::vector<vtkAMRBox> vtkAMRBoxList;
42 
44 class vtkIntArray;
45 class vtkDoubleArray;
46 class vtkAMRIndexIterator;
47 
48 class VTKCOMMONDATAMODEL_EXPORT vtkAMRInformation : public vtkObject
49 {
50 public:
52  vtkTypeMacro(vtkAMRInformation, vtkObject);
53 
54  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
55 
56  bool operator==(const vtkAMRInformation& other);
57 
63  void Initialize(int numLevels, const int* blocksPerLevel);
64 
66 
69  vtkGetMacro( GridDescription, int );
72 
74 
78  void GetOrigin( double origin[3] );
79  double* GetOrigin();
80  void SetOrigin(const double* origin);
82 
86  unsigned int GetNumberOfLevels() const
87  { return static_cast<unsigned int>(this->NumBlocks.size()-1);}
88 
92  unsigned int GetNumberOfDataSets(unsigned int level) const;
93 
97  unsigned int GetTotalNumberOfBlocks()
98  { return this->NumBlocks.back();}
99 
103  int GetIndex(unsigned int level, unsigned int id) const
104  { return this->NumBlocks[level] + id;}
105 
109  void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id);
110 
114  const double* GetBounds();
115 
119  void GetBounds(unsigned int level, unsigned int id, double* bb);
120 
124  bool GetOrigin(unsigned int level, unsigned int id, double* origin);
125 
129  void GetSpacing(unsigned int level, double spacing[3]);
130 
131  bool HasSpacing(unsigned int level);
132 
134 
137  void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
138  const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
140 
144  bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
145 
147 
152  void SetAMRBlockSourceIndex(int index, int sourceId);
154 
166 
172 
177  void SetRefinementRatio(unsigned int level, int ratio);
178 
182  int GetRefinementRatio(unsigned int level) const;
183 
187  void SetSpacing(unsigned int level,const double* h);
188 
193 
199  unsigned int *GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
200 
206  unsigned int *GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
207 
211  void PrintParentChildInfo(unsigned int level, unsigned int index);
212 
218 
222  bool Audit();
223 
229  bool FindCell(double q[3],unsigned int level, unsigned int index,int &cellIdx);
230 
234  bool FindGrid(double q[3], int level, unsigned int& gridId);
235 
239  bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
240 
244  const std::vector<int>& GetNumBlocks() const
245  { return this->NumBlocks;}
246 
247  std::vector<std::vector<unsigned int> >& GetChildrenAtLevel(unsigned int i)
248  { return this->AllChildren[i];}
249 
251 
252  private:
254  ~vtkAMRInformation() VTK_OVERRIDE;
255  vtkAMRInformation(const vtkAMRInformation&) VTK_DELETE_FUNCTION;
256  void operator=(const vtkAMRInformation&) VTK_DELETE_FUNCTION;
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> NumBlocks; //NumBlocks[i] stores the total number of blocks from level 0 to level i-1
274 
275  vtkSmartPointer<vtkIntArray> SourceIndex; //Typically, this maps to a file block index used by the reader
276  vtkSmartPointer<vtkDoubleArray> Spacing; //The grid spacing for all levels
277  double Bounds[6]; //the bounds of the entire domain
278 
279  //-------------------------------------------------------------------------
280  // Auxillary information that be computed
281  //-------------------------------------------------------------------------
282  vtkSmartPointer<vtkIntArray> Refinement; //refinement ratio between two adjacent levels
283  vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; //only necessary if need to call ComputeIndexPair
284 
285  //parent child information
286  std::vector<std::vector<std::vector<unsigned int> > > AllChildren;
287  std::vector<std::vector<std::vector<unsigned int> > > AllParents;
288 };
289 
290 #endif
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:40
Meta data that describes the structure of an AMR data set.
unsigned int * GetChildren(unsigned int level, unsigned int index, unsigned int &numChildren)
Return a pointer to Children of a block.
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.
const vtkAMRBox & GetAMRBox(unsigned int level, unsigned int id) const
unsigned int GetNumberOfLevels() const
Return the number of levels.
const std::vector< int > & GetNumBlocks() const
Returns internal arrays.
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.
unsigned int * GetParents(unsigned int level, unsigned int index, unsigned int &numParents)
Return a pointer to Parents of a block.
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)
void ComputeIndexPair(unsigned int index, unsigned int &level, unsigned int &id)
Returns the an index pair given a single index.
const double * GetBounds()
Returns the bounds of the entire domain.
void SetGridDescription(int description)
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)
void PrintParentChildInfo(unsigned int level, unsigned int index)
Prints the parents and children of a requested block (Debug Routine)
bool HasRefinementRatio()
Returns Wether refinement ratio has been set (either by calling GenerateRefinementRatio() or by calli...
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.
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.
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
void GenerateParentChildInformation()
Generate the parent/child relationships - needed to be called before GetParents or GetChildren can be...
void SetOrigin(const double *origin)
double * GetOrigin()
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)
static vtkAMRInformation * New()
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
a simple class to control print indentation
Definition: vtkIndent.h:40
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:46
abstract base class for most VTK objects
Definition: vtkObject.h:60
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned int
@ vector
Definition: vtkX3D.h:237
@ level
Definition: vtkX3D.h:395
@ spacing
Definition: vtkX3D.h:481
@ description
Definition: vtkX3D.h:322
@ index
Definition: vtkX3D.h:246
std::vector< vtkAMRBox > vtkAMRBoxList