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
00042 class VTK_FILTERING_EXPORT vtkPolygon : public vtkCell
00043 {
00044 public:
00045 static vtkPolygon *New();
00046 vtkTypeRevisionMacro(vtkPolygon,vtkCell);
00047 void PrintSelf(ostream& os, vtkIndent indent);
00048
00050
00051 int GetCellType() {return VTK_POLYGON;};
00052 int GetCellDimension() {return 2;};
00053 int GetNumberOfEdges() {return this->GetNumberOfPoints();};
00054 int GetNumberOfFaces() {return 0;};
00055 vtkCell *GetEdge(int edgeId);
00056 vtkCell *GetFace(int) {return 0;};
00057 int CellBoundary(int subId, double pcoords[3], vtkIdList *pts);
00058 void Contour(double value, vtkDataArray *cellScalars,
00059 vtkPointLocator *locator,vtkCellArray *verts,
00060 vtkCellArray *lines, vtkCellArray *polys,
00061 vtkPointData *inPd, vtkPointData *outPd,
00062 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd);
00063 void Clip(double value, vtkDataArray *cellScalars,
00064 vtkPointLocator *locator, vtkCellArray *tris,
00065 vtkPointData *inPd, vtkPointData *outPd,
00066 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd,
00067 int insideOut);
00068 int EvaluatePosition(double x[3], double* closestPoint,
00069 int& subId, double pcoords[3],
00070 double& dist2, double *weights);
00071 void EvaluateLocation(int& subId, double pcoords[3], double x[3],
00072 double *weights);
00073 int IntersectWithLine(double p1[3], double p2[3], double tol, double& t,
00074 double x[3], double pcoords[3], int& subId);
00075 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts);
00076 void Derivatives(int subId, double pcoords[3], double *values,
00077 int dim, double *derivs);
00078 int IsPrimaryCell() {return 0;}
00080
00082
00084 virtual void InterpolateFunctions(double pcoords[3], double *sf);
00085 virtual void InterpolateDerivs(double pcoords[3], double *derivs);
00087
00089
00090 static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts,
00091 double n[3]);
00092 static void ComputeNormal(vtkPoints *p, double n[3]);
00093 static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]);
00095
00099 static void ComputeNormal(int numPts, double *pts, double n[3]);
00100
00102
00103 static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts,
00104 double centroid[3]);
00106
00110 VTK_LEGACY(void ComputeWeights(double x[3], double *weights));
00111
00113
00116 static double ComputeArea(vtkPoints *p, vtkIdType numPts, vtkIdType *pts,
00117 double normal[3]);
00119
00121
00126 int ParameterizePolygon(double p0[3], double p10[3], double &l10,
00127 double p20[3], double &l20, double n[3]);
00129
00131
00135 static int PointInPolygon(double x[3], int numPts, double *pts,
00136 double bounds[6], double n[3]);
00138
00143 int Triangulate(vtkIdList *outTris);
00144
00147 int NonDegenerateTriangulate(vtkIdList *outTris);
00148
00150
00153 static double DistanceToPolygon(double x[3], int numPts, double *pts,
00154 double bounds[6], double closest[3]);
00156
00158
00164 static int IntersectPolygonWithPolygon(int npts, double *pts, double bounds[6],
00165 int npts2, double *pts2,
00166 double bounds2[3], double tol,
00167 double x[3]);
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2,
00181 double tol, double p0[3], double p1[3]);
00182
00183 protected:
00184 vtkPolygon();
00185 ~vtkPolygon();
00186
00187
00188 double Tolerance;
00189 int SuccessfulTriangulation;
00190 double Normal[3];
00191 vtkIdList *Tris;
00192 vtkTriangle *Triangle;
00193 vtkQuad *Quad;
00194 vtkDoubleArray *TriScalars;
00195 vtkLine *Line;
00196
00197
00202 int EarCutTriangulation();
00203
00204 private:
00205 vtkPolygon(const vtkPolygon&);
00206 void operator=(const vtkPolygon&);
00207 };
00208
00209 #endif
00210