VTK
vtkPolygon.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPolygon.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 =========================================================================*/
30 #ifndef __vtkPolygon_h
31 #define __vtkPolygon_h
32 
33 #include "vtkCommonDataModelModule.h" // For export macro
34 #include "vtkCell.h"
35 
36 class vtkDoubleArray;
37 class vtkIdTypeArray;
38 class vtkLine;
39 class vtkPoints;
40 class vtkQuad;
41 class vtkTriangle;
43 
45 {
46 public:
47  static vtkPolygon *New();
49  void PrintSelf(ostream& os, vtkIndent indent);
50 
52 
53  int GetCellType() {return VTK_POLYGON;};
54  int GetCellDimension() {return 2;};
55  int GetNumberOfEdges() {return this->GetNumberOfPoints();};
56  int GetNumberOfFaces() {return 0;};
57  vtkCell *GetEdge(int edgeId);
58  vtkCell *GetFace(int) {return 0;};
59  int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
60  void Contour(double value, vtkDataArray *cellScalars,
62  vtkCellArray *lines, vtkCellArray *polys,
63  vtkPointData *inPd, vtkPointData *outPd,
64  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
65  void Clip(double value, vtkDataArray *cellScalars,
67  vtkPointData *inPd, vtkPointData *outPd,
68  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
69  int insideOut);
70  int EvaluatePosition(double x[3], double* closestPoint,
71  int& subId, double pcoords[3],
72  double& dist2, double *weights);
73  void EvaluateLocation(int& subId, double pcoords[3], double x[3],
74  double *weights);
75  int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
76  double x[3], double pcoords[3], int& subId);
77  int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
78  void Derivatives(int subId, double pcoords[3], double *values,
79  int dim, double *derivs);
80  int IsPrimaryCell() {return 0;}
82 
87  double ComputeArea();
88 
90 
96  virtual void InterpolateFunctions(double x[3], double *sf);
97  virtual void InterpolateDerivs(double x[3], double *derivs);
99 
101 
102  static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
103  double n[3]);
104  static void ComputeNormal(vtkPoints *p, double n[3]);
105  static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
107 
111  static void ComputeNormal(int numPts, double *pts, double n[3]);
112 
114 
115  static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
116  double centroid[3]);
118 
120 
125  static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
126  double normal[3]);
128 
130 
135  int ParameterizePolygon(double p0[3], double p10[3], double &l10,
136  double p20[3], double &l20, double n[3]);
138 
140 
144  static int PointInPolygon(double x[3], int numPts, double *pts,
145  double bounds[6], double n[3]);
147 
152  int Triangulate(vtkIdList *outTris);
153 
156  int NonDegenerateTriangulate(vtkIdList *outTris);
157 
159 
162  static double DistanceToPolygon(double x[3], int numPts, double *pts,
163  double bounds[6], double closest[3]);
165 
167 
173  static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
174  int npts2, double *pts2,
175  double bounds2[3], double tol,
176  double x[3]);
178 
180 
189  static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
190  double tol, double p0[3], double p1[3]);
192 
194 
199  vtkGetMacro(UseMVCInterpolation, bool);
200  vtkSetMacro(UseMVCInterpolation, bool);
202 
203 protected:
204  vtkPolygon();
205  ~vtkPolygon();
206 
207  // Compute the interpolation functions using Mean Value Coordinate.
208  void InterpolateFunctionsUsingMVC(double x[3], double *weights);
209 
210  // variables used by instances of this class
211  double Tolerance; // Intersection tolerance
212  int SuccessfulTriangulation; // Stops recursive tri. if necessary
213  double Normal[3]; //polygon normal
219 
220  // Parameter indicating whether to use Mean Value Coordinate algorithm
221  // for interpolation. The parameter is false by default.
223 
224  // Helper methods for triangulation------------------------------
229  int EarCutTriangulation();
230 
231 private:
232  vtkPolygon(const vtkPolygon&); // Not implemented.
233  void operator=(const vtkPolygon&); // Not implemented.
234 };
235 
236 #endif
237 
vtkCell * GetFace(int)
Definition: vtkPolygon.h:58
vtkIdType GetNumberOfPoints()
Definition: vtkCell.h:114
represent and manipulate point attribute data
Definition: vtkPointData.h:36
int IsPrimaryCell()
Definition: vtkPolygon.h:80
GLuint index
Definition: vtkgl.h:11983
void PrintSelf(ostream &os, vtkIndent indent)
double Tolerance
Definition: vtkPolygon.h:211
int GetNumberOfEdges()
Definition: vtkPolygon.h:55
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
represent and manipulate cell attribute data
Definition: vtkCellData.h:37
Abstract class in support of both point location and point insertion.
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)=0
virtual void InterpolateFunctions(double pcoords[3], double weights[3])
Definition: vtkCell.h:298
virtual void EvaluateLocation(int &subId, double pcoords[3], double x[3], double *weights)=0
virtual int EvaluatePosition(double x[3], double *closestPoint, int &subId, double pcoords[3], double &dist2, double *weights)=0
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:40
dynamic, self-adjusting array of vtkIdType
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
int vtkIdType
Definition: vtkType.h:268
GLdouble GLdouble t
Definition: vtkgl.h:11602
GLuint * ids
Definition: vtkgl.h:11831
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
dynamic, self-adjusting array of double
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:58
vtkDoubleArray * TriScalars
Definition: vtkPolygon.h:217
const GLbyte * weights
Definition: vtkgl.h:12766
a simple class to control print indentation
Definition: vtkIndent.h:38
GLboolean GLenum GLenum GLvoid * values
Definition: vtkgl.h:11354
int GetNumberOfFaces()
Definition: vtkPolygon.h:56
list of point or cell ids
Definition: vtkIdList.h:35
int SuccessfulTriangulation
Definition: vtkPolygon.h:212
virtual void Derivatives(int subId, double pcoords[3], double *values, int dim, double *derivs)=0
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)=0
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:44
bool UseMVCInterpolation
Definition: vtkPolygon.h:222
virtual void Clip(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *connectivity, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, int insideOut)=0
object to represent cell connectivity
Definition: vtkCellArray.h:49
virtual vtkCell * GetEdge(int edgeId)=0
vtkLine * Line
Definition: vtkPolygon.h:218
int GetCellType()
Definition: vtkPolygon.h:53
a cell that represents a triangle
Definition: vtkTriangle.h:40
vtkIdList * Tris
Definition: vtkPolygon.h:214
virtual void Contour(double value, vtkDataArray *cellScalars, vtkIncrementalPointLocator *locator, vtkCellArray *verts, vtkCellArray *lines, vtkCellArray *polys, vtkPointData *inPd, vtkPointData *outPd, vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd)=0
virtual void InterpolateDerivs(double pcoords[3], double derivs[3])
Definition: vtkCell.h:303
int GetCellDimension()
Definition: vtkPolygon.h:54
GLclampd n
Definition: vtkgl.h:14370
vtkQuad * Quad
Definition: vtkPolygon.h:216
vtkTriangle * Triangle
Definition: vtkPolygon.h:215
virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts)=0
static vtkObject * New()
#define VTKCOMMONDATAMODEL_EXPORT
represent and manipulate 3D points
Definition: vtkPoints.h:39
GLfloat GLfloat p
Definition: vtkgl.h:15717
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69