00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00030 #ifndef __vtkPolygon_h
00031 #define __vtkPolygon_h
00032
00033 #include "vtkCell.h"
00034
00035 class vtkDoubleArray;
00036 class vtkIdTypeArray;
00037 class vtkLine;
00038 class vtkPoints;
00039 class vtkQuad;
00040 class vtkTriangle;
00041 class vtkIncrementalPointLocator;
00042
00043 class VTK_FILTERING_EXPORT vtkPolygon : public vtkCell
00044 {
00045 public:
00046 static vtkPolygon *New();
00047 vtkTypeMacro(vtkPolygon,vtkCell);
00048 void PrintSelf(ostream& os, vtkIndent indent);
00049
00051
00052 int GetCellType() {return VTK_POLYGON;};
00053 int GetCellDimension() {return 2;};
00054 int GetNumberOfEdges() {return this->GetNumberOfPoints();};
00055 int GetNumberOfFaces() {return 0;};
00056 vtkCell *GetEdge(int edgeId);
00057 vtkCell *GetFace(int) {return 0;};
00058 int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
00059 void Contour(double value, vtkDataArray *cellScalars,
00060 vtkIncrementalPointLocator *locator,vtkCellArray *verts,
00061 vtkCellArray *lines, vtkCellArray *polys,
00062 vtkPointData *inPd, vtkPointData *outPd,
00063 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
00064 void Clip(double value, vtkDataArray *cellScalars,
00065 vtkIncrementalPointLocator *locator, vtkCellArray *tris,
00066 vtkPointData *inPd, vtkPointData *outPd,
00067 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
00068 int insideOut);
00069 int EvaluatePosition(double x[3], double* closestPoint,
00070 int& subId, double pcoords[3],
00071 double& dist2, double *weights);
00072 void EvaluateLocation(int& subId, double pcoords[3], double x[3],
00073 double *weights);
00074 int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
00075 double x[3], double pcoords[3], int& subId);
00076 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
00077 void Derivatives(int subId, double pcoords[3], double *values,
00078 int dim, double *derivs);
00079 int IsPrimaryCell() {return 0;}
00081
00086 double ComputeArea();
00087
00089
00095 virtual void InterpolateFunctions(double x[3], double *sf);
00096 virtual void InterpolateDerivs(double x[3], double *derivs);
00098
00100
00101 static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
00102 double n[3]);
00103 static void ComputeNormal(vtkPoints *p, double n[3]);
00104 static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
00106
00110 static void ComputeNormal(int numPts, double *pts, double n[3]);
00111
00113
00114 static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
00115 double centroid[3]);
00117
00121 VTK_LEGACY(void ComputeWeights(double x[3], double *weights));
00122
00124
00129 static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
00130 double normal[3]);
00132
00134
00139 int ParameterizePolygon(double p0[3], double p10[3], double &l10,
00140 double p20[3], double &l20, double n[3]);
00142
00144
00148 static int PointInPolygon(double x[3], int numPts, double *pts,
00149 double bounds[6], double n[3]);
00151
00156 int Triangulate(vtkIdList *outTris);
00157
00160 int NonDegenerateTriangulate(vtkIdList *outTris);
00161
00163
00166 static double DistanceToPolygon(double x[3], int numPts, double *pts,
00167 double bounds[6], double closest[3]);
00169
00171
00177 static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
00178 int npts2, double *pts2,
00179 double bounds2[3], double tol,
00180 double x[3]);
00182
00184
00193 static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
00194 double tol, double p0[3], double p1[3]);
00196
00198
00203 vtkGetMacro(UseMVCInterpolation, bool);
00204 vtkSetMacro(UseMVCInterpolation, bool);
00206
00207 protected:
00208 vtkPolygon();
00209 ~vtkPolygon();
00210
00211
00212 void InterpolateFunctionsUsingMVC(double x[3], double *weights);
00213
00214
00215 double Tolerance;
00216 int SuccessfulTriangulation;
00217 double Normal[3];
00218 vtkIdList *Tris;
00219 vtkTriangle *Triangle;
00220 vtkQuad *Quad;
00221 vtkDoubleArray *TriScalars;
00222 vtkLine *Line;
00223
00224
00225
00226 bool UseMVCInterpolation;
00227
00228
00233 int EarCutTriangulation();
00234
00235 private:
00236 vtkPolygon(const vtkPolygon&);
00237 void operator=(const vtkPolygon&);
00238 };
00239
00240 #endif
00241