VTK  9.4.20250311
vtkExplicitStructuredGrid.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
74#ifndef vtkExplicitStructuredGrid_h
75#define vtkExplicitStructuredGrid_h
76
77#include "vtkAbstractCellLinks.h" // For vtkAbstractCellLinks
78#include "vtkCellArray.h" // For vtkCellArray
79#include "vtkCommonDataModelModule.h" // For export macro
80#include "vtkNew.h" // for vtkNew
81#include "vtkPointSet.h"
82#include "vtkStructuredData.h" // For static method usage
83
84VTK_ABI_NAMESPACE_BEGIN
85class vtkCellArray;
86
87class VTKCOMMONDATAMODEL_EXPORT vtkExplicitStructuredGrid : public vtkPointSet
88{
89public:
91
96 void PrintSelf(ostream& os, vtkIndent indent) override;
98
103
105
108 void Initialize() override;
110 vtkCell* GetCell(vtkIdType cellId) override;
111 void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
112 void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
113 int GetCellType(vtkIdType cellId) override;
116 void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
117 void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override;
118 int GetMaxCellSize() override { return 8; } // hexahedron is the largest
119 int GetMaxSpatialDimension() override { return 3; }
120 int GetMinSpatialDimension() override { return 3; }
121 void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
123
127 void CopyStructure(vtkDataSet* ds) override;
128
130
133 void ShallowCopy(vtkDataObject* src) override;
134 void DeepCopy(vtkDataObject* src) override;
136
140 int GetDataDimension() { return 3; }
141
143
148 void SetDimensions(int i, int j, int k);
149 void SetDimensions(int dim[3]);
150 void GetDimensions(int dim[3]);
152
158 void GetCellDims(int cellDims[3]);
159
163 int GetExtentType() override { return VTK_3D_EXTENT; }
164
166
173 void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1);
174 void SetExtent(int extent[6]);
175 vtkGetVector6Macro(Extent, int);
177
179
182 vtkSetSmartPointerMacro(Cells, vtkCellArray);
183 vtkGetSmartPointerMacro(Cells, vtkCellArray);
185
191
193
196 vtkSetSmartPointerMacro(Links, vtkAbstractCellLinks);
197 vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks);
199
206
212 void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType*& pts);
213
223 vtkIdType cellId, vtkIdType& npts, vtkIdType const*& pts, vtkIdList* ptIds) override;
224
228 void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int* wholeExtent = nullptr);
229
238 void ComputeCellStructuredCoords(
239 vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent = true);
240
249 vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent = true);
250
257
259
262 vtkSetStringMacro(FacesConnectivityFlagsArrayName);
263 vtkGetStringMacro(FacesConnectivityFlagsArrayName);
265
267
273 void BlankCell(vtkIdType cellId);
274 void UnBlankCell(vtkIdType cellId);
276
280 bool HasAnyBlankCells() override;
281
287 unsigned char IsCellVisible(vtkIdType cellId);
288
294 unsigned char IsCellGhost(vtkIdType cellId);
295
300
302
307 void Crop(const int* updateExtent) override;
308 virtual void Crop(
309 vtkExplicitStructuredGrid* input, const int* updateExtent, bool generateOriginalCellIds);
311
313
319
328 unsigned long GetActualMemorySize() override;
329
341
343
349 void GenerateGhostArray(int zeroExt[6], bool cellOnly) override;
351
352protected:
355
357
362 void ComputeScalarRange() override;
363
368
373
378 int FindConnectedFaces(int foundFaces[3]);
379
384 static void CheckConnectedFaces(int& nFoundFaces, int foundFaces[3]);
385
389 static void ComputeSwapFlag(int foundFaces[3], int swap[3]);
390
394 static void ComputeMirrorFlag(int foundFaces[3], int mirror[3]);
395
399 void ReorderCellsPoints(const int* ptsMap, const int transformFlag[3]);
400
403 int Extent[6];
405
406private:
408 void operator=(const vtkExplicitStructuredGrid&) = delete;
409};
410
411//----------------------------------------------------------------------------
413{
415}
416
417//----------------------------------------------------------------------------
418inline void vtkExplicitStructuredGrid::GetCellDims(int cellDims[3])
419{
421}
422
423//----------------------------------------------------------------------------
425 vtkIdType cellId, int& i, int& j, int& k, bool adjustForExtent)
426{
427 int ijk[3];
428 if (adjustForExtent)
429 {
431 }
432 else
433 {
434 int dims[3];
435 this->GetDimensions(dims);
437 }
438 i = ijk[0];
439 j = ijk[1];
440 k = ijk[2];
441}
442
443//----------------------------------------------------------------------------
444inline vtkIdType vtkExplicitStructuredGrid::ComputeCellId(int i, int j, int k, bool adjustForExtent)
445{
446 int ijk[] = { i, j, k };
447 if (adjustForExtent)
448 {
450 }
451 else
452 {
453 int dims[3];
454 this->GetDimensions(dims);
455 return vtkStructuredData::ComputeCellId(dims, ijk);
456 }
457}
458VTK_ABI_NAMESPACE_END
459#endif
object to represent cell connectivity
abstract class to specify cell behavior
Definition vtkCell.h:130
general representation of visualization data
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
virtual void GenerateGhostArray(int zeroExt[6])
Normally called by pipeline executives or algorithms only.
Definition vtkDataSet.h:565
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
structured grid with explicit topology and geometry
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkIdType * GetCellPoints(vtkIdType cellId)
Get direct raw pointer to the 8 points indices of an hexahedra.
int GetMinSpatialDimension() override
Standard vtkDataSet API methods.
void InternalCheckAndReorderFaces(bool swap)
Internal method used by CheckAndReorderFaces.
vtkSmartPointer< vtkAbstractCellLinks > Links
static vtkExplicitStructuredGrid * New()
Standard methods for instantiation, type information, and printing.
void Initialize() override
Standard vtkDataSet API methods.
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Standard vtkDataSet API methods.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
void ComputeScalarRange() override
Compute the range of the scalars and cache it into ScalarRange only if the cache became invalid (Scal...
int GetDataObjectType() override
Return what type of dataset this is.
void ReportReferences(vtkGarbageCollector *) override
void Crop(const int *updateExtent) override
Reallocates and copies to set the Extent to the UpdateExtent.
void GetCellDims(int cellDims[3])
Computes the cell dimensions according to internal point dimensions.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet API methods.
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
void ReorderCellsPoints(const int *ptsMap, const int transformFlag[3])
Reorder all cells points based on a transformFlag for each axis and a points map.
void ComputeCellStructuredCoords(vtkIdType cellId, int &i, int &j, int &k, bool adjustForExtent=true)
Given a cellId, get the structured coordinates (i-j-k).
int GetDataDimension()
Return the dimensionality of the data.
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input poly data object.
int GetMaxSpatialDimension() override
Standard vtkDataSet API methods.
virtual void InternalCopy(vtkExplicitStructuredGrid *src)
Internal method used by DeepCopy and ShallowCopy.
void SetExtent(int x0, int x1, int y0, int y1, int z0, int z1)
Set/Get the extent of this structured dataset in term of number of points along each direction.
int FindConnectedFaces(int foundFaces[3])
Find a connected face for each axis if any.
virtual void Crop(vtkExplicitStructuredGrid *input, const int *updateExtent, bool generateOriginalCellIds)
Reallocates and copies to set the Extent to the UpdateExtent.
vtkIdType ComputeCellId(int i, int j, int k, bool adjustForExtent=true)
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 GetCellType(vtkIdType cellId) override
Standard vtkDataSet API methods.
unsigned char IsCellVisible(vtkIdType cellId)
Return non-zero value if specified cell is visible.
void SetDimensions(int dim[3])
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kilobytes.
static vtkExplicitStructuredGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
void GetCellNeighbors(vtkIdType cellId, vtkIdType neighbors[6], int *wholeExtent=nullptr)
Get cell neighbors of the cell for every faces.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, type information, and printing.
static vtkExplicitStructuredGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
~vtkExplicitStructuredGrid() override
bool HasAnyGhostCells()
Returns true if one or more cells are ghost, false otherwise.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType *&pts)
More efficient method to obtain cell points.
void BuildLinks()
Build topological links from points to lists of cells that use each point.
void GetCellPoints(vtkIdType cellId, vtkIdType &npts, vtkIdType const *&pts, vtkIdList *ptIds) override
More efficient method to obtain cell points.
static void CheckConnectedFaces(int &nFoundFaces, int foundFaces[3])
Check a list of connected faces and remove invalid face or extrapolate missing faces.
int GetMaxCellSize() override
Standard vtkDataSet API methods.
static void ComputeSwapFlag(int foundFaces[3], int swap[3])
Compute a swap flag based if a face have been found.
int GetExtentType() override
The extent type is a 3D extent.
void SetDimensions(int i, int j, int k)
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
void BlankCell(vtkIdType cellId)
Methods for supporting blanking of cells.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
void CheckAndReorderFaces()
Check faces are numbered correctly regarding ijk numbering If not this will reorganize cell points or...
void UnBlankCell(vtkIdType cellId)
Methods for supporting blanking of cells.
void GetDimensions(int dim[3])
Set/Get the dimensions of this structured dataset in term of number of points along each direction.
static void ComputeMirrorFlag(int foundFaces[3], int mirror[3])
Compute a mirror flag based if a face have been found.
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
bool HasAnyBlankCells() override
Returns true if one or more cells are blanked, false otherwise.
vtkIdType GetCellSize(vtkIdType cellId) override
Standard vtkDataSet API methods.
unsigned char IsCellGhost(vtkIdType cellId)
Return non-zero value if specified cell is a ghost cell.
void ComputeFacesConnectivityFlagsArray()
Compute the faces connectivity flags array.
void GenerateGhostArray(int zeroExt[6], bool cellOnly) override
Normally called by pipeline executives or algorithms only.
void SetExtent(int extent[6])
Set/Get the extent of this structured dataset in term of number of points along each direction.
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet API methods.
vtkSmartPointer< vtkCellArray > Cells
Detect and break reference loops.
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
concrete class for storing a set of points
Definition vtkPointSet.h:98
Hold a reference to a vtkObjectBase instance.
static void GetCellDimensionsFromExtent(const int ext[6], int celldims[3], int dataDescription=VTK_EMPTY)
Returns the cell dimensions, i.e., the number of cells along the i,j,k for the grid with the given gr...
static void GetDimensionsFromExtent(const int ext[6], int dims[3], int dataDescription=VTK_EMPTY)
Computes the structured grid dimensions based on the given extent.
static void ComputeCellStructuredCoords(vtkIdType cellId, const int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
Given a cellId and grid dimensions 'dim', get the structured coordinates (i-j-k).
static void ComputeCellStructuredCoordsForExtent(vtkIdType cellIdx, const int ext[6], int ijk[3], int dataDescription=VTK_EMPTY)
Given the global grid extent and the linear index of a cell within the grid extent,...
static vtkIdType ComputeCellIdForExtent(const int extent[6], const int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the extent of the structured dataset,...
static vtkIdType ComputeCellId(const int dim[3], const int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the dimensions of the structured dataset,...
@ Cells
A cell specified by degrees of freedom held in arrays.
#define VTK_3D_EXTENT
int vtkIdType
Definition vtkType.h:332
@ VTK_EXPLICIT_STRUCTURED_GRID
Definition vtkType.h:121