VTK  9.4.20250222
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
143#ifndef vtkDataSet_h
144#define vtkDataSet_h
145
146#include "vtkCommonDataModelModule.h" // For export macro
147#include "vtkDataObject.h"
148#include "vtkNew.h" // For vtkNew
149#include "vtkSmartPointer.h" // For vtkSmartPointer
150#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
151
152VTK_ABI_NAMESPACE_BEGIN
153class vtkCell;
154class vtkCellData;
155class vtkCellIterator;
156class vtkCellTypes;
157class vtkGenericCell;
158class vtkIdList;
159class vtkPointData;
160class vtkPoints;
163
164class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkDataSet : public vtkDataObject
165{
166public:
167 vtkTypeMacro(vtkDataSet, vtkDataObject);
168 void PrintSelf(ostream& os, vtkIndent indent) override;
169
176 virtual void CopyStructure(vtkDataSet* ds) = 0;
177
183 virtual void CopyAttributes(vtkDataSet* ds);
184
190
196
204
209 virtual double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) = 0;
210
217 virtual void GetPoint(vtkIdType id, double x[3]);
218
224
237 virtual vtkCell* GetCell(vtkIdType cellId) = 0;
238 virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
239 {
240 vtkErrorMacro("ijk indices are only valid with structured data!");
241 return nullptr;
242 }
243
245
253 virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
254
266 virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
267
273 virtual int GetCellType(vtkIdType cellId) = 0;
274
284
294 virtual void GetCellTypes(vtkCellTypes* types);
295
301 virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
302
315 virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts,
316 vtkIdList* ptIds) VTK_SIZEHINT(pts, npts);
317
323 virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
324
332 virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
333
343 int GetCellNumberOfFaces(vtkIdType cellId, unsigned char& cellType, vtkGenericCell* cell);
344
346
353 vtkIdType FindPoint(double x, double y, double z)
354 {
355 double xyz[3];
356 xyz[0] = x;
357 xyz[1] = y;
358 xyz[2] = z;
359 return this->FindPoint(xyz);
360 }
361 virtual vtkIdType FindPoint(double x[3]) = 0;
363
375 virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
376 double pcoords[3], double* weights) = 0;
377
385 virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
386 double tol2, int& subId, double pcoords[3], double* weights) = 0;
387
396 virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
397 int& subId, double pcoords[3], double* weights);
398
404
409 vtkCellData* GetCellData() { return this->CellData; }
410
415 vtkPointData* GetPointData() { return this->PointData; }
416
421 virtual void Squeeze();
422
427 virtual void ComputeBounds();
428
435
442 void GetBounds(double bounds[6]);
443
448 double* GetCenter() VTK_SIZEHINT(3);
449
455 void GetCenter(double center[3]);
456
462 double GetLength();
463
469 double GetLength2();
470
475 void Initialize() override;
476
487 virtual void GetScalarRange(double range[2]);
488
498 double* GetScalarRange() VTK_SIZEHINT(2);
499
505 virtual int GetMaxCellSize() = 0;
506
508
515 virtual int GetMaxSpatialDimension();
516 virtual int GetMinSpatialDimension();
518
527 unsigned long GetActualMemorySize() override;
528
532 int GetDataObjectType() override { return VTK_DATA_SET; }
533
535
538 void ShallowCopy(vtkDataObject* src) override;
539 void DeepCopy(vtkDataObject* src) override;
541
543 {
544 DATA_OBJECT_FIELD = 0,
545 POINT_DATA_FIELD = 1,
546 CELL_DATA_FIELD = 2
547 };
548
558
560
565 virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
566 virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
568
570
576
584
588 vtkIdType GetNumberOfElements(int type) override;
589
600
616 virtual bool HasAnyBlankCells() { return false; }
622 virtual bool HasAnyBlankPoints() { return false; }
623
629
634
640
651
655 bool SupportsGhostArray(int type) override;
656
657protected:
658 // Constructor with default bounds (0,1, 0,1, 0,1).
660 ~vtkDataSet() override;
661
663
669
674 virtual void ComputeScalarRange();
675
676 vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
677 vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
678 vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
679 vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
680 double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
681 double Center[3];
682
683 // Cached scalar range
684 double ScalarRange[2];
685
686 // Time at which scalar range is computed
688
689private:
690 void InternalDataSetCopy(vtkDataSet* src);
691
692 // This should only be used if a vtkDataSet subclass don't define GetPoints()
694
695 vtkDataSet(const vtkDataSet&) = delete;
696 void operator=(const vtkDataSet&) = delete;
697};
698
699inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
700{
701 double* pt = this->GetPoint(id);
702 x[0] = pt[0];
703 x[1] = pt[1];
704 x[2] = pt[2];
705}
706
707VTK_ABI_NAMESPACE_END
708#endif
void GetPoint(int i, int j, int k, double pnt[3])
supports function callbacks
represent and manipulate cell attribute data
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:130
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
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:622
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:415
bool HasAnyGhostCells()
Returns 1 if there are any ghost cells 0 otherwise.
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
Locate cell based on global coordinate x and tolerance squared.
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:679
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:687
static vtkDataSet * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
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.
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.
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
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:616
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition vtkDataSet.h:565
vtkPointData * PointData
Definition vtkDataSet.h:677
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.
vtkNew< vtkGenericCell > GenericCell
Definition vtkDataSet.h:662
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition vtkDataSet.h:238
vtkCellData * CellData
Definition vtkDataSet.h:676
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 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
vtkCallbackCommand * DataObserver
Definition vtkDataSet.h:678
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.
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:353
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.
~vtkDataSet() override
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 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:409
virtual vtkIdType FindPoint(double x[3])=0
Locate the closest point to the global coordinate x.
represent and manipulate fields of data
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Allocate and hold a VTK object.
Definition vtkNew.h:167
represent and manipulate point attribute data
represent and manipulate 3D points
Definition vtkPoints.h:139
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
int vtkIdType
Definition vtkType.h:315
#define VTK_DATA_SET
Definition vtkType.h:73
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO
#define VTK_NEWINSTANCE