VTK
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 =========================================================================*/
40 #ifndef vtkDataSet_h
41 #define vtkDataSet_h
42 
43 #include "vtkCommonDataModelModule.h" // For export macro
44 #include "vtkDataObject.h"
45 
46 class vtkCell;
47 class vtkCellData;
48 class vtkCellIterator;
49 class vtkCellTypes;
50 class vtkGenericCell;
51 class vtkIdList;
52 class vtkPointData;
54 class vtkCallbackCommand;
55 
56 class VTKCOMMONDATAMODEL_EXPORT 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 
93  virtual double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) = 0;
94 
101  virtual void GetPoint(vtkIdType id, double x[3]);
102 
107  virtual vtkCellIterator* NewCellIterator();
108 
113  virtual vtkCell* GetCell(vtkIdType cellId) = 0;
114  virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
115  {
116  vtkErrorMacro("ijk indices are only valid with structured data!");
117  return nullptr;
118  }
119 
120  void SetCellOrderAndRationalWeights(vtkIdType cellId, vtkGenericCell* cell);
121 
129  virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
130 
142  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
143 
149  virtual int GetCellType(vtkIdType cellId) = 0;
150 
160  virtual void GetCellTypes(vtkCellTypes* types);
161 
167  virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
168 
174  virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
175 
183  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
184 
186 
193  vtkIdType FindPoint(double x, double y, double z)
194  {
195  double xyz[3];
196  xyz[0] = x;
197  xyz[1] = y;
198  xyz[2] = z;
199  return this->FindPoint(xyz);
200  }
201  virtual vtkIdType FindPoint(double x[3]) = 0;
203 
215  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
216  double pcoords[3], double* weights) = 0;
217 
225  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
226  double tol2, int& subId, double pcoords[3], double* weights) = 0;
227 
236  virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
237  int& subId, double pcoords[3], double* weights);
238 
243  vtkMTimeType GetMTime() override;
244 
249  vtkCellData* GetCellData() { return this->CellData; }
250 
255  vtkPointData* GetPointData() { return this->PointData; }
256 
261  virtual void Squeeze();
262 
267  virtual void ComputeBounds();
268 
274  double* GetBounds() VTK_SIZEHINT(6);
275 
282  void GetBounds(double bounds[6]);
283 
288  double* GetCenter() VTK_SIZEHINT(3);
289 
295  void GetCenter(double center[3]);
296 
302  double GetLength();
303 
308  void Initialize() override;
309 
320  virtual void GetScalarRange(double range[2]);
321 
331  double* GetScalarRange() VTK_SIZEHINT(2);
332 
338  virtual int GetMaxCellSize() = 0;
339 
348  unsigned long GetActualMemorySize() override;
349 
353  int GetDataObjectType() override { return VTK_DATA_SET; }
354 
356 
359  void ShallowCopy(vtkDataObject* src) override;
360  void DeepCopy(vtkDataObject* src) override;
362 
364  {
365  DATA_OBJECT_FIELD = 0,
366  POINT_DATA_FIELD = 1,
367  CELL_DATA_FIELD = 2
368  };
369 
378  int CheckAttributes();
379 
381 
386  virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
387  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
389 
391 
395  static vtkDataSet* GetData(vtkInformationVector* v, int i = 0);
397 
405 
409  vtkIdType GetNumberOfElements(int type) override;
410 
415  bool HasAnyGhostCells();
420  bool HasAnyGhostPoints();
426  virtual bool HasAnyBlankCells() { return 0; }
432  virtual bool HasAnyBlankPoints() { return 0; }
433 
438  vtkUnsignedCharArray* GetPointGhostArray();
442  void UpdatePointGhostArrayCache();
443 
447  vtkUnsignedCharArray* AllocatePointGhostArray();
448 
453  vtkUnsignedCharArray* GetCellGhostArray();
457  void UpdateCellGhostArrayCache();
458 
462  vtkUnsignedCharArray* AllocateCellGhostArray();
463 
464 protected:
465  // Constructor with default bounds (0,1, 0,1, 0,1).
466  vtkDataSet();
467  ~vtkDataSet() override;
468 
473  virtual void ComputeScalarRange();
474 
479  bool IsAnyBitSet(vtkUnsignedCharArray* a, int bitFlag);
480 
481  vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
482  vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
483  vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
484  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
485  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
486  double Center[3];
487 
488  // Cached scalar range
489  double ScalarRange[2];
490 
491  // Time at which scalar range is computed
493 
495 
504 
505 private:
506  void InternalDataSetCopy(vtkDataSet* src);
511  static void OnDataModified(
512  vtkObject* source, unsigned long eid, void* clientdata, void* calldata);
513 
514  friend class vtkImageAlgorithmToDataSetFriendship;
515 
516 private:
517  vtkDataSet(const vtkDataSet&) = delete;
518  void operator=(const vtkDataSet&) = delete;
519 };
520 
521 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
522 {
523  double* pt = this->GetPoint(id);
524  x[0] = pt[0];
525  x[1] = pt[1];
526  x[2] = pt[2];
527 }
528 
529 #endif
vtkDataSet::GenerateGhostArray
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:386
vtkDataSet::PointGhostArrayCached
bool PointGhostArrayCached
Definition: vtkDataSet.h:501
vtkDataSet::PointGhostArray
vtkUnsignedCharArray * PointGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:499
vtkDataSet::CellData
vtkCellData * CellData
Definition: vtkDataSet.h:481
vtkCellTypes
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:47
vtkDataSet::DataObserver
vtkCallbackCommand * DataObserver
Definition: vtkDataSet.h:483
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:31
vtkDataSet::ScalarRangeComputeTime
vtkTimeStamp ScalarRangeComputeTime
Definition: vtkDataSet.h:492
vtkDataObject::GetAttributesAsFieldData
virtual vtkFieldData * GetAttributesAsFieldData(int type)
Returns the attributes of the data object as a vtkFieldData.
vtkX3D::type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:343
vtkDataObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkDataSet::CellGhostArrayCached
bool CellGhostArrayCached
Definition: vtkDataSet.h:502
vtkX3D::range
Definition: vtkX3D.h:244
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkDataSet::GetCell
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition: vtkDataSet.h:114
vtkX3D::center
Definition: vtkX3D.h:236
vtkDataSet::FieldDataType
FieldDataType
Definition: vtkDataSet.h:363
vtkDataObject::DeepCopy
virtual void DeepCopy(vtkDataObject *src)
GetPoint
void GetPoint(const int i, const int j, const int k, double pnt[3])
vtkDataObject::GetMTime
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:53
vtkDataObject::GetNumberOfElements
virtual vtkIdType GetNumberOfElements(int type)
Get the number of elements for a specific attribute type (POINT, CELL, etc.).
VTK_DATA_SET
#define VTK_DATA_SET
Definition: vtkType.h:93
vtkDataSet::GetCellData
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:249
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkDataSet::FindPoint
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:193
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:56
vtkDataSet::GetPointData
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:255
vtkCellData
represent and manipulate cell attribute data
Definition: vtkCellData.h:32
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkDataSet::HasAnyBlankCells
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:426
vtkDataSet::HasAnyBlankPoints
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition: vtkDataSet.h:432
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:64
vtkX3D::info
Definition: vtkX3D.h:382
vtkDataSet::GetPoint
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
vtkDataSet::PointData
vtkPointData * PointData
Definition: vtkDataSet.h:482
vtkDataObject.h
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:44
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:36
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:959
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:42
vtkCellIterator
Efficient cell iterator for vtkDataSet topologies.
Definition: vtkCellIterator.h:77
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkDataObject::ShallowCopy
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.
vtkDataSet::CellGhostArray
vtkUnsignedCharArray * CellGhostArray
Definition: vtkDataSet.h:500
vtkDataSet::ComputeTime
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:484
vtkDataObject::GetData
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:298