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();
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 
215 
216 protected:
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
249 
250  // Bounds management
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
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.
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
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkPolyhedron::Edges
vtkIdTypeArray * Edges
Definition: vtkPolyhedron.h:240
vtkPolyhedron::ComputePositionFromParametricCoordinate
void ComputePositionFromParametricCoordinate(double pc[3], double x[3])
vtkPolyhedron::GenerateFaces
void GenerateFaces()
vtkPolyhedron::Tetra
vtkTetra * Tetra
Definition: vtkPolyhedron.h:225
VTK_POLYHEDRON
@ VTK_POLYHEDRON
Definition: vtkCellType.h:86
vtkgl::weights
const GLbyte * weights
Definition: vtkgl.h:12766
vtkPolyhedron::GetPolyData
vtkPolyData * GetPolyData()
vtkPolyhedron::FacesGenerated
int FacesGenerated
Definition: vtkPolyhedron.h:247
vtkCellLocator
octree-based spatial search object to quickly locate cells
Definition: vtkCellLocator.h:52
vtkPolyhedron::GetParametricCoords
virtual double * GetParametricCoords()
vtkPolyhedron::Cell
vtkGenericCell * Cell
Definition: vtkPolyhedron.h:266
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:37
vtkPolyhedron::GetParametricCenter
virtual int GetParametricCenter(double pcoords[3])
Definition: vtkPolyhedron.h:301
vtkPolyhedron::~vtkPolyhedron
~vtkPolyhedron()
vtkPolyhedron::Contour
virtual void Contour(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd)
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkPolyhedron::InternalContour
int InternalContour(double value, int insideOut, vtkIncrementalPointLocator *locator, vtkDataArray *inScalars, vtkDataArray *outScalars, vtkPointData *inPd, vtkPointData *outPd, vtkCellArray *contourPolys, vtkIdToIdVectorMapType &faceToPointsMap, vtkIdToIdVectorMapType &pointToFacesMap, vtkIdToIdMapType &pointIdMap)
vtkCommonDataModelModule.h
vtkPolyhedron::EdgeTable
vtkEdgeTable * EdgeTable
Definition: vtkPolyhedron.h:239
vtkPolygon
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:45
vtkPointLocator
quickly locate points in 3-space
Definition: vtkPointLocator.h:53
vtkPolyhedron::GenerateEdges
int GenerateEdges()
vtkPolyhedron::IsInside
int IsInside(double x[3], double tolerance)
vtkPolyhedron::Polys
vtkCellArray * Polys
Definition: vtkPolyhedron.h:259
vtkPolyhedron::Clip
virtual void Clip(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut)
vtkPolyhedron::PolyDataConstructed
int PolyDataConstructed
Definition: vtkPolyhedron.h:257
vtkPolyhedron::Triangulate
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkPolyhedron::PolyData
vtkPolyData * PolyData
Definition: vtkPolyhedron.h:258
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkPolyhedron::GetCellType
virtual int GetCellType()
Definition: vtkPolyhedron.h:77
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkPolyhedron::CellIds
vtkIdList * CellIds
Definition: vtkPolyhedron.h:265
vtkCell3D.h
vtkPolyhedron::ConstructPolyData
void ConstructPolyData()
vtkEdgeTable
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:40
vtkPolyhedron::BoundsComputed
int BoundsComputed
Definition: vtkPolyhedron.h:251
vtkPolyhedron::CellBoundary
virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts)
vtkLine
cell represents a 1D line
Definition: vtkLine.h:35
vtkPolyhedron::LocatorConstructed
int LocatorConstructed
Definition: vtkPolyhedron.h:262
vtkPolyhedron::RequiresExplicitFaceRepresentation
virtual int RequiresExplicitFaceRepresentation()
Definition: vtkPolyhedron.h:201
vtkCell3D
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:38
vtkPolyhedron::CellLocator
vtkCellLocator * CellLocator
Definition: vtkPolyhedron.h:263
vtkPolyhedron::vtkPolyhedron
vtkPolyhedron()
vtkPolyhedron::GetFaces
virtual vtkIdType * GetFaces()
vtkPolyhedron::New
static vtkPolyhedron * New()
vtkPolyhedron::SetFaces
virtual void SetFaces(vtkIdType *faces)
vtkNotUsed
#define vtkNotUsed(x)
Definition: vtkSetGet.h:557
vtkPolyhedron::IntersectWithContour
int IntersectWithContour(double value, int insideOut, vtkDataArray *inScalars)
vtkgl::value
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
vtkgl::values
GLboolean GLenum GLenum GLvoid * values
Definition: vtkgl.h:11354
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:62
vtkPolyhedron::GetFacePoints
virtual void GetFacePoints(int vtkNotUsed(faceId), int *&vtkNotUsed(pts))
Definition: vtkPolyhedron.h:72
vtkPolyhedron::Initialize
virtual void Initialize()
vtkCellData
represent and manipulate cell attribute data
Definition: vtkCellData.h:38
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkIncrementalPointLocator
Abstract class in support of both point location and point insertion.
Definition: vtkIncrementalPointLocator.h:54
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkPolyhedron::Line
vtkLine * Line
Definition: vtkPolyhedron.h:221
vtkPolyhedron::FaceLocations
vtkIdTypeArray * FaceLocations
Definition: vtkPolyhedron.h:227
vtkPolyhedron::ConstructLocator
void ConstructLocator()
vtkPolyhedron::EvaluateLocation
virtual void EvaluateLocation(int &subId, double pcoords[3], double x[3], double *weights)
vtkTriangle
a cell that represents a triangle
Definition: vtkTriangle.h:41
vtkPolyhedron::Derivatives
virtual void Derivatives(int subId, double pcoords[3], double *values, int dim, double *derivs)
vtkPolyhedron::EvaluatePosition
virtual int EvaluatePosition(double x[3], double *closestPoint, int &subId, double pcoords[3], double &dist2, double *weights)
vtkPolyhedron::GlobalFaces
vtkIdTypeArray * GlobalFaces
Definition: vtkPolyhedron.h:226
vtkgl::index
GLuint index
Definition: vtkgl.h:11983
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:49
vtkPolyhedron::ComputeBounds
void ComputeBounds()
vtkPolyhedron::InterpolateFunctions
virtual void InterpolateFunctions(double x[3], double *sf)
vtkPolyhedron::GetEdgePoints
virtual void GetEdgePoints(int vtkNotUsed(edgeId), int *&vtkNotUsed(pts))
Definition: vtkPolyhedron.h:71
vtkPolyhedron::Triangle
vtkTriangle * Triangle
Definition: vtkPolyhedron.h:222
vtkPolyhedron::InterpolateDerivs
virtual void InterpolateDerivs(double x[3], double *derivs)
vtkPolyhedron::GetNumberOfEdges
virtual int GetNumberOfEdges()
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkPolyhedron::PolyConnectivity
vtkIdTypeArray * PolyConnectivity
Definition: vtkPolyhedron.h:260
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:42
vtkCell::GetParametricCenter
virtual int GetParametricCenter(double pcoords[3])
vtkPolyhedron::IsPrimaryCell
int IsPrimaryCell()
Definition: vtkPolyhedron.h:184
VTKCOMMONDATAMODEL_EXPORT
#define VTKCOMMONDATAMODEL_EXPORT
Definition: vtkCommonDataModelModule.h:15
vtkPolyhedron::GetFace
virtual vtkCell * GetFace(int faceId)
vtkPolyhedron::PointIdMap
vtkPointIdMap * PointIdMap
Definition: vtkPolyhedron.h:234
vtkPolyhedron::EdgesGenerated
int EdgesGenerated
Definition: vtkPolyhedron.h:238
vtkTetra
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:47
vtkPolyhedron::GetNumberOfFaces
virtual int GetNumberOfFaces()
vtkPolyhedron::ComputeParametricCoordinate
void ComputeParametricCoordinate(double x[3], double pc[3])
vtkPolyhedron::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkPolyhedron::IntersectWithLine
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
vtkPolyhedron::Quad
vtkQuad * Quad
Definition: vtkPolyhedron.h:223
vtkPolyhedron::Polygon
vtkPolygon * Polygon
Definition: vtkPolyhedron.h:224
vtkPolyhedron::GetEdge
virtual vtkCell * GetEdge(int)
vtkPolyhedron::Faces
vtkIdTypeArray * Faces
Definition: vtkPolyhedron.h:246
vtkPolyhedron
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:60
vtkPolyhedron::RequiresInitialization
virtual int RequiresInitialization()
Definition: vtkPolyhedron.h:81
vtkQuad
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:41