Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkAMRBox.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkAMRBox.h,v $
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 =========================================================================*/
00038 #ifndef __vtkAMRBox_h
00039 #define __vtkAMRBox_h
00040 
00041 #include "vtkObject.h"
00042 
00043 class VTK_FILTERING_EXPORT vtkAMRBox
00044 {
00045 public:
00046   // public for quick access
00047   int LoCorner[3];
00048   int HiCorner[3];
00049 
00050   vtkAMRBox() 
00051     {
00052       for(int i=0; i<3; i++)
00053         {
00054         this->LoCorner[i] = this->HiCorner[i] = 0;
00055         }
00056     }
00057 
00058   vtkAMRBox(int dimensionality, int* loCorner, int* hiCorner) 
00059     {
00060       this->LoCorner[2] = this->HiCorner[2] = 0;
00061       memcpy(this->LoCorner, loCorner, dimensionality*sizeof(int));
00062       memcpy(this->HiCorner, hiCorner, dimensionality*sizeof(int));
00063     }
00064     
00066 
00068   vtkIdType GetNumberOfCells()
00069     {
00070       vtkIdType numCells=1;
00071       for(int i=0; i<3; i++)
00072         {
00073         numCells *= HiCorner[i] - LoCorner[i] + 1;
00074         }
00075       return numCells;
00076     }
00078 
00080 
00082   void Coarsen(int refinement)
00083     {
00084       for (int i=0; i<3; i++)
00085         {
00086         this->LoCorner[i] = 
00087           ( this->LoCorner[i] < 0 ? 
00088             -abs(this->LoCorner[i]+1)/refinement - 1 :
00089             this->LoCorner[i]/refinement );
00090         this->HiCorner[i] = 
00091           ( this->HiCorner[i] < 0 ? 
00092             -abs(this->HiCorner[i]+1)/refinement - 1 :
00093             this->HiCorner[i]/refinement );
00094         }
00095     }
00097 
00099 
00101   void Refine(int refinement)
00102     {
00103       for (int i=0; i<3; i++)
00104         {
00105         this->LoCorner[i] = this->LoCorner[i]*refinement;
00106         this->HiCorner[i] = this->HiCorner[i]*refinement;
00107         }
00108     }
00110 
00112 
00113   int DoesContainCell(int i, int j, int k)
00114     {
00115       return 
00116         i >= this->LoCorner[0] && i <= this->HiCorner[0] &&
00117         j >= this->LoCorner[1] && j <= this->HiCorner[1] &&
00118         k >= this->LoCorner[2] && k <= this->HiCorner[2];
00119     }
00121 
00122 };
00123 
00124 struct vtkAMRLevelInformation
00125 {
00126   unsigned int Level;
00127   unsigned int DataSetId;
00128   vtkAMRBox Box;
00129 };
00130 
00131 
00132 #endif
00133 
00134 
00135 
00136 
00137 
00138