00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00027 #ifndef __vtkPolygon_h
00028 #define __vtkPolygon_h
00029
00030 #include "vtkCell.h"
00031
00032 class vtkDoubleArray;
00033 class vtkIdTypeArray;
00034 class vtkLine;
00035 class vtkPoints;
00036 class vtkQuad;
00037 class vtkTriangle;
00038 class vtkIncrementalPointLocator;
00039
00040 class VTK_FILTERING_EXPORT vtkPolygon : public vtkCell
00041 {
00042 public:
00043 static vtkPolygon *New();
00044 vtkTypeRevisionMacro(vtkPolygon,vtkCell);
00045 void PrintSelf(ostream& os, vtkIndent indent);
00046
00048
00049 int GetCellType() {return VTK_POLYGON;};
00050 int GetCellDimension() {return 2;};
00051 int GetNumberOfEdges() {return this->GetNumberOfPoints();};
00052 int GetNumberOfFaces() {return 0;};
00053 vtkCell *GetEdge(int edgeId);
00054 vtkCell *GetFace(int) {return 0;};
00055 int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
00056 void Contour(double value, vtkDataArray *cellScalars,
00057 vtkIncrementalPointLocator *locator,vtkCellArray *verts,
00058 vtkCellArray *lines, vtkCellArray *polys,
00059 vtkPointData *inPd, vtkPointData *outPd,
00060 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
00061 void Clip(double value, vtkDataArray *cellScalars,
00062 vtkIncrementalPointLocator *locator, vtkCellArray *tris,
00063 vtkPointData *inPd, vtkPointData *outPd,
00064 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
00065 int insideOut);
00066 int EvaluatePosition(double x[3], double* closestPoint,
00067 int& subId, double pcoords[3],
00068 double& dist2, double *weights);
00069 void EvaluateLocation(int& subId, double pcoords[3], double x[3],
00070 double *weights);
00071 int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
00072 double x[3], double pcoords[3], int& subId);
00073 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
00074 void Derivatives(int subId, double pcoords[3], double *values,
00075 int dim, double *derivs);
00076 int IsPrimaryCell() {return 0;}
00078
00083 double ComputeArea();
00084
00086
00088 virtual void InterpolateFunctions(double pcoords[3], double *sf);
00089 virtual void InterpolateDerivs(double pcoords[3], double *derivs);
00091
00093
00094 static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
00095 double n[3]);
00096 static void ComputeNormal(vtkPoints *p, double n[3]);
00097 static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
00099
00103 static void ComputeNormal(int numPts, double *pts, double n[3]);
00104
00106
00107 static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
00108 double centroid[3]);
00110
00114 VTK_LEGACY(void ComputeWeights(double x[3], double *weights));
00115
00117
00122 static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
00123 double normal[3]);
00125
00127
00132 int ParameterizePolygon(double p0[3], double p10[3], double &l10,
00133 double p20[3], double &l20, double n[3]);
00135
00137
00141 static int PointInPolygon(double x[3], int numPts, double *pts,
00142 double bounds[6], double n[3]);
00144
00149 int Triangulate(vtkIdList *outTris);
00150
00153 int NonDegenerateTriangulate(vtkIdList *outTris);
00154
00156
00159 static double DistanceToPolygon(double x[3], int numPts, double *pts,
00160 double bounds[6], double closest[3]);
00162
00164
00170 static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
00171 int npts2, double *pts2,
00172 double bounds2[3], double tol,
00173 double x[3]);
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
00187 double tol, double p0[3], double p1[3]);
00188
00189 protected:
00190 vtkPolygon();
00191 ~vtkPolygon();
00192
00193
00194 double Tolerance;
00195 int SuccessfulTriangulation;
00196 double Normal[3];
00197 vtkIdList *Tris;
00198 vtkTriangle *Triangle;
00199 vtkQuad *Quad;
00200 vtkDoubleArray *TriScalars;
00201 vtkLine *Line;
00202
00203
00208 int EarCutTriangulation();
00209
00210 private:
00211 vtkPolygon(const vtkPolygon&);
00212 void operator=(const vtkPolygon&);
00213 };
00214
00215 #endif
00216