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) VTK_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) = 0;
94 
101  virtual void GetPoint(vtkIdType id, double x[3]);
102 
106  virtual vtkCellIterator* NewCellIterator();
107 
112  virtual vtkCell *GetCell(vtkIdType cellId) = 0;
113  virtual vtkCell *GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
114  {
115  vtkErrorMacro("ijk indices are only valid with structured data!");
116  return NULL;
117  }
118 
126  virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell) = 0;
127 
139  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
140 
146  virtual int GetCellType(vtkIdType cellId) = 0;
147 
157  virtual void GetCellTypes(vtkCellTypes *types);
158 
164  virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) = 0;
165 
171  virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) = 0;
172 
180  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
181  vtkIdList *cellIds);
182 
184 
191  vtkIdType FindPoint(double x, double y, double z)
192  {
193  double xyz[3];
194  xyz[0] = x; xyz[1] = y; xyz[2] = z;
195  return this->FindPoint (xyz);
196  }
197  virtual vtkIdType FindPoint(double x[3]) = 0;
199 
211  virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
212  double tol2, int& subId, double pcoords[3],
213  double *weights) = 0;
214 
222  virtual vtkIdType FindCell(double x[3], vtkCell *cell,
223  vtkGenericCell *gencell, vtkIdType cellId,
224  double tol2, int& subId, double pcoords[3],
225  double *weights) = 0;
226 
235  virtual vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
236  double tol2, int& subId, double pcoords[3],
237  double *weights);
238 
243  vtkMTimeType GetMTime() VTK_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();
275 
282  void GetBounds(double bounds[6]);
283 
288  double *GetCenter();
289 
295  void GetCenter(double center[3]);
296 
302  double GetLength();
303 
308  void Initialize() VTK_OVERRIDE;
309 
320  virtual void GetScalarRange(double range[2]);
321 
331  double *GetScalarRange();
332 
338  virtual int GetMaxCellSize() = 0;
339 
348  unsigned long GetActualMemorySize() VTK_OVERRIDE;
349 
353  int GetDataObjectType() VTK_OVERRIDE {return VTK_DATA_SET;}
354 
356 
359  void ShallowCopy(vtkDataObject *src) VTK_OVERRIDE;
360  void DeepCopy(vtkDataObject *src) VTK_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])
387  {
388  this->GenerateGhostArray(zeroExt, false);
389  }
390  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
392 
394 
398  static vtkDataSet* GetData(vtkInformationVector* v, int i=0);
400 
407  vtkFieldData* GetAttributesAsFieldData(int type) VTK_OVERRIDE;
408 
412  vtkIdType GetNumberOfElements(int type) VTK_OVERRIDE;
413 
418  bool HasAnyGhostCells();
423  bool HasAnyGhostPoints();
429  virtual bool HasAnyBlankCells()
430  {
431  return 0;
432  }
438  virtual bool HasAnyBlankPoints()
439  {
440  return 0;
441  }
442 
447  vtkUnsignedCharArray* GetPointGhostArray();
451  void UpdatePointGhostArrayCache();
452 
456  vtkUnsignedCharArray* AllocatePointGhostArray();
457 
462  vtkUnsignedCharArray* GetCellGhostArray();
466  void UpdateCellGhostArrayCache();
467 
471  vtkUnsignedCharArray* AllocateCellGhostArray();
472 
473 protected:
474  // Constructor with default bounds (0,1, 0,1, 0,1).
475  vtkDataSet();
476  ~vtkDataSet() VTK_OVERRIDE;
477 
482  virtual void ComputeScalarRange();
483 
488  bool IsAnyBitSet(vtkUnsignedCharArray *a, int bitFlag);
489 
490  vtkCellData *CellData; // Scalars, vectors, etc. associated w/ each cell
491  vtkPointData *PointData; // Scalars, vectors, etc. associated w/ each point
492  vtkCallbackCommand *DataObserver; // Observes changes to cell/point data
493  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
494  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
495  double Center[3];
496 
497  // Cached scalar range
498  double ScalarRange[2];
499 
500  // Time at which scalar range is computed
501  vtkTimeStamp ScalarRangeComputeTime;
502 
504 
508  vtkUnsignedCharArray* PointGhostArray;
509  vtkUnsignedCharArray* CellGhostArray;
510  bool PointGhostArrayCached;
511  bool CellGhostArrayCached;
513 
514 
515 private:
516  void InternalDataSetCopy(vtkDataSet *src);
521  static void OnDataModified(
522  vtkObject* source, unsigned long eid, void* clientdata, void *calldata);
523 
524  friend class vtkImageAlgorithmToDataSetFriendship;
525 
526 private:
527  vtkDataSet(const vtkDataSet&) VTK_DELETE_FUNCTION;
528  void operator=(const vtkDataSet&) VTK_DELETE_FUNCTION;
529 };
530 
531 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
532 {
533  double *pt = this->GetPoint(id);
534  x[0] = pt[0]; x[1] = pt[1]; x[2] = pt[2];
535 }
536 
537 #endif
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:386
virtual vtkFieldData * GetAttributesAsFieldData(int type)
Returns the attributes of the data object as a vtkFieldData.
abstract base class for most VTK objects
Definition: vtkObject.h:53
represent and manipulate point attribute data
Definition: vtkPointData.h:31
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
record modification and/or execution time
Definition: vtkTimeStamp.h:32
represent and manipulate cell attribute data
Definition: vtkCellData.h:32
virtual void Initialize()
Restore data object to initial state,.
int vtkIdType
Definition: vtkType.h:345
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:429
provides thread-safe access to cells
void GetPoint(const int i, const int j, const int k, double pnt[3])
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:255
abstract class to specify cell behavior
Definition: vtkCell.h:56
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition: vtkDataSet.h:438
list of point or cell ids
Definition: vtkIdList.h:30
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition: vtkDataSet.h:113
#define VTK_DATA_SET
Definition: vtkType.h:99
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 *)
Store zero or more vtkInformation instances.
Efficient cell iterator for vtkDataSet topologies.
vtkMTimeType GetMTime() override
Data objects are composite objects and need to check each part for MTime.
general representation of visualization data
Definition: vtkDataObject.h:58
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:191
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:46
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:53