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:
51  static vtkAMRInformation* New();
52  vtkTypeMacro(vtkAMRInformation, vtkObject);
53 
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
56  bool operator==(const vtkAMRInformation& other);
57 
63  void Initialize(int numLevels, const int* blocksPerLevel);
64 
66 
69  vtkGetMacro( GridDescription, int );
70  void SetGridDescription(int description);
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 
151  int GetAMRBlockSourceIndex(int index);
152  void SetAMRBlockSourceIndex(int index, int sourceId);
154 
165  void GenerateRefinementRatio();
166 
171  bool HasRefinementRatio();
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 
192  bool HasChildrenInformation();
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 
217  void GenerateParentChildInformation();
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 
250  void DeepCopy(vtkAMRInformation *other);
251 
252  private:
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> 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  // Auxiliary 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
dynamic, self-adjusting array of unsigned int
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:39
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
std::vector< vtkAMRBox > vtkAMRBoxList
dynamic, self-adjusting array of double
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
Meta data that describes the structure of an AMR data set.
a simple class to control print indentation
Definition: vtkIndent.h:39
unsigned int GetTotalNumberOfBlocks()
Returns total number of datasets.
unsigned int GetNumberOfLevels() const
Return the number of levels.
int GetIndex(unsigned int level, unsigned int id) const
Returns the single index from a pair of indices.
const std::vector< int > & GetNumBlocks() const
Returns internal arrays.
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...