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

dox/Common/vtkImageData.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkImageData.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 =========================================================================*/ 00030 #ifndef __vtkImageData_h 00031 #define __vtkImageData_h 00032 00033 #include "vtkDataSet.h" 00034 00035 #include "vtkStructuredData.h" // Needed for inline methods 00036 00037 class vtkDataArray; 00038 class vtkLine; 00039 class vtkPixel; 00040 class vtkVertex; 00041 class vtkVoxel; 00042 00043 class VTK_COMMON_EXPORT vtkImageData : public vtkDataSet 00044 { 00045 public: 00046 static vtkImageData *New(); 00047 00048 vtkTypeRevisionMacro(vtkImageData,vtkDataSet); 00049 void PrintSelf(ostream& os, vtkIndent indent); 00050 00053 void CopyStructure(vtkDataSet *ds); 00054 00056 int GetDataObjectType() {return VTK_IMAGE_DATA;}; 00057 00060 void UpdateData(); 00061 00063 00064 vtkIdType GetNumberOfCells(); 00065 vtkIdType GetNumberOfPoints(); 00066 double *GetPoint(vtkIdType ptId); 00067 void GetPoint(vtkIdType id, double x[3]); 00068 vtkCell *GetCell(vtkIdType cellId); 00069 void GetCell(vtkIdType cellId, vtkGenericCell *cell); 00070 void GetCellBounds(vtkIdType cellId, double bounds[6]); 00071 vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);}; 00072 vtkIdType FindPoint(double x[3]); 00073 vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, 00074 int& subId, double pcoords[3], double *weights); 00075 vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, 00076 vtkIdType cellId, double tol2, int& subId, 00077 double pcoords[3], double *weights); 00078 vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, 00079 double tol2, int& subId, double pcoords[3], 00080 double *weights); 00081 int GetCellType(vtkIdType cellId); 00082 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) 00083 {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription, 00084 this->GetDimensions());} 00085 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) 00086 {vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());} 00087 void ComputeBounds(); 00088 int GetMaxCellSize() {return 8;}; //voxel is the largest 00090 00092 void SetDimensions(int i, int j, int k); 00093 00095 void SetDimensions(int dims[3]); 00096 00098 00100 int *GetDimensions(); 00101 void GetDimensions(int dims[3]); 00103 00109 int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]); 00110 00119 void GetVoxelGradient(int i,int j,int k, vtkDataArray *s, vtkDataArray *g); 00120 00126 void GetPointGradient(int i, int j, int k, vtkDataArray *s, double g[3]); 00127 00129 int GetDataDimension(); 00130 00132 00134 vtkIdType ComputePointId(int ijk[3]) { 00135 return vtkStructuredData::ComputePointId(this->GetDimensions(),ijk);}; 00137 00139 00141 vtkIdType ComputeCellId(int ijk[3]) { 00142 return vtkStructuredData::ComputeCellId(this->GetDimensions(),ijk);}; 00144 00146 00147 void SetAxisUpdateExtent(int axis, int min, int max); 00148 void GetAxisUpdateExtent(int axis, int &min, int &max); 00150 00152 00155 void SetUpdateExtent(int piece, int numPieces, int ghostLevel); 00156 void SetUpdateExtent(int piece, int numPieces) 00157 {this->SetUpdateExtent(piece, numPieces, 0);} 00159 00161 00162 void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 ) 00163 { this->vtkDataSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); }; 00164 void SetUpdateExtent( int ext[6] ) 00165 { this->vtkDataSet::SetUpdateExtent( ext ); }; 00167 00169 00172 void SetExtent(int extent[6]); 00173 void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2); 00174 vtkGetVector6Macro(Extent,int); 00176 00181 virtual unsigned long GetEstimatedMemorySize(); 00182 00184 00186 double GetScalarTypeMin(); 00187 double GetScalarTypeMax(); 00189 00191 int GetScalarSize(); 00192 00194 00197 int *GetIncrements(); 00198 void GetIncrements(int &incX, int &incY, int &incZ); 00199 void GetIncrements(int inc[3]); 00201 00211 void GetContinuousIncrements(int extent[6], int &incX, int &incY, int &incZ); 00212 00214 00215 void *GetScalarPointerForExtent(int extent[6]); 00216 void *GetScalarPointer(int coordinates[3]); 00217 void *GetScalarPointer(int x, int y, int z); 00218 void *GetScalarPointer(); 00220 00222 00223 double GetScalarComponentAsDouble(int x, int y, int z, int component); 00224 void SetScalarComponentFromDouble(int x, int y, int z, int component, double v); 00226 00228 void AllocateScalars(); 00229 00231 00235 void CopyAndCastFrom(vtkImageData *inData, int extent[6]); 00236 void CopyAndCastFrom(vtkImageData *inData, int x0, int x1, 00237 int y0, int y1, int z0, int z1) 00238 {int e[6]; e[0]=x0; e[1]=x1; e[2]=y0; e[3]=y1; e[4]=z0; e[5]=z1; 00239 this->CopyAndCastFrom(inData, e);} 00241 00245 virtual void Crop(); 00246 00252 unsigned long GetActualMemorySize(); 00253 00255 00257 vtkSetVector3Macro(Spacing,double); 00258 vtkGetVector3Macro(Spacing,double); 00260 00262 00264 vtkSetVector3Macro(Origin,double); 00265 vtkGetVector3Macro(Origin,double); 00267 00269 00270 void SetScalarTypeToFloat(){this->SetScalarType(VTK_FLOAT);}; 00271 void SetScalarTypeToDouble(){this->SetScalarType(VTK_DOUBLE);}; 00272 void SetScalarTypeToInt(){this->SetScalarType(VTK_INT);}; 00273 void SetScalarTypeToUnsignedInt() 00274 {this->SetScalarType(VTK_UNSIGNED_INT);}; 00275 void SetScalarTypeToLong(){this->SetScalarType(VTK_LONG);}; 00276 void SetScalarTypeToUnsignedLong() 00277 {this->SetScalarType(VTK_UNSIGNED_LONG);}; 00278 void SetScalarTypeToShort(){this->SetScalarType(VTK_SHORT);}; 00279 void SetScalarTypeToUnsignedShort() 00280 {this->SetScalarType(VTK_UNSIGNED_SHORT);}; 00281 void SetScalarTypeToUnsignedChar() 00282 {this->SetScalarType(VTK_UNSIGNED_CHAR);}; 00283 void SetScalarTypeToChar() 00284 {this->SetScalarType(VTK_CHAR);}; 00285 vtkSetMacro(ScalarType, int); 00286 int GetScalarType(); 00287 const char* GetScalarTypeAsString() { return vtkImageScalarTypeNameMacro ( this->GetScalarType() ); }; 00289 00291 00292 void SetNumberOfScalarComponents( int n ); 00293 vtkGetMacro(NumberOfScalarComponents,int); 00295 00296 // Must only be called with vtkImageData (or subclass) as input 00297 void CopyTypeSpecificInformation( vtkDataObject *image ); 00298 00302 virtual void PrepareForNewData(); 00303 00305 00306 void ShallowCopy(vtkDataObject *src); 00307 void DeepCopy(vtkDataObject *src); 00309 00310 //-------------------------------------------------------------------------- 00311 // Methods that apply to any array (not just scalars). 00312 // I am starting to experiment with generalizing imaging fitlers 00313 // to operate on more than just scalars. 00314 00316 00319 void *GetArrayPointerForExtent(vtkDataArray* array, int extent[6]); 00320 void *GetArrayPointer(vtkDataArray* array, int coordinates[3]); 00322 00325 void GetArrayIncrements(vtkDataArray *array, int increments[3]); 00326 00331 void ComputeInternalExtent(int *intExt, int *tgtExt, int *bnds); 00332 00334 int GetExtentType() { return VTK_3D_EXTENT; }; 00335 00336 protected: 00337 vtkImageData(); 00338 ~vtkImageData(); 00339 00340 // for the GetCell method 00341 vtkVertex *Vertex; 00342 vtkLine *Line; 00343 vtkPixel *Pixel; 00344 vtkVoxel *Voxel; 00345 00346 // The extent of what is currently in the structured grid. 00347 // Dimensions is just an array to return a value. 00348 // Its contents are out of data until GetDimensions is called. 00349 int Dimensions[3]; 00350 int DataDescription; 00351 int Increments[3]; 00352 00353 double Origin[3]; 00354 double Spacing[3]; 00355 int ScalarType; 00356 int NumberOfScalarComponents; 00357 00358 void ComputeIncrements(); 00359 00360 private: 00361 void InternalImageDataCopy(vtkImageData *src); 00362 private: 00363 vtkImageData(const vtkImageData&); // Not implemented. 00364 void operator=(const vtkImageData&); // Not implemented. 00365 }; 00366 00367 00368 inline void vtkImageData::GetPoint(vtkIdType id, double x[3]) 00369 { 00370 double *p=this->GetPoint(id); 00371 x[0] = p[0]; x[1] = p[1]; x[2] = p[2]; 00372 } 00373 00374 00375 00376 inline vtkIdType vtkImageData::GetNumberOfPoints() 00377 { 00378 int *dims = this->GetDimensions(); 00379 return dims[0]*dims[1]*dims[2]; 00380 } 00381 00382 inline int vtkImageData::GetDataDimension() 00383 { 00384 return vtkStructuredData::GetDataDimension(this->DataDescription); 00385 } 00386 00387 #endif 00388 00389 00390