VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkQuadricClustering.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 =========================================================================*/ 00087 #ifndef __vtkQuadricClustering_h 00088 #define __vtkQuadricClustering_h 00089 00090 #include "vtkPolyDataAlgorithm.h" 00091 00092 class vtkCellArray; 00093 class vtkFeatureEdges; 00094 class vtkPoints; 00095 class vtkQuadricClusteringCellSet; 00096 00097 00098 class VTK_GRAPHICS_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm 00099 { 00100 public: 00102 00103 vtkTypeMacro(vtkQuadricClustering, vtkPolyDataAlgorithm); 00104 void PrintSelf(ostream& os, vtkIndent indent); 00105 static vtkQuadricClustering *New(); 00107 00109 00114 void SetNumberOfXDivisions(int num); 00115 void SetNumberOfYDivisions(int num); 00116 void SetNumberOfZDivisions(int num); 00117 vtkGetMacro(NumberOfXDivisions, int); 00118 vtkGetMacro(NumberOfYDivisions, int); 00119 vtkGetMacro(NumberOfZDivisions, int); 00120 void SetNumberOfDivisions(int div[3]) 00121 { this->SetNumberOfDivisions(div[0], div[1], div[2]); } 00122 void SetNumberOfDivisions(int div0, int div1, int div2); 00123 int *GetNumberOfDivisions(); 00124 void GetNumberOfDivisions(int div[3]); 00126 00128 00131 vtkSetMacro(AutoAdjustNumberOfDivisions,int); 00132 vtkGetMacro(AutoAdjustNumberOfDivisions,int); 00133 vtkBooleanMacro(AutoAdjustNumberOfDivisions,int); 00135 00137 00141 void SetDivisionOrigin(double x, double y, double z); 00142 void SetDivisionOrigin(double o[3]) 00143 {this->SetDivisionOrigin(o[0],o[1],o[2]);} 00144 vtkGetVector3Macro(DivisionOrigin, double); 00145 void SetDivisionSpacing(double x, double y, double z); 00146 void SetDivisionSpacing(double s[3]) 00147 {this->SetDivisionSpacing(s[0],s[1],s[2]);} 00148 vtkGetVector3Macro(DivisionSpacing, double); 00150 00152 00158 vtkSetMacro(UseInputPoints, int); 00159 vtkGetMacro(UseInputPoints, int); 00160 vtkBooleanMacro(UseInputPoints, int); 00162 00164 00168 vtkSetMacro(UseFeatureEdges, int); 00169 vtkGetMacro(UseFeatureEdges, int); 00170 vtkBooleanMacro(UseFeatureEdges, int); 00171 vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;} 00173 00175 00180 vtkSetMacro(UseFeaturePoints, int); 00181 vtkGetMacro(UseFeaturePoints, int); 00182 vtkBooleanMacro(UseFeaturePoints, int); 00184 00186 00188 vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0); 00189 vtkGetMacro(FeaturePointsAngle, double); 00191 00193 00197 vtkSetMacro(UseInternalTriangles, int); 00198 vtkGetMacro(UseInternalTriangles, int); 00199 vtkBooleanMacro(UseInternalTriangles, int); 00201 00203 00207 void StartAppend(double *bounds); 00208 void StartAppend(double x0,double x1,double y0,double y1,double z0,double z1) 00209 {double b[6]; b[0]=x0; b[1]=x1; b[2]=y0; b[3]=y1; b[4]=z0; b[5]=z1; 00210 this->StartAppend(b);} 00211 void Append(vtkPolyData *piece); 00212 void EndAppend(); 00214 00216 00220 vtkSetMacro(CopyCellData, int); 00221 vtkGetMacro(CopyCellData, int); 00222 vtkBooleanMacro(CopyCellData, int); 00224 00226 00230 vtkSetMacro(PreventDuplicateCells,int); 00231 vtkGetMacro(PreventDuplicateCells,int); 00232 vtkBooleanMacro(PreventDuplicateCells,int); 00234 00235 protected: 00236 vtkQuadricClustering(); 00237 ~vtkQuadricClustering(); 00238 00239 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00240 int FillInputPortInformation(int, vtkInformation *); 00241 00243 vtkIdType HashPoint(double point[3]); 00244 00246 00247 void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, 00248 double point[3]); 00250 00252 00254 void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag, 00255 vtkPolyData *input, vtkPolyData *output); 00256 void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag, 00257 vtkPolyData *input, vtkPolyData *output); 00258 void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2, 00259 int geometeryFlag, vtkPolyData *input, vtkPolyData *output); 00261 00263 00265 void AddEdges(vtkCellArray *edges, vtkPoints *points, 00266 int geometryFlag, 00267 vtkPolyData *input, vtkPolyData *output); 00268 void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag, 00269 vtkPolyData *input, vtkPolyData *output); 00271 00273 00275 void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag, 00276 vtkPolyData *input, vtkPolyData *output); 00277 void AddVertex(vtkIdType binId, double *pt, int geometryFlag, 00278 vtkPolyData *input, vtkPolyData *output); 00280 00282 void InitializeQuadric(double quadric[9]); 00283 00285 void AddQuadric(vtkIdType binId, double quadric[9]); 00286 00291 void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle); 00292 00294 00296 void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output); 00297 int UseInputPoints; 00299 00302 void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output); 00303 00304 // Unfinished option to handle boundary edges differently. 00305 void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output); 00306 int UseFeatureEdges; 00307 int UseFeaturePoints; 00308 int UseInternalTriangles; 00309 00310 int NumberOfXDivisions; 00311 int NumberOfYDivisions; 00312 int NumberOfZDivisions; 00313 00314 // Set this to eliminate duplicate cells 00315 int PreventDuplicateCells; 00316 vtkQuadricClusteringCellSet *CellSet; //PIMPLd stl set for tracking inserted cells 00317 vtkIdType NumberOfBins; 00318 00319 // Used internally. 00320 // can be smaller than user values when input numb er of points is small. 00321 int NumberOfDivisions[3]; 00322 00323 // Since there are two was of specifing the grid, we have this flag 00324 // to indicate which the user has set. When this flag is on, 00325 // the bin sizes are computed from the DivisionOrigin and DivisionSpacing. 00326 int ComputeNumberOfDivisions; 00327 00328 double DivisionOrigin[3]; 00329 double DivisionSpacing[3]; 00330 int AutoAdjustNumberOfDivisions; 00331 00332 double Bounds[6]; 00333 double XBinSize; 00334 double YBinSize; 00335 double ZBinSize; 00336 double XBinStep; //replace some divisions with multiplication 00337 double YBinStep; 00338 double ZBinStep; 00339 vtkIdType SliceSize; //eliminate one multiplication 00340 00341 //BTX 00342 struct PointQuadric 00343 { 00344 PointQuadric():VertexId(-1),Dimension(255) {} 00345 00346 vtkIdType VertexId; 00347 // Dimension is supposed to be a flag representing the dimension of the 00348 // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points 00349 // 0 in the future?) 00350 unsigned char Dimension; 00351 double Quadric[9]; 00352 }; 00353 //ETX 00354 00355 PointQuadric* QuadricArray; 00356 vtkIdType NumberOfBinsUsed; 00357 00358 // Have to make these instance variables if we are going to allow 00359 // the algorithm to be driven by the Append methods. 00360 vtkCellArray *OutputTriangleArray; 00361 vtkCellArray *OutputLines; 00362 00363 vtkFeatureEdges *FeatureEdges; 00364 vtkPoints *FeaturePoints; 00365 double FeaturePointsAngle; 00366 00367 int CopyCellData; 00368 int InCellCount; 00369 int OutCellCount; 00370 00371 private: 00372 vtkQuadricClustering(const vtkQuadricClustering&); // Not implemented. 00373 void operator=(const vtkQuadricClustering&); // Not implemented. 00374 }; 00375 00376 #endif