VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkStructuredData.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 =========================================================================*/ 00029 #ifndef __vtkStructuredData_h 00030 #define __vtkStructuredData_h 00031 00032 #include "vtkObject.h" 00033 00034 class vtkIdList; 00035 00036 #define VTK_UNCHANGED 0 00037 #define VTK_SINGLE_POINT 1 00038 #define VTK_X_LINE 2 00039 #define VTK_Y_LINE 3 00040 #define VTK_Z_LINE 4 00041 #define VTK_XY_PLANE 5 00042 #define VTK_YZ_PLANE 6 00043 #define VTK_XZ_PLANE 7 00044 #define VTK_XYZ_GRID 8 00045 #define VTK_EMPTY 9 00046 00047 class VTK_COMMON_EXPORT vtkStructuredData : public vtkObject 00048 { 00049 public: 00050 vtkTypeMacro(vtkStructuredData,vtkObject); 00051 00053 00058 static int SetDimensions(int inDim[3], int dim[3]); 00059 static int SetExtent(int inExt[6], int ext[6]); 00061 00064 static int GetDataDescription(int dims[3]); 00065 00067 static int GetDataDimension(int dataDescription); 00068 00070 00071 static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, 00072 int dataDescription, int dim[3]); 00074 00076 static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3]); 00077 00079 00081 static void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, 00082 vtkIdList *cellIds, int dim[3]); 00084 00086 00088 static vtkIdType ComputePointIdForExtent(int extent[6], int ijk[3]) { 00089 vtkIdType ydim = static_cast<vtkIdType>(extent[3] - extent[2] + 1); 00090 vtkIdType xdim = static_cast<vtkIdType>(extent[1] - extent[0] + 1); 00091 return ((ijk[2] - extent[4])*ydim + (ijk[1] - extent[2]))*xdim 00092 + (ijk[0] - extent[0]); } 00094 00096 00098 static vtkIdType ComputeCellIdForExtent(int extent[6], int ijk[3]) { 00099 vtkIdType ydim = static_cast<vtkIdType>(extent[3] - extent[2]); 00100 if (ydim == 0) ydim = 1; 00101 vtkIdType xdim = static_cast<vtkIdType>(extent[1] - extent[0]); 00102 if (xdim == 0) xdim = 1; 00103 return ((ijk[2] - extent[4])*(ydim) + (ijk[1] - extent[2]))*(xdim) 00104 + (ijk[0] - extent[0]); } 00106 00108 00111 static vtkIdType ComputePointId(int dim[3], int ijk[3]) { 00112 return (ijk[2]*static_cast<vtkIdType>(dim[1]) + ijk[1])*dim[0] + ijk[0];} 00114 00116 00119 static vtkIdType ComputeCellId(int dim[3], int ijk[3]) { 00120 return (ijk[2]*static_cast<vtkIdType>(dim[1]-1) + ijk[1])*(dim[0]-1) + ijk[0];} 00122 00124 00127 static void ComputeCellStructuredCoords(const vtkIdType cellId, int dim[3], int ijk[3]) 00128 { 00129 int Ni = dim[0]-1; 00130 int Nj = dim[1]-1; 00132 00133 int Nij = Ni*Nj; 00134 00135 int k = cellId/Nij + 1; 00136 int j = (cellId - (k-1)*Nij)/Ni + 1; 00137 int i = cellId - (k-1)*Nij - (j-1)*Ni + 1; 00138 ijk[0] = i-1; 00139 ijk[1] = j-1; 00140 ijk[2] = k-1; 00141 } 00142 00144 00147 static void ComputePointStructuredCoords(const vtkIdType cellId, int dim[3], int ijk[3]) 00148 { 00149 int Ni = dim[0]; 00150 int Nj = dim[1]; 00152 00153 int Nij = Ni*Nj; 00154 00155 int k = cellId/Nij + 1; 00156 int j = (cellId - (k-1)*Nij)/Ni + 1; 00157 int i = cellId - (k-1)*Nij - (j-1)*Ni + 1; 00158 ijk[0] = i-1; 00159 ijk[1] = j-1; 00160 ijk[2] = k-1; 00161 } 00162 00163 protected: 00164 vtkStructuredData() {}; 00165 ~vtkStructuredData() {}; 00166 00167 private: 00168 vtkStructuredData(const vtkStructuredData&); // Not implemented. 00169 void operator=(const vtkStructuredData&); // Not implemented. 00170 }; 00171 00172 00173 #endif 00174