VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAMRInformation.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00033 #ifndef vtkAMRInformation_h 00034 #define vtkAMRInformation_h 00035 00036 #include "vtkCommonDataModelModule.h" // For export macro 00037 #include "vtkObject.h" 00038 #include "vtkAMRBox.h" //for storing AMR Boxes 00039 #include "vtkSmartPointer.h" //for ivars 00040 #include <vector> //for storing AMR Boxes 00041 00042 00043 typedef std::vector<vtkAMRBox> vtkAMRBoxList; 00044 00045 class vtkUnsignedIntArray; 00046 class vtkIntArray; 00047 class vtkDoubleArray; 00048 class vtkAMRIndexIterator; 00049 00050 class VTKCOMMONDATAMODEL_EXPORT vtkAMRInformation : public vtkObject 00051 { 00052 public: 00053 static vtkAMRInformation* New(); 00054 vtkTypeMacro(vtkAMRInformation, vtkObject); 00055 00056 void PrintSelf(ostream& os, vtkIndent indent); 00057 00058 bool operator==(const vtkAMRInformation& other); 00059 00062 void Initialize(int numLevels, const int* blocksPerLevel); 00063 00065 00066 vtkGetMacro( GridDescription, int ); 00067 void SetGridDescription(int description); 00069 00071 00073 void GetOrigin( double origin[3] ); 00074 double* GetOrigin(); 00075 void SetOrigin(const double* origin); 00077 00079 00080 unsigned int GetNumberOfLevels() const 00081 { return static_cast<unsigned int>(this->NumBlocks.size()-1);} 00083 00085 unsigned int GetNumberOfDataSets(unsigned int level) const; 00086 00088 00089 unsigned int GetTotalNumberOfBlocks() 00090 { return this->NumBlocks.back();} 00092 00094 00095 int GetIndex(unsigned int level, unsigned int id) const 00096 { return this->NumBlocks[level] + id;} 00098 00100 void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id); 00101 00103 const double* GetBounds(); 00104 00106 void GetBounds(unsigned int level, unsigned int id, double* bb); 00107 00109 bool GetOrigin(unsigned int level, unsigned int id, double* origin); 00110 00112 void GetSpacing(unsigned int level, double spacing[3]); 00113 00114 bool HasSpacing(unsigned int level); 00115 00117 00118 void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box); 00119 const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const; 00121 00123 bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const; 00124 00126 00129 int GetAMRBlockSourceIndex(int index); 00130 void SetAMRBlockSourceIndex(int index, int sourceId); 00132 00139 void GenerateRefinementRatio(); 00140 00143 bool HasRefinementRatio(); 00144 00147 void SetRefinementRatio(unsigned int level, int ratio); 00148 00150 int GetRefinementRatio(unsigned int level) const; 00151 00153 void SetSpacing(unsigned int level,const double* h); 00154 00156 bool HasChildrenInformation(); 00157 00161 unsigned int *GetParents(unsigned int level, unsigned int index, unsigned int& numParents); 00162 00166 unsigned int *GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren); 00167 00169 void PrintParentChildInfo(unsigned int level, unsigned int index); 00170 00173 void GenerateParentChildInformation(); 00174 00176 bool Audit(); 00177 00181 bool FindCell(double q[3],unsigned int level, unsigned int index,int &cellIdx); 00182 00184 bool FindGrid(double q[3], int level, unsigned int& gridId); 00185 00187 bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId); 00188 00190 00191 const std::vector<int>& GetNumBlocks() const 00192 { return this->NumBlocks;} 00194 00195 std::vector<std::vector<unsigned int> >& GetChildrenAtLevel(unsigned int i) 00196 { return this->AllChildren[i];} 00197 00198 void DeepCopy(vtkAMRInformation *other); 00199 00200 private: 00201 vtkAMRInformation(); 00202 ~vtkAMRInformation(); 00203 vtkAMRInformation(const vtkAMRInformation&); // Not implemented. 00204 void operator=(const vtkAMRInformation&); // Not implemented. 00205 00206 bool HasValidOrigin(); 00207 bool HasValidBounds(); 00208 void UpdateBounds(const int level, const int id); 00209 void AllocateBoxes(unsigned int n); 00210 void GenerateBlockLevel(); 00211 void CalculateParentChildRelationShip( unsigned int level, 00212 std::vector<std::vector<unsigned int> >& children, 00213 std::vector<std::vector<unsigned int> >& parents ); 00214 00215 //------------------------------------------------------------------------- 00216 // Essential information that determines an AMR structure. Must be copied 00217 //------------------------------------------------------------------------- 00218 int GridDescription; //example: VTK_XYZ_GRID 00219 double Origin[3]; //the origin of the whole data set 00220 vtkAMRBoxList Boxes; // vtkAMRBoxes, one per data set 00221 std::vector<int> NumBlocks; //NumBlocks[i] stores the total number of blocks from level 0 to level i-1 00222 00223 vtkSmartPointer<vtkIntArray> SourceIndex; //Typically, this maps to a file block index used by the reader 00224 vtkSmartPointer<vtkDoubleArray> Spacing; //The grid spacing for all levels 00225 double Bounds[6]; //the bounds of the entire domain 00226 00227 //------------------------------------------------------------------------- 00228 // Auxillary information that be computed 00229 //------------------------------------------------------------------------- 00230 vtkSmartPointer<vtkIntArray> Refinement; //refinement ratio between two adjacent levels 00231 vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; //only necessary if need to call ComputeIndexPair 00232 00233 //parent child information 00234 std::vector<std::vector<std::vector<unsigned int> > > AllChildren; 00235 std::vector<std::vector<std::vector<unsigned int> > > AllParents; 00236 }; 00237 00238 #endif