VTK  9.0.20200703
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 
121  virtual vtkCell* GetCell(vtkIdType cellId) = 0;
122  virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
123  {
124  vtkErrorMacro("ijk indices are only valid with structured data!");
125  return nullptr;
126  }
127 
128  void SetCellOrderAndRationalWeights(vtkIdType cellId, vtkGenericCell* cell);
129 
137  virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
138 
150  virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
151 
157  virtual int GetCellType(vtkIdType cellId) = 0;
158 
168  virtual void GetCellTypes(vtkCellTypes* types);
169 
175  virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
176 
182  virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
183 
191  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
192 
194 
201  vtkIdType FindPoint(double x, double y, double z)
202  {
203  double xyz[3];
204  xyz[0] = x;
205  xyz[1] = y;
206  xyz[2] = z;
207  return this->FindPoint(xyz);
208  }
209  virtual vtkIdType FindPoint(double x[3]) = 0;
211 
223  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
224  double pcoords[3], double* weights) = 0;
225 
233  virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
234  double tol2, int& subId, double pcoords[3], double* weights) = 0;
235 
244  virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
245  int& subId, double pcoords[3], double* weights);
246 
251  vtkMTimeType GetMTime() override;
252 
257  vtkCellData* GetCellData() { return this->CellData; }
258 
263  vtkPointData* GetPointData() { return this->PointData; }
264 
269  virtual void Squeeze();
270 
275  virtual void ComputeBounds();
276 
282  double* GetBounds() VTK_SIZEHINT(6);
283 
290  void GetBounds(double bounds[6]);
291 
296  double* GetCenter() VTK_SIZEHINT(3);
297 
303  void GetCenter(double center[3]);
304 
310  double GetLength();
311 
316  void Initialize() override;
317 
328  virtual void GetScalarRange(double range[2]);
329 
339  double* GetScalarRange() VTK_SIZEHINT(2);
340 
346  virtual int GetMaxCellSize() = 0;
347 
356  unsigned long GetActualMemorySize() override;
357 
361  int GetDataObjectType() override { return VTK_DATA_SET; }
362 
364 
367  void ShallowCopy(vtkDataObject* src) override;
368  void DeepCopy(vtkDataObject* src) override;
370 
372  {
373  DATA_OBJECT_FIELD = 0,
374  POINT_DATA_FIELD = 1,
375  CELL_DATA_FIELD = 2
376  };
377 
386  int CheckAttributes();
387 
389 
394  virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
395  virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
397 
399 
403  static vtkDataSet* GetData(vtkInformationVector* v, int i = 0);
405 
413 
417  vtkIdType GetNumberOfElements(int type) override;
418 
423  bool HasAnyGhostCells();
428  bool HasAnyGhostPoints();
434  virtual bool HasAnyBlankCells() { return false; }
440  virtual bool HasAnyBlankPoints() { return false; }
441 
446  vtkUnsignedCharArray* GetPointGhostArray();
450  void UpdatePointGhostArrayCache();
451 
455  vtkUnsignedCharArray* AllocatePointGhostArray();
456 
461  vtkUnsignedCharArray* GetCellGhostArray();
465  void UpdateCellGhostArrayCache();
466 
470  vtkUnsignedCharArray* AllocateCellGhostArray();
471 
472 protected:
473  // Constructor with default bounds (0,1, 0,1, 0,1).
474  vtkDataSet();
475  ~vtkDataSet() override;
476 
481  virtual void ComputeScalarRange();
482 
487  bool IsAnyBitSet(vtkUnsignedCharArray* a, int bitFlag);
488 
489  vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
490  vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
491  vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
492  vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
493  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
494  double Center[3];
495 
496  // Cached scalar range
497  double ScalarRange[2];
498 
499  // Time at which scalar range is computed
501 
503 
512 
513 private:
514  void InternalDataSetCopy(vtkDataSet* src);
519  static void OnDataModified(
520  vtkObject* source, unsigned long eid, void* clientdata, void* calldata);
521 
522  friend class vtkImageAlgorithmToDataSetFriendship;
523 
524 private:
525  vtkDataSet(const vtkDataSet&) = delete;
526  void operator=(const vtkDataSet&) = delete;
527 };
528 
529 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
530 {
531  double* pt = this->GetPoint(id);
532  x[0] = pt[0];
533  x[1] = pt[1];
534  x[2] = pt[2];
535 }
536 
537 #endif
vtkDataSet::GenerateGhostArray
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:394
vtkDataSet::PointGhostArrayCached
bool PointGhostArrayCached
Definition: vtkDataSet.h:509
vtkDataSet::PointGhostArray
vtkUnsignedCharArray * PointGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:507
vtkDataSet::CellData
vtkCellData * CellData
Definition: vtkDataSet.h:489
vtkCellTypes
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:47
vtkDataSet::DataObserver
vtkCallbackCommand * DataObserver
Definition: vtkDataSet.h:491
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:32
vtkDataSet::ScalarRangeComputeTime
vtkTimeStamp ScalarRangeComputeTime
Definition: vtkDataSet.h:500
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:330
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
vtkIossUtilities::GetCellType
int GetCellType(const Ioss::ElementTopology *topology)
Returns VTK celltype for a Ioss topology element.
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:510
vtkX3D::range
Definition: vtkX3D.h:244
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkDataSet::GetCell
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition: vtkDataSet.h:122
vtkX3D::center
Definition: vtkX3D.h:236
vtkDataSet::FieldDataType
FieldDataType
Definition: vtkDataSet.h:371
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:85
vtkDataSet::GetCellData
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:257
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:201
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:57
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
vtkDataSet::GetPointData
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:263
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:434
vtkDataSet::HasAnyBlankPoints
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition: vtkDataSet.h:440
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
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:490
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:59
vtkDataObject::ShallowCopy
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.
vtkDataSet::CellGhostArray
vtkUnsignedCharArray * CellGhostArray
Definition: vtkDataSet.h:508
vtkDataSet::ComputeTime
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:492
vtkDataObject::GetData
static vtkDataObject * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285