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 =========================================================================*/
46 #ifndef vtkDataSet_h
47 #define vtkDataSet_h
48 
49 #include "vtkCommonDataModelModule.h" // For export macro
50 #include "vtkDataObject.h"
51 
52 class vtkCell;
53 class vtkCellData;
54 class vtkCellIterator;
55 class vtkCellTypes;
56 class vtkGenericCell;
57 class vtkIdList;
58 class vtkPointData;
60 class vtkCallbackCommand;
61 
62 class VTKCOMMONDATAMODEL_EXPORT vtkDataSet : public vtkDataObject
63 {
64 public:
65  vtkTypeMacro(vtkDataSet, vtkDataObject);
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
74  virtual void CopyStructure(vtkDataSet* ds) = 0;
75 
81  virtual void CopyAttributes(vtkDataSet* ds);
82 
87  virtual vtkIdType GetNumberOfPoints() = 0;
88 
93  virtual vtkIdType GetNumberOfCells() = 0;
94 
99  virtual double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) = 0;
100 
107  virtual void GetPoint(vtkIdType id, double x[3]);
108 
113  virtual vtkCellIterator* NewCellIterator();
114 
127  virtual vtkCell* GetCell(vtkIdType cellId) = 0;
128  virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
129  {
130  vtkErrorMacro("ijk indices are only valid with structured data!");
131  return nullptr;
132  }
133 
134  void SetCellOrderAndRationalWeights(vtkIdType cellId, vtkGenericCell* cell);
135 
143  virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
144 
156  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
157 
163  virtual int GetCellType(vtkIdType cellId) = 0;
164 
173  virtual vtkIdType GetCellSize(vtkIdType cellId);
174 
184  virtual void GetCellTypes(vtkCellTypes* types);
185 
191  virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
192 
205  virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts,
206  vtkIdList* ptIds) VTK_SIZEHINT(pts, npts);
207 
213  virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
214 
222  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
223 
225 
232  vtkIdType FindPoint(double x, double y, double z)
233  {
234  double xyz[3];
235  xyz[0] = x;
236  xyz[1] = y;
237  xyz[2] = z;
238  return this->FindPoint(xyz);
239  }
240  virtual vtkIdType FindPoint(double x[3]) = 0;
242 
254  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
255  double pcoords[3], double* weights) = 0;
256 
264  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
265  double tol2, int& subId, double pcoords[3], double* weights) = 0;
266 
275  virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
276  int& subId, double pcoords[3], double* weights);
277 
282  vtkMTimeType GetMTime() override;
283 
288  vtkCellData* GetCellData() { return this->CellData; }
289 
294  vtkPointData* GetPointData() { return this->PointData; }
295 
300  virtual void Squeeze();
301 
306  virtual void ComputeBounds();
307 
313  double* GetBounds() VTK_SIZEHINT(6);
314 
321  void GetBounds(double bounds[6]);
322 
327  double* GetCenter() VTK_SIZEHINT(3);
328 
334  void GetCenter(double center[3]);
335 
341  double GetLength();
342 
348  double GetLength2();
349 
354  void Initialize() override;
355 
366  virtual void GetScalarRange(double range[2]);
367 
377  double* GetScalarRange() VTK_SIZEHINT(2);
378 
384  virtual int GetMaxCellSize() = 0;
385 
394  unsigned long GetActualMemorySize() override;
395 
399  int GetDataObjectType() override { return VTK_DATA_SET; }
400 
402 
405  void ShallowCopy(vtkDataObject* src) override;
406  void DeepCopy(vtkDataObject* src) override;
408 
410  {
411  DATA_OBJECT_FIELD = 0,
412  POINT_DATA_FIELD = 1,
413  CELL_DATA_FIELD = 2
414  };
415 
424  int CheckAttributes();
425 
427 
432  virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
433  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
435 
437 
441  static vtkDataSet* GetData(vtkInformationVector* v, int i = 0);
443 
451 
455  vtkIdType GetNumberOfElements(int type) override;
456 
461  bool HasAnyGhostCells();
466  bool HasAnyGhostPoints();
472  virtual bool HasAnyBlankCells() { return false; }
478  virtual bool HasAnyBlankPoints() { return false; }
479 
484  vtkUnsignedCharArray* GetPointGhostArray();
488  void UpdatePointGhostArrayCache();
489 
493  vtkUnsignedCharArray* AllocatePointGhostArray();
494 
499  vtkUnsignedCharArray* GetCellGhostArray();
503  void UpdateCellGhostArrayCache();
504 
508  vtkUnsignedCharArray* AllocateCellGhostArray();
514  vtkUnsignedCharArray* GetGhostArray(int type) override;
515 
516 protected:
517  // Constructor with default bounds (0,1, 0,1, 0,1).
518  vtkDataSet();
519  ~vtkDataSet() override;
520 
525  virtual void ComputeScalarRange();
526 
531  bool IsAnyBitSet(vtkUnsignedCharArray* a, int bitFlag);
532 
533  vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
534  vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
535  vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
536  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
537  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
538  double Center[3];
539 
540  // Cached scalar range
541  double ScalarRange[2];
542 
543  // Time at which scalar range is computed
545 
547 
556 
557 private:
558  void InternalDataSetCopy(vtkDataSet* src);
563  static void OnDataModified(
564  vtkObject* source, unsigned long eid, void* clientdata, void* calldata);
565 
566  friend class vtkImageAlgorithmToDataSetFriendship;
567 
568 private:
569  vtkDataSet(const vtkDataSet&) = delete;
570  void operator=(const vtkDataSet&) = delete;
571 };
572 
573 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
574 {
575  double* pt = this->GetPoint(id);
576  x[0] = pt[0];
577  x[1] = pt[1];
578  x[2] = pt[2];
579 }
580 
581 #endif
bool CellGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:554
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:432
void GetBounds(T a, double bds[6])
virtual vtkFieldData * GetAttributesAsFieldData(int type)
Returns the attributes of the data object as a vtkFieldData.
vtkUnsignedCharArray * CellGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:552
abstract base class for most VTK objects
Definition: vtkObject.h:62
represent and manipulate point attribute data
Definition: vtkPointData.h:41
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkCellData * CellData
Definition: vtkDataSet.h:533
vtkPointData * PointData
Definition: vtkDataSet.h:534
record modification and/or execution time
Definition: vtkTimeStamp.h:35
represent and manipulate cell attribute data
Definition: vtkCellData.h:41
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:288
int vtkIdType
Definition: vtkType.h:332
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:472
provides thread-safe access to cells
void GetPoint(const int i, const int j, const int k, double pnt[3])
vtkTimeStamp ScalarRangeComputeTime
Definition: vtkDataSet.h:544
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:294
abstract class to specify cell behavior
Definition: vtkCell.h:60
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition: vtkDataSet.h:478
list of point or cell ids
Definition: vtkIdList.h:33
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition: vtkDataSet.h:128
#define VTK_DATA_SET
Definition: vtkType.h:85
vtkUnsignedCharArray * PointGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:551
#define VTK_SIZEHINT(...)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int GetCellType(const Ioss::ElementTopology *topology)
Returns VTK celltype for a Ioss topology element.
#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.).
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:536
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.
vtkCallbackCommand * DataObserver
Definition: vtkDataSet.h:535
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
general representation of visualization data
Definition: vtkDataObject.h:65
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:232
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:56
bool PointGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:553
virtual void DeepCopy(vtkDataObject *src)
Shallow and Deep copy.
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.
represent and manipulate fields of data
Definition: vtkFieldData.h:62