Common/vtkImageData.h Source File

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

# Common/vtkImageData.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkImageData.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 =========================================================================*/
    00045 #ifndef __vtkImageData_h
    00046 #define __vtkImageData_h
    00047
    00048 #include "vtkDataSet.h"
    00049
    00050 #include "vtkStructuredData.h" // Needed for inline methods
    00051
    00052 class vtkDataArray;
    00053 class vtkLine;
    00054 class vtkPixel;
    00055 class vtkVertex;
    00056 class vtkVoxel;
    00057
    00058 class VTK_COMMON_EXPORT vtkImageData : public vtkDataSet
    00059 {
    00060 public:
    00061   static vtkImageData *New();
    00062
    00063   vtkTypeRevisionMacro(vtkImageData,vtkDataSet);
    00064   void PrintSelf(ostream& os, vtkIndent indent);
    00065
    00068   void CopyStructure(vtkDataSet *ds);
    00069
    00071   int GetDataObjectType() {return VTK_IMAGE_DATA;};
    00072
    00075   void UpdateData();
    00076
    00078
    00079   vtkIdType GetNumberOfCells();
    00080   vtkIdType GetNumberOfPoints();
    00081   float *GetPoint(vtkIdType ptId);
    00082   void GetPoint(vtkIdType id, float x[3]);
    00083   vtkCell *GetCell(vtkIdType cellId);
    00084   void GetCell(vtkIdType cellId, vtkGenericCell *cell);
    00085   void GetCellBounds(vtkIdType cellId, float bounds[6]);
    00086   vtkIdType FindPoint(float x, float y, float z) { return this->vtkDataSet::FindPoint(x, y, z);};
    00087   vtkIdType FindPoint(float x[3]);
    00088   vtkIdType FindCell(float x[3], vtkCell *cell, vtkIdType cellId, float tol2,
    00089                      int& subId, float pcoords[3], float *weights);
    00090   vtkIdType FindCell(float x[3], vtkCell *cell, vtkGenericCell *gencell,
    00091                      vtkIdType cellId, float tol2, int& subId,
    00092                      float pcoords[3], float *weights);
    00093   vtkCell *FindAndGetCell(float x[3], vtkCell *cell, vtkIdType cellId,
    00094                           float tol2, int& subId, float pcoords[3],
    00095                           float *weights);
    00096   int GetCellType(vtkIdType cellId);
    00097   void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
    00098     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
    00099                                       this->GetDimensions());}
    00100   void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
    00101     {vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());}
    00102   void ComputeBounds();
    00103   int GetMaxCellSize() {return 8;}; //voxel is the largest
    00105
    00107   void SetDimensions(int i, int j, int k);
    00108
    00110   void SetDimensions(int dims[3]);
    00111
    00113
    00115   int *GetDimensions();
    00116   void GetDimensions(int dims[3]);
    00118
    00124   int ComputeStructuredCoordinates(float x[3], int ijk[3], float pcoords[3]);
    00125
    00134   void GetVoxelGradient(int i,int j,int k, vtkDataArray *s, vtkDataArray *g);
    00135
    00141   void GetPointGradient(int i, int j, int k, vtkDataArray *s, float g[3]);
    00142
    00144   int GetDataDimension();
    00145
    00147
    00149   vtkIdType ComputePointId(int ijk[3]) {
    00150     return vtkStructuredData::ComputePointId(this->GetDimensions(),ijk);};
    00152
    00154
    00156   vtkIdType ComputeCellId(int ijk[3]) {
    00157     return vtkStructuredData::ComputeCellId(this->GetDimensions(),ijk);};
    00159
    00161
    00162   void SetAxisUpdateExtent(int axis, int min, int max);
    00163   void GetAxisUpdateExtent(int axis, int &min, int &max);
    00165
    00167
    00170   void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
    00171   void SetUpdateExtent(int piece, int numPieces)
    00172     {this->SetUpdateExtent(piece, numPieces, 0);}
    00174
    00176
    00177   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
    00178     { this->vtkDataSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
    00179   void SetUpdateExtent( int ext[6] )
    00180     { this->vtkDataSet::SetUpdateExtent( ext ); };
    00182
    00184
    00187   void SetExtent(int extent[6]);
    00188   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
    00189   vtkGetVector6Macro(Extent,int);
    00191
    00196   virtual unsigned long GetEstimatedMemorySize();
    00197
    00199
    00201   double GetScalarTypeMin();
    00202   double GetScalarTypeMax();
    00204
    00206   int GetScalarSize();
    00207
    00209
    00212   int *GetIncrements();
    00213   void GetIncrements(int &incX, int &incY, int &incZ);
    00214   void GetIncrements(int inc[3]);
    00216
    00226   void GetContinuousIncrements(int extent[6], int &incX, int &incY, int &incZ);
    00227
    00229
    00230   void *GetScalarPointerForExtent(int extent[6]);
    00231   void *GetScalarPointer(int coordinates[3]);
    00232   void *GetScalarPointer(int x, int y, int z);
    00233   void *GetScalarPointer();
    00235
    00237
    00238   float GetScalarComponentAsFloat(int x, int y, int z, int component);
    00239   void SetScalarComponentFromFloat(int x, int y, int z, int component, float v);
    00241
    00243   void AllocateScalars();
    00244
    00246
    00250   void CopyAndCastFrom(vtkImageData *inData, int extent[6]);
    00251   void CopyAndCastFrom(vtkImageData *inData, int x0, int x1,
    00252                        int y0, int y1, int z0, int z1)
    00253     {int e[6]; e[0]=x0; e[1]=x1; e[2]=y0; e[3]=y1; e[4]=z0; e[5]=z1;
    00254     this->CopyAndCastFrom(inData, e);}
    00256
    00260   virtual void Crop();
    00261
    00267   unsigned long GetActualMemorySize();
    00268
    00270
    00272   vtkSetVector3Macro(Spacing,float);
    00273   vtkGetVector3Macro(Spacing,float);
    00275
    00277
    00279   vtkSetVector3Macro(Origin,float);
    00280   vtkGetVector3Macro(Origin,float);
    00282
    00284
    00285   void SetScalarTypeToFloat(){this->SetScalarType(VTK_FLOAT);};
    00286   void SetScalarTypeToDouble(){this->SetScalarType(VTK_DOUBLE);};
    00287   void SetScalarTypeToInt(){this->SetScalarType(VTK_INT);};
    00288   void SetScalarTypeToUnsignedInt()
    00289     {this->SetScalarType(VTK_UNSIGNED_INT);};
    00290   void SetScalarTypeToLong(){this->SetScalarType(VTK_LONG);};
    00291   void SetScalarTypeToUnsignedLong()
    00292     {this->SetScalarType(VTK_UNSIGNED_LONG);};
    00293   void SetScalarTypeToShort(){this->SetScalarType(VTK_SHORT);};
    00294   void SetScalarTypeToUnsignedShort()
    00295     {this->SetScalarType(VTK_UNSIGNED_SHORT);};
    00296   void SetScalarTypeToUnsignedChar()
    00297     {this->SetScalarType(VTK_UNSIGNED_CHAR);};
    00298   void SetScalarTypeToChar()
    00299     {this->SetScalarType(VTK_CHAR);};
    00300   vtkSetMacro(ScalarType, int);
    00301   int GetScalarType();
    00302   const char* GetScalarTypeAsString() { return vtkImageScalarTypeNameMacro ( this->GetScalarType() ); };
    00304
    00306
    00307   void SetNumberOfScalarComponents( int n );
    00308   vtkGetMacro(NumberOfScalarComponents,int);
    00310
    00311   // Must only be called with vtkImageData (or subclass) as input
    00312   void CopyTypeSpecificInformation( vtkDataObject *image );
    00313
    00317   virtual void PrepareForNewData();
    00318
    00320
    00321   void ShallowCopy(vtkDataObject *src);
    00322   void DeepCopy(vtkDataObject *src);
    00324
    00325   //--------------------------------------------------------------------------
    00326   // Methods that apply to any array (not just scalars).
    00327   // I am starting to experiment with generalizing imaging fitlers
    00328   // to operate on more than just scalars.
    00329
    00331
    00334   void *GetArrayPointerForExtent(vtkDataArray* array, int extent[6]);
    00335   void *GetArrayPointer(vtkDataArray* array, int coordinates[3]);
    00337
    00340   void GetArrayIncrements(vtkDataArray *array, int increments[3]);
    00341
    00346   void ComputeInternalExtent(int *intExt, int *tgtExt, int *bnds);
    00347
    00348 protected:
    00349   vtkImageData();
    00350   ~vtkImageData();
    00351
    00352   // for the GetCell method
    00353   vtkVertex *Vertex;
    00354   vtkLine *Line;
    00355   vtkPixel *Pixel;
    00356   vtkVoxel *Voxel;
    00357
    00358   // The extent type is a 3D extent
    00359   int GetExtentType() { return VTK_3D_EXTENT; };
    00360
    00361   // The extent of what is currently in the structured grid.
    00362   // Dimensions is just an array to return a value.
    00363   // Its contents are out of data until GetDimensions is called.
    00364   int Dimensions[3];
    00365   int DataDescription;
    00366   int Increments[3];
    00367
    00368   float Origin[3];
    00369   float Spacing[3];
    00370   int ScalarType;
    00371   int NumberOfScalarComponents;
    00372
    00373   void ComputeIncrements();
    00374
    00375 private:
    00376   void InternalImageDataCopy(vtkImageData *src);
    00377 private:
    00378   vtkImageData(const vtkImageData&);  // Not implemented.
    00379   void operator=(const vtkImageData&);  // Not implemented.
    00380 };
    00381
    00382
    00383 inline void vtkImageData::GetPoint(vtkIdType id, float x[3])
    00384 {
    00385   float *p=this->GetPoint(id);
    00386   x[0] = p[0]; x[1] = p[1]; x[2] = p[2];
    00387 }
    00388
    00389
    00390
    00391 inline vtkIdType vtkImageData::GetNumberOfPoints()
    00392 {
    00393   int *dims = this->GetDimensions();
    00394   return dims[0]*dims[1]*dims[2];
    00395 }
    00396
    00397 inline int vtkImageData::GetDataDimension()
    00398 {
    00399   return vtkStructuredData::GetDataDimension(this->DataDescription);
    00400 }
    00401
    00402 #endif
    00403
    00404
    00405