VTK  9.5.20250828
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
134#ifndef vtkImageData_h
135#define vtkImageData_h
136
137#include "vtkCartesianGrid.h"
138#include "vtkCommonDataModelModule.h" // For export macro
139#include "vtkSmartPointer.h" // For vtkSmartPointer ivars
140#include "vtkStructuredData.h" // Needed for inline methods
141#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
142
143VTK_ABI_NAMESPACE_BEGIN
144class vtkDataArray;
146class vtkLine;
147class vtkMatrix3x3;
148class vtkMatrix4x4;
149class vtkPixel;
150class vtkPoints;
151class vtkVertex;
152class vtkVoxel;
153
154class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkImageData : public vtkCartesianGrid
155{
156public:
157 static vtkImageData* New();
159
161 void PrintSelf(ostream& os, vtkIndent indent) override;
162
166 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_IMAGE_DATA; }
167
169
172 void ShallowCopy(vtkDataObject* src) override;
173 void DeepCopy(vtkDataObject* src) override;
175
180 void CopyStructure(vtkDataSet* ds) override;
181
182 using Superclass::FindCell;
183 using Superclass::GetCell;
184
186
189 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
190 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
192 vtkIdType FindPoint(double x[3]) override;
193 vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
194 double pcoords[3], double* weights) override;
195 void ComputeBounds() override;
197
199
206 int ComputeStructuredCoordinates(const double x[3], int ijk[3], double pcoords[3]) override;
208 const double x[3], int ijk[3], double pcoords[3], double tol2);
210
215 vtkIdType ComputePointId(int ijk[3]) override;
216
221 vtkIdType ComputeCellId(int ijk[3]) override;
222
232 virtual void GetVoxelGradient(int i, int j, int k, vtkDataArray* s, vtkDataArray* g);
233
240 virtual void GetPointGradient(int i, int j, int k, vtkDataArray* s, double g[3]);
241
243
247 int axis, int min, int max, const int* updateExtent, int* axisUpdateExtent);
248 virtual void GetAxisUpdateExtent(int axis, int& min, int& max, const int* updateExtent);
250
252
256 virtual double GetScalarTypeMin(vtkInformation* meta_data);
257 virtual double GetScalarTypeMin();
258 virtual double GetScalarTypeMax(vtkInformation* meta_data);
259 virtual double GetScalarTypeMax();
261
263
266 virtual int GetScalarSize(vtkInformation* meta_data);
267 virtual int GetScalarSize();
269
271
283 virtual void GetIncrements(vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
284 virtual void GetIncrements(vtkIdType inc[3]);
285 virtual vtkIdType* GetIncrements(vtkDataArray* scalars) VTK_SIZEHINT(3);
286 virtual void GetIncrements(
287 vtkDataArray* scalars, vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
288 virtual void GetIncrements(vtkDataArray* scalars, vtkIdType inc[3]);
290
292
305 virtual void GetContinuousIncrements(
306 int extent[6], vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
307 virtual void GetContinuousIncrements(
308 vtkDataArray* scalars, int extent[6], vtkIdType& incX, vtkIdType& incY, vtkIdType& incZ);
310
312
315 virtual void* GetScalarPointerForExtent(int extent[6]);
316 virtual void* GetScalarPointer(int coordinates[3]);
317 virtual void* GetScalarPointer(int x, int y, int z);
318 virtual void* GetScalarPointer();
320
322
325 virtual vtkIdType GetScalarIndexForExtent(int extent[6]);
326 virtual vtkIdType GetScalarIndex(int coordinates[3]);
327 virtual vtkIdType GetScalarIndex(int x, int y, int z);
329
331
334 virtual float GetScalarComponentAsFloat(int x, int y, int z, int component);
335 virtual void SetScalarComponentFromFloat(int x, int y, int z, int component, float v);
336 virtual double GetScalarComponentAsDouble(int x, int y, int z, int component);
337 virtual void SetScalarComponentFromDouble(int x, int y, int z, int component, double v);
339
345 virtual void AllocateScalars(int dataType, int numComponents);
346
353 virtual void AllocateScalars(vtkInformation* pipeline_info);
354
356
362 virtual void CopyAndCastFrom(vtkImageData* inData, int extent[6]);
363 virtual void CopyAndCastFrom(vtkImageData* inData, int x0, int x1, int y0, int y1, int z0, int z1)
364 {
365 int e[6];
366 e[0] = x0;
367 e[1] = x1;
368 e[2] = y0;
369 e[3] = y1;
370 e[4] = z0;
371 e[5] = z1;
372 this->CopyAndCastFrom(inData, e);
373 }
375
381 void Crop(const int* updateExtent) override;
382
391 unsigned long GetActualMemorySize() override;
392
394
398 vtkGetVector3Macro(Spacing, double);
399 virtual void SetSpacing(double i, double j, double k);
400 virtual void SetSpacing(const double ijk[3]);
402
404
412 vtkGetVector3Macro(Origin, double);
413 virtual void SetOrigin(double i, double j, double k);
414 virtual void SetOrigin(const double ijk[3]);
416
418
422 vtkGetObjectMacro(DirectionMatrix, vtkMatrix3x3);
424 virtual void SetDirectionMatrix(const double elements[9]);
425 virtual void SetDirectionMatrix(double e00, double e01, double e02, double e10, double e11,
426 double e12, double e20, double e21, double e22);
428
430
434 vtkGetObjectMacro(IndexToPhysicalMatrix, vtkMatrix4x4);
436
438
449
451
454 virtual void TransformContinuousIndexToPhysicalPoint(double i, double j, double k, double xyz[3]);
455 virtual void TransformContinuousIndexToPhysicalPoint(const double ijk[3], double xyz[3]);
456 virtual void TransformIndexToPhysicalPoint(int i, int j, int k, double xyz[3]);
457 virtual void TransformIndexToPhysicalPoint(const int ijk[3], double xyz[3]);
458 static void TransformContinuousIndexToPhysicalPoint(double i, double j, double k,
459 double const origin[3], double const spacing[3], double const direction[9], double xyz[3]);
461
463
467 vtkGetObjectMacro(PhysicalToIndexMatrix, vtkMatrix4x4);
469
471
482
484
487 virtual void TransformPhysicalPointToContinuousIndex(double x, double y, double z, double ijk[3]);
488 virtual void TransformPhysicalPointToContinuousIndex(const double xyz[3], double ijk[3]);
490
492
495 virtual void TransformPhysicalNormalToContinuousIndex(const double xyz[3], double ijk[3]);
497
502 virtual void TransformPhysicalPlaneToContinuousIndex(double const pplane[4], double iplane[4]);
503
505
509 double const origin[3], double const spacing[3], double const direction[9], double result[16]);
510
512
516 double const origin[3], double const spacing[3], double const direction[9], double result[16]);
518
523 void CopyInformationFromPipeline(vtkInformation* information) override;
524
530 void CopyInformationToPipeline(vtkInformation* information) override;
531
537 void PrepareForNewData() override;
538
539 //--------------------------------------------------------------------------
540 // Methods that apply to any array (not just scalars).
541 // I am starting to experiment with generalizing imaging filters
542 // to operate on more than just scalars.
543
545
550 void* GetArrayPointerForExtent(vtkDataArray* array, int extent[6]);
551 void* GetArrayPointer(vtkDataArray* array, int coordinates[3]);
553
555
562 vtkIdType GetTupleIndex(vtkDataArray* array, int coordinates[3]);
564
569 void GetArrayIncrements(vtkDataArray* array, vtkIdType increments[3]);
570
577 void ComputeInternalExtent(int* intExt, int* tgtExt, int* bnds);
578
580
586
587protected:
589 ~vtkImageData() override;
590
591 vtkIdType Increments[3];
592
593 // Variables used to define dataset physical orientation
594 double Origin[3];
595 double Spacing[3];
599
600 // The first method assumes Active Scalars
601 void ComputeIncrements();
602 // This one is given the number of components of the
603 // scalar field explicitly
604 void ComputeIncrements(int numberOfComponents);
605 void ComputeIncrements(vtkDataArray* scalars);
606
607 // The first method assumes Active Scalars
609 // This one is given the number of components of the
610 // scalar field explicitly
611 void ComputeIncrements(int numberOfComponents, vtkIdType inc[3]);
613
614 // for the index to physical methods
616
617 void BuildPoints() override;
618
622 void ComputeScalarRange() override;
623
624private:
625 void InternalImageDataCopy(vtkImageData* src);
626
627 friend class vtkUniformGrid;
628
629 bool DirectionMatrixIsIdentity;
630
631 vtkImageData(const vtkImageData&) = delete;
632 void operator=(const vtkImageData&) = delete;
633};
634
635//----------------------------------------------------------------------------
637{
638 this->ComputeIncrements(this->Increments);
639}
640
641//----------------------------------------------------------------------------
642inline void vtkImageData::ComputeIncrements(int numberOfComponents)
643{
644 this->ComputeIncrements(numberOfComponents, this->Increments);
645}
646
647//----------------------------------------------------------------------------
649{
650 this->ComputeIncrements(scalars, this->Increments);
651}
652
653//----------------------------------------------------------------------------
655{
657}
658
659//----------------------------------------------------------------------------
661{
663}
664
665VTK_ABI_NAMESPACE_END
666#endif
Abstract API for vtkImageData and vtkRectilinearGrid.
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.
abstract class to specify cell behavior
Definition vtkCell.h:129
abstract superclass for arrays of numeric data
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition vtkDataSet.h:352
provides thread-safe access to cells
topologically and geometrically regular array of data
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.
void BuildPoints() override
Pure abstract method responsible to build and set internal points.
virtual void SetDirectionMatrix(vtkMatrix3x3 *m)
Set/Get the direction transform of the dataset.
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()
vtkIdType GetTupleIndex(vtkDataArray *array, int coordinates[3])
Given a data array and a coordinate, return the index of the tuple in the array corresponding to that...
void ComputeIncrements(int numberOfComponents, vtkIdType inc[3])
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 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.
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.
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).
void ComputeIncrements(vtkIdType inc[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.
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 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 double GetScalarTypeMax()
These returns the minimum and maximum values the ScalarType can hold without overflowing.
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:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
cell represents a 1D line
Definition vtkLine.h:132
represent and manipulate 3x3 transformation matrices
represent and manipulate 4x4 transformation matrices
a cell that represents an orthogonal quadrilateral
Definition vtkPixel.h:66
represent and manipulate 3D points
Definition vtkPoints.h:139
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,...
Deprecated vtkImageData.
a cell that represents a 3D point
Definition vtkVertex.h:92
a cell that represents a 3D orthogonal parallelepiped
Definition vtkVoxel.h:80
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition vtkType.h:332
@ VTK_IMAGE_DATA
Definition vtkType.h:82
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO
#define max(a, b)