VTK
vtkStructuredData.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStructuredData.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 =========================================================================*/
29 #ifndef __vtkStructuredData_h
30 #define __vtkStructuredData_h
31 
32 #include "vtkObject.h"
33 
34 class vtkIdList;
35 
36 #define VTK_UNCHANGED 0
37 #define VTK_SINGLE_POINT 1
38 #define VTK_X_LINE 2
39 #define VTK_Y_LINE 3
40 #define VTK_Z_LINE 4
41 #define VTK_XY_PLANE 5
42 #define VTK_YZ_PLANE 6
43 #define VTK_XZ_PLANE 7
44 #define VTK_XYZ_GRID 8
45 #define VTK_EMPTY 9
46 
48 {
49 public:
51 
53 
58  static int SetDimensions(int inDim[3], int dim[3]);
59  static int SetExtent(int inExt[6], int ext[6]);
61 
64  static int GetDataDescription(int dims[3]);
65 
67  static int GetDataDimension(int dataDescription);
68 
70 
71  static void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds,
72  int dataDescription, int dim[3]);
74 
76  static void GetPointCells(vtkIdType ptId, vtkIdList *cellIds, int dim[3]);
77 
79 
81  static void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
82  vtkIdList *cellIds, int dim[3]);
84 
86 
88  static vtkIdType ComputePointIdForExtent(int extent[6], int ijk[3]) {
89  vtkIdType ydim = static_cast<vtkIdType>(extent[3] - extent[2] + 1);
90  vtkIdType xdim = static_cast<vtkIdType>(extent[1] - extent[0] + 1);
91  return ((ijk[2] - extent[4])*ydim + (ijk[1] - extent[2]))*xdim
92  + (ijk[0] - extent[0]); }
94 
96 
98  static vtkIdType ComputeCellIdForExtent(int extent[6], int ijk[3]) {
99  vtkIdType ydim = static_cast<vtkIdType>(extent[3] - extent[2]);
100  if (ydim == 0) ydim = 1;
101  vtkIdType xdim = static_cast<vtkIdType>(extent[1] - extent[0]);
102  if (xdim == 0) xdim = 1;
103  return ((ijk[2] - extent[4])*(ydim) + (ijk[1] - extent[2]))*(xdim)
104  + (ijk[0] - extent[0]); }
106 
108 
111  static vtkIdType ComputePointId(int dim[3], int ijk[3]) {
112  return (ijk[2]*static_cast<vtkIdType>(dim[1]) + ijk[1])*dim[0] + ijk[0];}
114 
116 
119  static vtkIdType ComputeCellId(int dim[3], int ijk[3]) {
120  return (ijk[2]*static_cast<vtkIdType>(dim[1]-1) + ijk[1])*(dim[0]-1) + ijk[0];}
122 
124 
127  static void ComputeCellStructuredCoords(const vtkIdType cellId, int dim[3], int ijk[3])
128  {
129  int Ni = dim[0]-1;
130  int Nj = dim[1]-1;
132 
133  int Nij = Ni*Nj;
134 
135  int k = cellId/Nij + 1;
136  int j = (cellId - (k-1)*Nij)/Ni + 1;
137  int i = cellId - (k-1)*Nij - (j-1)*Ni + 1;
138  ijk[0] = i-1;
139  ijk[1] = j-1;
140  ijk[2] = k-1;
141  }
142 
144 
147  static void ComputePointStructuredCoords(const vtkIdType cellId, int dim[3], int ijk[3])
148  {
149  int Ni = dim[0];
150  int Nj = dim[1];
152 
153  int Nij = Ni*Nj;
154 
155  int k = cellId/Nij + 1;
156  int j = (cellId - (k-1)*Nij)/Ni + 1;
157  int i = cellId - (k-1)*Nij - (j-1)*Ni + 1;
158  ijk[0] = i-1;
159  ijk[1] = j-1;
160  ijk[2] = k-1;
161  }
162 
163 protected:
166 
167 private:
168  vtkStructuredData(const vtkStructuredData&); // Not implemented.
169  void operator=(const vtkStructuredData&); // Not implemented.
170 };
171 
172 
173 #endif
174