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 =========================================================================*/
33 #ifndef vtkAMRInformation_h
34 #define vtkAMRInformation_h
35 
36 #include "vtkCommonDataModelModule.h" // For export macro
37 #include "vtkObject.h"
38 #include "vtkAMRBox.h" //for storing AMR Boxes
39 #include "vtkSmartPointer.h" //for ivars
40 #include <vector> //for storing AMR Boxes
41 
42 
43 typedef std::vector<vtkAMRBox> vtkAMRBoxList;
44 
46 class vtkIntArray;
47 class vtkDoubleArray;
48 class vtkAMRIndexIterator;
49 
51 {
52 public:
53  static vtkAMRInformation* New();
54  vtkTypeMacro(vtkAMRInformation, vtkObject);
55 
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
58  bool operator==(const vtkAMRInformation& other);
59 
62  void Initialize(int numLevels, const int* blocksPerLevel);
63 
65 
66  vtkGetMacro( GridDescription, int );
67  void SetGridDescription(int description);
69 
71 
73  void GetOrigin( double origin[3] );
74  double* GetOrigin();
75  void SetOrigin(const double* origin);
77 
79 
80  unsigned int GetNumberOfLevels() const
81  { return static_cast<unsigned int>(this->NumBlocks.size()-1);}
83 
85  unsigned int GetNumberOfDataSets(unsigned int level) const;
86 
88 
89  unsigned int GetTotalNumberOfBlocks()
90  { return this->NumBlocks.back();}
92 
94 
95  int GetIndex(unsigned int level, unsigned int id) const
96  { return this->NumBlocks[level] + id;}
98 
100  void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id);
101 
103  const double* GetBounds();
104 
106  void GetBounds(unsigned int level, unsigned int id, double* bb);
107 
109  bool GetOrigin(unsigned int level, unsigned int id, double* origin);
110 
112  void GetSpacing(unsigned int level, double spacing[3]);
113 
114  bool HasSpacing(unsigned int level);
115 
117 
118  void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
119  const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
121 
123  bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
124 
126 
129  int GetAMRBlockSourceIndex(int index);
130  void SetAMRBlockSourceIndex(int index, int sourceId);
132 
139  void GenerateRefinementRatio();
140 
143  bool HasRefinementRatio();
144 
147  void SetRefinementRatio(unsigned int level, int ratio);
148 
150  int GetRefinementRatio(unsigned int level) const;
151 
153  void SetSpacing(unsigned int level,const double* h);
154 
156  bool HasChildrenInformation();
157 
161  unsigned int *GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
162 
166  unsigned int *GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
167 
169  void PrintParentChildInfo(unsigned int level, unsigned int index);
170 
173  void GenerateParentChildInformation();
174 
176  bool Audit();
177 
181  bool FindCell(double q[3],unsigned int level, unsigned int index,int &cellIdx);
182 
184  bool FindGrid(double q[3], int level, unsigned int& gridId);
185 
187  bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
188 
190 
191  const std::vector<int>& GetNumBlocks() const
192  { return this->NumBlocks;}
194 
195  std::vector<std::vector<unsigned int> >& GetChildrenAtLevel(unsigned int i)
196  { return this->AllChildren[i];}
197 
198  void DeepCopy(vtkAMRInformation *other);
199 
200  private:
203  vtkAMRInformation(const vtkAMRInformation&); // Not implemented.
204  void operator=(const vtkAMRInformation&); // Not implemented.
205 
206  bool HasValidOrigin();
207  bool HasValidBounds();
208  void UpdateBounds(const int level, const int id);
209  void AllocateBoxes(unsigned int n);
210  void GenerateBlockLevel();
211  void CalculateParentChildRelationShip( unsigned int level,
212  std::vector<std::vector<unsigned int> >& children,
213  std::vector<std::vector<unsigned int> >& parents );
214 
215  //-------------------------------------------------------------------------
216  // Essential information that determines an AMR structure. Must be copied
217  //-------------------------------------------------------------------------
218  int GridDescription; //example: VTK_XYZ_GRID
219  double Origin[3]; //the origin of the whole data set
220  vtkAMRBoxList Boxes; // vtkAMRBoxes, one per data set
221  std::vector<int> NumBlocks; //NumBlocks[i] stores the total number of blocks from level 0 to level i-1
222 
223  vtkSmartPointer<vtkIntArray> SourceIndex; //Typically, this maps to a file block index used by the reader
224  vtkSmartPointer<vtkDoubleArray> Spacing; //The grid spacing for all levels
225  double Bounds[6]; //the bounds of the entire domain
226 
227  //-------------------------------------------------------------------------
228  // Auxillary information that be computed
229  //-------------------------------------------------------------------------
230  vtkSmartPointer<vtkIntArray> Refinement; //refinement ratio between two adjacent levels
231  vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; //only necessary if need to call ComputeIndexPair
232 
233  //parent child information
234  std::vector<std::vector<std::vector<unsigned int> > > AllChildren;
235  std::vector<std::vector<std::vector<unsigned int> > > AllParents;
236 };
237 
238 #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