VTK  9.7.1
vtkCartesianGrid.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
16
17#ifndef vtkCartesianGrid_h
18#define vtkCartesianGrid_h
19
20#include "vtkCommonDataModelModule.h" // For export macro
21#include "vtkConstantArray.h" // For vtkConstantArray
22#include "vtkDataSet.h"
23#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_6_0()
24#include "vtkStructuredData.h" // For inline methods
25
26VTK_ABI_NAMESPACE_BEGIN
28class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkCartesianGrid : public vtkDataSet
29{
30public:
32
36 void PrintSelf(ostream& os, vtkIndent indent) override;
37 void ShallowCopy(vtkDataObject* src) override;
38 void DeepCopy(vtkDataObject* src) override;
39 void CopyStructure(vtkDataSet* ds) override;
41
45 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_CARTESIAN_GRID; }
46
47 using Superclass::FindCell;
48 using Superclass::GetCell;
49 using Superclass::GetPoint;
50
52
55 vtkPoints* GetPoints() override;
56 void GetPoint(vtkIdType id, double x[3]) override;
57 double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
58 vtkIdType GetNumberOfCells() override;
60 int GetMaxSpatialDimension() override;
61 int GetMinSpatialDimension() override;
62 int GetCellType(vtkIdType cellId) override;
64 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds)
65 VTK_SIZEHINT(pts, npts) override;
66 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
67 vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
68 double pcoords[3], double* weights) override;
69 void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override
70 {
71 vtkStructuredData::GetPointCells(ptId, cellIds, this->GetDimensions());
72 }
73 int GetMaxCellSize() override { return 8; } // voxel is the largest
74 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
75 vtkCell* GetCell(vtkIdType cellId) override;
76 vtkCell* GetCell(int i, int j, int k) override;
77 bool HasAnyBlankPoints() override;
78 bool HasAnyBlankCells() override;
79 void Initialize() override;
81
88 virtual int ComputeStructuredCoordinates(const double x[3], int ijk[3], double pcoords[3]) = 0;
89
93 virtual vtkIdType ComputePointId(int ijk[3]) = 0;
94
98 virtual vtkIdType ComputeCellId(int ijk[3]) = 0;
99
107 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds, int* seedLoc);
108
112 int GetDataDimension();
113
120
122
128 using vtkDataSet::GetCellTypes; // VTK_DEPRECATED_IN_9_6_0
130 VTK_DEPRECATED_IN_9_6_0("Use vtkConstantArray<unsigned char>* GetCellTypes() instead")
133
140 void GetCellDims(int cellDims[3]);
141
143
149 virtual void BlankPoint(vtkIdType ptId);
150 virtual void UnBlankPoint(vtkIdType ptId);
151 virtual void BlankPoint(int i, int j, int k);
152 virtual void UnBlankPoint(int i, int j, int k);
154
156
162 virtual void BlankCell(vtkIdType ptId);
163 virtual void UnBlankCell(vtkIdType ptId);
164 virtual void BlankCell(int i, int j, int k);
165 virtual void UnBlankCell(int i, int j, int k);
167
173 unsigned char IsPointVisible(vtkIdType ptId);
174
180 unsigned char IsCellVisible(vtkIdType cellId);
181
185 vtkGetMacro(DataDescription, int);
186
188
192 void SetDimensions(int i, int j, int k) { this->SetExtent(0, i - 1, 0, j - 1, 0, k - 1); };
193 void SetDimensions(const int dim[3])
194 {
195 this->SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1);
196 };
197
198
206
213 void GetDimensions(int dims[3]);
214#if VTK_ID_TYPE_IMPL != VTK_INT
215 void GetDimensions(vtkIdType dims[3]);
216#endif
217
221 int GetExtentType() VTK_FUTURE_CONST override { return VTK_3D_EXTENT; }
222
224
235 void SetExtent(VTK_FUTURE_CONST int extent[6]);
236 void SetExtent(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax);
237 vtkGetVector6Macro(Extent, int);
239
241
245 static void SetScalarType(int, vtkInformation* meta_data);
246 static int GetScalarType(vtkInformation* meta_data);
247 static bool HasScalarType(vtkInformation* meta_data);
249 const char* GetScalarTypeAsString() { return vtkImageScalarTypeNameMacro(this->GetScalarType()); }
251
253
258 static void SetNumberOfScalarComponents(int n, vtkInformation* meta_data);
263
265
269 vtkIdType GetTupleIndexForExtent(vtkDataArray* array, VTK_FUTURE_CONST int extent[6]);
270 vtkIdType GetTupleIndex(vtkDataArray* array, VTK_FUTURE_CONST int coordinates[3]);
271 vtkIdType GetTupleIndex(vtkDataArray* array, int x, int y, int z);
273
275
279 vtkIdType GetValueIndexForExtent(vtkDataArray* array, VTK_FUTURE_CONST int extent[6]);
280 vtkIdType GetValueIndex(vtkDataArray* array, VTK_FUTURE_CONST int coordinates[3]);
281 vtkIdType GetValueIndex(vtkDataArray* array, int x, int y, int z);
283
285
291
292protected:
294 ~vtkCartesianGrid() override = default;
295
300
304 virtual void BuildPoints() = 0;
305
306private:
307 // Build internals fields
308 void BuildImplicitStructures();
309 void BuildCells();
310 void BuildCellTypes();
311
312 // API members
313 int DataDescription = vtkStructuredData::VTK_STRUCTURED_EMPTY;
314 int Dimensions[3] = { 0, 0, 0 };
315 int Extent[6] = { 0, -1, 0, -1, 0, -1 };
316
317 // For the GetPoint method
318 double Point[3] = { 0, 0, 0 };
319
320 // Internals fields
321 vtkSmartPointer<vtkPoints> StructuredPoints;
322 vtkSmartPointer<vtkStructuredCellArray> StructuredCells;
323 vtkSmartPointer<vtkConstantArray<unsigned char>> StructuredCellTypes;
324 vtkSmartPointer<vtkConstantArray<int>> LegacyStructuredCellTypes; // VTK_DEPRECATED_IN_9_6_0
325};
326
327//----------------------------------------------------------------------------
329{
330 this->GetPoint(id, this->Point);
331 return this->Point;
332}
333
334//----------------------------------------------------------------------------
339
340//----------------------------------------------------------------------------
345
346//----------------------------------------------------------------------------
348{
349 return vtkStructuredData::GetDataDimension(this->DataDescription);
350}
351
352//----------------------------------------------------------------------------
354{
355 return vtkStructuredData::GetDataDimension(this->DataDescription);
356}
357
358//----------------------------------------------------------------------------
360{
361 return vtkStructuredData::GetDataDimension(this->DataDescription);
362}
363
364VTK_ABI_NAMESPACE_END
365#endif
vtkIdType GetTupleIndexForExtent(vtkDataArray *array, VTK_FUTURE_CONST int extent[6])
Given a data array and a coordinate, return the index of the tuple in the array corresponding to that...
int GetDataObjectType() VTK_FUTURE_CONST override
Return what type of dataset this is.
static bool HasNumberOfScalarComponents(vtkInformation *meta_data)
Set/Get the number of scalar components for points.
void DeepCopy(vtkDataObject *src) override
Standard vtkObject API methods.
void CopyStructure(vtkDataSet *ds) override
Standard vtkObject API methods.
virtual void BlankPoint(vtkIdType ptId)
Methods for supporting blanking of cells.
~vtkCartesianGrid() override=default
int GetDataDimension()
Return the dimensionality of the data.
void SetDimensions(int i, int j, int k)
Set dimensions of rectilinear grid dataset.
bool HasAnyBlankCells() override
Standard vtkDataSet API methods.
vtkPoints * GetPoints() override
Standard vtkDataSet API methods.
static void SetNumberOfScalarComponents(int n, vtkInformation *meta_data)
Set/Get the number of scalar components for points.
static vtkCartesianGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
static vtkCartesianGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds, int *seedLoc)
Get cell neighbors around cell located at seedloc, except cell of id cellId.
vtkIdType GetTupleIndex(vtkDataArray *array, int x, int y, int z)
Given a data array and a coordinate, return the index of the tuple in the array corresponding to that...
void GetCellDims(int cellDims[3])
Given the node dimensions of this grid instance, this method computes the node dimensions.
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
void GetPoint(vtkIdType id, double x[3]) override
Standard vtkDataSet API methods.
void SetExtent(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax)
Set/Get the extent.
int * GetDimensions()
Get dimensions of this structured points dataset.
virtual void BlankCell(vtkIdType ptId)
Methods for supporting blanking of cells.
virtual int ComputeStructuredCoordinates(const double x[3], int ijk[3], double pcoords[3])=0
Computes the structured coordinates for a point x[3].
void Initialize() override
Standard vtkDataSet API methods.
static void SetScalarType(int, vtkInformation *meta_data)
Set/Get the scalar data type for the points.
void SetExtent(VTK_FUTURE_CONST int extent[6])
Set/Get the extent.
int GetScalarType()
Set/Get the scalar data type for the points.
virtual void UnBlankCell(vtkIdType ptId)
Methods for supporting blanking of cells.
unsigned char IsPointVisible(vtkIdType ptId)
Return non-zero value if specified point is visible.
virtual void UnBlankPoint(vtkIdType ptId)
Methods for supporting blanking of cells.
vtkIdType GetValueIndex(vtkDataArray *array, int x, int y, int z)
Given a data array and a coordinate, return the index of the value in the array corresponding to that...
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
vtkStructuredCellArray * GetCells()
Return the image data connectivity array.
static bool HasScalarType(vtkInformation *meta_data)
Set/Get the scalar data type for the points.
void SetDimensions(const int dim[3])
Set dimensions of rectilinear grid dataset.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
vtkIdType GetNumberOfPoints() override
Standard vtkDataSet API methods.
virtual void BuildPoints()=0
Pure abstract method responsible to build and set internal points.
int GetMaxSpatialDimension() override
Standard vtkDataSet API methods.
int GetMaxCellSize() override
Standard vtkDataSet API methods.
unsigned char IsCellVisible(vtkIdType cellId)
Return non-zero value if specified point is visible.
vtkIdType GetCellSize(vtkIdType cellId) override
Standard vtkDataSet API methods.
bool HasAnyBlankPoints() override
Standard vtkDataSet API methods.
virtual vtkIdType ComputeCellId(int ijk[3])=0
Given a location in structured coordinates (i-j-k), return the cell id.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
int GetMinSpatialDimension() override
Standard vtkDataSet API methods.
vtkConstantArray< unsigned char > * GetCellTypes()
Get the array of all cell types in the image data.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
vtkIdType GetValueIndexForExtent(vtkDataArray *array, VTK_FUTURE_CONST int extent[6])
Given a data array and a coordinate, return the index of the value in the array corresponding to that...
int GetCellType(vtkIdType cellId) override
Standard vtkDataSet API methods.
vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Standard vtkDataSet API methods.
static int GetNumberOfScalarComponents(vtkInformation *meta_data)
Set/Get the number of scalar components for points.
const char * GetScalarTypeAsString()
Set/Get the scalar data type for the points.
virtual vtkIdType ComputePointId(int ijk[3])=0
Given a location in structured coordinates (i-j-k), return the point id.
vtkIdType GetValueIndex(vtkDataArray *array, VTK_FUTURE_CONST int coordinates[3])
Given a data array and a coordinate, return the index of the value in the array corresponding to that...
void SetStructuredPoints(vtkPoints *)
Set the internally built structured points.
vtkCell * GetCell(int i, int j, int k) override
Standard vtkDataSet API methods.
vtkConstantArray< int > * GetCellTypesArray()
Get the array of all cell types in the image data.
int GetNumberOfScalarComponents()
Set/Get the number of scalar components for points.
static int GetScalarType(vtkInformation *meta_data)
Set/Get the scalar data type for the points.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard vtkObject API methods.
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet API methods.
int GetExtentType() VTK_FUTURE_CONST override
Structured extent.
void ShallowCopy(vtkDataObject *src) override
Standard vtkObject API methods.
vtkIdType GetTupleIndex(vtkDataArray *array, VTK_FUTURE_CONST int coordinates[3])
Given a data array and a coordinate, return the index of the tuple in the array corresponding to that...
abstract class to specify cell behavior
Definition vtkCell.h:130
A utility array for wrapping constant functions in implicit arrays.
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
virtual int GetMaxSpatialDimension()
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
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.
Definition vtkDataSet.h:298
virtual int GetMinSpatialDimension()
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
list of point or cell ids
Definition vtkIdList.h:135
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition vtkPoints.h:140
implicit object to represent cell connectivity
static vtkIdType GetNumberOfCells(const int ext[6], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given the grid extent, this method returns the total number of cells within the extent.
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
static vtkIdType GetNumberOfPoints(const int ext[6], int dataDescription=vtkStructuredData::VTK_STRUCTURED_EMPTY)
Given the grid extent, this method returns the total number of points within the extent.
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, VTK_FUTURE_CONST int dim[3])
Get the cells using a point.
#define vtkDataArray
#define VTK_3D_EXTENT
#define VTK_DEPRECATED_IN_9_6_0(reason)
int vtkIdType
Definition vtkType.h:363
@ VTK_CARTESIAN_GRID
Definition vtkType.h:160
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO