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 =========================================================================*/
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 
112  virtual vtkCellIterator* NewCellIterator();
113 
118  virtual vtkCell *GetCell(vtkIdType cellId) = 0;
119  virtual vtkCell *GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
120  {
121  vtkErrorMacro("ijk indices are only valid with structured data!");
122  return nullptr;
123  }
124 
132  virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell) = 0;
133 
145  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
146 
152  virtual int GetCellType(vtkIdType cellId) = 0;
153 
163  virtual void GetCellTypes(vtkCellTypes *types);
164 
170  virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) = 0;
171 
177  virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) = 0;
178 
186  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
187  vtkIdList *cellIds);
188 
190 
197  vtkIdType FindPoint(double x, double y, double z)
198  {
199  double xyz[3];
200  xyz[0] = x; xyz[1] = y; xyz[2] = z;
201  return this->FindPoint (xyz);
202  }
203  virtual vtkIdType FindPoint(double x[3]) = 0;
205 
217  virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
218  double tol2, int& subId, double pcoords[3],
219  double *weights) = 0;
220 
228  virtual vtkIdType FindCell(double x[3], vtkCell *cell,
229  vtkGenericCell *gencell, vtkIdType cellId,
230  double tol2, int& subId, double pcoords[3],
231  double *weights) = 0;
232 
241  virtual vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
242  double tol2, int& subId, double pcoords[3],
243  double *weights);
244 
249  vtkMTimeType GetMTime() override;
250 
255  vtkCellData *GetCellData() {return this->CellData;};
256 
261  vtkPointData *GetPointData() {return this->PointData;};
262 
267  virtual void Squeeze();
268 
273  virtual void ComputeBounds();
274 
280  double *GetBounds() VTK_SIZEHINT(6);
281 
288  void GetBounds(double bounds[6]);
289 
294  double *GetCenter() VTK_SIZEHINT(3);
295 
301  void GetCenter(double center[3]);
302 
308  double GetLength();
309 
314  void Initialize() override;
315 
326  virtual void GetScalarRange(double range[2]);
327 
337  double *GetScalarRange() VTK_SIZEHINT(2);
338 
344  virtual int GetMaxCellSize() = 0;
345 
354  unsigned long GetActualMemorySize() override;
355 
359  int GetDataObjectType() override {return VTK_DATA_SET;}
360 
362 
365  void ShallowCopy(vtkDataObject *src) override;
366  void DeepCopy(vtkDataObject *src) override;
368 
370  {
371  DATA_OBJECT_FIELD=0,
372  POINT_DATA_FIELD=1,
373  CELL_DATA_FIELD=2
374  };
375 
384  int CheckAttributes();
385 
387 
392  virtual void GenerateGhostArray(int zeroExt[6])
393  {
394  this->GenerateGhostArray(zeroExt, false);
395  }
396  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
398 
400 
404  static vtkDataSet* GetData(vtkInformationVector* v, int i=0);
406 
414 
418  vtkIdType GetNumberOfElements(int type) override;
419 
424  bool HasAnyGhostCells();
429  bool HasAnyGhostPoints();
435  virtual bool HasAnyBlankCells()
436  {
437  return 0;
438  }
444  virtual bool HasAnyBlankPoints()
445  {
446  return 0;
447  }
448 
453  vtkUnsignedCharArray* GetPointGhostArray();
457  void UpdatePointGhostArrayCache();
458 
462  vtkUnsignedCharArray* AllocatePointGhostArray();
463 
468  vtkUnsignedCharArray* GetCellGhostArray();
472  void UpdateCellGhostArrayCache();
473 
477  vtkUnsignedCharArray* AllocateCellGhostArray();
478 
479 protected:
480  // Constructor with default bounds (0,1, 0,1, 0,1).
481  vtkDataSet();
482  ~vtkDataSet() override;
483 
488  virtual void ComputeScalarRange();
489 
494  bool IsAnyBitSet(vtkUnsignedCharArray *a, int bitFlag);
495 
496  vtkCellData *CellData; // Scalars, vectors, etc. associated w/ each cell
497  vtkPointData *PointData; // Scalars, vectors, etc. associated w/ each point
498  vtkCallbackCommand *DataObserver; // Observes changes to cell/point data
499  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
500  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
501  double Center[3];
502 
503  // Cached scalar range
504  double ScalarRange[2];
505 
506  // Time at which scalar range is computed
508 
510 
519 
520 
521 private:
522  void InternalDataSetCopy(vtkDataSet *src);
527  static void OnDataModified(
528  vtkObject* source, unsigned long eid, void* clientdata, void *calldata);
529 
530  friend class vtkImageAlgorithmToDataSetFriendship;
531 
532 private:
533  vtkDataSet(const vtkDataSet&) = delete;
534  void operator=(const vtkDataSet&) = delete;
535 };
536 
537 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
538 {
539  double *pt = this->GetPoint(id);
540  x[0] = pt[0]; x[1] = pt[1]; x[2] = pt[2];
541 }
542 
543 #endif
bool CellGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:517
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:392
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:515
abstract base class for most VTK objects
Definition: vtkObject.h:59
represent and manipulate point attribute data
Definition: vtkPointData.h:37
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkCellData * CellData
Definition: vtkDataSet.h:496
vtkPointData * PointData
Definition: vtkDataSet.h:497
record modification and/or execution time
Definition: vtkTimeStamp.h:35
represent and manipulate cell attribute data
Definition: vtkCellData.h:38
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:255
virtual void Initialize()
Restore data object to initial state,.
int vtkIdType
Definition: vtkType.h:347
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:435
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:507
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:261
abstract class to specify cell behavior
Definition: vtkCell.h:59
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:444
list of point or cell ids
Definition: vtkIdList.h:36
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition: vtkDataSet.h:119
int GetDataObjectType() override
Return the type of data object.
Definition: vtkDataSet.h:359
#define VTK_DATA_SET
Definition: vtkType.h:99
vtkUnsignedCharArray * PointGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:514
#define VTK_SIZEHINT(...)
virtual unsigned long GetActualMemorySize()
Return the actual size of the data in kibibytes (1024 bytes).
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.).
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:499
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:498
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
general representation of visualization data
Definition: vtkDataObject.h:64
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:197
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:53
bool PointGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:516
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:56