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) 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,
107  vtkIncrementalPointLocator *locator, vtkCellArray *verts,
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 
243 protected:
244  vtkPolyhedron();
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;
288  vtkCellArray *Polys;
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 
319 private:
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 //----------------------------------------------------------------------------
329 inline int vtkPolyhedron::GetParametricCenter(double pcoords[3])
330 {
331  pcoords[0] = pcoords[1] = pcoords[2] = 0.5;
332  return 0;
333 }
334 
335 #endif
represent and manipulate point attribute data
Definition: vtkPointData.h:37
int RequiresInitialization() override
This cell requires that it be initialized prior to access.
Definition: vtkPolyhedron.h:87
quickly locate points in 3-space
void GetFacePoints(int vtkNotUsed(faceId), int *&vtkNotUsed(pts)) override
Definition: vtkPolyhedron.h:76
virtual void InterpolateFunctions(double vtkNotUsed(pcoords)[3], double *vtkNotUsed(weight))
Compute the interpolation functions/derivatives (aka shape functions/derivatives) No-ops at this leve...
Definition: vtkCell.h:347
virtual double * GetParametricCoords()
Return a contiguous array of parametric coordinates of the points defining this cell.
represent and manipulate cell attribute data
Definition: vtkCellData.h:38
Abstract class in support of both point location and point insertion.
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:41
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:287
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
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:40
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:47
virtual void SetFaces(vtkIdType *vtkNotUsed(faces))
Definition: vtkCell.h:121
cell represents a 1D line
Definition: vtkLine.h:35
abstract class to specify cell behavior
Definition: vtkCell.h:59
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
a simple class to control print indentation
Definition: vtkIndent.h:39
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
virtual void InterpolateDerivs(double vtkNotUsed(pcoords)[3], double *vtkNotUsed(derivs))
Definition: vtkCell.h:350
object to represent cell connectivity
Definition: vtkCellArray.h:50
a cell that represents a triangle
Definition: vtkTriangle.h:41
int Contour(vtkDataSet *input, vtkPolyData *output, vtkDataArray *field, float isoValue, bool computeScalars)
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:122
virtual void Initialize()
Definition: vtkCell.h:106
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3D points
Definition: vtkPoints.h:39
int RequiresExplicitFaceRepresentation() override
Methods supporting the definition of faces.