VTK
vtkPolyhedron.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPolyhedron.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 =========================================================================*/
37 #ifndef vtkPolyhedron_h
38 #define vtkPolyhedron_h
39 
40 #include "vtkCommonDataModelModule.h" // For export macro
41 #include "vtkCell3D.h"
42 
43 class vtkIdTypeArray;
44 class vtkCellArray;
45 class vtkTriangle;
46 class vtkQuad;
47 class vtkTetra;
48 class vtkPolygon;
49 class vtkLine;
50 class vtkPointIdMap;
51 class vtkIdToIdVectorMapType;
52 class vtkIdToIdMapType;
53 class vtkEdgeTable;
54 class vtkPolyData;
55 class vtkCellLocator;
56 class vtkGenericCell;
57 class vtkPointLocator;
58 
60 {
61 public:
63 
64  static vtkPolyhedron *New();
65  vtkTypeMacro(vtkPolyhedron,vtkCell3D);
66  void PrintSelf(ostream& os, vtkIndent indent);
68 
70 
71  virtual void GetEdgePoints(int vtkNotUsed(edgeId), int* &vtkNotUsed(pts)) {}
72  virtual void GetFacePoints(int vtkNotUsed(faceId), int* &vtkNotUsed(pts)) {}
73  virtual double *GetParametricCoords();
75 
77  virtual int GetCellType() {return VTK_POLYHEDRON;}
78 
80 
81  virtual int RequiresInitialization() {return 1;}
82  virtual void Initialize();
84 
86 
88  virtual int GetNumberOfEdges();
89  virtual vtkCell *GetEdge(int);
90  virtual int GetNumberOfFaces();
91  virtual vtkCell *GetFace(int faceId);
93 
95 
99  virtual void Contour(double value, vtkDataArray *scalars,
100  vtkIncrementalPointLocator *locator, vtkCellArray *verts,
101  vtkCellArray *lines, vtkCellArray *polys,
102  vtkPointData *inPd, vtkPointData *outPd,
103  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
105 
107 
115  virtual void Clip(double value, vtkDataArray *scalars,
116  vtkIncrementalPointLocator *locator, vtkCellArray *connectivity,
117  vtkPointData *inPd, vtkPointData *outPd,
118  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
119  int insideOut);
121 
123 
129  virtual int EvaluatePosition(double x[3], double* closestPoint,
130  int& subId, double pcoords[3],
131  double& dist2, double *weights);
133 
135 
137  virtual void EvaluateLocation(int& subId, double pcoords[3], double x[3],
138  double *weights);
140 
142 
146  virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
147  double x[3], double pcoords[3], int& subId);
149 
163  virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
164 
166 
171  virtual void Derivatives(int subId, double pcoords[3], double *values,
172  int dim, double *derivs);
174 
177  virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
178 
181  virtual int GetParametricCenter(double pcoords[3]);
182 
184  int IsPrimaryCell() {return 1;}
185 
187 
190  virtual void InterpolateFunctions(double x[3], double *sf);
191  virtual void InterpolateDerivs(double x[3], double *derivs);
193 
195 
201  virtual int RequiresExplicitFaceRepresentation() {return 1;}
202  virtual void SetFaces(vtkIdType *faces);
203  virtual vtkIdType *GetFaces();
205 
206  // Descriprion:
207  // A method particular to vtkPolyhedron. It determines whether a point x[3]
208  // is inside the polyhedron or not (returns 1 is the point is inside, 0
209  // otherwise). The tolerance is expressed in normalized space; i.e., a
210  // fraction of the size of the bounding box.
211  int IsInside(double x[3], double tolerance);
212 
214  vtkPolyData* GetPolyData();
215 
216 protected:
217  vtkPolyhedron();
218  ~vtkPolyhedron();
219 
220  // Internal classes for supporting operations on this cell
226  vtkIdTypeArray *GlobalFaces; //these are numbered in gloabl id space
228 
229  // vtkCell has the data members Points (x,y,z coordinates) and PointIds
230  // (global cell ids corresponding to cell canonical numbering (0,1,2,....)).
231  // These data members are implicitly organized in canonical space, i.e., where
232  // the cell point ids are (0,1,...,npts-1). The PointIdMap maps global point id
233  // back to these canonoical point ids.
234  vtkPointIdMap *PointIdMap;
235 
236  // If edges are needed. Note that the edge numbering is in
237  // canonical space.
238  int EdgesGenerated; //true/false
239  vtkEdgeTable *EdgeTable; //keep track of all edges
240  vtkIdTypeArray *Edges; //edge pairs kept in this list, in canonical id space
241  int GenerateEdges(); //method populates the edge table and edge array
242 
243  // If faces need renumbering into canonical numbering space these members
244  // are used. When initiallly loaded, the face numbering uses global dataset
245  // ids. Once renumbered, they are converted to canonical space.
246  vtkIdTypeArray *Faces; //these are numbered in canonical id space
248  void GenerateFaces();
249 
250  // Bounds management
252  void ComputeBounds();
253  void ComputeParametricCoordinate(double x[3], double pc[3]);
254  void ComputePositionFromParametricCoordinate(double pc[3], double x[3]);
255 
256  // Members for supporting geometric operations
261  void ConstructPolyData();
264  void ConstructLocator();
267 
268  // This is the internal implementation of contouring a polyhedron. It is used
269  // by both Clip and Contour functions.
270  int InternalContour(double value,
271  int insideOut,
273  vtkDataArray *inScalars,
274  vtkDataArray *outScalars,
275  vtkPointData *inPd,
276  vtkPointData *outPd,
277  vtkCellArray *contourPolys,
278  vtkIdToIdVectorMapType & faceToPointsMap,
279  vtkIdToIdVectorMapType & pointToFacesMap,
280  vtkIdToIdMapType & pointIdMap);
281 
282 
283  // Check if the polyhedron cell intersect with the contour/clip function.
284  // If intersect, return 0. Otherwise return 1 or -1 when the polyhedron cell
285  // is on the positive or negative side of contour/clip function respectively.
286  int IntersectWithContour(double value,
287  int insideOut,
288  vtkDataArray *inScalars);
289 
290 private:
291  vtkPolyhedron(const vtkPolyhedron&); // Not implemented.
292  void operator=(const vtkPolyhedron&); // Not implemented.
293 
294  //BTX
295  class vtkInternal;
296  vtkInternal * Internal;
297  //ETX
298 };
299 
300 //----------------------------------------------------------------------------
301 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
302 {
303  pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
304  return 0;
305 }
306 
307 #endif
vtkCellLocator * CellLocator
vtkTetra * Tetra
vtkPolygon * Polygon
represent and manipulate point attribute data
Definition: vtkPointData.h:36
virtual int GetNumberOfFaces()=0
quickly locate points in 3-space
vtkIdTypeArray * GlobalFaces
vtkQuad * Quad
virtual int GetCellType()
Definition: vtkPolyhedron.h:77
virtual void InterpolateFunctions(double vtkNotUsed(pcoords)[3], double *vtkNotUsed(weight))
Definition: vtkCell.h:303
virtual double * GetParametricCoords()
vtkEdgeTable * EdgeTable
vtkTriangle * Triangle
represent and manipulate cell attribute data
Definition: vtkCellData.h:37
Abstract class in support of both point location and point insertion.
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)=0
virtual void EvaluateLocation(int &subId, double pcoords[3], double x[3], double *weights)=0
virtual void GetFacePoints(int vtkNotUsed(faceId), int *&vtkNotUsed(pts))
Definition: vtkPolyhedron.h:72
virtual int EvaluatePosition(double x[3], double *closestPoint, int &subId, double pcoords[3], double &dist2, double *weights)=0
virtual void Clip(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut)
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:40
vtkPolyData * PolyData
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:247
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
provides thread-safe access to cells
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:37
vtkIdTypeArray * Faces
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:39
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:46
virtual void SetFaces(vtkIdType *vtkNotUsed(faces))
Definition: vtkCell.h:106
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:58
octree-based spatial search object to quickly locate cells
virtual void Contour(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd)
vtkPointIdMap * PointIdMap
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkGenericCell * Cell
vtkIdTypeArray * PolyConnectivity
vtkLine * Line
list of point or cell ids
Definition: vtkIdList.h:35
virtual void Derivatives(int subId, double pcoords[3], double *values, int dim, double *derivs)=0
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)=0
void PrintSelf(ostream &os, vtkIndent indent)
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:44
vtkIdTypeArray * Edges
virtual void InterpolateDerivs(double vtkNotUsed(pcoords)[3], double *vtkNotUsed(derivs))
Definition: vtkCell.h:306
virtual vtkCell * GetFace(int faceId)=0
virtual int GetNumberOfEdges()=0
vtkIdList * CellIds
object to represent cell connectivity
Definition: vtkCellArray.h:49
virtual vtkCell * GetEdge(int edgeId)=0
virtual int RequiresExplicitFaceRepresentation()
a cell that represents a triangle
Definition: vtkTriangle.h:40
virtual void GetEdgePoints(int vtkNotUsed(edgeId), int *&vtkNotUsed(pts))
Definition: vtkPolyhedron.h:71
virtual int RequiresInitialization()
Definition: vtkPolyhedron.h:81
virtual int GetParametricCenter(double pcoords[3])
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:59
virtual vtkIdType * GetFaces()
Definition: vtkCell.h:107
virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts)=0
virtual void Initialize()
Definition: vtkCell.h:93
static vtkObject * New()
virtual int GetParametricCenter(double pcoords[3])
vtkIdTypeArray * FaceLocations
#define VTKCOMMONDATAMODEL_EXPORT
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkCellArray * Polys