VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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;
42 class vtkIncrementalPointLocator;
43 
44 class VTKCOMMONDATAMODEL_EXPORT vtkPolygon : public vtkCell
45 {
46 public:
47  static vtkPolygon *New();
48  vtkTypeMacro(vtkPolygon,vtkCell);
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,
61  vtkIncrementalPointLocator *locator,vtkCellArray *verts,
62  vtkCellArray *lines, vtkCellArray *polys,
63  vtkPointData *inPd, vtkPointData *outPd,
64  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
65  void Clip(double value, vtkDataArray *cellScalars,
66  vtkIncrementalPointLocator *locator, vtkCellArray *tris,
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
215  vtkTriangle *Triangle;
216  vtkQuad *Quad;
218  vtkLine *Line;
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
int IsPrimaryCell()
Definition: vtkPolygon.h:80
double Tolerance
Definition: vtkPolygon.h:211
int GetNumberOfEdges()
Definition: vtkPolygon.h:55
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:268
dynamic, self-adjusting array of double
vtkDoubleArray * TriScalars
Definition: vtkPolygon.h:217
a simple class to control print indentation
Definition: vtkIndent.h:38
int GetNumberOfFaces()
Definition: vtkPolygon.h:56
list of point or cell ids
Definition: vtkIdList.h:35
int SuccessfulTriangulation
Definition: vtkPolygon.h:212
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:44
bool UseMVCInterpolation
Definition: vtkPolygon.h:222
vtkLine * Line
Definition: vtkPolygon.h:218
int GetCellType()
Definition: vtkPolygon.h:53
vtkIdList * Tris
Definition: vtkPolygon.h:214
int GetCellDimension()
Definition: vtkPolygon.h:54
vtkQuad * Quad
Definition: vtkPolygon.h:216
vtkTriangle * Triangle
Definition: vtkPolygon.h:215
represent and manipulate 3D points
Definition: vtkPoints.h:39