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
00091 virtual void InterpolateFunctions(double pcoords[3], double *sf);
00092 virtual void InterpolateDerivs(double pcoords[3], double *derivs);
00094
00096
00097 static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
00098 double n[3]);
00099 static void ComputeNormal(vtkPoints *p, double n[3]);
00100 static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
00102
00106 static void ComputeNormal(int numPts, double *pts, double n[3]);
00107
00109
00110 static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
00111 double centroid[3]);
00113
00117 VTK_LEGACY(void ComputeWeights(double x[3], double *weights));
00118
00120
00125 static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
00126 double normal[3]);
00128
00130
00135 int ParameterizePolygon(double p0[3], double p10[3], double &l10,
00136 double p20[3], double &l20, double n[3]);
00138
00140
00144 static int PointInPolygon(double x[3], int numPts, double *pts,
00145 double bounds[6], double n[3]);
00147
00152 int Triangulate(vtkIdList *outTris);
00153
00156 int NonDegenerateTriangulate(vtkIdList *outTris);
00157
00159
00162 static double DistanceToPolygon(double x[3], int numPts, double *pts,
00163 double bounds[6], double closest[3]);
00165
00167
00173 static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
00174 int npts2, double *pts2,
00175 double bounds2[3], double tol,
00176 double x[3]);
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
00190 double tol, double p0[3], double p1[3]);
00191
00192 protected:
00193 vtkPolygon();
00194 ~vtkPolygon();
00195
00196
00197 double Tolerance;
00198 int SuccessfulTriangulation;
00199 double Normal[3];
00200 vtkIdList *Tris;
00201 vtkTriangle *Triangle;
00202 vtkQuad *Quad;
00203 vtkDoubleArray *TriScalars;
00204 vtkLine *Line;
00205
00206
00211 int EarCutTriangulation();
00212
00213 private:
00214 vtkPolygon(const vtkPolygon&);
00215 void operator=(const vtkPolygon&);
00216 };
00217
00218 #endif
00219