VTK
dox/Common/DataModel/vtkAMRInformation.h
Go to the documentation of this file.
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 =========================================================================*/
00030 #ifndef __vtkAMRInformation_h
00031 #define __vtkAMRInformation_h
00032 
00033 #include "vtkCommonDataModelModule.h" // For export macro
00034 #include "vtkObject.h"
00035 #include "vtkAMRBox.h" //for storing AMR Boxes
00036 #include "vtkSmartPointer.h" //for ivars
00037 #include <vector> //for storing AMR Boxes
00038 
00039 
00040 typedef std::vector<vtkAMRBox> vtkAMRBoxList;
00041 
00042 class vtkUnsignedIntArray;
00043 class vtkIntArray;
00044 class vtkDoubleArray;
00045 class vtkAMRIndexIterator;
00046 
00047 class VTKCOMMONDATAMODEL_EXPORT vtkAMRInformation : public vtkObject
00048 {
00049 public:
00050   static vtkAMRInformation* New();
00051   vtkTypeMacro(vtkAMRInformation, vtkObject);
00052 
00053   void PrintSelf(ostream& os, vtkIndent indent);
00054 
00055   bool operator==(const vtkAMRInformation& other);
00056 
00059   void Initialize(int numLevels, const int* blocksPerLevel);
00060 
00062 
00063   vtkGetMacro( GridDescription, int );
00064   void SetGridDescription(int description);
00066 
00068 
00070   void GetOrigin( double origin[3] );
00071   double* GetOrigin();
00072   void SetOrigin(const double* origin);
00074 
00076 
00077   unsigned int GetNumberOfLevels() const
00078   { return static_cast<unsigned int>(this->NumBlocks.size()-1);}
00080 
00082   unsigned int GetNumberOfDataSets(unsigned int level) const;
00083 
00085 
00086   unsigned int GetTotalNumberOfBlocks()
00087   { return this->NumBlocks.back();}
00089 
00091 
00092   int GetIndex(unsigned int level, unsigned int id) const
00093   { return this->NumBlocks[level] + id;}
00095 
00097   void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id);
00098 
00100   const double* GetBounds();
00101 
00103   void GetBounds(unsigned int level, unsigned int id, double* bb);
00104 
00106   bool GetOrigin(unsigned int level, unsigned int id, double* origin);
00107 
00109   void GetSpacing(unsigned int level, double spacing[3]);
00110 
00111   bool HasSpacing(unsigned int level);
00112 
00114 
00115   void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
00116   const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
00118 
00120   bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
00121 
00123 
00126   int GetAMRBlockSourceIndex(int index);
00127   void SetAMRBlockSourceIndex(int index, int sourceId);
00129 
00136   void GenerateRefinementRatio();
00137 
00140   bool HasRefinementRatio();
00141 
00144   void SetRefinementRatio(unsigned int level, int ratio);
00145 
00147   int GetRefinementRatio(unsigned int level) const;
00148 
00150   void SetSpacing(unsigned int level,const double* h);
00151 
00153   bool HasChildrenInformation();
00154 
00158   unsigned int *GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
00159 
00163   unsigned int *GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
00164 
00166   void PrintParentChildInfo(unsigned int level, unsigned int index);
00167 
00170   void GenerateParentChildInformation();
00171 
00173   bool Audit();
00174 
00178   bool FindCell(double q[3],unsigned int level, unsigned int index,int &cellIdx);
00179 
00181   bool FindGrid(double q[3], int level, unsigned int& gridId);
00182 
00184   bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
00185 
00187 
00188   const std::vector<int>& GetNumBlocks() const
00189   { return this->NumBlocks;}
00191 
00192   std::vector<std::vector<unsigned int> >& GetChildrenAtLevel(unsigned int i)
00193   { return this->AllChildren[i];}
00194 
00195   void DeepCopy(vtkAMRInformation *other);
00196 
00197  private:
00198   vtkAMRInformation();
00199   ~vtkAMRInformation();
00200   vtkAMRInformation(const vtkAMRInformation&); // Not implemented.
00201   void operator=(const vtkAMRInformation&); // Not implemented.
00202 
00203   bool HasValidOrigin();
00204   bool HasValidBounds();
00205   void UpdateBounds(const int level, const int id);
00206   void AllocateBoxes(unsigned int n);
00207   void GenerateBlockLevel();
00208   void CalculateParentChildRelationShip( unsigned int level,
00209                                         std::vector<std::vector<unsigned int> >& children,
00210                                         std::vector<std::vector<unsigned int> >& parents );
00211 
00212   //-------------------------------------------------------------------------
00213   // Essential information that determines an AMR structure. Must be copied
00214   //-------------------------------------------------------------------------
00215   int GridDescription; //example: VTK_XYZ_GRID
00216   double Origin[3]; //the origin of the whole data set
00217   vtkAMRBoxList Boxes; // vtkAMRBoxes, one per data set
00218   std::vector<int> NumBlocks; //NumBlocks[i] stores the total number of blocks from level 0 to level i-1
00219 
00220   vtkSmartPointer<vtkIntArray> SourceIndex; //Typically, this maps to a file block index used by the reader
00221   vtkSmartPointer<vtkDoubleArray> Spacing; //The grid spacing for all levels
00222   double Bounds[6]; //the bounds of the entire domain
00223 
00224   //-------------------------------------------------------------------------
00225   // Auxillary information that be computed
00226   //-------------------------------------------------------------------------
00227   vtkSmartPointer<vtkIntArray> Refinement; //refinement ratio between two adjacent levels
00228   vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; //only necessary if need to call ComputeIndexPair
00229 
00230   //parent child information
00231   std::vector<std::vector<std::vector<unsigned int> > > AllChildren;
00232   std::vector<std::vector<std::vector<unsigned int> > > AllParents;
00233 };
00234 
00235 #endif