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 =========================================================================*/
43 #ifndef vtkRectilinearGrid_h
44 #define vtkRectilinearGrid_h
45 
46 #include "vtkCommonDataModelModule.h" // For export macro
47 #include "vtkDataSet.h"
48 #include "vtkStructuredData.h" // For inline methods
49 
50 class vtkVertex;
51 class vtkLine;
52 class vtkPixel;
53 class vtkVoxel;
54 class vtkDataArray;
55 class vtkPoints;
56 
57 class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet
58 {
59 public:
60  static vtkRectilinearGrid* New();
61  static vtkRectilinearGrid* ExtendedNew();
62 
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
69  int GetDataObjectType() override { return VTK_RECTILINEAR_GRID; }
70 
75  void CopyStructure(vtkDataSet* ds) override;
76 
80  void Initialize() override;
81 
83 
86  vtkIdType GetNumberOfCells() override;
87  vtkIdType GetNumberOfPoints() override;
88  double* GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
89  void GetPoint(vtkIdType id, double x[3]) override;
90  vtkCell* GetCell(vtkIdType cellId) override;
91  vtkCell* GetCell(int i, int j, int k) override;
92  void GetCell(vtkIdType cellId, vtkGenericCell* cell) override;
93  void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
94  vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z); }
95  vtkIdType FindPoint(double x[3]) override;
96  vtkIdType FindCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
97  double pcoords[3], double* weights) override;
98  vtkIdType FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell, vtkIdType cellId,
99  double tol2, int& subId, double pcoords[3], double* weights) override;
100  vtkCell* FindAndGetCell(double x[3], vtkCell* cell, vtkIdType cellId, double tol2, int& subId,
101  double pcoords[3], double* weights) override;
102  int GetCellType(vtkIdType cellId) override;
103  vtkIdType GetCellSize(vtkIdType cellId) override;
105  void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override
106  {
107  vtkStructuredData::GetCellPoints(cellId, ptIds, this->DataDescription, this->Dimensions);
108  }
109  void GetPointCells(vtkIdType ptId, vtkIdList* cellIds) override
110  {
111  vtkStructuredData::GetPointCells(ptId, cellIds, this->Dimensions);
112  }
113  void ComputeBounds() override;
114  int GetMaxCellSize() override { return 8; } // voxel is the largest
115  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds) override;
116  void GetCellNeighbors(vtkIdType cellId, vtkIdList* ptIds, vtkIdList* cellIds, int* seedLoc);
118 
124  unsigned char IsPointVisible(vtkIdType ptId);
125 
131  unsigned char IsCellVisible(vtkIdType cellId);
132 
137  bool HasAnyBlankPoints() override;
142  bool HasAnyBlankCells() override;
143 
150  void GetCellDims(int cellDims[3]);
151 
156  void GetPoints(vtkPoints* pnts);
157 
159 
163  void SetDimensions(int i, int j, int k);
164  void SetDimensions(const int dim[3]);
166 
168 
171  vtkGetVectorMacro(Dimensions, int, 3);
173 
177  int GetDataDimension();
178 
185  int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
186 
190  vtkIdType ComputePointId(int ijk[3]);
191 
195  vtkIdType ComputeCellId(int ijk[3]);
196 
202  void GetPoint(const int i, const int j, const int k, double p[3]);
203 
205 
208  virtual void SetXCoordinates(vtkDataArray*);
209  vtkGetObjectMacro(XCoordinates, vtkDataArray);
211 
213 
216  virtual void SetYCoordinates(vtkDataArray*);
217  vtkGetObjectMacro(YCoordinates, vtkDataArray);
219 
221 
224  virtual void SetZCoordinates(vtkDataArray*);
225  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
227 
229 
234  void SetExtent(int extent[6]);
235  void SetExtent(int xMin, int xMax, int yMin, int yMax, int zMin, int zMax);
236  vtkGetVector6Macro(Extent, int);
238 
247  unsigned long GetActualMemorySize() override;
248 
250 
253  void ShallowCopy(vtkDataObject* src) override;
254  void DeepCopy(vtkDataObject* src) override;
256 
260  int GetExtentType() override { return VTK_3D_EXTENT; }
261 
267  void Crop(const int* updateExtent) override;
268 
270 
274  static vtkRectilinearGrid* GetData(vtkInformationVector* v, int i = 0);
276 
278 
281  static void SetScalarType(int, vtkInformation* meta_data);
282  static int GetScalarType(vtkInformation* meta_data);
283  static bool HasScalarType(vtkInformation* meta_data);
284  int GetScalarType();
285  const char* GetScalarTypeAsString() { return vtkImageScalarTypeNameMacro(this->GetScalarType()); }
287 
289 
293  static void SetNumberOfScalarComponents(int n, vtkInformation* meta_data);
294  static int GetNumberOfScalarComponents(vtkInformation* meta_data);
295  static bool HasNumberOfScalarComponents(vtkInformation* meta_data);
296  int GetNumberOfScalarComponents();
298 
299 protected:
301  ~vtkRectilinearGrid() override;
302 
303  // for the GetCell method
308 
309  int Dimensions[3];
311 
312  int Extent[6];
313 
317 
318  // Hang on to some space for returning points when GetPoint(id) is called.
319  double PointReturn[3];
320 
321 private:
322  void Cleanup();
323 
324 private:
325  vtkRectilinearGrid(const vtkRectilinearGrid&) = delete;
326  void operator=(const vtkRectilinearGrid&) = delete;
327 };
328 
329 //----------------------------------------------------------------------------
331 {
332  vtkIdType nCells = 1;
333  int i;
334 
335  for (i = 0; i < 3; i++)
336  {
337  if (this->Dimensions[i] <= 0)
338  {
339  return 0;
340  }
341  if (this->Dimensions[i] > 1)
342  {
343  nCells *= (this->Dimensions[i] - 1);
344  }
345  }
346 
347  return nCells;
348 }
349 
350 //----------------------------------------------------------------------------
352 {
353  return static_cast<vtkIdType>(this->Dimensions[0]) * this->Dimensions[1] * this->Dimensions[2];
354 }
355 
356 //----------------------------------------------------------------------------
358 {
360 }
361 
362 //----------------------------------------------------------------------------
364 {
366 }
367 
368 //----------------------------------------------------------------------------
370 {
371  return vtkStructuredData::ComputeCellId(this->Dimensions, ijk);
372 }
373 
374 #endif
int GetDataDimension()
Return the dimensionality of the data.
vtkIdType FindPoint(double x, double y, double z)
Standard vtkDataSet API methods.
int GetDataObjectType() override
Return what type of dataset this is.
a dataset that is topologically regular with variable spacing in the three coordinate directions ...
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 vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
vtkIdType ComputeCellId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the cell id.
int GetMaxCellSize() override
Standard vtkDataSet API methods.
static vtkDataObject * New()
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.
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:80
Store vtkAlgorithm input/output information.
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
a cell that represents a 3D point
Definition: vtkVertex.h:33
virtual vtkIdType GetCellSize(vtkIdType cellId)
Get the size of cell with cellId such that: 0 <= cellId < NumberOfCells.
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:62
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:37
virtual void ComputeBounds()
Compute the data bounding box from data points.
int GetExtentType() override
Structured extent.
vtkDataArray * XCoordinates
int vtkIdType
Definition: vtkType.h:332
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override
Standard vtkDataSet API methods.
virtual bool HasAnyBlankCells()
Returns 1 if there are any blanking cells 0 otherwise.
Definition: vtkDataSet.h:472
static vtkDataSet * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
provides thread-safe access to cells
vtkIdType ComputePointId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the point id.
virtual void Crop(const int *updateExtent)
This method crops the data object (if necessary) so that the extent matches the update extent...
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...
const char * GetScalarTypeAsString()
Set/Get the scalar data type for the points.
cell represents a 1D line
Definition: vtkLine.h:33
abstract class to specify cell behavior
Definition: vtkCell.h:60
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:41
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkIdType GetNumberOfPoints() override
Standard vtkDataSet API methods.
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
Get the points defining a cell.
vtkDataArray * ZCoordinates
virtual bool HasAnyBlankPoints()
Returns 1 if there are any blanking points 0 otherwise.
Definition: vtkDataSet.h:478
list of point or cell ids
Definition: vtkIdList.h:33
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e...
#define VTK_SIZEHINT(...)
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
Get the cells using a point.
void Initialize() override
Restore data object to initial state.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Standard vtkDataSet API methods.
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...
vtkDataArray * YCoordinates
vtkIdType GetNumberOfCells() override
Standard vtkDataSet API methods.
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
Store zero or more vtkInformation instances.
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
general representation of visualization data
Definition: vtkDataObject.h:65
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:232
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
represent and manipulate 3D points
Definition: vtkPoints.h:39
virtual void GetCellBounds(vtkIdType cellId, double bounds[6])
Get the bounds of the cell with cellId such that: 0 <= cellId < NumberOfCells.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.