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 "vtkCell.h"
34 
35 class vtkDoubleArray;
36 class vtkIdTypeArray;
37 class vtkLine;
38 class vtkPoints;
39 class vtkQuad;
40 class vtkTriangle;
41 class vtkIncrementalPointLocator;
42 
44 {
45 public:
46  static vtkPolygon *New();
47  vtkTypeMacro(vtkPolygon,vtkCell);
48  void PrintSelf(ostream& os, vtkIndent indent);
49 
51 
52  int GetCellType() {return VTK_POLYGON;};
53  int GetCellDimension() {return 2;};
54  int GetNumberOfEdges() {return this->GetNumberOfPoints();};
55  int GetNumberOfFaces() {return 0;};
56  vtkCell *GetEdge(int edgeId);
57  vtkCell *GetFace(int) {return 0;};
58  int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
59  void Contour(double value, vtkDataArray *cellScalars,
60  vtkIncrementalPointLocator *locator,vtkCellArray *verts,
61  vtkCellArray *lines, vtkCellArray *polys,
62  vtkPointData *inPd, vtkPointData *outPd,
63  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
64  void Clip(double value, vtkDataArray *cellScalars,
65  vtkIncrementalPointLocator *locator, vtkCellArray *tris,
66  vtkPointData *inPd, vtkPointData *outPd,
67  vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
68  int insideOut);
69  int EvaluatePosition(double x[3], double* closestPoint,
70  int& subId, double pcoords[3],
71  double& dist2, double *weights);
72  void EvaluateLocation(int& subId, double pcoords[3], double x[3],
73  double *weights);
74  int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
75  double x[3], double pcoords[3], int& subId);
76  int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
77  void Derivatives(int subId, double pcoords[3], double *values,
78  int dim, double *derivs);
79  int IsPrimaryCell() {return 0;}
81 
86  double ComputeArea();
87 
89 
95  virtual void InterpolateFunctions(double x[3], double *sf);
96  virtual void InterpolateDerivs(double x[3], double *derivs);
98 
100 
101  static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
102  double n[3]);
103  static void ComputeNormal(vtkPoints *p, double n[3]);
104  static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
106 
110  static void ComputeNormal(int numPts, double *pts, double n[3]);
111 
113 
114  static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
115  double centroid[3]);
117 
121  VTK_LEGACY(void ComputeWeights(double x[3], double *weights));
122 
124 
129  static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
130  double normal[3]);
132 
134 
139  int ParameterizePolygon(double p0[3], double p10[3], double &l10,
140  double p20[3], double &l20, double n[3]);
142 
144 
148  static int PointInPolygon(double x[3], int numPts, double *pts,
149  double bounds[6], double n[3]);
151 
156  int Triangulate(vtkIdList *outTris);
157 
160  int NonDegenerateTriangulate(vtkIdList *outTris);
161 
163 
166  static double DistanceToPolygon(double x[3], int numPts, double *pts,
167  double bounds[6], double closest[3]);
169 
171 
177  static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
178  int npts2, double *pts2,
179  double bounds2[3], double tol,
180  double x[3]);
182 
184 
193  static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
194  double tol, double p0[3], double p1[3]);
196 
198 
203  vtkGetMacro(UseMVCInterpolation, bool);
204  vtkSetMacro(UseMVCInterpolation, bool);
206 
207 protected:
208  vtkPolygon();
209  ~vtkPolygon();
210 
211  // Compute the interpolation functions using Mean Value Coordinate.
212  void InterpolateFunctionsUsingMVC(double x[3], double *weights);
213 
214  // variables used by instances of this class
215  double Tolerance; // Intersection tolerance
216  int SuccessfulTriangulation; // Stops recursive tri. if necessary
217  double Normal[3]; //polygon normal
223 
224  // Parameter indicating whether to use Mean Value Coordinate algorithm
225  // for interpolation. The parameter is false by default.
227 
228  // Helper methods for triangulation------------------------------
233  int EarCutTriangulation();
234 
235 private:
236  vtkPolygon(const vtkPolygon&); // Not implemented.
237  void operator=(const vtkPolygon&); // Not implemented.
238 };
239 
240 #endif
241 
vtkCell * GetFace(int)
Definition: vtkPolygon.h:57
vtkIdType GetNumberOfPoints()
Definition: vtkCell.h:113
represent and manipulate point attribute data
Definition: vtkPointData.h:35
int IsPrimaryCell()
Definition: vtkPolygon.h:79
void PrintSelf(ostream &os, vtkIndent indent)
#define VTK_FILTERING_EXPORT
double Tolerance
Definition: vtkPolygon.h:215
int GetNumberOfEdges()
Definition: vtkPolygon.h:54
represent and manipulate cell attribute data
Definition: vtkCellData.h:36
virtual int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)=0
virtual void InterpolateFunctions(double pcoords[3], double weights[3])
Definition: vtkCell.h:297
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:39
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:255
dynamic, self-adjusting array of double
cell represents a 1D line
Definition: vtkLine.h:33
abstract class to specify cell behavior
Definition: vtkCell.h:57
vtkDoubleArray * TriScalars
Definition: vtkPolygon.h:221
a simple class to control print indentation
Definition: vtkIndent.h:37
int GetNumberOfFaces()
Definition: vtkPolygon.h:55
list of point or cell ids
Definition: vtkIdList.h:34
int SuccessfulTriangulation
Definition: vtkPolygon.h:216
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:43
bool UseMVCInterpolation
Definition: vtkPolygon.h:226
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:48
virtual vtkCell * GetEdge(int edgeId)=0
vtkLine * Line
Definition: vtkPolygon.h:222
int GetCellType()
Definition: vtkPolygon.h:52
a cell that represents a triangle
Definition: vtkTriangle.h:39
vtkIdList * Tris
Definition: vtkPolygon.h:218
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:302
int GetCellDimension()
Definition: vtkPolygon.h:53
vtkQuad * Quad
Definition: vtkPolygon.h:220
vtkTriangle * Triangle
Definition: vtkPolygon.h:219
virtual int CellBoundary(int subId, double pcoords[3], vtkIdList *pts)=0
static vtkObject * New()
represent and manipulate 3D points
Definition: vtkPoints.h:38