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=========================================================================*/
38#ifndef vtkPolyhedron_h
39#define vtkPolyhedron_h
40
41#include "vtkCommonDataModelModule.h" // For export macro
42#include "vtkCell3D.h"
43
44class vtkIdTypeArray;
45class vtkCellArray;
46class vtkTriangle;
47class vtkQuad;
48class vtkTetra;
49class vtkPolygon;
50class vtkLine;
51class vtkPointIdMap;
52class vtkIdToIdVectorMapType;
53class vtkIdToIdMapType;
54class vtkEdgeTable;
55class vtkPolyData;
56class vtkCellLocator;
57class vtkGenericCell;
58class vtkPointLocator;
59
60class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
61{
62public:
64
67 static vtkPolyhedron *New();
68 vtkTypeMacro(vtkPolyhedron,vtkCell3D);
69 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
71
75 void GetEdgePoints(int vtkNotUsed(edgeId), int* &vtkNotUsed(pts)) VTK_OVERRIDE {}
76 void GetFacePoints(int vtkNotUsed(faceId), int* &vtkNotUsed(pts)) VTK_OVERRIDE {}
77 double *GetParametricCoords() VTK_OVERRIDE;
78
82 int GetCellType() VTK_OVERRIDE {return VTK_POLYHEDRON;}
83
87 int RequiresInitialization() VTK_OVERRIDE {return 1;}
88 void Initialize() VTK_OVERRIDE;
89
91
95 int GetNumberOfEdges() VTK_OVERRIDE;
96 vtkCell *GetEdge(int) VTK_OVERRIDE;
97 int GetNumberOfFaces() VTK_OVERRIDE;
98 vtkCell *GetFace(int faceId) VTK_OVERRIDE;
100
106 void Contour(double value, vtkDataArray *scalars,
108 vtkCellArray *lines, vtkCellArray *polys,
109 vtkPointData *inPd, vtkPointData *outPd,
110 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) VTK_OVERRIDE;
111
121 void Clip(double value, vtkDataArray *scalars,
122 vtkIncrementalPointLocator *locator, vtkCellArray *connectivity,
123 vtkPointData *inPd, vtkPointData *outPd,
124 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
125 int insideOut) VTK_OVERRIDE;
126
134 int EvaluatePosition(double x[3], double* closestPoint,
135 int& subId, double pcoords[3],
136 double& dist2, double *weights) VTK_OVERRIDE;
137
142 void EvaluateLocation(int& subId, double pcoords[3], double x[3],
143 double *weights) VTK_OVERRIDE;
144
151 int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
152 double x[3], double pcoords[3], int& subId) VTK_OVERRIDE;
153
169 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts) VTK_OVERRIDE;
170
178 void Derivatives(int subId, double pcoords[3], double *values,
179 int dim, double *derivs) VTK_OVERRIDE;
180
185 int CellBoundary(int subId, double pcoords[3], vtkIdList *pts) VTK_OVERRIDE;
186
191 int GetParametricCenter(double pcoords[3]) VTK_OVERRIDE;
192
196 int IsPrimaryCell() VTK_OVERRIDE {return 1;}
197
199
204 void InterpolateFunctions(double x[3], double *sf) VTK_OVERRIDE;
205 void InterpolateDerivs(double x[3], double *derivs) VTK_OVERRIDE;
207
209
217 int RequiresExplicitFaceRepresentation() VTK_OVERRIDE {return 1;}
218 void SetFaces(vtkIdType *faces) VTK_OVERRIDE;
219 vtkIdType *GetFaces() VTK_OVERRIDE;
221
228 int IsInside(double x[3], double tolerance);
229
236 bool IsConvex();
237
241 vtkPolyData* GetPolyData();
242
243protected:
245 ~vtkPolyhedron() VTK_OVERRIDE;
246
247 // Internal classes for supporting operations on this cell
248 vtkLine *Line;
249 vtkTriangle *Triangle;
250 vtkQuad *Quad;
251 vtkPolygon *Polygon;
252 vtkTetra *Tetra;
253 vtkIdTypeArray *GlobalFaces; //these are numbered in gloabl id space
254 vtkIdTypeArray *FaceLocations;
255
256 // vtkCell has the data members Points (x,y,z coordinates) and PointIds
257 // (global cell ids corresponding to cell canonical numbering (0,1,2,....)).
258 // These data members are implicitly organized in canonical space, i.e., where
259 // the cell point ids are (0,1,...,npts-1). The PointIdMap maps global point id
260 // back to these canonoical point ids.
261 vtkPointIdMap *PointIdMap;
262
263 // If edges are needed. Note that the edge numbering is in
264 // canonical space.
265 int EdgesGenerated; //true/false
266 vtkEdgeTable *EdgeTable; //keep track of all edges
267 vtkIdTypeArray *Edges; //edge pairs kept in this list, in canonical id space
268 vtkIdTypeArray *EdgeFaces; // face pairs that comprise each edge, with the
269 // same ordering as EdgeTable
270 int GenerateEdges(); //method populates the edge table and edge array
271
272 // If faces need renumbering into canonical numbering space these members
273 // are used. When initiallly loaded, the face numbering uses global dataset
274 // ids. Once renumbered, they are converted to canonical space.
275 vtkIdTypeArray *Faces; //these are numbered in canonical id space
276 int FacesGenerated;
277 void GenerateFaces();
278
279 // Bounds management
280 int BoundsComputed;
281 void ComputeBounds();
282 void ComputeParametricCoordinate(double x[3], double pc[3]);
283 void ComputePositionFromParametricCoordinate(double pc[3], double x[3]);
284
285 // Members for supporting geometric operations
286 int PolyDataConstructed;
287 vtkPolyData *PolyData;
289 vtkIdTypeArray *PolyConnectivity;
290 void ConstructPolyData();
291 int LocatorConstructed;
292 vtkCellLocator *CellLocator;
293 void ConstructLocator();
294 vtkIdList *CellIds;
296
297 // This is the internal implementation of contouring a polyhedron. It is used
298 // by both Clip and Contour functions.
299 int InternalContour(double value,
300 int insideOut,
302 vtkDataArray *inScalars,
303 vtkDataArray *outScalars,
304 vtkPointData *inPd,
305 vtkPointData *outPd,
306 vtkCellArray *contourPolys,
307 vtkIdToIdVectorMapType & faceToPointsMap,
308 vtkIdToIdVectorMapType & pointToFacesMap,
309 vtkIdToIdMapType & pointIdMap);
310
311
312 // Check if the polyhedron cell intersect with the contour/clip function.
313 // If intersect, return 0. Otherwise return 1 or -1 when the polyhedron cell
314 // is on the positive or negative side of contour/clip function respectively.
315 int IntersectWithContour(double value,
316 int insideOut,
317 vtkDataArray *inScalars);
318
319private:
320 vtkPolyhedron(const vtkPolyhedron&) VTK_DELETE_FUNCTION;
321 void operator=(const vtkPolyhedron&) VTK_DELETE_FUNCTION;
322
323 class vtkInternal;
324 vtkInternal * Internal;
325
326};
327
328//----------------------------------------------------------------------------
329inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
330{
331 pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
332 return 0;
333}
334
335#endif
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:39
object to represent cell connectivity
Definition: vtkCellArray.h:51
represent and manipulate cell attribute data
Definition: vtkCellData.h:39
octree-based spatial search object to quickly locate cells
abstract class to specify cell behavior
Definition: vtkCell.h:60
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:41
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:37
dynamic, self-adjusting array of vtkIdType
Abstract class in support of both point location and point insertion.
a simple class to control print indentation
Definition: vtkIndent.h:40
cell represents a 1D line
Definition: vtkLine.h:36
represent and manipulate point attribute data
Definition: vtkPointData.h:38
quickly locate points in 3-space
represent and manipulate 3D points
Definition: vtkPoints.h:40
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:46
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:61
int RequiresExplicitFaceRepresentation() override
Methods supporting the definition of faces.
void SetFaces(vtkIdType *faces) override
void InterpolateDerivs(double x[3], double *derivs) override
void GetEdgePoints(int vtkNotUsed(edgeId), int *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:75
double * GetParametricCoords() override
Return a contiguous array of parametric coordinates of the points defining this cell.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetFacePoints(int vtkNotUsed(faceId), int *&vtkNotUsed(pts)) override
Definition: vtkPolyhedron.h:76
vtkIdType * GetFaces() override
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
Definition: vtkPolyhedron.h:87
static vtkPolyhedron * New()
Standard new methods.
void InterpolateFunctions(double x[3], double *sf) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives).
void Initialize() override
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:42
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:48
a cell that represents a triangle
Definition: vtkTriangle.h:42
int Contour(vtkDataSet *input, vtkPolyData *output, vtkDataArray *field, float isoValue, bool computeScalars)
@ value
Definition: vtkX3D.h:220
@ index
Definition: vtkX3D.h:246
@ VTK_POLYHEDRON
Definition: vtkCellType.h:87
int vtkIdType
Definition: vtkType.h:287