VTK  9.2.6
vtkRectilinearGrid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRectilinearGrid.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 =========================================================================*/
52 #ifndef vtkRectilinearGrid_h
53 #define vtkRectilinearGrid_h
54 
55 #include "vtkCommonDataModelModule.h" // For export macro
56 #include "vtkDataSet.h"
57 #include "vtkStructuredData.h" // For inline methods
58 
59 class vtkVertex;
60 class vtkLine;
61 class vtkPixel;
62 class vtkVoxel;
63 class vtkDataArray;
64 class vtkPoints;
65 
66 class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet
67 {
68 public:
71 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
78  int GetDataObjectType() override { return VTK_RECTILINEAR_GRID; }
79 
84  void CopyStructure(vtkDataSet* ds) override;
85 
89  void Initialize() override;
90 
92 
95  vtkIdType GetNumberOfCells() override;
96  vtkIdType GetNumberOfPoints() override;
97  double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
98  void GetPoint(vtkIdType id, double x[3]) override;
99  vtkCell* GetCell(vtkIdType cellId) override;
100  vtkCell* GetCell(int i, int j, int k) override;
101  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
102  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
103  vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z); }
104  vtkIdType FindPoint(double x[3]) override;
105  vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
106  double pcoords[3], double* weights) override;
107  vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
108  double tol2, int& subId, double pcoords[3], double* weights) override;
109  vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
110  double pcoords[3], double* weights) override;
111  int GetCellType(vtkIdType cellId) override;
112  vtkIdType GetCellSize(vtkIdType cellId) override;
114  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override
115  {
116  vtkStructuredData::GetCellPoints(cellId, ptIds, this->DataDescription, this->Dimensions);
117  }
118  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override
119  {
120  vtkStructuredData::GetPointCells(ptId, cellIds, this->Dimensions);
121  }
122  void ComputeBounds() override;
123  int GetMaxCellSize() override { return 8; } // voxel is the largest
124  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
125  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds, int* seedLoc);
127 
133  unsigned char IsPointVisible(vtkIdType ptId);
134 
140  unsigned char IsCellVisible(vtkIdType cellId);
141 
146  bool HasAnyBlankPoints() override;
151  bool HasAnyBlankCells() override;
152 
159  void GetCellDims(int cellDims[3]);
160 
165  void GetPoints(vtkPoints* pnts);
166 
168 
172  void SetDimensions(int i, int j, int k);
173  void SetDimensions(const int dim[3]);
175 
177 
180  vtkGetVectorMacro(Dimensions, int, 3);
182 
186  int GetDataDimension();
187 
194  int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
195 
199  vtkIdType ComputePointId(int ijk[3]);
200 
204  vtkIdType ComputeCellId(int ijk[3]);
205 
211  void GetPoint(const int i, const int j, const int k, double p[3]);
212 
214 
218  vtkGetObjectMacro(XCoordinates, vtkDataArray);
220 
222 
226  vtkGetObjectMacro(YCoordinates, vtkDataArray);
228 
230 
234  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
236 
238 
243  void SetExtent(int extent[6]);
244  void SetExtent(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax);
245  vtkGetVector6Macro(Extent, int);
247 
256  unsigned long GetActualMemorySize() override;
257 
259 
262  void ShallowCopy(vtkDataObject* src) override;
263  void DeepCopy(vtkDataObject* src) override;
265 
269  int GetExtentType() override { return VTK_3D_EXTENT; }
270 
276  void Crop(const int* updateExtent) override;
277 
279 
285 
287 
290  static void SetScalarType(int, vtkInformation* meta_data);
291  static int GetScalarType(vtkInformation* meta_data);
292  static bool HasScalarType(vtkInformation* meta_data);
294  const char* GetScalarTypeAsString() { return vtkImageScalarTypeNameMacro(this->GetScalarType()); }
296 
298 
302  static void SetNumberOfScalarComponents(int n, vtkInformation* meta_data);
307 
308 protected:
311 
312  // for the GetCell method
317 
318  int Dimensions[3];
320 
321  int Extent[6];
322 
326 
327  // Hang on to some space for returning points when GetPoint(id) is called.
328  double PointReturn[3];
329 
330 private:
331  void Cleanup();
332 
333 private:
334  vtkRectilinearGrid(const vtkRectilinearGrid&) = delete;
335  void operator=(const vtkRectilinearGrid&) = delete;
336 };
337 
338 //----------------------------------------------------------------------------
340 {
341  vtkIdType nCells = 1;
342  int i;
343 
344  for (i = 0; i < 3; i++)
345  {
346  if (this->Dimensions[i] <= 0)
347  {
348  return 0;
349  }
350  if (this->Dimensions[i] > 1)
351  {
352  nCells *= (this->Dimensions[i] - 1);
353  }
354  }
355 
356  return nCells;
357 }
358 
359 //----------------------------------------------------------------------------
361 {
362  return static_cast<vtkIdType>(this->Dimensions[0]) * this->Dimensions[1] * this->Dimensions[2];
363 }
364 
365 //----------------------------------------------------------------------------
367 {
369 }
370 
371 //----------------------------------------------------------------------------
373 {
375 }
376 
377 //----------------------------------------------------------------------------
379 {
380  return vtkStructuredData::ComputeCellId(this->Dimensions, ijk);
381 }
382 
383 #endif
abstract class to specify cell behavior
Definition: vtkCell.h:70
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:65
general representation of visualization data
Definition: vtkDataObject.h:75
abstract class to specify dataset behavior
Definition: vtkDataSet.h:72
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 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:241
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:43
a simple class to control print indentation
Definition: vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
cell represents a 1D line
Definition: vtkLine.h:43
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:47
represent and manipulate 3D points
Definition: vtkPoints.h:49
a dataset that is topologically regular with variable spacing in the three coordinate directions
static bool HasScalarType(vtkInformation *meta_data)
Set/Get the scalar data type for the points.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Initialize() override
Restore object to initial state.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Standard vtkDataSet API methods.
virtual void SetZCoordinates(vtkDataArray *)
Specify the grid coordinates in the z-direction.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
void GetPoint(const int i, const int j, const int k, double p[3])
Given the IJK-coordinates of the point, it returns the corresponding xyz-coordinates.
vtkIdType GetNumberOfPoints() override
Standard vtkDataSet API methods.
bool HasAnyBlankCells() override
Returns 1 if there is any visibility constraint on the cells, 0 otherwise.
unsigned char IsCellVisible(vtkIdType cellId)
Return non-zero value if specified point is visible.
const char * GetScalarTypeAsString()
Set/Get the scalar data type for the points.
bool HasAnyBlankPoints() override
Returns 1 if there is any visibility constraint on the points, 0 otherwise.
virtual void SetYCoordinates(vtkDataArray *)
Specify the grid coordinates in the y-direction.
virtual void SetXCoordinates(vtkDataArray *)
Specify the grid coordinates in the x-direction.
vtkCell * GetCell(vtkIdType cellId) override
Standard vtkDataSet API methods.
vtkIdType ComputeCellId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the cell id.
int GetExtentType() override
Structured extent.
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkDataArray * YCoordinates
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
void SetExtent(int extent[6])
Different ways to set the extent of the data array.
vtkIdType FindPoint(double x, double y, double z)
Standard vtkDataSet API methods.
int GetDataObjectType() override
Return what type of dataset this is.
static void SetNumberOfScalarComponents(int n, vtkInformation *meta_data)
Set/Get the number of scalar components for points.
static int GetNumberOfScalarComponents(vtkInformation *meta_data)
Set/Get the number of scalar components for points.
vtkDataArray * XCoordinates
static vtkRectilinearGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input rectilinear grid object.
static int GetScalarType(vtkInformation *meta_data)
Set/Get the scalar data type for the points.
void SetDimensions(int i, int j, int k)
Set dimensions of rectilinear grid dataset.
void GetPoints(vtkPoints *pnts)
Given a user-supplied vtkPoints container object, this method fills in all the points of the Rectilin...
static void SetScalarType(int, vtkInformation *meta_data)
Set/Get the scalar data type for the points.
~vtkRectilinearGrid() override
void GetCellDims(int cellDims[3])
Given the node dimensions of this grid instance, this method computes the node dimensions.
unsigned char IsPointVisible(vtkIdType ptId)
Return non-zero value if specified point is visible.
vtkIdType ComputePointId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the point id.
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
static bool HasNumberOfScalarComponents(vtkInformation *meta_data)
Set/Get the number of scalar components for points.
vtkIdType GetCellSize(vtkIdType cellId) override
Standard vtkDataSet API methods.
vtkIdType FindPoint(double x[3]) override
Standard vtkDataSet API methods.
int GetNumberOfScalarComponents()
Set/Get the number of scalar components for points.
double * GetPoint(vtkIdType ptId) override
Standard vtkDataSet API methods.
int GetCellType(vtkIdType cellId) override
Standard vtkDataSet API methods.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds, int *seedLoc)
Standard vtkDataSet API methods.
void GetPoint(vtkIdType id, double x[3]) override
Standard vtkDataSet API methods.
vtkDataArray * ZCoordinates
static vtkRectilinearGrid * ExtendedNew()
void GetCellBounds(vtkIdType cellId, double bounds[6]) override
Standard vtkDataSet API methods.
static vtkRectilinearGrid * New()
vtkCell * GetCell(int i, int j, int k) override
Standard vtkDataSet API methods.
int GetScalarType()
Set/Get the scalar data type for the points.
int GetDataDimension()
Return the dimensionality of the data.
void ComputeBounds() override
Standard vtkDataSet API methods.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
void Crop(const int *updateExtent) override
Reallocates and copies to set the Extent to the UpdateExtent.
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.
int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3])
Convenience function computes the structured coordinates for a point x[3].
static vtkRectilinearGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
int GetMaxCellSize() override
Standard vtkDataSet API methods.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
void SetExtent(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax)
Different ways to set the extent of the data array.
vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Standard vtkDataSet API methods.
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override
Standard vtkDataSet API methods.
void SetDimensions(const int dim[3])
Set dimensions of rectilinear grid dataset.
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
Get the points defining a cell.
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
static vtkIdType ComputePointId(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,...
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
Get the cells using a point.
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,...
a cell that represents a 3D point
Definition: vtkVertex.h:43
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:51
@ info
Definition: vtkX3D.h:382
@ extent
Definition: vtkX3D.h:351
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:71
int vtkIdType
Definition: vtkType.h:332
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:80
#define VTK_SIZEHINT(...)