VTK  9.3.20240412
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
149 #include "vtkNew.h" // For vtkNew
150 #include "vtkSmartPointer.h" // For vtkSmartPointer
151 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
152 
153 VTK_ABI_NAMESPACE_BEGIN
154 class vtkCell;
155 class vtkCellData;
156 class vtkCellIterator;
157 class vtkCellTypes;
158 class vtkGenericCell;
159 class vtkIdList;
160 class vtkPointData;
161 class vtkPoints;
163 class vtkCallbackCommand;
164 
165 class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkDataSet : public vtkDataObject
166 {
167 public:
168  vtkTypeMacro(vtkDataSet, vtkDataObject);
169  void PrintSelf(ostream& os, vtkIndent indent) override;
170 
177  virtual void CopyStructure(vtkDataSet* ds) = 0;
178 
184  virtual void CopyAttributes(vtkDataSet* ds);
185 
191 
197 
204  virtual vtkPoints* GetPoints();
205 
210  virtual double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) = 0;
211 
218  virtual void GetPoint(vtkIdType id, double x[3]);
219 
225 
238  virtual vtkCell* GetCell(vtkIdType cellId) = 0;
239  virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
240  {
241  vtkErrorMacro("ijk indices are only valid with structured data!");
242  return nullptr;
243  }
244 
246 
254  virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
255 
267  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
268 
274  virtual int GetCellType(vtkIdType cellId) = 0;
275 
284  virtual vtkIdType GetCellSize(vtkIdType cellId);
285 
295  virtual void GetCellTypes(vtkCellTypes* types);
296 
302  virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
303 
316  virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts,
317  vtkIdList* ptIds) VTK_SIZEHINT(pts, npts);
318 
324  virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
325 
333  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
334 
344  int GetCellNumberOfFaces(vtkIdType cellId, unsigned char& cellType, vtkGenericCell* cell);
345 
347 
354  vtkIdType FindPoint(double x, double y, double z)
355  {
356  double xyz[3];
357  xyz[0] = x;
358  xyz[1] = y;
359  xyz[2] = z;
360  return this->FindPoint(xyz);
361  }
362  virtual vtkIdType FindPoint(double x[3]) = 0;
364 
376  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
377  double pcoords[3], double* weights) = 0;
378 
386  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
387  double tol2, int& subId, double pcoords[3], double* weights) = 0;
388 
397  virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
398  int& subId, double pcoords[3], double* weights);
399 
404  vtkMTimeType GetMTime() override;
405 
410  vtkCellData* GetCellData() { return this->CellData; }
411 
416  vtkPointData* GetPointData() { return this->PointData; }
417 
422  virtual void Squeeze();
423 
428  virtual void ComputeBounds();
429 
435  double* GetBounds() VTK_SIZEHINT(6);
436 
443  void GetBounds(double bounds[6]);
444 
449  double* GetCenter() VTK_SIZEHINT(3);
450 
456  void GetCenter(double center[3]);
457 
463  double GetLength();
464 
470  double GetLength2();
471 
476  void Initialize() override;
477 
488  virtual void GetScalarRange(double range[2]);
489 
499  double* GetScalarRange() VTK_SIZEHINT(2);
500 
506  virtual int GetMaxCellSize() = 0;
507 
515  virtual int GetMaxSpatialDimension();
516 
525  unsigned long GetActualMemorySize() override;
526 
530  int GetDataObjectType() override { return VTK_DATA_SET; }
531 
533 
536  void ShallowCopy(vtkDataObject* src) override;
537  void DeepCopy(vtkDataObject* src) override;
539 
541  {
542  DATA_OBJECT_FIELD = 0,
543  POINT_DATA_FIELD = 1,
544  CELL_DATA_FIELD = 2
545  };
546 
556 
558 
563  virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
564  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
566 
568 
572  static vtkDataSet* GetData(vtkInformationVector* v, int i = 0);
574 
582 
587 
603  virtual bool HasAnyBlankCells() { return false; }
609  virtual bool HasAnyBlankPoints() { return false; }
610 
616 
620  VTK_DEPRECATED_IN_9_3_0("This function is deprecated. It has no effect.")
621  void UpdatePointGhostArrayCache() {}
622 
627 
633 
637  VTK_DEPRECATED_IN_9_3_0("This function is deprecated. It has no effect.")
638  void UpdateCellGhostArrayCache() {}
639 
650 
654  bool SupportsGhostArray(int type) override;
655 
656 protected:
657  // Constructor with default bounds (0,1, 0,1, 0,1).
659  ~vtkDataSet() override;
660 
661  vtkNew<vtkGenericCell> GenericCell; // used by GetCell()
662 
668 
673  virtual void ComputeScalarRange();
674 
675  vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
676  vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
677  vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
678  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
679  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
680  double Center[3];
681 
682  // Cached scalar range
683  double ScalarRange[2];
684 
685  // Time at which scalar range is computed
687 
689 
693  VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.")
694  vtkUnsignedCharArray* PointGhostArray;
695  VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.")
696  vtkUnsignedCharArray* CellGhostArray;
697  VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.")
698  bool PointGhostArrayCached;
699  VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.")
700  bool CellGhostArrayCached;
702 
703 private:
704  void InternalDataSetCopy(vtkDataSet* src);
709  static void OnDataModified(
710  vtkObject* source, unsigned long eid, void* clientdata, void* calldata);
711 
712  // This should only be used if a vtkDataSet subclass don't define GetPoints()
713  vtkSmartPointer<vtkPoints> TempPoints;
714 
715  vtkDataSet(const vtkDataSet&) = delete;
716  void operator=(const vtkDataSet&) = delete;
717 };
718 
719 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
720 {
721  double* pt = this->GetPoint(id);
722  x[0] = pt[0];
723  x[1] = pt[1];
724  x[2] = pt[2];
725 }
726 
727 VTK_ABI_NAMESPACE_END
728 #endif
void GetPoint(int i, int j, int k, double pnt[3])
supports function callbacks
represent and manipulate cell attribute data
Definition: vtkCellData.h:141
Efficient cell iterator for vtkDataSet topologies.
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:134
abstract class to specify cell behavior
Definition: vtkCell.h:130
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
vtkFieldData * GetAttributesAsFieldData(int type) override
Returns the attributes of the data object as a vtkFieldData.
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:609
vtkUnsignedCharArray * GetPointGhostArray()
Gets the array that defines the ghost type of each point.
vtkMTimeType GetMTime() override
Datasets are composite objects and need to check each part for MTime THIS METHOD IS THREAD SAFE.
vtkUnsignedCharArray * GetCellGhostArray()
Get the array that defines the ghost type of each cell.
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.
bool HasAnyGhostCells()
Returns 1 if there are any ghost cells 0 otherwise.
static vtkDataSet * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
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.
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.
bool HasAnyGhostPoints()
Returns 1 if there are any ghost points 0 otherwise.
virtual void ComputeBounds()
Compute the data bounding box from data points.
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:678
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:686
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
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.
double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
vtkUnsignedCharArray * GetGhostArray(int type) override
Returns the ghost array for the given type (point or cell).
virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
static vtkDataSet * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:603
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:563
vtkPointData * PointData
Definition: vtkDataSet.h:676
virtual void ComputeScalarRange()
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
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.
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition: vtkDataSet.h:239
virtual vtkPoints * GetPoints()
If the subclass has (implicit/explicit) points, then return them.
vtkNew< vtkGenericCell > GenericCell
Definition: vtkDataSet.h:661
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:416
vtkCellData * CellData
Definition: vtkDataSet.h:675
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:677
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:410
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.
virtual vtkCellIterator * NewCellIterator()
Return an iterator that traverses the cells in this data set.
int GetCellNumberOfFaces(vtkIdType cellId, unsigned char &cellType, vtkGenericCell *cell)
Get the number of faces of a cell.
vtkUnsignedCharArray * AllocateCellGhostArray()
Allocate ghost array for cells.
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:354
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.
virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly)
Normally called by pipeline executives or algorithms only.
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
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.
virtual vtkIdType FindPoint(double x[3])=0
Locate the closest point to the global coordinate x.
vtkUnsignedCharArray * AllocatePointGhostArray()
Allocate ghost array for points.
represent and manipulate fields of data
Definition: vtkFieldData.h:162
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.
abstract base class for most VTK objects
Definition: vtkObject.h:162
represent and manipulate point attribute data
Definition: vtkPointData.h:140
represent and manipulate 3D points
Definition: vtkPoints.h:139
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
dynamic, self-adjusting array of unsigned char
void GetBounds(T a, double bds[6])
@ info
Definition: vtkX3D.h:376
@ range
Definition: vtkX3D.h:238
@ center
Definition: vtkX3D.h:230
@ type
Definition: vtkX3D.h:516
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_DEPRECATED_IN_9_3_0(reason)
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