VTK
vtkImageData.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageData.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
30 #ifndef vtkImageData_h
31 #define vtkImageData_h
32 
33 #include "vtkCommonDataModelModule.h" // For export macro
34 #include "vtkDataSet.h"
35 
36 #include "vtkStructuredData.h" // Needed for inline methods
37 
38 class vtkDataArray;
39 class vtkLine;
40 class vtkPixel;
41 class vtkVertex;
42 class vtkVoxel;
43 
45 {
46 public:
47  static vtkImageData *New();
48 
49  vtkTypeMacro(vtkImageData,vtkDataSet);
50  void PrintSelf(ostream& os, vtkIndent indent);
51 
54  virtual void CopyStructure(vtkDataSet *ds);
55 
57  virtual int GetDataObjectType() {return VTK_IMAGE_DATA;};
58 
60 
61  virtual vtkIdType GetNumberOfCells();
62  virtual vtkIdType GetNumberOfPoints();
63  virtual double *GetPoint(vtkIdType ptId);
64  virtual void GetPoint(vtkIdType id, double x[3]);
65  virtual vtkCell *GetCell(vtkIdType cellId);
66  virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
67  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
68  virtual vtkIdType FindPoint(double x, double y, double z)
69  {
70  return this->vtkDataSet::FindPoint(x, y, z);
71  }
72  virtual vtkIdType FindPoint(double x[3]);
73  virtual vtkIdType FindCell(
74  double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
75  int& subId, double pcoords[3], double *weights);
76  virtual vtkIdType FindCell(
77  double x[3], vtkCell *cell, vtkGenericCell *gencell,
78  vtkIdType cellId, double tol2, int& subId,
79  double pcoords[3], double *weights);
80  virtual vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
81  double tol2, int& subId, double pcoords[3],
82  double *weights);
83  virtual int GetCellType(vtkIdType cellId);
84  virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
85  {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
86  this->GetDimensions());}
87  virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
88  {vtkStructuredData::GetPointCells(ptId,cellIds,this->GetDimensions());}
89  virtual void ComputeBounds();
90  virtual int GetMaxCellSize() {return 8;}; //voxel is the largest
92 
94  virtual void Initialize();
95 
98  virtual void SetDimensions(int i, int j, int k);
99 
103  virtual void SetDimensions(const int dims[3]);
104 
109  virtual int *GetDimensions();
110 
114  virtual void GetDimensions(int dims[3]);
115 
117 
122  virtual int ComputeStructuredCoordinates(
123  const double x[3], int ijk[3], double pcoords[3]);
125 
126  static int ComputeStructuredCoordinates( const double x[3], int ijk[3], double pcoords[3],
127  const int* extent,
128  const double* spacing,
129  const double* origin,
130  const double* bounds);
132 
140  virtual void GetVoxelGradient(
141  int i,int j,int k, vtkDataArray *s, vtkDataArray *g);
143 
145 
150  virtual void GetPointGradient(
151  int i, int j, int k, vtkDataArray *s, double g[3]);
153 
155  virtual int GetDataDimension();
156 
158 
160  virtual vtkIdType ComputePointId(int ijk[3]) {
161  return vtkStructuredData::ComputePointIdForExtent(this->Extent,ijk);};
163 
165 
167  virtual vtkIdType ComputeCellId(int ijk[3]) {
168  return vtkStructuredData::ComputeCellIdForExtent(this->Extent,ijk);};
170 
172 
173  virtual void SetAxisUpdateExtent(int axis, int min, int max,
174  const int* updateExtent,
175  int* axisUpdateExtent);
176  virtual void GetAxisUpdateExtent(int axis, int &min, int &max, const int* updateExtent);
178 
180 
188  virtual void SetExtent(int extent[6]);
189  virtual void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
190  vtkGetVector6Macro(Extent, int);
192 
194 
196  virtual double GetScalarTypeMin(vtkInformation* meta_data);
197  virtual double GetScalarTypeMin();
198  virtual double GetScalarTypeMax(vtkInformation* meta_data);
199  virtual double GetScalarTypeMax();
201 
203 
204  virtual int GetScalarSize(vtkInformation* meta_data);
205  virtual int GetScalarSize();
207 
209 
214  virtual vtkIdType *GetIncrements();
215  virtual void GetIncrements(vtkIdType &incX, vtkIdType &incY, vtkIdType &incZ);
216  virtual void GetIncrements(vtkIdType inc[3]);
217  virtual vtkIdType *GetIncrements(vtkDataArray *scalars);
218  virtual void GetIncrements(vtkDataArray *scalars,
219  vtkIdType &incX, vtkIdType &incY, vtkIdType &incZ);
220  virtual void GetIncrements(vtkDataArray *scalars, vtkIdType inc[3]);
222 
224 
235  virtual void GetContinuousIncrements(
236  int extent[6], vtkIdType &incX, vtkIdType &incY, vtkIdType &incZ);
237  virtual void GetContinuousIncrements(vtkDataArray *scalars,
238  int extent[6], vtkIdType &incX, vtkIdType &incY, vtkIdType &incZ);
240 
242 
243  virtual void *GetScalarPointerForExtent(int extent[6]);
244  virtual void *GetScalarPointer(int coordinates[3]);
245  virtual void *GetScalarPointer(int x, int y, int z);
246  virtual void *GetScalarPointer();
248 
250 
251  virtual float GetScalarComponentAsFloat(int x, int y, int z, int component);
252  virtual void SetScalarComponentFromFloat(
253  int x, int y, int z, int component, float v);
254  virtual double GetScalarComponentAsDouble(int x, int y, int z, int component);
255  virtual void SetScalarComponentFromDouble(
256  int x, int y, int z, int component, double v);
258 
262  virtual void AllocateScalars(int dataType, int numComponents);
263 
268  virtual void AllocateScalars(vtkInformation* pipeline_info);
269 
271 
275  virtual void CopyAndCastFrom(vtkImageData *inData, int extent[6]);
276  virtual void CopyAndCastFrom(vtkImageData *inData, int x0, int x1,
277  int y0, int y1, int z0, int z1)
278  {int e[6]; e[0]=x0; e[1]=x1; e[2]=y0; e[3]=y1; e[4]=z0; e[5]=z1;
279  this->CopyAndCastFrom(inData, e);}
281 
285  virtual void Crop(const int* updateExtent);
286 
292  virtual unsigned long GetActualMemorySize();
293 
295 
297  vtkSetVector3Macro(Spacing,double);
298  vtkGetVector3Macro(Spacing,double);
300 
302 
308  vtkSetVector3Macro(Origin,double);
309  vtkGetVector3Macro(Origin,double);
311 
312  static void SetScalarType(int, vtkInformation* meta_data);
313  static int GetScalarType(vtkInformation* meta_data);
314  static bool HasScalarType(vtkInformation* meta_data);
315  int GetScalarType();
316  const char* GetScalarTypeAsString()
317  { return vtkImageScalarTypeNameMacro ( this->GetScalarType() ); };
318 
320 
322  static void SetNumberOfScalarComponents( int n, vtkInformation* meta_data);
323  static int GetNumberOfScalarComponents(vtkInformation* meta_data);
324  static bool HasNumberOfScalarComponents(vtkInformation* meta_data);
325  int GetNumberOfScalarComponents();
327 
330  virtual void CopyInformationFromPipeline(vtkInformation* information);
331 
335  virtual void CopyInformationToPipeline(vtkInformation* information);
336 
340  virtual void PrepareForNewData();
341 
343 
344  virtual void ShallowCopy(vtkDataObject *src);
345  virtual void DeepCopy(vtkDataObject *src);
347 
348  //--------------------------------------------------------------------------
349  // Methods that apply to any array (not just scalars).
350  // I am starting to experiment with generalizing imaging fitlers
351  // to operate on more than just scalars.
352 
354 
357  void *GetArrayPointerForExtent(vtkDataArray* array, int extent[6]);
358  void *GetArrayPointer(vtkDataArray* array, int coordinates[3]);
360 
363  void GetArrayIncrements(vtkDataArray *array, vtkIdType increments[3]);
364 
369  void ComputeInternalExtent(int *intExt, int *tgtExt, int *bnds);
370 
372  virtual int GetExtentType() { return VTK_3D_EXTENT; };
373 
374  //BTX
376 
378  static vtkImageData* GetData(vtkInformationVector* v, int i=0);
379  //ETX
381 
382 protected:
383  vtkImageData();
384  ~vtkImageData();
385 
386  // The extent of what is currently in the structured grid.
387  // Dimensions is just an array to return a value.
388  // Its contents are out of data until GetDimensions is called.
389  int Dimensions[3];
390  vtkIdType Increments[3];
391 
392  double Origin[3];
393  double Spacing[3];
394 
395  int Extent[6];
396 
397  // The first method assumes Active Scalars
398  void ComputeIncrements();
399  // This one is given the number of components of the
400  // scalar field explicitly
401  void ComputeIncrements(int numberOfComponents);
402  void ComputeIncrements(vtkDataArray *scalars);
403 
404  // The first method assumes Acitive Scalars
405  void ComputeIncrements(vtkIdType inc[3]);
406  // This one is given the number of components of the
407  // scalar field explicitly
408  void ComputeIncrements(int numberOfComponents, vtkIdType inc[3]);
409  void ComputeIncrements(vtkDataArray *scalars, vtkIdType inc[3]);
410  void CopyOriginAndSpacingFromPipeline(vtkInformation* info);
411 
413 
414  void SetDataDescription(int desc);
415  int GetDataDescription() { return this->DataDescription; }
416 
417 private:
418  void InternalImageDataCopy(vtkImageData *src);
419 private:
420 
421  //BTX
422  friend class vtkUniformGrid;
423  //ETX
424 
425  // for the GetCell method
426  vtkVertex *Vertex;
427  vtkLine *Line;
428  vtkPixel *Pixel;
429  vtkVoxel *Voxel;
430 
431  // for the GetPoint method
432  double Point[3];
433 
434  int DataDescription;
435 
436  vtkImageData(const vtkImageData&); // Not implemented.
437  void operator=(const vtkImageData&); // Not implemented.
438 };
439 
440 
441 //----------------------------------------------------------------------------
443 {
444  this->ComputeIncrements(this->Increments);
445 }
446 
447 //----------------------------------------------------------------------------
448 inline void vtkImageData::ComputeIncrements(int numberOfComponents)
449 {
450  this->ComputeIncrements(numberOfComponents, this->Increments);
451 }
452 
453 //----------------------------------------------------------------------------
455 {
456  this->ComputeIncrements(scalars, this->Increments);
457 }
458 
459 //----------------------------------------------------------------------------
461 {
462  this->GetPoint(id, this->Point);
463  return this->Point;
464 }
465 
466 //----------------------------------------------------------------------------
468 {
469  const int *extent = this->Extent;
470  vtkIdType dims[3];
471  dims[0] = extent[1] - extent[0] + 1;
472  dims[1] = extent[3] - extent[2] + 1;
473  dims[2] = extent[5] - extent[4] + 1;
474 
475  return dims[0]*dims[1]*dims[2];
476 }
477 
478 //----------------------------------------------------------------------------
480 {
481  return vtkStructuredData::GetDataDimension(this->DataDescription);
482 }
483 
484 #endif
virtual int GetExtentType()
Definition: vtkImageData.h:372
virtual int GetMaxCellSize()
Definition: vtkImageData.h:90
#define VTK_IMAGE_DATA
Definition: vtkType.h:70
virtual vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)
virtual vtkIdType GetNumberOfCells()=0
unsigned long GetActualMemorySize()
static vtkDataObject * New()
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
Store vtkAlgorithm input/output information.
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)
Definition: vtkImageData.h:87
virtual vtkIdType GetNumberOfPoints()=0
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
a cell that represents a 3D point
Definition: vtkVertex.h:35
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:61
record modification and/or execution time
Definition: vtkTimeStamp.h:34
static int GetDataDimension(int dataDescription)
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:39
virtual void ComputeBounds()
virtual void PrepareForNewData()
virtual vtkIdType FindPoint(double x, double y, double z)
Definition: vtkImageData.h:68
int vtkIdType
Definition: vtkType.h:247
virtual vtkIdType ComputeCellId(int ijk[3])
Definition: vtkImageData.h:167
static vtkDataSet * GetData(vtkInformation *info)
provides thread-safe access to cells
virtual vtkIdType ComputePointId(int ijk[3])
Definition: vtkImageData.h:160
virtual void Crop(const int *updateExtent)
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:58
void PrintSelf(ostream &os, vtkIndent indent)
virtual int GetDataObjectType()
Definition: vtkImageData.h:57
virtual void CopyAndCastFrom(vtkImageData *inData, int x0, int x1, int y0, int y1, int z0, int z1)
Definition: vtkImageData.h:276
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:43
a simple class to control print indentation
Definition: vtkIndent.h:38
static vtkIdType ComputeCellIdForExtent(int extent[6], int ijk[3], int dataDescription=VTK_EMPTY)
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
list of point or cell ids
Definition: vtkIdList.h:35
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual double * GetPoint(vtkIdType ptId)
Definition: vtkImageData.h:460
virtual void CopyInformationFromPipeline(vtkInformation *vtkNotUsed(info))
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)
Definition: vtkImageData.h:84
int GetDataDescription()
Definition: vtkImageData.h:415
void DeepCopy(vtkDataObject *src)
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
vtkIdType Increments[3]
Definition: vtkImageData.h:390
image data with blanking
static vtkIdType ComputePointIdForExtent(int extent[6], int ijk[3], int dataDescription=VTK_EMPTY)
const char * GetScalarTypeAsString()
Definition: vtkImageData.h:316
void ComputeIncrements()
Definition: vtkImageData.h:442
void Initialize()
virtual void CopyStructure(vtkDataSet *ds)=0
Store zero or more vtkInformation instances.
virtual double * GetPoint(vtkIdType ptId)=0
general representation of visualization data
Definition: vtkDataObject.h:64
virtual void CopyInformationToPipeline(vtkInformation *vtkNotUsed(info))
vtkIdType FindPoint(double x, double y, double z)
Definition: vtkDataSet.h:154
virtual vtkIdType GetNumberOfPoints()
Definition: vtkImageData.h:467
#define VTKCOMMONDATAMODEL_EXPORT
virtual vtkCell * GetCell(vtkIdType cellId)=0
#define max(a, b)
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
virtual int GetDataDimension()
Definition: vtkImageData.h:479
virtual int GetCellType(vtkIdType cellId)=0
void ShallowCopy(vtkDataObject *src)
vtkTimeStamp ExtentComputeTime
Definition: vtkImageData.h:412