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

dox/Common/vtkAMRBox.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkAMRBox.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00033 #ifndef __vtkAMRBox_h 00034 #define __vtkAMRBox_h 00035 00036 #include "vtkObject.h" 00037 00038 class VTK_COMMON_EXPORT vtkAMRBox 00039 { 00040 public: 00041 // public for quick access 00042 int LoCorner[3]; 00043 int HiCorner[3]; 00044 00045 vtkAMRBox() 00046 { 00047 for(int i=0; i<3; i++) 00048 { 00049 this->LoCorner[i] = this->HiCorner[i] = 0; 00050 } 00051 } 00052 00053 vtkAMRBox(int dimensionality, int* loCorner, int* hiCorner) 00054 { 00055 this->LoCorner[2] = this->HiCorner[2] = 0; 00056 memcpy(this->LoCorner, loCorner, dimensionality*sizeof(int)); 00057 memcpy(this->HiCorner, hiCorner, dimensionality*sizeof(int)); 00058 } 00059 00061 00063 vtkIdType GetNumberOfCells() 00064 { 00065 vtkIdType numCells=1; 00066 for(int i=0; i<3; i++) 00067 { 00068 numCells *= HiCorner[i] - LoCorner[i] + 1; 00069 } 00070 return numCells; 00071 } 00073 00075 00077 void Coarsen(int refinement) 00078 { 00079 for (int i=0; i<3; i++) 00080 { 00081 this->LoCorner[i] = 00082 ( this->LoCorner[i] < 0 ? 00083 -abs(this->LoCorner[i]+1)/refinement - 1 : 00084 this->LoCorner[i]/refinement ); 00085 this->HiCorner[i] = 00086 ( this->HiCorner[i] < 0 ? 00087 -abs(this->HiCorner[i]+1)/refinement - 1 : 00088 this->HiCorner[i]/refinement ); 00089 } 00090 } 00092 00094 00096 void Refine(int refinement) 00097 { 00098 for (int i=0; i<3; i++) 00099 { 00100 this->LoCorner[i] = this->LoCorner[i]*refinement; 00101 this->HiCorner[i] = this->HiCorner[i]*refinement; 00102 } 00103 } 00105 00107 00108 int DoesContainCell(int i, int j, int k) 00109 { 00110 return 00111 i >= this->LoCorner[0] && i <= this->HiCorner[0] && 00112 j >= this->LoCorner[1] && j <= this->HiCorner[1] && 00113 k >= this->LoCorner[2] && k <= this->HiCorner[2]; 00114 } 00116 00117 }; 00118 00119 struct vtkAMRLevelInformation 00120 { 00121 unsigned int Level; 00122 unsigned int DataSetId; 00123 vtkAMRBox Box; 00124 }; 00125 00126 00127 #endif 00128 00129 00130 00131 00132 00133