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 
241  vtkPolyData* GetPolyData();
242 
243 protected:
244  vtkPolyhedron();
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
277  void GenerateFaces();
278 
279  // Bounds management
281  void ComputeBounds();
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
290  void ConstructPolyData();
293  void ConstructLocator();
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
vtkCellLocator * CellLocator
vtkTetra * Tetra
void Contour(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd) override
Generate contouring primitives.
vtkPolygon * Polygon
represent and manipulate point attribute data
Definition: vtkPointData.h:37
virtual int GetNumberOfFaces()=0
Return the number of faces in the cell.
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
Definition: vtkPolyhedron.h:87
quickly locate points in 3-space
vtkIdTypeArray * GlobalFaces
vtkIdTypeArray * EdgeFaces
vtkQuad * Quad
void GetFacePoints(int vtkNotUsed(faceId), int *&vtkNotUsed(pts)) override
Definition: vtkPolyhedron.h:76
vtkEdgeTable * EdgeTable
vtkTriangle * Triangle
represent and manipulate cell attribute data
Definition: vtkCellData.h:38
Abstract class in support of both point location and point insertion.
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)=0
Generate simplices of proper dimension.
virtual void InterpolateFunctions(const double vtkNotUsed(pcoords)[3], double *vtkNotUsed(weight))
Compute the interpolation functions/derivatives (aka shape functions/derivatives) No-ops at this leve...
Definition: vtkCell.h:357
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:41
vtkPolyData * PolyData
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:347
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
provides thread-safe access to cells
abstract class to specify 3D cell interface
Definition: vtkCell3D.h:38
virtual int CellBoundary(int subId, const double pcoords[3], vtkIdList *pts)=0
Given parametric coordinates of a point, return the closest cell boundary, and whether the point is i...
vtkIdTypeArray * Faces
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:40
virtual void InterpolateDerivs(const double vtkNotUsed(pcoords)[3], double *vtkNotUsed(derivs))
Definition: vtkCell.h:360
int IsPrimaryCell() override
A polyhedron is a full-fledged primary cell.
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:47
virtual void SetFaces(vtkIdType *vtkNotUsed(faces))
Definition: vtkCell.h:129
cell represents a 1D line
Definition: vtkLine.h:35
abstract class to specify cell behavior
Definition: vtkCell.h:59
virtual void EvaluateLocation(int &subId, const double pcoords[3], double x[3], double *weights)=0
Determine global coordinate (x[3]) from subId and parametric coordinates.
octree-based spatial search object to quickly locate cells
void GetEdgePoints(int vtkNotUsed(edgeId), int *&vtkNotUsed(pts)) override
See vtkCell3D API for description of these methods.
Definition: vtkPolyhedron.h:75
vtkPointIdMap * PointIdMap
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkGenericCell * Cell
vtkIdTypeArray * PolyConnectivity
vtkLine * Line
list of point or cell ids
Definition: vtkIdList.h:36
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:45
vtkIdTypeArray * Edges
virtual vtkCell * GetFace(int faceId)=0
Return the face cell from the faceId of the cell.
virtual int GetNumberOfEdges()=0
Return the number of edges in the cell.
virtual int EvaluatePosition(const double x[3], double closestPoint[3], int &subId, double pcoords[3], double &dist2, double weights[])=0
Given a point x[3] return inside(=1), outside(=0) cell, or (-1) computational problem encountered; ev...
vtkIdList * CellIds
object to represent cell connectivity
Definition: vtkCellArray.h:50
virtual vtkCell * GetEdge(int edgeId)=0
Return the edge cell from the edgeId of the cell.
a cell that represents a triangle
Definition: vtkTriangle.h:41
virtual void Derivatives(int subId, const double pcoords[3], const double *values, int dim, double *derivs)=0
Compute derivatives given cell subId and parametric coordinates.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a 3D cell defined by a set of polygonal faces
Definition: vtkPolyhedron.h:60
virtual vtkIdType * GetFaces()
Definition: vtkCell.h:130
virtual void Initialize()
Definition: vtkCell.h:114
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual double * GetParametricCoords())
Return a contiguous array of parametric coordinates of the points defining this cell.
virtual int GetParametricCenter(double pcoords[3])
Return center of the cell in parametric coordinates.
virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)=0
Intersect with a ray.
void Clip(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut) override
Cut (or clip) the cell based on the input cellScalars and the specified value.
vtkIdTypeArray * FaceLocations
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkCellArray * Polys
int GetParametricCenter(double pcoords[3]) override
Return the center of the cell in parametric coordinates.
int GetCellType() override
See the vtkCell API for descriptions of these methods.
Definition: vtkPolyhedron.h:82
int RequiresExplicitFaceRepresentation() override
Methods supporting the definition of faces.