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();
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,
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 
95  virtual void InterpolateFunctions(double x[3], double *sf);
96 
98 
99  static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
100  double n[3]);
101  static void ComputeNormal(vtkPoints *p, double n[3]);
102  static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
104 
108  static void ComputeNormal(int numPts, double *pts, double n[3]);
109 
111 
112  static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
113  double centroid[3]);
115 
117 
122  static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
123  double normal[3]);
125 
127 
132  int ParameterizePolygon(double p0[3], double p10[3], double &l10,
133  double p20[3], double &l20, double n[3]);
135 
137 
141  static int PointInPolygon(double x[3], int numPts, double *pts,
142  double bounds[6], double n[3]);
144 
149  int Triangulate(vtkIdList *outTris);
150 
153  int NonDegenerateTriangulate(vtkIdList *outTris);
154 
156 
159  static double DistanceToPolygon(double x[3], int numPts, double *pts,
160  double bounds[6], double closest[3]);
162 
164 
170  static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
171  int npts2, double *pts2,
172  double bounds2[3], double tol,
173  double x[3]);
175 
177 
186  static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
187  double tol, double p0[3], double p1[3]);
189 
191 
196  vtkGetMacro(UseMVCInterpolation, bool);
197  vtkSetMacro(UseMVCInterpolation, bool);
199 
200 protected:
201  vtkPolygon();
202  ~vtkPolygon();
203 
204  // Compute the interpolation functions using Mean Value Coordinate.
205  void InterpolateFunctionsUsingMVC(double x[3], double *weights);
206 
207  // variables used by instances of this class
208  double Tolerance; // Intersection tolerance
209  int SuccessfulTriangulation; // Stops recursive tri. if necessary
210  double Normal[3]; //polygon normal
216 
217  // Parameter indicating whether to use Mean Value Coordinate algorithm
218  // for interpolation. The parameter is false by default.
220 
221  // Helper methods for triangulation------------------------------
226  int EarCutTriangulation();
227 
228 private:
229  vtkPolygon(const vtkPolygon&); // Not implemented.
230  void operator=(const vtkPolygon&); // Not implemented.
231 };
232 
233 #endif
vtkCell * GetFace(int)
Definition: vtkPolygon.h:58
vtkIdType GetNumberOfPoints()
Definition: vtkCell.h:117
represent and manipulate point attribute data
Definition: vtkPointData.h:36
int IsPrimaryCell()
Definition: vtkPolygon.h:80
void PrintSelf(ostream &os, vtkIndent indent)
virtual void InterpolateFunctions(double vtkNotUsed(pcoords)[3], double *vtkNotUsed(weight))
Definition: vtkCell.h:306
double Tolerance
Definition: vtkPolygon.h:208
int GetNumberOfEdges()
Definition: vtkPolygon.h:55
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 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
int vtkIdType
Definition: vtkType.h:275
dynamic, self-adjusting array of double
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:61
vtkDoubleArray * TriScalars
Definition: vtkPolygon.h:214
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:209
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:54
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:219
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:215
int GetCellType()
Definition: vtkPolygon.h:53
a cell that represents a triangle
Definition: vtkTriangle.h:40
vtkIdList * Tris
Definition: vtkPolygon.h:211
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
int GetCellDimension()
Definition: vtkPolygon.h:54
vtkQuad * Quad
Definition: vtkPolygon.h:213
vtkTriangle * Triangle
Definition: vtkPolygon.h:212
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:38