VTK  9.2.6
vtkDataSet.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDataSet.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
155 #ifndef vtkDataSet_h
156 #define vtkDataSet_h
157 
158 #include "vtkCommonDataModelModule.h" // For export macro
159 #include "vtkDataObject.h"
160 
161 class vtkCell;
162 class vtkCellData;
163 class vtkCellIterator;
164 class vtkCellTypes;
165 class vtkGenericCell;
166 class vtkIdList;
167 class vtkPointData;
169 class vtkCallbackCommand;
170 
171 class VTKCOMMONDATAMODEL_EXPORT vtkDataSet : public vtkDataObject
172 {
173 public:
174  vtkTypeMacro(vtkDataSet, vtkDataObject);
175  void PrintSelf(ostream& os, vtkIndent indent) override;
176 
183  virtual void CopyStructure(vtkDataSet* ds) = 0;
184 
190  virtual void CopyAttributes(vtkDataSet* ds);
191 
197 
203 
208  virtual double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) = 0;
209 
216  virtual void GetPoint(vtkIdType id, double x[3]);
217 
223 
236  virtual vtkCell* GetCell(vtkIdType cellId) = 0;
237  virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
238  {
239  vtkErrorMacro("ijk indices are only valid with structured data!");
240  return nullptr;
241  }
242 
244 
252  virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
253 
265  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
266 
272  virtual int GetCellType(vtkIdType cellId) = 0;
273 
282  virtual vtkIdType GetCellSize(vtkIdType cellId);
283 
293  virtual void GetCellTypes(vtkCellTypes* types);
294 
300  virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
301 
314  virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts,
315  vtkIdList* ptIds) VTK_SIZEHINT(pts, npts);
316 
322  virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
323 
331  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
332 
334 
341  vtkIdType FindPoint(double x, double y, double z)
342  {
343  double xyz[3];
344  xyz[0] = x;
345  xyz[1] = y;
346  xyz[2] = z;
347  return this->FindPoint(xyz);
348  }
349  virtual vtkIdType FindPoint(double x[3]) = 0;
351 
363  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
364  double pcoords[3], double* weights) = 0;
365 
373  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
374  double tol2, int& subId, double pcoords[3], double* weights) = 0;
375 
384  virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
385  int& subId, double pcoords[3], double* weights);
386 
391  vtkMTimeType GetMTime() override;
392 
397  vtkCellData* GetCellData() { return this->CellData; }
398 
403  vtkPointData* GetPointData() { return this->PointData; }
404 
409  virtual void Squeeze();
410 
415  virtual void ComputeBounds();
416 
422  double* GetBounds() VTK_SIZEHINT(6);
423 
430  void GetBounds(double bounds[6]);
431 
436  double* GetCenter() VTK_SIZEHINT(3);
437 
443  void GetCenter(double center[3]);
444 
450  double GetLength();
451 
457  double GetLength2();
458 
463  void Initialize() override;
464 
475  virtual void GetScalarRange(double range[2]);
476 
486  double* GetScalarRange() VTK_SIZEHINT(2);
487 
493  virtual int GetMaxCellSize() = 0;
494 
503  unsigned long GetActualMemorySize() override;
504 
508  int GetDataObjectType() override { return VTK_DATA_SET; }
509 
511 
514  void ShallowCopy(vtkDataObject* src) override;
515  void DeepCopy(vtkDataObject* src) override;
517 
519  {
520  DATA_OBJECT_FIELD = 0,
521  POINT_DATA_FIELD = 1,
522  CELL_DATA_FIELD = 2
523  };
524 
534 
536 
541  virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
542  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
544 
546 
550  static vtkDataSet* GetData(vtkInformationVector* v, int i = 0);
552 
560 
565 
581  virtual bool HasAnyBlankCells() { return false; }
587  virtual bool HasAnyBlankPoints() { return false; }
588 
598 
603 
613 
624 
625 protected:
626  // Constructor with default bounds (0,1, 0,1, 0,1).
628  ~vtkDataSet() override;
629 
634  virtual void ComputeScalarRange();
635 
640  bool IsAnyBitSet(vtkUnsignedCharArray* a, int bitFlag);
641 
642  vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
643  vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
644  vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
645  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
646  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
647  double Center[3];
648 
649  // Cached scalar range
650  double ScalarRange[2];
651 
652  // Time at which scalar range is computed
654 
656 
665 
666 private:
667  void InternalDataSetCopy(vtkDataSet* src);
672  static void OnDataModified(
673  vtkObject* source, unsigned long eid, void* clientdata, void* calldata);
674 
675  friend class vtkImageAlgorithmToDataSetFriendship;
676 
677 private:
678  vtkDataSet(const vtkDataSet&) = delete;
679  void operator=(const vtkDataSet&) = delete;
680 };
681 
682 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
683 {
684  double* pt = this->GetPoint(id);
685  x[0] = pt[0];
686  x[1] = pt[1];
687  x[2] = pt[2];
688 }
689 
690 #endif
void GetPoint(const int i, const int j, const int k, double pnt[3])
supports function callbacks
represent and manipulate cell attribute data
Definition: vtkCellData.h:151
Efficient cell iterator for vtkDataSet topologies.
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:146
abstract class to specify cell behavior
Definition: vtkCell.h:150
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:172
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:587
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:645
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.
vtkUnsignedCharArray * PointGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:660
vtkTimeStamp ScalarRangeComputeTime
Definition: vtkDataSet.h:653
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.
bool CellGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:663
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:581
bool IsAnyBitSet(vtkUnsignedCharArray *a, int bitFlag)
Helper function that tests if any of the values in 'a' have bitFlag set.
bool PointGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:662
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:541
vtkPointData * PointData
Definition: vtkDataSet.h:643
virtual void ComputeScalarRange()
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
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:237
vtkUnsignedCharArray * CellGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
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:403
vtkCellData * CellData
Definition: vtkDataSet.h:642
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:644
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:397
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.
void UpdateCellGhostArrayCache()
Updates the pointer to the cell ghost array.
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:341
virtual void Squeeze()
Reclaim any extra memory used to store data.
void UpdatePointGhostArrayCache()
Updates the pointer to the point ghost array.
~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.
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:172
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:143
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition: vtkObject.h:82
represent and manipulate point attribute data
Definition: vtkPointData.h:151
record modification and/or execution time
Definition: vtkTimeStamp.h:55
dynamic, self-adjusting array of unsigned char
void GetBounds(T a, double bds[6])
@ info
Definition: vtkX3D.h:382
@ range
Definition: vtkX3D.h:244
@ center
Definition: vtkX3D.h:236
@ type
Definition: vtkX3D.h:522
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:332
#define VTK_DATA_SET
Definition: vtkType.h:85
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE