Thanks to visit codestin.com
Credit goes to vtk.org

VTK  9.5.20251001
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
17#ifndef vtkCartesianGrid_h
18#define vtkCartesianGrid_h
19
20#include "vtkCommonDataModelModule.h" // For export macro
21#include "vtkDataSet.h"
22#include "vtkStructuredData.h" // For inline methods
23
24VTK_ABI_NAMESPACE_BEGIN
26class VTKCOMMONDATAMODEL_EXPORT VTK_MARSHALAUTO vtkCartesianGrid : public vtkDataSet
27{
28public:
30
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35 void ShallowCopy(vtkDataObject* src) override;
36 void DeepCopy(vtkDataObject* src) override;
37 void CopyStructure(vtkDataSet* ds) override;
39
43 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_CARTESIAN_GRID; }
44
45 using Superclass::FindCell;
46 using Superclass::GetCell;
47 using Superclass::GetPoint;
48
50
53 vtkPoints* GetPoints() override;
54 void GetPoint(vtkIdType id, double x[3]) override;
55 double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
56 vtkIdType GetNumberOfCells() override;
58 int GetMaxSpatialDimension() override;
59 int GetMinSpatialDimension() override;
60 int GetCellType(vtkIdType cellId) override;
62 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds)
63 VTK_SIZEHINT(pts, npts) override;
64 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
65 vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
66 double tol2, int& subId, double pcoords[3], double* weights) override;
67 vtkCell* FindAndGetCell(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
128
135 void GetCellDims(int cellDims[3]);
136
138
144 virtual void BlankPoint(vtkIdType ptId);
145 virtual void UnBlankPoint(vtkIdType ptId);
146 virtual void BlankPoint(int i, int j, int k);
147 virtual void UnBlankPoint(int i, int j, int k);
149
151
157 virtual void BlankCell(vtkIdType ptId);
158 virtual void UnBlankCell(vtkIdType ptId);
159 virtual void BlankCell(int i, int j, int k);
160 virtual void UnBlankCell(int i, int j, int k);
162
168 unsigned char IsPointVisible(vtkIdType ptId);
169
175 unsigned char IsCellVisible(vtkIdType cellId);
176
180 vtkGetMacro(DataDescription, int);
181
183
187 void SetDimensions(int i, int j, int k) { this->SetExtent(0, i - 1, 0, j - 1, 0, k - 1); };
188 void SetDimensions(const int dim[3])
189 {
190 this->SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1);
191 };
193
201
208 void GetDimensions(int dims[3]);
209#if VTK_ID_TYPE_IMPL != VTK_INT
210 void GetDimensions(vtkIdType dims[3]);
211#endif
212
216 int GetExtentType() VTK_FUTURE_CONST override { return VTK_3D_EXTENT; }
217
219
230 void SetExtent(int extent[6]);
231 void SetExtent(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax);
232 vtkGetVector6Macro(Extent, int);
234
236
240 static void SetScalarType(int, vtkInformation* meta_data);
241 static int GetScalarType(vtkInformation* meta_data);
242 static bool HasScalarType(vtkInformation* meta_data);
244 const char* GetScalarTypeAsString() { return vtkImageScalarTypeNameMacro(this->GetScalarType()); }
246
248
253 static void SetNumberOfScalarComponents(int n, vtkInformation* meta_data);
258
259protected:
261 ~vtkCartesianGrid() override = default;
262
267
271 virtual void BuildPoints() = 0;
272
273private:
274 // Build internals fields
275 void BuildImplicitStructures();
276 void BuildCells();
277 void BuildCellTypes();
278
279 // API members
280 int DataDescription = vtkStructuredData::VTK_STRUCTURED_EMPTY;
281 int Dimensions[3] = { 0, 0, 0 };
282 int Extent[6] = { 0, -1, 0, -1, 0, -1 };
283
284 // For the GetPoint method
285 double Point[3] = { 0, 0, 0 };
286
287 // Internals fields
288 vtkSmartPointer<vtkPoints> StructuredPoints;
290 vtkSmartPointer<vtkConstantArray<int>> StructuredCellTypes;
291};
292
293//----------------------------------------------------------------------------
295{
296 this->GetPoint(id, this->Point);
297 return this->Point;
298}
299
300//----------------------------------------------------------------------------
302{
303 return vtkStructuredData::GetNumberOfPoints(this->Extent);
304}
305
306//----------------------------------------------------------------------------
308{
309 return vtkStructuredData::GetNumberOfCells(this->Extent);
310}
311
312//----------------------------------------------------------------------------
314{
315 return vtkStructuredData::GetDataDimension(this->DataDescription);
316}
317
318//----------------------------------------------------------------------------
320{
321 return vtkStructuredData::GetDataDimension(this->DataDescription);
322}
323
324//----------------------------------------------------------------------------
326{
327 return vtkStructuredData::GetDataDimension(this->DataDescription);
328}
329
330VTK_ABI_NAMESPACE_END
331#endif
Abstract API for vtkImageData and vtkRectilinearGrid.
virtual void UnBlankCell(int i, int j, int k)
Methods for supporting blanking of cells.
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.
virtual void UnBlankPoint(int i, int j, int k)
Methods for supporting blanking of cells.
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.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds, int *seedLoc)
Get cell neighbors around cell located at seedloc, except cell of id cellId.
vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Standard vtkDataSet API methods.
virtual void BlankPoint(int i, int j, int k)
Methods for supporting blanking of cells.
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.
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.
vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Standard vtkDataSet API methods.
virtual void UnBlankPoint(vtkIdType ptId)
Methods for supporting blanking of cells.
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
vtkStructuredCellArray * GetCells()
Return the image data connectivity array.
void SetExtent(int extent[6])
Set/Get the extent.
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.
virtual void BlankCell(int i, int j, int k)
Methods for supporting blanking of cells.
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.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
int GetCellType(vtkIdType cellId) 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.
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.
abstract class to specify cell behavior
Definition vtkCell.h:129
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
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 int GetMinSpatialDimension()
Get the maximum/minimum spatial dimensionality of the data which is the maximum/minimum dimension of ...
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:133
A read only array class that wraps an implicit function from integers to any value type supported by ...
a simple class to control print indentation
Definition vtkIndent.h:108
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition vtkPoints.h:139
Hold a reference to a vtkObjectBase instance.
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 VTK_3D_EXTENT
int vtkIdType
Definition vtkType.h:334
@ VTK_CARTESIAN_GRID
Definition vtkType.h:132
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO