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:
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 );
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 
130  void SetAMRBlockSourceIndex(int index, int sourceId);
132 
140 
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 
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 
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 
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
vtkAMRBox
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:39
vtkX3D::vector
@ vector
Definition: vtkX3D.h:237
vtkgl::id
GLuint id
Definition: vtkgl.h:11834
vtkAMRInformation::SetAMRBlockSourceIndex
void SetAMRBlockSourceIndex(int index, int sourceId)
vtkgl::h
GLfloat GLfloat GLfloat GLfloat h
Definition: vtkgl.h:14364
vtkCommonDataModelModule.h
vtkAMRInformation::SetSpacing
void SetSpacing(unsigned int level, const double *h)
vtkUnsignedIntArray
dynamic, self-adjusting array of unsigned int
Definition: vtkUnsignedIntArray.h:50
vtkAMRInformation
Meta data that describes the structure of an AMR data set.
Definition: vtkAMRInformation.h:51
vtkAMRInformation::GetChildrenAtLevel
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
Definition: vtkAMRInformation.h:195
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkSmartPointer< vtkIntArray >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkAMRInformation::GenerateParentChildInformation
void GenerateParentChildInformation()
vtkAMRInformation::Audit
bool Audit()
vtkAMRInformation::GetChildren
unsigned int * GetChildren(unsigned int level, unsigned int index, unsigned int &numChildren)
vtkAMRInformation::SetGridDescription
void SetGridDescription(int description)
vtkAMRInformation::GetNumberOfLevels
unsigned int GetNumberOfLevels() const
Definition: vtkAMRInformation.h:80
vtkAMRInformation::HasChildrenInformation
bool HasChildrenInformation()
vtkAMRInformation::GetOrigin
void GetOrigin(double origin[3])
vtkAMRInformation::GetNumberOfDataSets
unsigned int GetNumberOfDataSets(unsigned int level) const
vtkAMRInformation::ComputeIndexPair
void ComputeIndexPair(unsigned int index, unsigned int &level, unsigned int &id)
vtkAMRBoxList
std::vector< vtkAMRBox > vtkAMRBoxList
Definition: vtkAMRInformation.h:43
vtkAMRInformation::GenerateRefinementRatio
void GenerateRefinementRatio()
vtkAMRInformation::operator==
bool operator==(const vtkAMRInformation &other)
vtkAMRInformation::GetNumBlocks
const std::vector< int > & GetNumBlocks() const
Definition: vtkAMRInformation.h:191
vtkAMRInformation::FindCell
bool FindCell(double q[3], unsigned int level, unsigned int index, int &cellIdx)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkAMRInformation::SetRefinementRatio
void SetRefinementRatio(unsigned int level, int ratio)
vtkAMRInformation::PrintParentChildInfo
void PrintParentChildInfo(unsigned int level, unsigned int index)
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:53
vtkAMRInformation::SetAMRBox
void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox &box)
vtkSmartPointer.h
vtkAMRInformation::GetTotalNumberOfBlocks
unsigned int GetTotalNumberOfBlocks()
Definition: vtkAMRInformation.h:89
vtkAMRInformation::New
static vtkAMRInformation * New()
vtkAMRInformation::FindGrid
bool FindGrid(double q[3], unsigned int &level, unsigned int &gridId)
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkgl::level
GLint level
Definition: vtkgl.h:11316
vtkAMRInformation::HasRefinementRatio
bool HasRefinementRatio()
vtkObject.h
vtkAMRInformation::GetIndex
int GetIndex(unsigned int level, unsigned int id) const
Definition: vtkAMRInformation.h:95
vtkX3D::spacing
@ spacing
Definition: vtkX3D.h:481
vtkAMRInformation::GetBounds
const double * GetBounds()
vtkgl::index
GLuint index
Definition: vtkgl.h:11983
vtkAMRInformation::GetAMRBlockSourceIndex
int GetAMRBlockSourceIndex(int index)
vtkAMRInformation::GetOrigin
double * GetOrigin()
vtkAMRInformation::GetRefinementRatio
int GetRefinementRatio(unsigned int level) const
vtkAMRBox.h
vtkX3D::description
@ description
Definition: vtkX3D.h:322
vtkAMRInformation::GetCoarsenedAMRBox
bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box) const
vtkAMRInformation::GetAMRBox
const vtkAMRBox & GetAMRBox(unsigned int level, unsigned int id) const
vtkAMRInformation::GetBounds
void GetBounds(unsigned int level, unsigned int id, double *bb)
vtkAMRInformation::SetOrigin
void SetOrigin(const double *origin)
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:49
vtkAMRInformation::GetSpacing
void GetSpacing(unsigned int level, double spacing[3])
VTKCOMMONDATAMODEL_EXPORT
#define VTKCOMMONDATAMODEL_EXPORT
Definition: vtkCommonDataModelModule.h:15
vtkAMRInformation::DeepCopy
void DeepCopy(vtkAMRInformation *other)
vtkAMRInformation::FindGrid
bool FindGrid(double q[3], int level, unsigned int &gridId)
q
VTKWRAPPINGJAVA_EXPORT jlong q(JNIEnv *env, jobject obj)
vtkAMRInformation::Initialize
void Initialize(int numLevels, const int *blocksPerLevel)
vtkAMRInformation::HasSpacing
bool HasSpacing(unsigned int level)
vtkAMRInformation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkAMRInformation::GetOrigin
bool GetOrigin(unsigned int level, unsigned int id, double *origin)
vtkAMRInformation::GetParents
unsigned int * GetParents(unsigned int level, unsigned int index, unsigned int &numParents)