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 "vtkCell3D.h"
41 
42 class vtkIdTypeArray;
43 class vtkCellArray;
44 class vtkTriangle;
45 class vtkQuad;
46 class vtkTetra;
47 class vtkPolygon;
48 class vtkLine;
49 class vtkPointIdMap;
50 class vtkIdToIdVectorMapType;
51 class vtkIdToIdMapType;
52 class vtkEdgeTable;
53 class vtkPolyData;
54 class vtkCellLocator;
55 class vtkGenericCell;
56 class vtkPointLocator;
57 
59 {
60 public:
62 
63  static vtkPolyhedron *New();
64  vtkTypeMacro(vtkPolyhedron,vtkCell3D);
65  void PrintSelf(ostream& os, vtkIndent indent);
67 
69 
70  virtual void GetEdgePoints(int vtkNotUsed(edgeId), int* &vtkNotUsed(pts)) {}
71  virtual void GetFacePoints(int vtkNotUsed(faceId), int* &vtkNotUsed(pts)) {}
72  virtual double *GetParametricCoords();
74 
76  virtual int GetCellType() {return VTK_POLYHEDRON;}
77 
79 
80  virtual int RequiresInitialization() {return 1;}
81  virtual void Initialize();
83 
85 
87  virtual int GetNumberOfEdges();
88  virtual vtkCell *GetEdge(int);
89  virtual int GetNumberOfFaces();
90  virtual vtkCell *GetFace(int faceId);
92 
94 
98  virtual void Contour(double value, vtkDataArray *scalars,
100  vtkCellArray *lines, vtkCellArray *polys,
101  vtkPointData *inPd, vtkPointData *outPd,
102  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
104 
106 
114  virtual void Clip(double value, vtkDataArray *scalars,
115  vtkIncrementalPointLocator *locator, vtkCellArray *connectivity,
116  vtkPointData *inPd, vtkPointData *outPd,
117  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
118  int insideOut);
120 
122 
128  virtual int EvaluatePosition(double x[3], double* closestPoint,
129  int& subId, double pcoords[3],
130  double& dist2, double *weights);
132 
134 
136  virtual void EvaluateLocation(int& subId, double pcoords[3], double x[3],
137  double *weights);
139 
141 
145  virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
146  double x[3], double pcoords[3], int& subId);
148 
162  virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
163 
165 
170  virtual void Derivatives(int subId, double pcoords[3], double *values,
171  int dim, double *derivs);
173 
176  virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
177 
180  virtual int GetParametricCenter(double pcoords[3]);
181 
183  int IsPrimaryCell() {return 1;}
184 
186 
189  virtual void InterpolateFunctions(double x[3], double *sf);
190  virtual void InterpolateDerivs(double x[3], double *derivs);
192 
194 
200  virtual int RequiresExplicitFaceRepresentation() {return 1;}
201  virtual void SetFaces(vtkIdType *faces);
202  virtual vtkIdType *GetFaces();
204 
205  // Descriprion:
206  // A method particular to vtkPolyhedron. It determines whether a point x[3]
207  // is inside the polyhedron or not (returns 1 is the point is inside, 0
208  // otherwise). The tolerance is expressed in normalized space; i.e., a
209  // fraction of the size of the bounding box.
210  int IsInside(double x[3], double tolerance);
211 
213  vtkPolyData* GetPolyData();
214 
215 protected:
216  vtkPolyhedron();
217  ~vtkPolyhedron();
218 
219  // Internal classes for supporting operations on this cell
225  vtkIdTypeArray *GlobalFaces; //these are numbered in gloabl id space
227 
228  // vtkCell has the data members Points (x,y,z coordinates) and PointIds
229  // (global cell ids corresponsing to cell canonical numbering (0,1,2,....)).
230  // These data members are implicitly organized in canonical space, i.e., where
231  // the cell point ids are (0,1,...,npts-1). The PointIdMap maps global point id
232  // back to these canonoical point ids.
233  vtkPointIdMap *PointIdMap;
234 
235  // If edges are needed. Note that the edge numbering is in
236  // canonical space.
237  int EdgesGenerated; //true/false
238  vtkEdgeTable *EdgeTable; //keep track of all edges
239  vtkIdTypeArray *Edges; //edge pairs kept in this list, in canonical id space
240  int GenerateEdges(); //method populates the edge table and edge array
241 
242  // If faces need renumbering into canonical numbering space these members
243  // are used. When initiallly loaded, the face numbering uses global dataset
244  // ids. Once renumbered, they are converted to canonical space.
245  vtkIdTypeArray *Faces; //these are numbered in canonical id space
247  void GenerateFaces();
248 
249  // Bounds management
251  void ComputeBounds();
252  void ComputeParametricCoordinate(double x[3], double pc[3]);
253  void ComputePositionFromParametricCoordinate(double pc[3], double x[3]);
254 
255  // Members for supporting geometric operations
260  void ConstructPolyData();
263  void ConstructLocator();
266 
267  // This is the internal implementation of contouring a polyhedron. It is used
268  // by both Clip and Contour functions.
269  int InternalContour(double value,
270  int insideOut,
272  vtkDataArray *inScalars,
273  vtkDataArray *outScalars,
274  vtkPointData *inPd,
275  vtkPointData *outPd,
276  vtkCellArray *contourPolys,
277  vtkIdToIdVectorMapType & faceToPointsMap,
278  vtkIdToIdVectorMapType & pointToFacesMap,
279  vtkIdToIdMapType & pointIdMap);
280 
281 
282  // Check if the polyhedron cell intersect with the contour/clip function.
283  // If intersect, return 0. Otherwise return 1 or -1 when the polyhedron cell
284  // is on the positive or negative side of contour/clip function respectively.
285  int IntersectWithContour(double value,
286  int insideOut,
287  vtkDataArray *inScalars);
288 
289 private:
290  vtkPolyhedron(const vtkPolyhedron&); // Not implemented.
291  void operator=(const vtkPolyhedron&); // Not implemented.
292 
293  //BTX
294  class vtkInternal;
295  vtkInternal * Internal;
296  //ETX
297 };
298 
299 //----------------------------------------------------------------------------
300 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
301 {
302  pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
303  return 0;
304 }
305 
306 #endif
vtkCellLocator * CellLocator
vtkTetra * Tetra
vtkPolygon * Polygon
represent and manipulate point attribute data
Definition: vtkPointData.h:35
virtual int GetNumberOfFaces()=0
quickly locate points in 3-space
vtkIdTypeArray * GlobalFaces
vtkQuad * Quad
virtual int GetCellType()
Definition: vtkPolyhedron.h:76
#define VTK_FILTERING_EXPORT
virtual double * GetParametricCoords()
vtkEdgeTable * EdgeTable
vtkTriangle * Triangle
represent and manipulate cell attribute data
Definition: vtkCellData.h:36
Abstract class in support of both point location and point insertion.
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)=0
virtual void InterpolateFunctions(double pcoords[3], double weights[3])
Definition: vtkCell.h:297
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:71
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:39
vtkPolyData * PolyData
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:255
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:81
provides thread-safe access to cells
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:36
vtkIdTypeArray * Faces
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:38
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:45
virtual void SetFaces(vtkIdType *vtkNotUsed(faces))
Definition: vtkCell.h:105
cell represents a 1D line
Definition: vtkLine.h:33
abstract class to specify cell behavior
Definition: vtkCell.h:57
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:37
vtkGenericCell * Cell
vtkIdTypeArray * PolyConnectivity
vtkLine * Line
list of point or cell ids
Definition: vtkIdList.h:34
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:53
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:43
vtkIdTypeArray * Edges
virtual vtkCell * GetFace(int faceId)=0
virtual int GetNumberOfEdges()=0
vtkIdList * CellIds
object to represent cell connectivity
Definition: vtkCellArray.h:48
virtual vtkCell * GetEdge(int edgeId)=0
virtual int RequiresExplicitFaceRepresentation()
a cell that represents a triangle
Definition: vtkTriangle.h:39
virtual void GetEdgePoints(int vtkNotUsed(edgeId), int *&vtkNotUsed(pts))
Definition: vtkPolyhedron.h:70
virtual int RequiresInitialization()
Definition: vtkPolyhedron.h:80
virtual void InterpolateDerivs(double pcoords[3], double derivs[3])
Definition: vtkCell.h:302
virtual int GetParametricCenter(double pcoords[3])
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:58
virtual vtkIdType * GetFaces()
Definition: vtkCell.h:106
virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts)=0
virtual void Initialize()
Definition: vtkCell.h:92
static vtkObject * New()
virtual int GetParametricCenter(double pcoords[3])
vtkIdTypeArray * FaceLocations
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkCellArray * Polys