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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00055 #ifndef __vtkImageData_h
00056 #define __vtkImageData_h
00057 
00058 #include "vtkDataSet.h"
00059 #include "vtkStructuredData.h"
00060 class vtkVertex;
00061 class vtkLine;
00062 class vtkPixel;
00063 class vtkVoxel;
00064 class vtkImageToStructuredPoints;
00065 
00066 
00067 class VTK_EXPORT vtkImageData : public vtkDataSet
00068 {
00069 public:
00070   static vtkImageData *New();
00071 
00072   vtkTypeMacro(vtkImageData,vtkDataSet);
00073   void PrintSelf(ostream& os, vtkIndent indent);
00074 
00076   vtkDataObject *MakeObject() {return vtkImageData::New();};
00077 
00080   void CopyStructure(vtkDataSet *ds);
00081 
00083   int GetDataObjectType() {return VTK_IMAGE_DATA;};
00084 
00087   void UpdateData();
00088   
00090   int GetNumberOfCells();
00091   int GetNumberOfPoints();
00092   float *GetPoint(int ptId);
00093   void GetPoint(int id, float x[3]);
00094   vtkCell *GetCell(int cellId);
00095   void GetCell(int cellId, vtkGenericCell *cell);
00096   void GetCellBounds(int cellId, float bounds[6]);
00097   int FindPoint(float x, float y, float z) { return this->vtkDataSet::FindPoint(x, y, z);};
00098   int FindPoint(float x[3]);
00099   int FindCell(float x[3], vtkCell *cell, int cellId, float tol2, int& subId, 
00100                float pcoords[3], float *weights);
00101   int FindCell(float x[3], vtkCell *cell, vtkGenericCell *gencell,
00102           int cellId, float tol2, int& subId, 
00103                float pcoords[3], float *weights);
00104   vtkCell *FindAndGetCell(float x[3], vtkCell *cell, int cellId, 
00105                float tol2, int& subId, float pcoords[3], float *weights);
00106   int GetCellType(int cellId);
00107   void GetCellPoints(int cellId, vtkIdList *ptIds)
00108     {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
00109                   this->GetDimensions());}
00110   void GetPointCells(int ptId, vtkIdList *cellIds)
00111     {vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());}
00112   void ComputeBounds();
00113   int GetMaxCellSize() {return 8;}; //voxel is the largest
00114 
00116   void SetDimensions(int i, int j, int k);
00117 
00119   void SetDimensions(int dims[3]);
00120 
00123   int *GetDimensions();
00124   void GetDimensions(int dims[3]);
00125 
00131   int ComputeStructuredCoordinates(float x[3], int ijk[3], float pcoords[3]);
00132   
00141   void GetVoxelGradient(int i,int j,int k, vtkScalars *s, vtkVectors *g);
00142 
00148   void GetPointGradient(int i, int j, int k, vtkScalars *s, float g[3]);
00149 
00151   int GetDataDimension();
00152 
00155   int ComputePointId(int ijk[3]) {
00156     return vtkStructuredData::ComputePointId(this->GetDimensions(),ijk);};
00157 
00160   int ComputeCellId(int ijk[3]) {
00161     return vtkStructuredData::ComputeCellId(this->GetDimensions(),ijk);};
00162 
00164   void SetAxisUpdateExtent(int axis, int min, int max);
00165   void GetAxisUpdateExtent(int axis, int &min, int &max);
00166 
00170   void SetUpdateExtent(int piece, int numPieces, int ghostLevel);
00171   void SetUpdateExtent(int piece, int numPieces)
00172     {this->SetUpdateExtent(piece, numPieces, 0);}
00173   
00175   void SetUpdateExtent( int x1, int x2, int y1, int y2, int z1, int z2 )
00176     { this->vtkDataSet::SetUpdateExtent( x1, x2, y1, y2, z1, z2 ); };
00177   void SetUpdateExtent( int ext[6] )
00178     { this->vtkDataSet::SetUpdateExtent( ext ); };
00179 
00183   void SetExtent(int extent[6]);
00184   void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
00185   vtkGetVector6Macro(Extent,int);
00186 
00191   virtual unsigned long GetEstimatedMemorySize();
00192 
00195   double GetScalarTypeMin();
00196   double GetScalarTypeMax();
00197   
00199   int GetScalarSize();
00200 
00204   int *GetIncrements();
00205   void GetIncrements(int &incX, int &incY, int &incZ);
00206   void GetIncrements(int inc[3]);
00207   
00212   void GetContinuousIncrements(int extent[6], int &incX, int &incY,
00213                 int &incZ);
00214   
00216   void *GetScalarPointerForExtent(int coordinates[6]);
00217   void *GetScalarPointer(int coordinates[3]);
00218   void *GetScalarPointer(int x, int y, int z);
00219   void *GetScalarPointer();
00220 
00222   float GetScalarComponentAsFloat(int x, int y, int z, int component);
00223   
00225   void AllocateScalars();
00226   
00231   void CopyAndCastFrom(vtkImageData *inData, int extent[6]);
00232 
00235   vtkImageToStructuredPoints *MakeImageToStructuredPoints();
00236 
00242   unsigned long GetActualMemorySize();
00243   
00246   vtkSetVector3Macro(Spacing,float);
00247   vtkGetVector3Macro(Spacing,float);
00248   
00251   vtkSetVector3Macro(Origin,float);
00252   vtkGetVector3Macro(Origin,float);
00253   
00255   vtkSetMacro(ScalarType, int);
00256   int GetScalarType();
00257 
00259   void SetNumberOfScalarComponents( int n );
00260   vtkGetMacro(NumberOfScalarComponents,int);
00261 
00262   // Must only be called with vtkImageData (or subclass) as input
00263   void CopyTypeSpecificInformation( vtkDataObject *image );
00264 
00268   virtual void PrepareForNewData();
00269 
00271   void ShallowCopy(vtkDataObject *src);  
00272   void DeepCopy(vtkDataObject *src);
00273 
00274 #ifndef VTK_REMOVE_LEGACY_CODE
00275 
00276   void GetCellPoints(int cellId, vtkIdList &ptIds)
00277     {VTK_LEGACY_METHOD(GetCellPoints,"3.2");this->GetCellPoints(cellId, &ptIds);}
00278   void GetPointCells(int ptId, vtkIdList &cellIds)
00279     {VTK_LEGACY_METHOD(GetPointCells,"3.2");this->GetPointCells(ptId, &cellIds);}
00280   void GetVoxelGradient(int i,int j,int k, vtkScalars *s, vtkVectors &g)
00281     {VTK_LEGACY_METHOD(GetVoxelGradient,"3.2");this->GetVoxelGradient(i, j, k, s, &g);}
00282   vtkImageData *UpdateAndReturnData() 
00283     {VTK_LEGACY_METHOD(UpdateAndReturnData,"3.2");this->Update();return this;}
00284 #endif
00285   
00286 protected:
00287   vtkImageData();
00288   ~vtkImageData();
00289   vtkImageData(const vtkImageData&) {};
00290   void operator=(const vtkImageData&) {};
00291 
00292   vtkImageToStructuredPoints *ImageToStructuredPoints;
00293 
00294   // for the GetCell method
00295   vtkVertex *Vertex;
00296   vtkLine *Line;
00297   vtkPixel *Pixel;
00298   vtkVoxel *Voxel;
00299 
00300   // The extent type is a 3D extent
00301   int GetExtentType() { return VTK_3D_EXTENT; };
00302 
00303   // The extent of what is currently in the structured grid.
00304   // Dimensions is just an array to return a value.
00305   // Its contents are out of data until GetDimensions is called.
00306   int Dimensions[3];
00307   int DataDescription;
00308   int Increments[3];
00309 
00310   float Origin[3];
00311   float Spacing[3];
00312   int ScalarType;
00313   int NumberOfScalarComponents;
00314 
00315   void ComputeIncrements();
00316 
00317 private:
00318   void InternalImageDataCopy(vtkImageData *src);
00319 };
00320 
00321 
00322 inline void vtkImageData::GetPoint(int id, float x[3])
00323 {
00324   float *p=this->GetPoint(id);
00325   x[0] = p[0]; x[1] = p[1]; x[2] = p[2];
00326 }
00327 
00328 
00329 
00330 inline int vtkImageData::GetNumberOfPoints()
00331 {
00332   int *dims = this->GetDimensions();
00333   return dims[0]*dims[1]*dims[2];
00334 }
00335 
00336 inline int vtkImageData::GetDataDimension()
00337 {
00338   return vtkStructuredData::GetDataDimension(this->DataDescription);
00339 }
00340 
00341 #endif
00342 
00343 
00344 

Generated on Wed Nov 21 12:26:52 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001