VTK  9.7.1
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
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 
44 VTK_ABI_NAMESPACE_BEGIN
45 class vtkCell;
46 class vtkCellData;
47 class vtkCellIterator;
48 class vtkCellTypes;
49 class vtkGenericCell;
50 class vtkIdList;
51 class vtkPointData;
52 class vtkPoints;
54 class vtkCallbackCommand;
55 
56 class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkDataSet : public vtkDataObject
57 {
58 public:
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 
81  virtual vtkIdType GetNumberOfPoints() = 0;
82 
87  virtual vtkIdType GetNumberOfCells() = 0;
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 
115  virtual vtkCellIterator* NewCellIterator();
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 
136  void SetCellOrderAndRationalWeights(vtkIdType cellId, vtkGenericCell* cell);
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 
175  virtual vtkIdType GetCellSize(vtkIdType cellId);
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 
298  vtkMTimeType GetMTime() override;
299 
304  vtkCellData* GetCellData() { return this->CellData; }
305 
310  vtkPointData* GetPointData() { return this->PointData; }
311 
316  virtual void Squeeze();
317 
322  virtual void ComputeBounds();
323 
329  double* GetBounds() VTK_SIZEHINT(6);
330 
337  void GetBounds(double bounds[6]);
338 
343  double* GetCenter() VTK_SIZEHINT(3);
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 
410  double* GetScalarRange() VTK_SIZEHINT(2);
411 
417  virtual int GetMaxCellSize() = 0;
418 
420 
427  virtual int GetMaxSpatialDimension();
428  virtual int GetMinSpatialDimension();
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  {
456  DATA_OBJECT_FIELD = 0,
457  POINT_DATA_FIELD = 1,
458  CELL_DATA_FIELD = 2
459  };
460 
469  int CheckAttributes();
470 
472 
477  virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
478  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
480 
482 
486  static vtkDataSet* GetData(vtkInformationVector* v, int i = 0);
488 
496 
500  vtkIdType GetNumberOfElements(int type) override;
501 
511  virtual vtkMTimeType GetMeshMTime();
512 
517  bool HasAnyGhostCells();
522  bool HasAnyGhostPoints();
528  virtual bool HasAnyBlankCells() { return false; }
534  virtual bool HasAnyBlankPoints() { return false; }
535 
540  vtkUnsignedCharArray* GetPointGhostArray();
541 
545  vtkUnsignedCharArray* AllocatePointGhostArray();
546 
551  vtkUnsignedCharArray* GetCellGhostArray();
552 
556  vtkUnsignedCharArray* AllocateCellGhostArray();
562  vtkUnsignedCharArray* GetGhostArray(int type) override;
563 
567  bool SupportsGhostArray(int type) override;
568 
569 protected:
570  // Constructor with default bounds (0,1, 0,1, 0,1).
571  vtkDataSet();
572  ~vtkDataSet() override;
573 
574  vtkNew<vtkGenericCell> GenericCell; // used by GetCell()
575 
580  vtkMTimeType GetGhostCellsTime();
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 
601 private:
602  void InternalDataSetCopy(vtkDataSet* src);
603 
604  // This should only be used if a vtkDataSet subclass don't define GetPoints()
605  vtkSmartPointer<vtkPoints> TempPoints;
606 
607  vtkDataSet(const vtkDataSet&) = delete;
608  void operator=(const vtkDataSet&) = delete;
609 };
610 
611 inline 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 
619 VTK_ABI_NAMESPACE_END
620 #endif
virtual vtkUnsignedCharArray * GetGhostArray(int type)
Returns the ghost arrays of the data object of the specified attribute type.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:477
void GetBounds(T a, double bds[6])
virtual vtkFieldData * GetAttributesAsFieldData(int type)
Returns the attributes of the data object as a vtkFieldData.
represent and manipulate point attribute data
Definition: vtkPointData.h:30
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkCellData * CellData
Definition: vtkDataSet.h:588
vtkPointData * PointData
Definition: vtkDataSet.h:589
record modification and/or execution time
Definition: vtkTimeStamp.h:24
represent and manipulate cell attribute data
Definition: vtkCellData.h:31
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:304
virtual bool SupportsGhostArray(int type)
Returns if this type of data object support ghost array for specified type.
int vtkIdType
Definition: vtkType.h:363
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:528
provides thread-safe access to cells
vtkTimeStamp ScalarRangeComputeTime
Definition: vtkDataSet.h:599
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:310
vtkNew< vtkGenericCell > GenericCell
Definition: vtkDataSet.h:574
abstract class to specify cell behavior
Definition: vtkCell.h:50
#define VTK_DEPRECATED_IN_9_6_0(reason)
supports function callbacks
VTKIOCATALYSTCONDUIT_EXPORT int GetCellType(const std::string &shape)
Get vtk cell type from conduit shape name throw a runtime_error on unsupported type.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition: vtkDataSet.h:534
list of point or cell ids
Definition: vtkIdList.h:25
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE
dynamic, self-adjusting array of unsigned char
virtual vtkIdType GetNumberOfElements(int type)
Get the number of elements for a specific attribute type (POINT, CELL, etc.).
virtual vtkCell * GetCell(int i, int j, int k)
Definition: vtkDataSet.h:130
void GetPoint(int i, int j, int k, double pnt[3])
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:591
Store zero or more vtkInformation instances.
Efficient cell iterator for vtkDataSet topologies.
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
#define VTK_MARSHALAUTO
vtkCallbackCommand * DataObserver
Definition: vtkDataSet.h:590
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
general representation of visualization data
Definition: vtkDataObject.h:55
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:248
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:43
virtual void DeepCopy(vtkDataObject *src)
The goal of the method is to copy the complete data from src into this object.
represent and manipulate 3D points
Definition: vtkPoints.h:30
virtual void ShallowCopy(vtkDataObject *src)
The goal of the method is to copy the data up to the array pointers only.
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51