VTK  9.7.0
vtkDataSet.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
33
34#ifndef vtkDataSet_h
35#define vtkDataSet_h
36
37#include "vtkCommonDataModelModule.h" // For export macro
38#include "vtkDataObject.h"
39#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_6_0()
40#include "vtkNew.h" // For vtkNew
41#include "vtkSmartPointer.h" // For vtkSmartPointer
42#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
43
44VTK_ABI_NAMESPACE_BEGIN
45class vtkCell;
46class vtkCellData;
47class vtkCellIterator;
48class vtkCellTypes;
49class vtkGenericCell;
50class vtkIdList;
51class vtkPointData;
52class vtkPoints;
55
56class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkDataSet : public vtkDataObject
57{
58public:
59 vtkTypeMacro(vtkDataSet, vtkDataObject);
60 void PrintSelf(ostream& os, vtkIndent indent) override;
61
68 virtual void CopyStructure(vtkDataSet* ds) = 0;
69
75 virtual void CopyAttributes(vtkDataSet* ds);
76
82
88
95 virtual vtkPoints* GetPoints();
96
101 virtual double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) = 0;
102
109 virtual void GetPoint(vtkIdType id, double x[3]);
110
116
129 virtual vtkCell* GetCell(vtkIdType cellId) = 0;
130 virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
131 {
132 vtkErrorMacro("ijk indices are only valid with structured data!");
133 return nullptr;
134 }
135
137
145 virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
146
158 virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
159
165 virtual int GetCellType(vtkIdType cellId) = 0;
166
176
178
187 virtual void GetDistinctCellTypes(vtkCellTypes* types);
188 VTK_DEPRECATED_IN_9_6_0("Use GetDistinctCellTypes(vtkCellTypes* types) instead.")
189 virtual void GetCellTypes(vtkCellTypes* types) { this->GetDistinctCellTypes(types); }
191
197 virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
198
211 virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts,
212 vtkIdList* ptIds) VTK_SIZEHINT(pts, npts);
213
219 virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
220
228 virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
229
238 virtual int GetCellNumberOfFaces(vtkIdType cellId, unsigned char& cellType, vtkGenericCell* cell);
239
241
248 vtkIdType FindPoint(double x, double y, double z)
249 {
250 double xyz[3];
251 xyz[0] = x;
252 xyz[1] = y;
253 xyz[2] = z;
254 return this->FindPoint(xyz);
255 }
256 virtual vtkIdType FindPoint(double x[3]) = 0;
258
270 virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
271 double pcoords[3], double* weights);
272
280 virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
281 double tol2, int& subId, double pcoords[3], double* weights) = 0;
282
291 virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
292 int& subId, double pcoords[3], double* weights);
293
299
304 vtkCellData* GetCellData() { return this->CellData; }
305
311
316 virtual void Squeeze();
317
322 virtual void ComputeBounds();
323
330
337 void GetBounds(double bounds[6]);
338
344
350 void GetCenter(double center[3]);
351
357 double GetLength();
358
364 double GetLength2();
365
381 double GetSampledMaxCellLength2(vtkIdType numSamples = 100);
382
387 void Initialize() override;
388
399 virtual void GetScalarRange(double range[2]);
400
411
417 virtual int GetMaxCellSize() = 0;
418
420
430
439 unsigned long GetActualMemorySize() override;
440
444 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_DATA_SET; }
445
447
450 void ShallowCopy(vtkDataObject* src) override;
451 void DeepCopy(vtkDataObject* src) override;
453
455 {
459 };
460
470
472
477 virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
478 virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
480
482
488
496
500 vtkIdType GetNumberOfElements(int type) override;
501
512
528 virtual bool HasAnyBlankCells() { return false; }
534 virtual bool HasAnyBlankPoints() { return false; }
535
541
546
552
563
567 bool SupportsGhostArray(int type) override;
568
569protected:
570 // Constructor with default bounds (0,1, 0,1, 0,1).
572 ~vtkDataSet() override;
573
575
581
586 virtual void ComputeScalarRange();
587
588 vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
589 vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
590 vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
591 vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
592 double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
593 double Center[3];
594
595 // Cached scalar range
596 double ScalarRange[2];
597
598 // Time at which scalar range is computed
600
601private:
602 void InternalDataSetCopy(vtkDataSet* src);
603
604 // This should only be used if a vtkDataSet subclass don't define GetPoints()
606
607 vtkDataSet(const vtkDataSet&) = delete;
608 void operator=(const vtkDataSet&) = delete;
609};
610
611inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
612{
613 double* pt = this->GetPoint(id);
614 x[0] = pt[0];
615 x[1] = pt[1];
616 x[2] = pt[2];
617}
618
619VTK_ABI_NAMESPACE_END
620#endif
supports function callbacks
represent and manipulate cell attribute data
Definition vtkCellData.h:32
Efficient cell iterator for vtkDataSet topologies.
object provides direct access to cells in vtkCellArray and type information
abstract class to specify cell behavior
Definition vtkCell.h:51
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)
Locate cell based on global coordinate x and tolerance squared.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition vtkDataSet.h:534
static vtkDataSet * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
vtkMTimeType GetMTime() override
Datasets are composite objects and need to check each part for MTime THIS METHOD IS THREAD SAFE.
vtkIdType GetNumberOfElements(int type) override
Get the number of elements for a specific attribute type (POINT, CELL, etc.).
virtual vtkIdType GetCellSize(vtkIdType cellId)
Get the size of cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition vtkDataSet.h:310
bool HasAnyGhostCells()
Returns 1 if there are any ghost cells 0 otherwise.
double Center[3]
Definition vtkDataSet.h:593
vtkUnsignedCharArray * AllocateCellGhostArray()
Allocate ghost array for cells.
bool HasAnyGhostPoints()
Returns 1 if there are any ghost points 0 otherwise.
virtual void ComputeBounds()
Compute the data bounding box from data points.
vtkUnsignedCharArray * GetGhostArray(int type) override
Returns the ghost array for the given type (point or cell).
vtkTimeStamp ComputeTime
Definition vtkDataSet.h:591
virtual void CopyAttributes(vtkDataSet *ds)
Copy the attributes associated with the specified dataset to this instance of vtkDataSet.
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
Topological inquiry to get cells using point.
vtkTimeStamp ScalarRangeComputeTime
Definition vtkDataSet.h:599
static vtkDataSet * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
int GetDataObjectType() VTK_FUTURE_CONST override
Return the type of data object.
Definition vtkDataSet.h:444
virtual vtkMTimeType GetMeshMTime()
Abstract method which return the mesh (geometry/topology) modification time.
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual vtkPoints * GetPoints()
If the subclass has (implicit/explicit) points, then return them.
double GetLength()
Return the length of the diagonal of the bounding box.
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
This is a version of the above method that can be used with multithreaded applications.
double GetLength2()
Return the squared length of the diagonal of the bounding box.
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
@ DATA_OBJECT_FIELD
Definition vtkDataSet.h:456
virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
vtkFieldData * GetAttributesAsFieldData(int type) override
Returns the attributes of the data object as a vtkFieldData.
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition vtkDataSet.h:528
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition vtkDataSet.h:477
virtual int GetMaxSpatialDimension()
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
vtkPointData * PointData
Definition vtkDataSet.h:589
virtual void ComputeScalarRange()
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
vtkMTimeType GetGhostCellsTime()
Return the MTime of the ghost cells array.
virtual void GetCellTypes(vtkCellTypes *types)
Get a list of types of cells in a dataset.
Definition vtkDataSet.h:189
virtual void GetScalarRange(double range[2])
Convenience method to get the range of the first component (and only the first component) of any scal...
double * GetCenter()
Get the center of the bounding box.
vtkNew< vtkGenericCell > GenericCell
Definition vtkDataSet.h:574
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
void Initialize() override
Restore data object to initial state.
double Bounds[6]
Definition vtkDataSet.h:592
virtual void GetDistinctCellTypes(vtkCellTypes *types)
Get a list of types of cells in a dataset.
double GetSampledMaxCellLength2(vtkIdType numSamples=100)
Samples max squared cell length using strided indexing.
vtkCellData * CellData
Definition vtkDataSet.h:588
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual int GetMinSpatialDimension()
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
vtkCallbackCommand * DataObserver
Definition vtkDataSet.h:590
virtual void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts, vtkIdList *ptIds)
Topological inquiry to get points defining cell.
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkUnsignedCharArray * GetCellGhostArray()
Get the array that defines the ghost type of each cell.
virtual int GetCellNumberOfFaces(vtkIdType cellId, unsigned char &cellType, vtkGenericCell *cell)
Get the number of faces of a cell.
vtkUnsignedCharArray * AllocatePointGhostArray()
Allocate ghost array for points.
void SetCellOrderAndRationalWeights(vtkIdType cellId, vtkGenericCell *cell)
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition vtkDataSet.h:248
virtual vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)
Locate the cell that contains a point and return the cell.
virtual void Squeeze()
Reclaim any extra memory used to store data.
double ScalarRange[2]
Definition vtkDataSet.h:596
~vtkDataSet() override
virtual int GetMaxCellSize()=0
Convenience method returns largest cell size in dataset.
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUnsignedCharArray * GetPointGhostArray()
Gets the array that defines the ghost type of each point.
virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly)
Normally called by pipeline executives or algorithms only.
virtual vtkCell * GetCell(int i, int j, int k)
Definition vtkDataSet.h:130
virtual vtkCellIterator * NewCellIterator()
Return an iterator that traverses the cells in this data set.
int CheckAttributes()
This method checks to see if the cell and point attributes match the geometry.
bool SupportsGhostArray(int type) override
Returns true for POINT or CELL, false otherwise.
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition vtkDataSet.h:304
virtual vtkIdType FindPoint(double x[3])=0
Locate the closest point to the global coordinate x.
Represents and manipulates a collection of data arrays.
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:26
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Allocate and hold a VTK object.
Definition vtkNew.h:59
represent and manipulate point attribute data
represent and manipulate 3D points
Definition vtkPoints.h:31
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:363
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
@ VTK_DATA_SET
Definition vtkType.h:117
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO
#define VTK_NEWINSTANCE