VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPolygon.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00030 #ifndef __vtkPolygon_h 00031 #define __vtkPolygon_h 00032 00033 #include "vtkCommonDataModelModule.h" // For export macro 00034 #include "vtkCell.h" 00035 00036 class vtkDoubleArray; 00037 class vtkIdTypeArray; 00038 class vtkLine; 00039 class vtkPoints; 00040 class vtkQuad; 00041 class vtkTriangle; 00042 class vtkIncrementalPointLocator; 00043 00044 class VTKCOMMONDATAMODEL_EXPORT vtkPolygon : public vtkCell 00045 { 00046 public: 00047 static vtkPolygon *New(); 00048 vtkTypeMacro(vtkPolygon,vtkCell); 00049 void PrintSelf(ostream& os, vtkIndent indent); 00050 00052 00053 int GetCellType() {return VTK_POLYGON;}; 00054 int GetCellDimension() {return 2;}; 00055 int GetNumberOfEdges() {return this->GetNumberOfPoints();}; 00056 int GetNumberOfFaces() {return 0;}; 00057 vtkCell *GetEdge(int edgeId); 00058 vtkCell *GetFace(int) {return 0;}; 00059 int CellBoundary(int subId, double pcoords[3], vtkIdList *pts); 00060 void Contour(double value, vtkDataArray *cellScalars, 00061 vtkIncrementalPointLocator *locator,vtkCellArray *verts, 00062 vtkCellArray *lines, vtkCellArray *polys, 00063 vtkPointData *inPd, vtkPointData *outPd, 00064 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd); 00065 void Clip(double value, vtkDataArray *cellScalars, 00066 vtkIncrementalPointLocator *locator, vtkCellArray *tris, 00067 vtkPointData *inPd, vtkPointData *outPd, 00068 vtkCellData *inCd, vtkIdType cellId, vtkCellData *outCd, 00069 int insideOut); 00070 int EvaluatePosition(double x[3], double* closestPoint, 00071 int& subId, double pcoords[3], 00072 double& dist2, double *weights); 00073 void EvaluateLocation(int& subId, double pcoords[3], double x[3], 00074 double *weights); 00075 int IntersectWithLine(double p1[3], double p2[3], double tol, double& t, 00076 double x[3], double pcoords[3], int& subId); 00077 int Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts); 00078 void Derivatives(int subId, double pcoords[3], double *values, 00079 int dim, double *derivs); 00080 int IsPrimaryCell() {return 0;} 00082 00087 double ComputeArea(); 00088 00090 00096 virtual void InterpolateFunctions(double x[3], double *sf); 00097 virtual void InterpolateDerivs(double x[3], double *derivs); 00099 00101 00102 static void ComputeNormal(vtkPoints *p, int numPts, vtkIdType *pts, 00103 double n[3]); 00104 static void ComputeNormal(vtkPoints *p, double n[3]); 00105 static void ComputeNormal(vtkIdTypeArray *ids, vtkPoints *pts, double n[3]); 00107 00111 static void ComputeNormal(int numPts, double *pts, double n[3]); 00112 00114 00115 static void ComputeCentroid(vtkIdTypeArray *ids, vtkPoints *pts, 00116 double centroid[3]); 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 00180 00189 static int IntersectConvex2DCells(vtkCell *cell1, vtkCell *cell2, 00190 double tol, double p0[3], double p1[3]); 00192 00194 00199 vtkGetMacro(UseMVCInterpolation, bool); 00200 vtkSetMacro(UseMVCInterpolation, bool); 00202 00203 protected: 00204 vtkPolygon(); 00205 ~vtkPolygon(); 00206 00207 // Compute the interpolation functions using Mean Value Coordinate. 00208 void InterpolateFunctionsUsingMVC(double x[3], double *weights); 00209 00210 // variables used by instances of this class 00211 double Tolerance; // Intersection tolerance 00212 int SuccessfulTriangulation; // Stops recursive tri. if necessary 00213 double Normal[3]; //polygon normal 00214 vtkIdList *Tris; 00215 vtkTriangle *Triangle; 00216 vtkQuad *Quad; 00217 vtkDoubleArray *TriScalars; 00218 vtkLine *Line; 00219 00220 // Parameter indicating whether to use Mean Value Coordinate algorithm 00221 // for interpolation. The parameter is false by default. 00222 bool UseMVCInterpolation; 00223 00224 // Helper methods for triangulation------------------------------ 00229 int EarCutTriangulation(); 00230 00231 private: 00232 vtkPolygon(const vtkPolygon&); // Not implemented. 00233 void operator=(const vtkPolygon&); // Not implemented. 00234 }; 00235 00236 #endif 00237