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 =========================================================================*/
30 #ifndef vtkAMRInformation_h
31 #define vtkAMRInformation_h
32 
33 #include "vtkCommonDataModelModule.h" // For export macro
34 #include "vtkObject.h"
35 #include "vtkAMRBox.h" //for storing AMR Boxes
36 #include "vtkSmartPointer.h" //for ivars
37 #include <vector> //for storing AMR Boxes
38 
39 
40 typedef std::vector<vtkAMRBox> vtkAMRBoxList;
41 
43 class vtkIntArray;
44 class vtkDoubleArray;
45 class vtkAMRIndexIterator;
46 
48 {
49 public:
50  static vtkAMRInformation* New();
51  vtkTypeMacro(vtkAMRInformation, vtkObject);
52 
53  void PrintSelf(ostream& os, vtkIndent indent);
54 
55  bool operator==(const vtkAMRInformation& other);
56 
59  void Initialize(int numLevels, const int* blocksPerLevel);
60 
62 
63  vtkGetMacro( GridDescription, int );
64  void SetGridDescription(int description);
66 
68 
70  void GetOrigin( double origin[3] );
71  double* GetOrigin();
72  void SetOrigin(const double* origin);
74 
76 
77  unsigned int GetNumberOfLevels() const
78  { return static_cast<unsigned int>(this->NumBlocks.size()-1);}
80 
82  unsigned int GetNumberOfDataSets(unsigned int level) const;
83 
85 
86  unsigned int GetTotalNumberOfBlocks()
87  { return this->NumBlocks.back();}
89 
91 
92  int GetIndex(unsigned int level, unsigned int id) const
93  { return this->NumBlocks[level] + id;}
95 
97  void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id);
98 
100  const double* GetBounds();
101 
103  void GetBounds(unsigned int level, unsigned int id, double* bb);
104 
106  bool GetOrigin(unsigned int level, unsigned int id, double* origin);
107 
109  void GetSpacing(unsigned int level, double spacing[3]);
110 
111  bool HasSpacing(unsigned int level);
112 
114 
115  void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
116  const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
118 
120  bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
121 
123 
126  int GetAMRBlockSourceIndex(int index);
127  void SetAMRBlockSourceIndex(int index, int sourceId);
129 
136  void GenerateRefinementRatio();
137 
140  bool HasRefinementRatio();
141 
144  void SetRefinementRatio(unsigned int level, int ratio);
145 
147  int GetRefinementRatio(unsigned int level) const;
148 
150  void SetSpacing(unsigned int level,const double* h);
151 
153  bool HasChildrenInformation();
154 
158  unsigned int *GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
159 
163  unsigned int *GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
164 
166  void PrintParentChildInfo(unsigned int level, unsigned int index);
167 
170  void GenerateParentChildInformation();
171 
173  bool Audit();
174 
178  bool FindCell(double q[3],unsigned int level, unsigned int index,int &cellIdx);
179 
181  bool FindGrid(double q[3], int level, unsigned int& gridId);
182 
184  bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
185 
187 
188  const std::vector<int>& GetNumBlocks() const
189  { return this->NumBlocks;}
191 
192  std::vector<std::vector<unsigned int> >& GetChildrenAtLevel(unsigned int i)
193  { return this->AllChildren[i];}
194 
195  void DeepCopy(vtkAMRInformation *other);
196 
197  private:
200  vtkAMRInformation(const vtkAMRInformation&); // Not implemented.
201  void operator=(const vtkAMRInformation&); // Not implemented.
202 
203  bool HasValidOrigin();
204  bool HasValidBounds();
205  void UpdateBounds(const int level, const int id);
206  void AllocateBoxes(unsigned int n);
207  void GenerateBlockLevel();
208  void CalculateParentChildRelationShip( unsigned int level,
209  std::vector<std::vector<unsigned int> >& children,
210  std::vector<std::vector<unsigned int> >& parents );
211 
212  //-------------------------------------------------------------------------
213  // Essential information that determines an AMR structure. Must be copied
214  //-------------------------------------------------------------------------
215  int GridDescription; //example: VTK_XYZ_GRID
216  double Origin[3]; //the origin of the whole data set
217  vtkAMRBoxList Boxes; // vtkAMRBoxes, one per data set
218  std::vector<int> NumBlocks; //NumBlocks[i] stores the total number of blocks from level 0 to level i-1
219 
220  vtkSmartPointer<vtkIntArray> SourceIndex; //Typically, this maps to a file block index used by the reader
221  vtkSmartPointer<vtkDoubleArray> Spacing; //The grid spacing for all levels
222  double Bounds[6]; //the bounds of the entire domain
223 
224  //-------------------------------------------------------------------------
225  // Auxillary information that be computed
226  //-------------------------------------------------------------------------
227  vtkSmartPointer<vtkIntArray> Refinement; //refinement ratio between two adjacent levels
228  vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; //only necessary if need to call ComputeIndexPair
229 
230  //parent child information
231  std::vector<std::vector<std::vector<unsigned int> > > AllChildren;
232  std::vector<std::vector<std::vector<unsigned int> > > AllParents;
233 };
234 
235 #endif
dynamic, self-adjusting array of unsigned int
abstract base class for most VTK objects
Definition: vtkObject.h:61
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:38
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
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:49
virtual void PrintSelf(ostream &os, vtkIndent indent)
Meta data that describes the structure of an AMR data set.
a simple class to control print indentation
Definition: vtkIndent.h:38
unsigned int GetTotalNumberOfBlocks()
unsigned int GetNumberOfLevels() const
int GetIndex(unsigned int level, unsigned int id) const
const std::vector< int > & GetNumBlocks() const
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKWRAPPINGJAVA_EXPORT jlong q(JNIEnv *env, jobject obj)
static vtkObject * New()
#define VTKCOMMONDATAMODEL_EXPORT