VTK  9.1.0
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=========================================================================*/
49#ifndef vtkDataSet_h
50#define vtkDataSet_h
51
52#include "vtkCommonDataModelModule.h" // For export macro
53#include "vtkDataObject.h"
54
55class vtkCell;
56class vtkCellData;
57class vtkCellIterator;
58class vtkCellTypes;
59class vtkGenericCell;
60class vtkIdList;
61class vtkPointData;
64
65class VTKCOMMONDATAMODEL_EXPORT vtkDataSet : public vtkDataObject
66{
67public:
68 vtkTypeMacro(vtkDataSet, vtkDataObject);
69 void PrintSelf(ostream& os, vtkIndent indent) override;
70
77 virtual void CopyStructure(vtkDataSet* ds) = 0;
78
84 virtual void CopyAttributes(vtkDataSet* ds);
85
91
97
102 virtual double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) = 0;
103
110 virtual void GetPoint(vtkIdType id, double x[3]);
111
117
130 virtual vtkCell* GetCell(vtkIdType cellId) = 0;
131 virtual vtkCell* GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
132 {
133 vtkErrorMacro("ijk indices are only valid with structured data!");
134 return nullptr;
135 }
136
138
146 virtual void GetCell(vtkIdType cellId, vtkGenericCell* cell) = 0;
147
159 virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
160
166 virtual int GetCellType(vtkIdType cellId) = 0;
167
177 virtual void GetCellTypes(vtkCellTypes* types);
178
184 virtual void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) = 0;
185
191 virtual void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) = 0;
192
200 virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds);
201
203
210 vtkIdType FindPoint(double x, double y, double z)
211 {
212 double xyz[3];
213 xyz[0] = x;
214 xyz[1] = y;
215 xyz[2] = z;
216 return this->FindPoint(xyz);
217 }
218 virtual vtkIdType FindPoint(double x[3]) = 0;
220
232 virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
233 double pcoords[3], double* weights) = 0;
234
242 virtual vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
243 double tol2, int& subId, double pcoords[3], double* weights) = 0;
244
253 virtual vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2,
254 int& subId, double pcoords[3], double* weights);
255
261
266 vtkCellData* GetCellData() { return this->CellData; }
267
272 vtkPointData* GetPointData() { return this->PointData; }
273
278 virtual void Squeeze();
279
284 virtual void ComputeBounds();
285
292
299 void GetBounds(double bounds[6]);
300
305 double* GetCenter() VTK_SIZEHINT(3);
306
312 void GetCenter(double center[3]);
313
319 double GetLength();
320
325 void Initialize() override;
326
337 virtual void GetScalarRange(double range[2]);
338
348 double* GetScalarRange() VTK_SIZEHINT(2);
349
355 virtual int GetMaxCellSize() = 0;
356
365 unsigned long GetActualMemorySize() override;
366
370 int GetDataObjectType() override { return VTK_DATA_SET; }
371
373
376 void ShallowCopy(vtkDataObject* src) override;
377 void DeepCopy(vtkDataObject* src) override;
379
381 {
382 DATA_OBJECT_FIELD = 0,
383 POINT_DATA_FIELD = 1,
384 CELL_DATA_FIELD = 2
385 };
386
396
398
403 virtual void GenerateGhostArray(int zeroExt[6]) { this->GenerateGhostArray(zeroExt, false); }
404 virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly);
406
408
414
422
427
443 virtual bool HasAnyBlankCells() { return false; }
449 virtual bool HasAnyBlankPoints() { return false; }
450
460
465
475
480
481protected:
482 // Constructor with default bounds (0,1, 0,1, 0,1).
484 ~vtkDataSet() override;
485
490 virtual void ComputeScalarRange();
491
496 bool IsAnyBitSet(vtkUnsignedCharArray* a, int bitFlag);
497
498 vtkCellData* CellData; // Scalars, vectors, etc. associated w/ each cell
499 vtkPointData* PointData; // Scalars, vectors, etc. associated w/ each point
500 vtkCallbackCommand* DataObserver; // Observes changes to cell/point data
501 vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
502 double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
503 double Center[3];
504
505 // Cached scalar range
506 double ScalarRange[2];
507
508 // Time at which scalar range is computed
510
512
521
522private:
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
533private:
534 vtkDataSet(const vtkDataSet&) = delete;
535 void operator=(const vtkDataSet&) = delete;
536};
537
538inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
539{
540 double* pt = this->GetPoint(id);
541 x[0] = pt[0];
542 x[1] = pt[1];
543 x[2] = pt[2];
544}
545
546#endif
void GetPoint(const int i, const int j, const int k, double pnt[3])
supports function callbacks
represent and manipulate cell attribute data
Definition: vtkCellData.h:42
Efficient cell iterator for vtkDataSet topologies.
object provides direct access to cells in vtkCellArray and type information
Definition: vtkCellTypes.h:57
abstract class to specify cell behavior
Definition: vtkCell.h:67
general representation of visualization data
Definition: vtkDataObject.h:69
abstract class to specify dataset behavior
Definition: vtkDataSet.h:66
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition: vtkDataSet.h:449
static vtkDataSet * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
vtkMTimeType GetMTime() override
Datasets are composite objects and need to check each part for MTime THIS METHOD IS THREAD SAFE.
vtkIdType GetNumberOfElements(int type) override
Get the number of elements for a specific attribute type (POINT, CELL, etc.).
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition: vtkDataSet.h:272
bool HasAnyGhostCells()
Returns 1 if there are any ghost cells 0 otherwise.
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
Locate cell based on global coordinate x and tolerance squared.
vtkUnsignedCharArray * AllocateCellGhostArray()
Allocate ghost array for cells.
bool HasAnyGhostPoints()
Returns 1 if there are any ghost points 0 otherwise.
virtual void ComputeBounds()
Compute the data bounding box from data points.
vtkTimeStamp ComputeTime
Definition: vtkDataSet.h:501
virtual void CopyAttributes(vtkDataSet *ds)
Copy the attributes associated with the specified dataset to this instance of vtkDataSet.
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
Topological inquiry to get cells using point.
vtkUnsignedCharArray * PointGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:516
vtkTimeStamp ScalarRangeComputeTime
Definition: vtkDataSet.h:509
static vtkDataSet * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
This is a version of the above method that can be used with multithreaded applications.
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
bool CellGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:519
virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
vtkFieldData * GetAttributesAsFieldData(int type) override
Returns the attributes of the data object as a vtkFieldData.
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:443
bool IsAnyBitSet(vtkUnsignedCharArray *a, int bitFlag)
Helper function that tests if any of the values in 'a' have bitFlag set.
bool PointGhostArrayCached
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:518
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition: vtkDataSet.h:403
vtkPointData * PointData
Definition: vtkDataSet.h:499
virtual void ComputeScalarRange()
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
virtual void GetCellTypes(vtkCellTypes *types)
Get a list of types of cells in a dataset.
vtkUnsignedCharArray * CellGhostArray
These arrays pointers are caches used to avoid a string comparison (when getting ghost arrays using G...
Definition: vtkDataSet.h:517
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
virtual vtkCell * GetCell(int vtkNotUsed(i), int vtkNotUsed(j), int vtkNotUsed(k))
Definition: vtkDataSet.h:131
vtkCellData * CellData
Definition: vtkDataSet.h:498
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
vtkCallbackCommand * DataObserver
Definition: vtkDataSet.h:500
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkUnsignedCharArray * GetCellGhostArray()
Get the array that defines the ghost type of each cell.
void UpdateCellGhostArrayCache()
Updates the pointer to the cell ghost array.
vtkUnsignedCharArray * AllocatePointGhostArray()
Allocate ghost array for points.
void SetCellOrderAndRationalWeights(vtkIdType cellId, vtkGenericCell *cell)
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:210
virtual vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)
Locate the cell that contains a point and return the cell.
virtual void Squeeze()
Reclaim any extra memory used to store data.
void UpdatePointGhostArrayCache()
Updates the pointer to the point ghost array.
~vtkDataSet() override
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUnsignedCharArray * GetPointGhostArray()
Gets the array that defines the ghost type of each point.
virtual void GenerateGhostArray(int zeroExt[6], bool cellOnly)
Normally called by pipeline executives or algorithms only.
virtual vtkCellIterator * NewCellIterator()
Return an iterator that traverses the cells in this data set.
int CheckAttributes()
This method checks to see if the cell and point attributes match the geometry.
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition: vtkDataSet.h:266
virtual vtkIdType FindPoint(double x[3])=0
Locate the closest point to the global coordinate x.
represent and manipulate fields of data
Definition: vtkFieldData.h:64
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:40
a simple class to control print indentation
Definition: vtkIndent.h:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition: vtkObject.h:63
represent and manipulate point attribute data
Definition: vtkPointData.h:42
record modification and/or execution time
Definition: vtkTimeStamp.h:42
dynamic, self-adjusting array of unsigned char
void GetBounds(T a, double bds[6])
@ info
Definition: vtkX3D.h:382
@ range
Definition: vtkX3D.h:244
@ center
Definition: vtkX3D.h:236
@ type
Definition: vtkX3D.h:522
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:332
#define VTK_DATA_SET
Definition: vtkType.h:85
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE