dox/Filtering/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_FILTERING_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   virtual void CopyStructure(vtkDataSet *ds);
00054 
00056   virtual int GetDataObjectType() {return VTK_IMAGE_DATA;};
00057 
00059 
00060   virtual vtkIdType GetNumberOfCells();
00061   virtual vtkIdType GetNumberOfPoints();
00062   virtual double *GetPoint(vtkIdType ptId);
00063   virtual void GetPoint(vtkIdType id, double x[3]);
00064   virtual vtkCell *GetCell(vtkIdType cellId);
00065   virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00066   virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
00067   virtual vtkIdType FindPoint(double x, double y, double z)
00068     {
00069     return this->vtkDataSet::FindPoint(x, y, z);
00070     }
00071   virtual vtkIdType FindPoint(double x[3]);
00072   virtual vtkIdType FindCell(
00073     double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
00074     int& subId, double pcoords[3], double *weights);
00075   virtual vtkIdType FindCell(
00076     double x[3], vtkCell *cell, vtkGenericCell *gencell,
00077     vtkIdType cellId, double tol2, int& subId,
00078     double pcoords[3], double *weights);
00079   virtual vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
00080                                   double tol2, int& subId, double pcoords[3],
00081                                   double *weights);
00082   virtual int GetCellType(vtkIdType cellId);
00083   virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
00084     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
00085                                       this->GetDimensions());}
00086   virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
00087     {vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());}
00088   virtual void ComputeBounds();
00089   virtual int GetMaxCellSize() {return 8;}; //voxel is the largest
00091 
00093   virtual void Initialize();
00094 
00096   virtual void SetDimensions(int i, int j, int k);
00097 
00099   virtual void SetDimensions(const int dims[3]);
00100 
00102 
00105   virtual int *GetDimensions();
00106   virtual void GetDimensions(int dims[3]);
00108 
00110 
00115   virtual int ComputeStructuredCoordinates(
00116     double x[3], int ijk[3], double pcoords[3]);
00118 
00120 
00128   virtual void GetVoxelGradient(
00129     int i,int j,int k, vtkDataArray *s, vtkDataArray *g);
00131 
00133 
00138   virtual void GetPointGradient(
00139     int i, int j, int k, vtkDataArray *s, double g[3]);
00141 
00143   virtual int GetDataDimension();
00144 
00146 
00148   virtual vtkIdType ComputePointId(int ijk[3]) {
00149     return vtkStructuredData::ComputePointId(this->GetDimensions(),ijk);};
00151 
00153 
00155   virtual vtkIdType ComputeCellId(int ijk[3]) {
00156     return vtkStructuredData::ComputeCellId(this->GetDimensions(),ijk);};
00158 
00160 
00161   virtual void SetAxisUpdateExtent(int axis, int min, int max);
00162   virtual void GetAxisUpdateExtent(int axis, int &min, int &max);
00164 
00168   virtual void UpdateInformation();
00169 
00171 
00179   virtual void SetExtent(int extent[6]);
00180   virtual void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00181   vtkGetVector6Macro(Extent, int);
00183 
00188   virtual unsigned long GetEstimatedMemorySize();
00189 
00191 
00193   virtual double GetScalarTypeMin();
00194   virtual double GetScalarTypeMax();
00196 
00198   virtual int GetScalarSize();
00199 
00201 
00204   virtual vtkIdType *GetIncrements();
00205   virtual void GetIncrements(vtkIdType &incX, vtkIdType &incY, vtkIdType &incZ);
00206   virtual void GetIncrements(vtkIdType inc[3]);
00208 
00210 
00219   virtual void GetContinuousIncrements(
00220     int extent[6], vtkIdType &incX, vtkIdType &incY, vtkIdType &incZ);
00222 
00224 
00225   virtual void *GetScalarPointerForExtent(int extent[6]);
00226   virtual void *GetScalarPointer(int coordinates[3]);
00227   virtual void *GetScalarPointer(int x, int y, int z);
00228   virtual void *GetScalarPointer();
00230 
00232 
00233   virtual float GetScalarComponentAsFloat(int x, int y, int z, int component);
00234   virtual void SetScalarComponentFromFloat(
00235     int x, int y, int z, int component, float v);
00236   virtual double GetScalarComponentAsDouble(int x, int y, int z, int component);
00237   virtual void SetScalarComponentFromDouble(
00238     int x, int y, int z, int component, double v);
00240 
00242   virtual void AllocateScalars();
00243 
00245 
00249   virtual void CopyAndCastFrom(vtkImageData *inData, int extent[6]);
00250   virtual void CopyAndCastFrom(vtkImageData *inData, int x0, int x1,
00251                                int y0, int y1, int z0, int z1)
00252     {int e[6]; e[0]=x0; e[1]=x1; e[2]=y0; e[3]=y1; e[4]=z0; e[5]=z1;
00253     this->CopyAndCastFrom(inData, e);}
00255 
00259   virtual void Crop();
00260 
00266   virtual unsigned long GetActualMemorySize();
00267 
00269 
00271   vtkSetVector3Macro(Spacing,double);
00272   vtkGetVector3Macro(Spacing,double);
00274 
00276 
00282   vtkSetVector3Macro(Origin,double);
00283   vtkGetVector3Macro(Origin,double);
00285 
00287 
00292   void SetScalarTypeToFloat(){this->SetScalarType(VTK_FLOAT);};
00293   void SetScalarTypeToDouble(){this->SetScalarType(VTK_DOUBLE);};
00294   void SetScalarTypeToInt(){this->SetScalarType(VTK_INT);};
00295   void SetScalarTypeToUnsignedInt()
00296     {this->SetScalarType(VTK_UNSIGNED_INT);};
00297   void SetScalarTypeToLong(){this->SetScalarType(VTK_LONG);};
00298   void SetScalarTypeToUnsignedLong()
00299     {this->SetScalarType(VTK_UNSIGNED_LONG);};
00300   void SetScalarTypeToShort(){this->SetScalarType(VTK_SHORT);};
00301   void SetScalarTypeToUnsignedShort()
00302     {this->SetScalarType(VTK_UNSIGNED_SHORT);};
00303   void SetScalarTypeToUnsignedChar()
00304     {this->SetScalarType(VTK_UNSIGNED_CHAR);};
00305   void SetScalarTypeToSignedChar()
00306     {this->SetScalarType(VTK_SIGNED_CHAR);};
00307   void SetScalarTypeToChar()
00308     {this->SetScalarType(VTK_CHAR);};
00309   void SetScalarType(int);
00310   int GetScalarType();
00311   const char* GetScalarTypeAsString()
00312     { return vtkImageScalarTypeNameMacro ( this->GetScalarType() ); };
00314 
00316 
00318   void SetNumberOfScalarComponents( int n );
00319   int GetNumberOfScalarComponents();
00321 
00322   // Must only be called with vtkImageData (or subclass) as input
00323   virtual void CopyTypeSpecificInformation( vtkDataObject *image );
00324 
00326 
00328   virtual void CopyInformationToPipeline(vtkInformation* request,
00329                                          vtkInformation* input,
00330                                          vtkInformation* output,
00331                                          int forceCopy);
00332   virtual void CopyInformationFromPipeline(vtkInformation* request);
00334 
00338   virtual void PrepareForNewData();
00339 
00341 
00342   virtual void ShallowCopy(vtkDataObject *src);
00343   virtual void DeepCopy(vtkDataObject *src);
00345 
00346   //--------------------------------------------------------------------------
00347   // Methods that apply to any array (not just scalars).
00348   // I am starting to experiment with generalizing imaging fitlers
00349   // to operate on more than just scalars.
00350 
00352 
00355   void *GetArrayPointerForExtent(vtkDataArray* array, int extent[6]);
00356   void *GetArrayPointer(vtkDataArray* array, int coordinates[3]);
00358 
00361   void GetArrayIncrements(vtkDataArray *array, vtkIdType increments[3]);
00362 
00367   void ComputeInternalExtent(int *intExt, int *tgtExt, int *bnds);
00368 
00370   virtual int GetExtentType() { return VTK_3D_EXTENT; };
00371 
00372   //BTX
00374 
00375   static vtkImageData* GetData(vtkInformation* info);
00376   static vtkImageData* GetData(vtkInformationVector* v, int i=0);
00377   //ETX
00379 
00380 protected:
00381   vtkImageData();
00382   ~vtkImageData();
00383 
00384   // for the GetCell method
00385   vtkVertex *Vertex;
00386   vtkLine *Line;
00387   vtkPixel *Pixel;
00388   vtkVoxel *Voxel;
00389 
00390   // The extent of what is currently in the structured grid.
00391   // Dimensions is just an array to return a value.
00392   // Its contents are out of data until GetDimensions is called.
00393   int Dimensions[3];
00394   int DataDescription;
00395   vtkIdType Increments[3];
00396 
00397   double Origin[3];
00398   double Spacing[3];
00399 
00400   int Extent[6];
00401 
00402   void ComputeIncrements();
00403   void CopyOriginAndSpacingFromPipeline();
00404 
00405   vtkTimeStamp ExtentComputeTime;
00406 
00407 private:
00408   void InternalImageDataCopy(vtkImageData *src);
00409 private:
00410   vtkImageData(const vtkImageData&);  // Not implemented.
00411   void operator=(const vtkImageData&);  // Not implemented.
00412 };
00413 
00414 
00415 //----------------------------------------------------------------------------
00416 inline void vtkImageData::GetPoint(vtkIdType id, double x[3])
00417 {
00418   const double *p = this->GetPoint(id);
00419   x[0] = p[0]; x[1] = p[1]; x[2] = p[2];
00420 }
00421 
00422 //----------------------------------------------------------------------------
00423 inline vtkIdType vtkImageData::GetNumberOfPoints()
00424 {
00425   const int *extent = this->Extent;
00426   vtkIdType dims[3];
00427   dims[0] = extent[1] - extent[0] + 1;
00428   dims[1] = extent[3] - extent[2] + 1;
00429   dims[2] = extent[5] - extent[4] + 1;
00430 
00431   return dims[0]*dims[1]*dims[2];
00432 }
00433 
00434 //----------------------------------------------------------------------------
00435 inline int vtkImageData::GetDataDimension()
00436 {
00437   return vtkStructuredData::GetDataDimension(this->DataDescription);
00438 }
00439 
00440 #endif
00441 
00442 
00443 

Generated on Thu Jan 8 14:38:23 2009 for VTK by  doxygen 1.4.7