VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkDelaunay2D.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 =========================================================================*/ 00130 #ifndef __vtkDelaunay2D_h 00131 #define __vtkDelaunay2D_h 00132 00133 #include "vtkFiltersCoreModule.h" // For export macro 00134 #include "vtkPolyDataAlgorithm.h" 00135 00136 class vtkAbstractTransform; 00137 class vtkCellArray; 00138 class vtkIdList; 00139 class vtkPointSet; 00140 00141 #define VTK_DELAUNAY_XY_PLANE 0 00142 #define VTK_SET_TRANSFORM_PLANE 1 00143 #define VTK_BEST_FITTING_PLANE 2 00144 00145 class VTKFILTERSCORE_EXPORT vtkDelaunay2D : public vtkPolyDataAlgorithm 00146 { 00147 public: 00148 vtkTypeMacro(vtkDelaunay2D,vtkPolyDataAlgorithm); 00149 void PrintSelf(ostream& os, vtkIndent indent); 00150 00153 static vtkDelaunay2D *New(); 00154 00161 void SetSourceData(vtkPolyData *); 00162 00169 void SetSourceConnection(vtkAlgorithmOutput *algOutput); 00170 00172 vtkPolyData *GetSource(); 00173 00175 00179 vtkSetClampMacro(Alpha,double,0.0,VTK_DOUBLE_MAX); 00180 vtkGetMacro(Alpha,double); 00182 00184 00187 vtkSetClampMacro(Tolerance,double,0.0,1.0); 00188 vtkGetMacro(Tolerance,double); 00190 00192 00194 vtkSetClampMacro(Offset,double,0.75,VTK_DOUBLE_MAX); 00195 vtkGetMacro(Offset,double); 00197 00199 00203 vtkSetMacro(BoundingTriangulation,int); 00204 vtkGetMacro(BoundingTriangulation,int); 00205 vtkBooleanMacro(BoundingTriangulation,int); 00207 00209 00217 virtual void SetTransform(vtkAbstractTransform*); 00218 vtkGetObjectMacro(Transform, vtkAbstractTransform); 00220 00222 00223 vtkSetClampMacro(ProjectionPlaneMode,int, 00224 VTK_DELAUNAY_XY_PLANE,VTK_BEST_FITTING_PLANE); 00225 vtkGetMacro(ProjectionPlaneMode,int); 00227 00228 protected: 00229 vtkDelaunay2D(); 00230 ~vtkDelaunay2D(); 00231 00232 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00233 00234 vtkAbstractTransform * ComputeBestFittingPlane(vtkPointSet *input); 00235 00236 double Alpha; 00237 double Tolerance; 00238 int BoundingTriangulation; 00239 double Offset; 00240 00241 vtkAbstractTransform *Transform; 00242 00243 int ProjectionPlaneMode; //selects the plane in 3D where the Delaunay triangulation will be computed. 00244 00245 private: 00246 vtkPolyData *Mesh; //the created mesh 00247 double *Points; //the raw points in double precision 00248 void SetPoint(vtkIdType id, double *x) 00249 {vtkIdType idx=3*id; 00250 this->Points[idx] = x[0]; 00251 this->Points[idx+1] = x[1]; 00252 this->Points[idx+2] = x[2]; 00253 } 00254 00255 void GetPoint(vtkIdType id, double x[3]) 00256 {double *ptr = this->Points + 3*id; 00257 x[0] = *ptr++; 00258 x[1] = *ptr++; 00259 x[2] = *ptr; 00260 } 00261 00262 int NumberOfDuplicatePoints; 00263 int NumberOfDegeneracies; 00264 00265 int *RecoverBoundary(vtkPolyData *source); 00266 int RecoverEdge(vtkIdType p1, vtkIdType p2); 00267 void FillPolygons(vtkCellArray *polys, int *triUse); 00268 00269 int InCircle (double x[3], double x1[3], double x2[3], double x3[3]); 00270 vtkIdType FindTriangle(double x[3], vtkIdType ptIds[3], vtkIdType tri, 00271 double tol, vtkIdType nei[3], vtkIdList *neighbors); 00272 void CheckEdge(vtkIdType ptId, double x[3], vtkIdType p1, vtkIdType p2, 00273 vtkIdType tri); 00274 00275 virtual int FillInputPortInformation(int, vtkInformation*); 00276 00277 private: 00278 vtkDelaunay2D(const vtkDelaunay2D&); // Not implemented. 00279 void operator=(const vtkDelaunay2D&); // Not implemented. 00280 }; 00281 00282 #endif