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 
44 class vtkIdTypeArray;
45 class vtkCellArray;
46 class vtkTriangle;
47 class vtkQuad;
48 class vtkTetra;
49 class vtkPolygon;
50 class vtkLine;
51 class vtkPointIdMap;
52 class vtkIdToIdVectorMapType;
53 class vtkIdToIdMapType;
54 class vtkEdgeTable;
55 class vtkPolyData;
56 class vtkCellLocator;
57 class vtkGenericCell;
58 class vtkPointLocator;
59 
60 class VTKCOMMONDATAMODEL_EXPORT vtkPolyhedron : public vtkCell3D
61 {
62 public:
64 
67  static vtkPolyhedron *New();
68  vtkTypeMacro(vtkPolyhedron,vtkCell3D);
69  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
75  void GetEdgePoints(int vtkNotUsed(edgeId), int* &vtkNotUsed(pts)) override {}
76  void GetFacePoints(int vtkNotUsed(faceId), int* &vtkNotUsed(pts)) override {}
77  double *GetParametricCoords() override;
78 
82  int GetCellType() override {return VTK_POLYHEDRON;}
83 
87  int RequiresInitialization() override {return 1;}
88  void Initialize() override;
89 
91 
95  int GetNumberOfEdges() override;
96  vtkCell *GetEdge(int) override;
97  int GetNumberOfFaces() override;
98  vtkCell *GetFace(int faceId) override;
100 
106  void Contour(double value, vtkDataArray *scalars,
107  vtkIncrementalPointLocator *locator, vtkCellArray *verts,
108  vtkCellArray *lines, vtkCellArray *polys,
109  vtkPointData *inPd, vtkPointData *outPd,
110  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) 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) override;
126 
134  int EvaluatePosition(const double x[3], double closestPoint[3],
135  int& subId, double pcoords[3],
136  double& dist2, double weights[]) override;
137 
142  void EvaluateLocation(int& subId, const double pcoords[3], double x[3],
143  double *weights) override;
144 
151  int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t,
152  double x[3], double pcoords[3], int& subId) override;
153 
169  int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts) override;
170 
178  void Derivatives(int subId, const double pcoords[3], const double *values,
179  int dim, double *derivs) override;
180 
185  int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts) override;
186 
191  int GetParametricCenter(double pcoords[3]) override;
192 
196  int IsPrimaryCell() override {return 1;}
197 
199 
204  void InterpolateFunctions(const double x[3], double *sf) override;
205  void InterpolateDerivs(const double x[3], double *derivs) override;
207 
209 
217  int RequiresExplicitFaceRepresentation() override {return 1;}
218  void SetFaces(vtkIdType *faces) override;
219  vtkIdType *GetFaces() override;
221 
228  int IsInside(const double x[3], double tolerance);
229 
236  bool IsConvex();
237 
242 
243 protected:
245  ~vtkPolyhedron() override;
246 
247  // Internal classes for supporting operations on this cell
253  vtkIdTypeArray *GlobalFaces; //these are numbered in global id space
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
278 
279  // Bounds management
282  void ComputeParametricCoordinate(const double x[3], double pc[3]);
283  void ComputePositionFromParametricCoordinate(const double pc[3], double x[3]);
284 
285  // Members for supporting geometric operations
296 
297 private:
298  vtkPolyhedron(const vtkPolyhedron&) = delete;
299  void operator=(const vtkPolyhedron&) = delete;
300 
301 };
302 
303 //----------------------------------------------------------------------------
304 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
305 {
306  pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
307  return 0;
308 }
309 
310 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:40
vtkPolyhedron::Edges
vtkIdTypeArray * Edges
Definition: vtkPolyhedron.h:267
vtkPolyhedron::Contour
void Contour(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) override
Satisfy the vtkCell API.
vtkPolyhedron::GenerateFaces
void GenerateFaces()
vtkPolyhedron::RequiresExplicitFaceRepresentation
int RequiresExplicitFaceRepresentation() override
Methods supporting the definition of faces.
Definition: vtkPolyhedron.h:217
vtkPolyhedron::Tetra
vtkTetra * Tetra
Definition: vtkPolyhedron.h:252
VTK_POLYHEDRON
@ VTK_POLYHEDRON
Definition: vtkCellType.h:87
vtkPolyhedron::InterpolateDerivs
void InterpolateDerivs(const double x[3], double *derivs) override
vtkPolyhedron::GetPolyData
vtkPolyData * GetPolyData()
Construct polydata if no one exist, then return this->PolyData.
vtkPolyhedron::EvaluateLocation
void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights) override
The inverse of EvaluatePosition.
vtkPolyhedron::SetFaces
void SetFaces(vtkIdType *faces) override
vtkPolyhedron::ComputeParametricCoordinate
void ComputeParametricCoordinate(const double x[3], double pc[3])
vtkPolyhedron::FacesGenerated
int FacesGenerated
Definition: vtkPolyhedron.h:276
vtkCellLocator
octree-based spatial search object to quickly locate cells
Definition: vtkCellLocator.h:53
vtkPolyhedron::Cell
vtkGenericCell * Cell
Definition: vtkPolyhedron.h:295
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:38
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkPolyhedron::Initialize
void Initialize() override
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkPolyhedron::EdgeTable
vtkEdgeTable * EdgeTable
Definition: vtkPolyhedron.h:266
vtkPolygon
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:46
vtkPointLocator
quickly locate points in 3-space
Definition: vtkPointLocator.h:54
vtkPolyhedron::GenerateEdges
int GenerateEdges()
vtkPolyhedron::Polys
vtkCellArray * Polys
Definition: vtkPolyhedron.h:288
vtkPolyhedron::PolyDataConstructed
int PolyDataConstructed
Definition: vtkPolyhedron.h:286
vtkPolyhedron::IsConvex
bool IsConvex()
Determine whether or not a polyhedron is convex.
vtkPolyhedron::GetParametricCenter
int GetParametricCenter(double pcoords[3]) override
Return the center of the cell in parametric coordinates.
Definition: vtkPolyhedron.h:304
vtkPolyhedron::PolyData
vtkPolyData * PolyData
Definition: vtkPolyhedron.h:287
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkPolyhedron::GetParametricCoords
double * GetParametricCoords() override
Return a contiguous array of parametric coordinates of the points defining this cell.
vtkPolyhedron::CellIds
vtkIdList * CellIds
Definition: vtkPolyhedron.h:294
vtkCell3D.h
vtkPolyhedron::ConstructPolyData
void ConstructPolyData()
vtkEdgeTable
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:41
vtkPolyhedron::BoundsComputed
int BoundsComputed
Definition: vtkPolyhedron.h:280
vtkLine
cell represents a 1D line
Definition: vtkLine.h:36
vtkPolyhedron::LocatorConstructed
int LocatorConstructed
Definition: vtkPolyhedron.h:291
vtkPolyhedron::GetFaces
vtkIdType * GetFaces() override
vtkCell3D
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:39
vtkPolyhedron::CellLocator
vtkCellLocator * CellLocator
Definition: vtkPolyhedron.h:292
vtkPolyhedron::vtkPolyhedron
vtkPolyhedron()
vtkPolyhedron::Triangulate
int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts) override
Use vtkOrderedTriangulator to tetrahedralize the polyhedron mesh.
vtkPolyhedron::GetNumberOfFaces
int GetNumberOfFaces() override
Return the number of faces in the cell.
vtkPolyhedron::New
static vtkPolyhedron * New()
Standard new methods.
vtkPolyhedron::Clip
void Clip(double value, vtkDataArray *scalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut) override
Satisfy the vtkCell API.
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:60
vtkPolyhedron::ComputePositionFromParametricCoordinate
void ComputePositionFromParametricCoordinate(const double pc[3], double x[3])
vtkPolyhedron::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCellData
represent and manipulate cell attribute data
Definition: vtkCellData.h:39
vtkPolyhedron::EdgeFaces
vtkIdTypeArray * EdgeFaces
Definition: vtkPolyhedron.h:268
vtkPolyhedron::GetFace
vtkCell * GetFace(int faceId) override
Return the face cell from the faceId of the cell.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:51
vtkPolyhedron::GetFacePoints
void GetFacePoints(int vtkNotUsed(faceId), int *&vtkNotUsed(pts)) override
Definition: vtkPolyhedron.h:76
vtkPolyhedron::Derivatives
void Derivatives(int subId, const double pcoords[3], const double *values, int dim, double *derivs) override
Computes derivatives at the point specified by the parameter coordinate.
vtkIncrementalPointLocator
Abstract class in support of both point location and point insertion.
Definition: vtkIncrementalPointLocator.h:52
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:37
vtkPolyhedron::Line
vtkLine * Line
Definition: vtkPolyhedron.h:248
vtkPolyhedron::GetEdge
vtkCell * GetEdge(int) override
Return the edge cell from the edgeId of the cell.
vtkPolyhedron::GetCellType
int GetCellType() override
See the vtkCell API for descriptions of these methods.
Definition: vtkPolyhedron.h:82
vtkPolyhedron::FaceLocations
vtkIdTypeArray * FaceLocations
Definition: vtkPolyhedron.h:254
vtkPolyhedron::InterpolateFunctions
void InterpolateFunctions(const double x[3], double *sf) override
Compute the interpolation functions/derivatives (aka shape functions/derivatives).
vtkPolyhedron::CellBoundary
int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts) override
Find the boundary face closest to the point defined by the pcoords[3] and subId of the cell (subId ca...
vtkPolyhedron::ConstructLocator
void ConstructLocator()
vtkTriangle
a cell that represents a triangle
Definition: vtkTriangle.h:42
vtkPolyhedron::~vtkPolyhedron
~vtkPolyhedron() override
vtkPolyhedron::GlobalFaces
vtkIdTypeArray * GlobalFaces
Definition: vtkPolyhedron.h:253
vtkPolyhedron::RequiresInitialization
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
Definition: vtkPolyhedron.h:87
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:42
vtkPolyhedron::ComputeBounds
void ComputeBounds()
vtkPolyhedron::IsInside
int IsInside(const double x[3], double tolerance)
A method particular to vtkPolyhedron.
vtkPolyhedron::Triangle
vtkTriangle * Triangle
Definition: vtkPolyhedron.h:249
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkPolyhedron::PolyConnectivity
vtkIdTypeArray * PolyConnectivity
Definition: vtkPolyhedron.h:289
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:40
vtkCell::GetParametricCenter
virtual int GetParametricCenter(double pcoords[3])
Return center of the cell in parametric coordinates.
vtkPolyhedron::IntersectWithLine
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId) override
Intersect the line (p1,p2) with a given tolerance tol to determine a point of intersection x[3] with ...
vtkPolyhedron::PointIdMap
vtkPointIdMap * PointIdMap
Definition: vtkPolyhedron.h:261
vtkPolyhedron::EdgesGenerated
int EdgesGenerated
Definition: vtkPolyhedron.h:265
vtkTetra
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:48
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkPolyhedron::Quad
vtkQuad * Quad
Definition: vtkPolyhedron.h:250
vtkPolyhedron::GetEdgePoints
void GetEdgePoints(int vtkNotUsed(edgeId), int *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:75
vtkPolyhedron::Polygon
vtkPolygon * Polygon
Definition: vtkPolyhedron.h:251
vtkPolyhedron::Faces
vtkIdTypeArray * Faces
Definition: vtkPolyhedron.h:275
vtkPolyhedron
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:61
vtkPolyhedron::GetNumberOfEdges
int GetNumberOfEdges() override
A polyhedron is represented internally by a set of polygonal faces.
vtkQuad
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:42
vtkPolyhedron::EvaluatePosition
int EvaluatePosition(const double x[3], double closestPoint[3], int &subId, double pcoords[3], double &dist2, double weights[]) override
Satisfy the vtkCell API.
vtkPolyhedron::IsPrimaryCell
int IsPrimaryCell() override
A polyhedron is a full-fledged primary cell.
Definition: vtkPolyhedron.h:196