VTK  9.6.1
vtkImageData.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
24
25#ifndef vtkImageData_h
26#define vtkImageData_h
27
28#include "vtkCartesianGrid.h"
29#include "vtkCommonDataModelModule.h" // For export macro
30#include "vtkSmartPointer.h" // For vtkSmartPointer ivars
31#include "vtkStructuredData.h" // Needed for inline methods
32#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
33
34VTK_ABI_NAMESPACE_BEGIN
35class vtkDataArray;
37class vtkLine;
38class vtkMatrix3x3;
39class vtkMatrix4x4;
40class vtkPixel;
41class vtkPoints;
42class vtkVertex;
43class vtkVoxel;
44
45class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkImageData : public vtkCartesianGrid
46{
47public:
48 static vtkImageData* New();
50
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
57 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_IMAGE_DATA; }
58
60
63 void ShallowCopy(vtkDataObject* src) override;
64 void DeepCopy(vtkDataObject* src) override;
66
71 void CopyStructure(vtkDataSet* ds) override;
72
75
77
80 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
81 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
83 vtkIdType FindPoint(double x[3]) override;
84 vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
85 double pcoords[3], double* weights) override;
86 void ComputeBounds() override;
88
90
97 int ComputeStructuredCoordinates(const double x[3], int ijk[3], double pcoords[3]) override;
99 const double x[3], int ijk[3], double pcoords[3], double tol2);
101
106 vtkIdType ComputePointId(int ijk[3]) override;
107
112 vtkIdType ComputeCellId(int ijk[3]) override;
113
123 virtual void GetVoxelGradient(int i, int j, int k, vtkDataArray* s, vtkDataArray* g);
124
131 virtual void GetPointGradient(int i, int j, int k, vtkDataArray* s, double g[3]);
132
134
138 int axis, int min, int max, const int* updateExtent, int* axisUpdateExtent);
139 virtual void GetAxisUpdateExtent(int axis, int& min, int& max, const int* updateExtent);
141
143
147 virtual double GetScalarTypeMin(vtkInformation* meta_data);
148 virtual double GetScalarTypeMin();
149 virtual double GetScalarTypeMax(vtkInformation* meta_data);
150 virtual double GetScalarTypeMax();
152
154
157 virtual int GetScalarSize(vtkInformation* meta_data);
158 virtual int GetScalarSize();
160
162
174 virtual void GetIncrements(vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
175 virtual void GetIncrements(vtkIdType inc[3]);
177 virtual void GetIncrements(
178 vtkDataArray* scalars, vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
179 virtual void GetIncrements(vtkDataArray* scalars, vtkIdType inc[3]);
181
183
197 int extent[6], vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
199 vtkDataArray* scalars, int extent[6], vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
201
203
206 virtual void* GetScalarPointerForExtent(int extent[6]);
207 virtual void* GetScalarPointer(int coordinates[3]);
208 virtual void* GetScalarPointer(int x, int y, int z);
209 virtual void* GetScalarPointer();
211
213
216 virtual vtkIdType GetScalarIndexForExtent(int extent[6]);
217 virtual vtkIdType GetScalarIndex(int coordinates[3]);
218 virtual vtkIdType GetScalarIndex(int x, int y, int z);
220
222
225 virtual float GetScalarComponentAsFloat(int x, int y, int z, int component);
226 virtual void SetScalarComponentFromFloat(int x, int y, int z, int component, float v);
227 virtual double GetScalarComponentAsDouble(int x, int y, int z, int component);
228 virtual void SetScalarComponentFromDouble(int x, int y, int z, int component, double v);
230
236 virtual void AllocateScalars(int dataType, int numComponents);
237
244 virtual void AllocateScalars(vtkInformation* pipeline_info);
245
247
253 virtual void CopyAndCastFrom(vtkImageData* inData, int extent[6]);
254 virtual void CopyAndCastFrom(vtkImageData* inData, int x0, int x1, int y0, int y1, int z0, int z1)
255 {
256 int e[6];
257 e[0] = x0;
258 e[1] = x1;
259 e[2] = y0;
260 e[3] = y1;
261 e[4] = z0;
262 e[5] = z1;
263 this->CopyAndCastFrom(inData, e);
264 }
265
266
272 void Crop(const int* updateExtent) override;
273
282 unsigned long GetActualMemorySize() override;
283
285
289 vtkGetVector3Macro(Spacing, double);
290 virtual void SetSpacing(double i, double j, double k);
291 virtual void SetSpacing(const double ijk[3]);
293
295
303 vtkGetVector3Macro(Origin, double);
304 virtual void SetOrigin(double i, double j, double k);
305 virtual void SetOrigin(const double ijk[3]);
307
309
313 vtkGetObjectMacro(DirectionMatrix, vtkMatrix3x3);
315 virtual void SetDirectionMatrix(const double elements[9]);
316 virtual void SetDirectionMatrix(double e00, double e01, double e02, double e10, double e11,
317 double e12, double e20, double e21, double e22);
319
321
327
329
340
342
345 virtual void TransformContinuousIndexToPhysicalPoint(double i, double j, double k, double xyz[3]);
346 virtual void TransformContinuousIndexToPhysicalPoint(const double ijk[3], double xyz[3]);
347 virtual void TransformIndexToPhysicalPoint(int i, int j, int k, double xyz[3]);
348 virtual void TransformIndexToPhysicalPoint(const int ijk[3], double xyz[3]);
349 static void TransformContinuousIndexToPhysicalPoint(double i, double j, double k,
350 double const origin[3], double const spacing[3], double const direction[9], double xyz[3]);
352
354
360
362
373
375
378 virtual void TransformPhysicalPointToContinuousIndex(double x, double y, double z, double ijk[3]);
379 virtual void TransformPhysicalPointToContinuousIndex(const double xyz[3], double ijk[3]);
381
383
386 virtual void TransformPhysicalNormalToContinuousIndex(const double xyz[3], double ijk[3]);
388
393 virtual void TransformPhysicalPlaneToContinuousIndex(double const pplane[4], double iplane[4]);
394
396
400 double const origin[3], double const spacing[3], double const direction[9], double result[16]);
401
403
407 double const origin[3], double const spacing[3], double const direction[9], double result[16]);
409
414 void CopyInformationFromPipeline(vtkInformation* information) override;
415
421 void CopyInformationToPipeline(vtkInformation* information) override;
422
428 void PrepareForNewData() override;
429
430 //--------------------------------------------------------------------------
431 // Methods that apply to any array (not just scalars).
432 // I am starting to experiment with generalizing imaging filters
433 // to operate on more than just scalars.
434
436
441 void* GetArrayPointerForExtent(vtkDataArray* array, int extent[6]);
442 void* GetArrayPointer(vtkDataArray* array, int coordinates[3]);
443 void* GetArrayPointer(vtkDataArray* array, int x, int y, int z);
445
450 void GetArrayIncrements(vtkDataArray* array, vtkIdType increments[3]);
451
458 void ComputeInternalExtent(int* intExt, int* tgtExt, int* bnds);
459
461
467
468protected:
470 ~vtkImageData() override;
471
473
474 // Variables used to define dataset physical orientation
475 double Origin[3];
476 double Spacing[3];
480
481 // The first method assumes Active Scalars
482 void ComputeIncrements();
483 // This one is given the number of components of the
484 // scalar field explicitly
485 void ComputeIncrements(int numberOfComponents);
486 void ComputeIncrements(vtkDataArray* scalars);
487
488 // The first method assumes Active Scalars
490 // This one is given the number of components of the
491 // scalar field explicitly
492 void ComputeIncrements(int numberOfComponents, vtkIdType inc[3]);
494
495 // for the index to physical methods
497
498 void BuildPoints() override;
499
503 void ComputeScalarRange() override;
504
505private:
506 void InternalImageDataCopy(vtkImageData* src);
507
508 friend class vtkUniformGrid;
509
510 bool DirectionMatrixIsIdentity;
511
512 vtkImageData(const vtkImageData&) = delete;
513 void operator=(const vtkImageData&) = delete;
514};
515
516//----------------------------------------------------------------------------
518{
519 this->ComputeIncrements(this->Increments);
520}
521
522//----------------------------------------------------------------------------
523inline void vtkImageData::ComputeIncrements(int numberOfComponents)
524{
525 this->ComputeIncrements(numberOfComponents, this->Increments);
526}
527
528//----------------------------------------------------------------------------
530{
531 this->ComputeIncrements(scalars, this->Increments);
532}
533
534//----------------------------------------------------------------------------
539
540//----------------------------------------------------------------------------
545
546VTK_ABI_NAMESPACE_END
547#endif
vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Standard vtkDataSet API methods.
virtual int * GetExtent()
Set/Get the extent.
virtual vtkIdType ComputeCellId(int ijk[3])=0
Given a location in structured coordinates (i-j-k), return the cell id.
virtual vtkIdType ComputePointId(int ijk[3])=0
Given a location in structured coordinates (i-j-k), return the point id.
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet API methods.
abstract class to specify cell behavior
Definition vtkCell.h:50
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition vtkDataSet.h:248
provides thread-safe access to cells
void Crop(const int *updateExtent) override
Reallocates and copies to set the Extent to updateExtent.
virtual void TransformPhysicalPointToContinuousIndex(const double xyz[3], double ijk[3])
Convert coordinates from physical space (xyz) to index space (ijk).
int ComputeStructuredCoordinates(const double x[3], int ijk[3], double pcoords[3]) override
Computes the structured coordinates for a point x[3].
virtual vtkIdType * GetIncrements()
Different ways to get the increments for moving around the data.
void GetArrayIncrements(vtkDataArray *array, vtkIdType increments[3])
Since various arrays have different number of components, the will have different increments.
int GetDataObjectType() VTK_FUTURE_CONST override
Return what type of dataset this is.
virtual void TransformContinuousIndexToPhysicalPoint(const double ijk[3], double xyz[3])
Convert coordinates from index space (ijk) to physical space (xyz).
void CopyInformationToPipeline(vtkInformation *information) override
Copy information from this data object to the pipeline information.
virtual void CopyAndCastFrom(vtkImageData *inData, int extent[6])
This method is passed a input and output region, and executes the filter algorithm to fill the output...
void * GetArrayPointer(vtkDataArray *array, int x, int y, int z)
These are convenience methods for getting a pointer from any filed array.
void BuildPoints() override
Pure abstract method responsible to build and set internal points.
friend class vtkUniformGrid
virtual void SetDirectionMatrix(vtkMatrix3x3 *m)
Set/Get the direction transform of the dataset.
virtual float GetScalarComponentAsFloat(int x, int y, int z, int component)
For access to data from wrappers.
vtkMatrix4x4 * IndexToPhysicalMatrix
void ComputeInternalExtent(int *intExt, int *tgtExt, int *bnds)
Given how many pixel are required on a side for boundary conditions (in bnds), the target extent to t...
virtual double GetScalarTypeMin()
These returns the minimum and maximum values the ScalarType can hold without overflowing.
virtual void SetDirectionMatrix(const double elements[9])
Set/Get the direction transform of the dataset.
void ComputeIncrements()
static vtkImageData * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
virtual void TransformIndexToPhysicalPoint(const int ijk[3], double xyz[3])
Convert coordinates from index space (ijk) to physical space (xyz).
void ComputeBounds() override
Standard vtkDataSet API methods.
void * GetArrayPointerForExtent(vtkDataArray *array, int extent[6])
These are convenience methods for getting a pointer from any filed array.
static vtkImageData * ExtendedNew()
virtual double GetScalarTypeMin(vtkInformation *meta_data)
These returns the minimum and maximum values the ScalarType can hold without overflowing.
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Standard vtkDataSet API methods.
virtual void TransformPhysicalNormalToContinuousIndex(const double xyz[3], double ijk[3])
Convert normal from physical space (xyz) to index space (ijk).
virtual int GetScalarSize(vtkInformation *meta_data)
Get the size of the scalar type in bytes.
void ComputeScalarRange() override
Override this method because of blanking.
virtual void TransformPhysicalPlaneToContinuousIndex(double const pplane[4], double iplane[4])
Convert a plane from physical to a continuous index.
virtual void GetVoxelGradient(int i, int j, int k, vtkDataArray *s, vtkDataArray *g)
Given structured coordinates (i,j,k) for a voxel cell, compute the eight gradient values for the voxe...
virtual double GetScalarTypeMax(vtkInformation *meta_data)
These returns the minimum and maximum values the ScalarType can hold without overflowing.
static vtkImageData * New()
void ComputeIncrements(int numberOfComponents, vtkIdType inc[3])
virtual vtkIdType GetScalarIndex(int coordinates[3])
Access the index for the scalar data.
vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Standard vtkDataSet API methods.
static void ComputePhysicalToIndexMatrix(double const origin[3], double const spacing[3], double const direction[9], double result[16])
Static method to compute the PhysicalToIndexMatrix.
void ComputeIncrements(vtkDataArray *scalars, vtkIdType inc[3])
virtual void GetAxisUpdateExtent(int axis, int &min, int &max, const int *updateExtent)
Set / Get the extent on just one axis.
void * GetArrayPointer(vtkDataArray *array, int coordinates[3])
These are convenience methods for getting a pointer from any filed array.
virtual void AllocateScalars(int dataType, int numComponents)
Allocate the point scalars for this dataset.
virtual void SetScalarComponentFromFloat(int x, int y, int z, int component, float v)
For access to data from wrappers.
virtual void SetSpacing(double i, double j, double k)
Set the spacing (width,height,length) of the cubical cells that compose the data set.
virtual void SetDirectionMatrix(double e00, double e01, double e02, double e10, double e11, double e12, double e20, double e21, double e22)
Set/Get the direction transform of the dataset.
vtkIdType Increments[3]
void ApplyIndexToPhysicalMatrix(vtkMatrix4x4 *source)
Set the transformation matrix from the index space to the physical space coordinate system of the dat...
vtkIdType ComputeCellId(int ijk[3]) override
Given a location in structured coordinates (i-j-k), return the cell id.
virtual void SetSpacing(const double ijk[3])
Set the spacing (width,height,length) of the cubical cells that compose the data set.
virtual void SetOrigin(const double ijk[3])
Set/Get the origin of the dataset.
virtual void GetContinuousIncrements(int extent[6], vtkIdType &incX, vtkIdType &incY, vtkIdType &incZ)
Different ways to get the increments for moving around the data.
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
virtual int GetScalarSize()
Get the size of the scalar type in bytes.
virtual void TransformPhysicalPointToContinuousIndex(double x, double y, double z, double ijk[3])
Convert coordinates from physical space (xyz) to index space (ijk).
void CopyInformationFromPipeline(vtkInformation *information) override
Override these to handle origin, spacing, scalar type, and scalar number of components.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard vtkObject API methods.
virtual double GetScalarComponentAsDouble(int x, int y, int z, int component)
For access to data from wrappers.
static void TransformContinuousIndexToPhysicalPoint(double i, double j, double k, double const origin[3], double const spacing[3], double const direction[9], double xyz[3])
Convert coordinates from index space (ijk) to physical space (xyz).
virtual vtkIdType GetScalarIndexForExtent(int extent[6])
Access the index for the scalar data.
void ComputeIncrements(vtkIdType inc[3])
double Spacing[3]
void ApplyPhysicalToIndexMatrix(vtkMatrix4x4 *source)
Get the transformation matrix from the physical space to the index space coordinate system of the dat...
void ComputeTransforms()
vtkMatrix3x3 * DirectionMatrix
vtkIdType FindPoint(double x[3]) override
Standard vtkDataSet API methods.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet API methods.
double Origin[3]
static void ComputeIndexToPhysicalMatrix(double const origin[3], double const spacing[3], double const direction[9], double result[16])
Static method to compute the IndexToPhysicalMatrix.
virtual void SetScalarComponentFromDouble(int x, int y, int z, int component, double v)
For access to data from wrappers.
virtual void TransformContinuousIndexToPhysicalPoint(double i, double j, double k, double xyz[3])
Convert coordinates from index space (ijk) to physical space (xyz).
virtual void SetOrigin(double i, double j, double k)
Set/Get the origin of the dataset.
virtual void * GetScalarPointer(int coordinates[3])
Access the native pointer for the scalar data.
virtual double GetScalarTypeMax()
These returns the minimum and maximum values the ScalarType can hold without overflowing.
virtual void * GetScalarPointerForExtent(int extent[6])
Access the native pointer for the scalar data.
virtual void TransformIndexToPhysicalPoint(int i, int j, int k, double xyz[3])
Convert coordinates from index space (ijk) to physical space (xyz).
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
virtual void SetAxisUpdateExtent(int axis, int min, int max, const int *updateExtent, int *axisUpdateExtent)
Set / Get the extent on just one axis.
virtual void GetPointGradient(int i, int j, int k, vtkDataArray *s, double g[3])
Given structured coordinates (i,j,k) for a point in a structured point dataset, compute the gradient ...
~vtkImageData() override
void PrepareForNewData() override
make the output data ready for new data to be inserted.
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input image data object.
vtkIdType ComputePointId(int ijk[3]) override
Given a location in structured coordinates (i-j-k), return the point id.
virtual int ComputeStructuredCoordinates(const double x[3], int ijk[3], double pcoords[3], double tol2)
Computes the structured coordinates for a point x[3].
vtkMatrix4x4 * PhysicalToIndexMatrix
static vtkImageData * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
cell represents a 1D line
Definition vtkLine.h:23
represent and manipulate 3x3 transformation matrices
represent and manipulate 4x4 transformation matrices
a cell that represents an orthogonal quadrilateral
Definition vtkPixel.h:27
represent and manipulate 3D points
Definition vtkPoints.h:30
implicit object to represent cell connectivity
static vtkIdType ComputePointIdForExtent(const int extent[6], const int ijk[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given a location in structured coordinates (i-j-k), and the extent of the structured dataset,...
static vtkIdType ComputeCellIdForExtent(const int extent[6], const int ijk[3], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given a location in structured coordinates (i-j-k), and the extent of the structured dataset,...
a cell that represents a 3D point
Definition vtkVertex.h:23
a cell that represents a 3D orthogonal parallelepiped
Definition vtkVoxel.h:31
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define vtkDataArray
int vtkIdType
Definition vtkType.h:368
@ VTK_IMAGE_DATA
Definition vtkType.h:115
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO
#define max(a, b)