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 
113  virtual vtkCellIterator* NewCellIterator();
114 
119  virtual vtkCell *GetCell(vtkIdType cellId) = 0;
120  virtual vtkCell *GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
121  {
122  vtkErrorMacro("ijk indices are only valid with structured data!");
123  return nullptr;
124  }
125 
133  virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell) = 0;
134 
146  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
147 
153  virtual int GetCellType(vtkIdType cellId) = 0;
154 
164  virtual void GetCellTypes(vtkCellTypes *types);
165 
171  virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) = 0;
172 
178  virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) = 0;
179 
187  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
188  vtkIdList *cellIds);
189 
191 
198  vtkIdType FindPoint(double x, double y, double z)
199  {
200  double xyz[3];
201  xyz[0] = x; xyz[1] = y; xyz[2] = z;
202  return this->FindPoint (xyz);
203  }
204  virtual vtkIdType FindPoint(double x[3]) = 0;
206 
218  virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
219  double tol2, int& subId, double pcoords[3],
220  double *weights) = 0;
221 
229  virtual vtkIdType FindCell(double x[3], vtkCell *cell,
230  vtkGenericCell *gencell, vtkIdType cellId,
231  double tol2, int& subId, double pcoords[3],
232  double *weights) = 0;
233 
242  virtual vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
243  double tol2, int& subId, double pcoords[3],
244  double *weights);
245 
250  vtkMTimeType GetMTime() override;
251 
256  vtkCellData *GetCellData() {return this->CellData;};
257 
262  vtkPointData *GetPointData() {return this->PointData;};
263 
268  virtual void Squeeze();
269 
274  virtual void ComputeBounds();
275 
281  double *GetBounds() VTK_SIZEHINT(6);
282 
289  void GetBounds(double bounds[6]);
290 
295  double *GetCenter() VTK_SIZEHINT(3);
296 
302  void GetCenter(double center[3]);
303 
309  double GetLength();
310 
315  void Initialize() override;
316 
327  virtual void GetScalarRange(double range[2]);
328 
338  double *GetScalarRange() VTK_SIZEHINT(2);
339 
345  virtual int GetMaxCellSize() = 0;
346 
355  unsigned long GetActualMemorySize() override;
356 
360  int GetDataObjectType() override {return VTK_DATA_SET;}
361 
363 
366  void ShallowCopy(vtkDataObject *src) override;
367  void DeepCopy(vtkDataObject *src) override;
369 
371  {
372  DATA_OBJECT_FIELD=0,
373  POINT_DATA_FIELD=1,
374  CELL_DATA_FIELD=2
375  };
376 
385  int CheckAttributes();
386 
388 
393  virtual void GenerateGhostArray(int zeroExt[6])
394  {
395  this->GenerateGhostArray(zeroExt, false);
396  }
397  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
399 
401 
405  static vtkDataSet* GetData(vtkInformationVector* v, int i=0);
407 
415 
419  vtkIdType GetNumberOfElements(int type) override;
420 
425  bool HasAnyGhostCells();
430  bool HasAnyGhostPoints();
436  virtual bool HasAnyBlankCells()
437  {
438  return 0;
439  }
445  virtual bool HasAnyBlankPoints()
446  {
447  return 0;
448  }
449 
454  vtkUnsignedCharArray* GetPointGhostArray();
458  void UpdatePointGhostArrayCache();
459 
463  vtkUnsignedCharArray* AllocatePointGhostArray();
464 
469  vtkUnsignedCharArray* GetCellGhostArray();
473  void UpdateCellGhostArrayCache();
474 
478  vtkUnsignedCharArray* AllocateCellGhostArray();
479 
480 protected:
481  // Constructor with default bounds (0,1, 0,1, 0,1).
482  vtkDataSet();
483  ~vtkDataSet() override;
484 
489  virtual void ComputeScalarRange();
490 
495  bool IsAnyBitSet(vtkUnsignedCharArray *a, int bitFlag);
496 
497  vtkCellData *CellData; // Scalars, vectors, etc. associated w/ each cell
498  vtkPointData *PointData; // Scalars, vectors, etc. associated w/ each point
499  vtkCallbackCommand *DataObserver; // Observes changes to cell/point data
500  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
501  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
502  double Center[3];
503 
504  // Cached scalar range
505  double ScalarRange[2];
506 
507  // Time at which scalar range is computed
509 
511 
520 
521 
522 private:
523  void InternalDataSetCopy(vtkDataSet *src);
528  static void OnDataModified(
529  vtkObject* source, unsigned long eid, void* clientdata, void *calldata);
530 
531  friend class vtkImageAlgorithmToDataSetFriendship;
532 
533 private:
534  vtkDataSet(const vtkDataSet&) = delete;
535  void operator=(const vtkDataSet&) = delete;
536 };
537 
538 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
539 {
540  double *pt = this->GetPoint(id);
541  x[0] = pt[0]; x[1] = pt[1]; x[2] = pt[2];
542 }
543 
544 #endif
bool CellGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:518
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:393
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:516
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:304
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkCellData * CellData
Definition: vtkDataSet.h:497
vtkPointData * PointData
Definition: vtkDataSet.h:498
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:256
virtual void Initialize()
Restore data object to initial state,.
int vtkIdType
Definition: vtkType.h:349
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:436
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:508
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:262
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:445
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:120
int GetDataObjectType() override
Return the type of data object.
Definition: vtkDataSet.h:360
#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:515
#define VTK_SIZEHINT(...)
virtual unsigned long GetActualMemorySize()
Return the actual size of the data in kibibytes (1024 bytes).
#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.).
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:500
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:499
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:198
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:517
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