VTK
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=========================================================================*/
42#ifndef vtkRectilinearGrid_h
43#define vtkRectilinearGrid_h
44
45#include "vtkCommonDataModelModule.h" // For export macro
46#include "vtkDataSet.h"
47#include "vtkStructuredData.h" // For inline methods
48
49class vtkVertex;
50class vtkLine;
51class vtkPixel;
52class vtkVoxel;
53class vtkDataArray;
54class vtkPoints;
55
56class VTKCOMMONDATAMODEL_EXPORT vtkRectilinearGrid : public vtkDataSet
57{
58public:
60
62 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
63
67 int GetDataObjectType() VTK_OVERRIDE {return VTK_RECTILINEAR_GRID;};
68
73 void CopyStructure(vtkDataSet *ds) VTK_OVERRIDE;
74
78 void Initialize() VTK_OVERRIDE;
79
81
84 vtkIdType GetNumberOfCells() VTK_OVERRIDE;
85 vtkIdType GetNumberOfPoints() VTK_OVERRIDE;
86 double *GetPoint(vtkIdType ptId) VTK_OVERRIDE;
87 void GetPoint(vtkIdType id, double x[3]) VTK_OVERRIDE;
88 vtkCell *GetCell(vtkIdType cellId) VTK_OVERRIDE;
89 void GetCell(vtkIdType cellId, vtkGenericCell *cell) VTK_OVERRIDE;
90 void GetCellBounds(vtkIdType cellId, double bounds[6]) VTK_OVERRIDE;
91 vtkIdType FindPoint(double x, double y, double z) { return this->vtkDataSet::FindPoint(x, y, z);};
92 vtkIdType FindPoint(double x[3]) VTK_OVERRIDE;
93 vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2,
94 int& subId, double pcoords[3], double *weights) VTK_OVERRIDE;
95 vtkIdType FindCell(double x[3], vtkCell *cell, vtkGenericCell *gencell,
96 vtkIdType cellId, double tol2, int& subId,
97 double pcoords[3], double *weights) VTK_OVERRIDE;
98 vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
99 double tol2, int& subId, double pcoords[3],
100 double *weights) VTK_OVERRIDE;
101 int GetCellType(vtkIdType cellId) VTK_OVERRIDE;
102 void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) VTK_OVERRIDE
103 {vtkStructuredData::GetCellPoints(cellId,ptIds,this->DataDescription,
104 this->Dimensions);}
105 void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) VTK_OVERRIDE
106 {vtkStructuredData::GetPointCells(ptId,cellIds,this->Dimensions);}
107 void ComputeBounds() VTK_OVERRIDE;
108 int GetMaxCellSize() VTK_OVERRIDE {return 8;}; //voxel is the largest
110 vtkIdList *cellIds) VTK_OVERRIDE;
112
117 void GetPoints(vtkPoints* pnts);
118
120
124 void SetDimensions(int i, int j, int k);
125 void SetDimensions(int dim[3]);
127
129
132 vtkGetVectorMacro(Dimensions,int,3);
134
138 int GetDataDimension();
139
146 int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3]);
147
151 vtkIdType ComputePointId(int ijk[3]);
152
156 vtkIdType ComputeCellId(int ijk[3]);
157
163 void GetPoint(const int i,const int j,const int k,double p[3]);
164
166
170 vtkGetObjectMacro(XCoordinates,vtkDataArray);
172
174
178 vtkGetObjectMacro(YCoordinates,vtkDataArray);
180
182
186 vtkGetObjectMacro(ZCoordinates,vtkDataArray);
188
190
195 void SetExtent(int extent[6]);
196 void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
197 vtkGetVector6Macro(Extent, int);
199
208 unsigned long GetActualMemorySize() VTK_OVERRIDE;
209
211
214 void ShallowCopy(vtkDataObject *src) VTK_OVERRIDE;
215 void DeepCopy(vtkDataObject *src) VTK_OVERRIDE;
217
221 int GetExtentType() VTK_OVERRIDE { return VTK_3D_EXTENT; };
222
228 void Crop(const int* updateExtent) VTK_OVERRIDE;
229
231
237
238protected:
240 ~vtkRectilinearGrid() VTK_OVERRIDE;
241
242 // for the GetCell method
243 vtkVertex *Vertex;
244 vtkLine *Line;
245 vtkPixel *Pixel;
246 vtkVoxel *Voxel;
247
248 int Dimensions[3];
249 int DataDescription;
250
251 int Extent[6];
252
253 vtkDataArray *XCoordinates;
254 vtkDataArray *YCoordinates;
255 vtkDataArray *ZCoordinates;
256
257 // Hang on to some space for returning points when GetPoint(id) is called.
258 double PointReturn[3];
259
260private:
261 void Cleanup();
262
263private:
264 vtkRectilinearGrid(const vtkRectilinearGrid&) VTK_DELETE_FUNCTION;
265 void operator=(const vtkRectilinearGrid&) VTK_DELETE_FUNCTION;
266};
267
268//----------------------------------------------------------------------------
269inline vtkIdType vtkRectilinearGrid::GetNumberOfCells()
270{
271 vtkIdType nCells=1;
272 int i;
273
274 for (i=0; i<3; i++)
275 {
276 if (this->Dimensions[i] <= 0)
277 {
278 return 0;
279 }
280 if (this->Dimensions[i] > 1)
281 {
282 nCells *= (this->Dimensions[i]-1);
283 }
284 }
285
286 return nCells;
287}
288
289//----------------------------------------------------------------------------
291{
292 return this->Dimensions[0]*this->Dimensions[1]*this->Dimensions[2];
293}
294
295//----------------------------------------------------------------------------
297{
298 return vtkStructuredData::GetDataDimension(this->DataDescription);
299}
300
301//----------------------------------------------------------------------------
303{
304 return vtkStructuredData::ComputePointId(this->Dimensions,ijk);
305}
306
307//----------------------------------------------------------------------------
309{
310 return vtkStructuredData::ComputeCellId(this->Dimensions,ijk);
311}
312
313#endif
void GetPoint(const int i, const int j, const int k, double pnt[3])
abstract class to specify cell behavior
Definition: vtkCell.h:60
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
general representation of visualization data
Definition: vtkDataObject.h:65
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:192
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
cell represents a 1D line
Definition: vtkLine.h:36
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:41
represent and manipulate 3D points
Definition: vtkPoints.h:40
a dataset that is topologically regular with variable spacing in the three coordinate directions
static vtkRectilinearGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
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
Locate cell based on global coordinate x and tolerance squared.
virtual void SetZCoordinates(vtkDataArray *)
Specify the grid coordinates in the z-direction.
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override
Topological inquiry to get cells using point.
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
Determine the number of points composing the dataset.
virtual void SetYCoordinates(vtkDataArray *)
Specify the grid coordinates in the y-direction.
virtual void SetXCoordinates(vtkDataArray *)
Specify the grid coordinates in the x-direction.
vtkIdType ComputeCellId(int ijk[3])
Given a location in structured coordinates (i-j-k), return the cell id.
static vtkRectilinearGrid * GetData(vtkInformationVector *v, int i=0)
void SetDimensions(int dim[3])
void SetExtent(int extent[6])
Different ways to set the extent of the data array.
int GetDataObjectType() override
Return what type of dataset this is.
void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2)
void CopyStructure(vtkDataSet *ds) override
Copy the geometric and topological structure of an input rectilinear grid object.
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...
~vtkRectilinearGrid() override
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
Topological inquiry to get points defining cell.
vtkIdType FindPoint(double x[3]) override
int GetCellType(vtkIdType cellId) override
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
static vtkRectilinearGrid * New()
int GetDataDimension()
Return the dimensionality of the data.
void ComputeBounds() override
Compute the data bounding box from data points.
void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds) override
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
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
This is a version of the above method that can be used with multithreaded applications.
vtkCell * FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights) override
Locate the cell that contains a point and return the cell.
int ComputeStructuredCoordinates(double x[3], int ijk[3], double pcoords[3])
Convenience function computes the structured coordinates for a point x[3].
static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds, int dataDescription, int dim[3])
Get the points defining a cell.
static vtkIdType ComputePointId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the dimensions of the structured dataset,...
static vtkIdType ComputeCellId(int dim[3], int ijk[3], int dataDescription=VTK_EMPTY)
Given a location in structured coordinates (i-j-k), and the dimensions of the structured dataset,...
static int GetDataDimension(int dataDescription)
Return the topological dimension of the data (e.g., 0, 1, 2, or 3D).
static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3])
Get the cells using a point.
a cell that represents a 3D point
Definition: vtkVertex.h:37
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:45
@ info
Definition: vtkX3D.h:376
@ extent
Definition: vtkX3D.h:345
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:61
int vtkIdType
Definition: vtkType.h:287
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:90