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 "vtkFiltersCoreModule.h" // For export macro 00091 #include "vtkPolyDataAlgorithm.h" 00092 00093 class vtkCellArray; 00094 class vtkFeatureEdges; 00095 class vtkPoints; 00096 class vtkQuadricClusteringCellSet; 00097 00098 00099 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm 00100 { 00101 public: 00103 00104 vtkTypeMacro(vtkQuadricClustering, vtkPolyDataAlgorithm); 00105 void PrintSelf(ostream& os, vtkIndent indent); 00106 static vtkQuadricClustering *New(); 00108 00110 00115 void SetNumberOfXDivisions(int num); 00116 void SetNumberOfYDivisions(int num); 00117 void SetNumberOfZDivisions(int num); 00118 vtkGetMacro(NumberOfXDivisions, int); 00119 vtkGetMacro(NumberOfYDivisions, int); 00120 vtkGetMacro(NumberOfZDivisions, int); 00121 void SetNumberOfDivisions(int div[3]) 00122 { this->SetNumberOfDivisions(div[0], div[1], div[2]); } 00123 void SetNumberOfDivisions(int div0, int div1, int div2); 00124 int *GetNumberOfDivisions(); 00125 void GetNumberOfDivisions(int div[3]); 00127 00129 00132 vtkSetMacro(AutoAdjustNumberOfDivisions,int); 00133 vtkGetMacro(AutoAdjustNumberOfDivisions,int); 00134 vtkBooleanMacro(AutoAdjustNumberOfDivisions,int); 00136 00138 00142 void SetDivisionOrigin(double x, double y, double z); 00143 void SetDivisionOrigin(double o[3]) 00144 {this->SetDivisionOrigin(o[0],o[1],o[2]);} 00145 vtkGetVector3Macro(DivisionOrigin, double); 00146 void SetDivisionSpacing(double x, double y, double z); 00147 void SetDivisionSpacing(double s[3]) 00148 {this->SetDivisionSpacing(s[0],s[1],s[2]);} 00149 vtkGetVector3Macro(DivisionSpacing, double); 00151 00153 00159 vtkSetMacro(UseInputPoints, int); 00160 vtkGetMacro(UseInputPoints, int); 00161 vtkBooleanMacro(UseInputPoints, int); 00163 00165 00169 vtkSetMacro(UseFeatureEdges, int); 00170 vtkGetMacro(UseFeatureEdges, int); 00171 vtkBooleanMacro(UseFeatureEdges, int); 00172 vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;} 00174 00176 00181 vtkSetMacro(UseFeaturePoints, int); 00182 vtkGetMacro(UseFeaturePoints, int); 00183 vtkBooleanMacro(UseFeaturePoints, int); 00185 00187 00189 vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0); 00190 vtkGetMacro(FeaturePointsAngle, double); 00192 00194 00198 vtkSetMacro(UseInternalTriangles, int); 00199 vtkGetMacro(UseInternalTriangles, int); 00200 vtkBooleanMacro(UseInternalTriangles, int); 00202 00204 00208 void StartAppend(double *bounds); 00209 void StartAppend(double x0,double x1,double y0,double y1,double z0,double z1) 00210 {double b[6]; b[0]=x0; b[1]=x1; b[2]=y0; b[3]=y1; b[4]=z0; b[5]=z1; 00211 this->StartAppend(b);} 00212 void Append(vtkPolyData *piece); 00213 void EndAppend(); 00215 00217 00221 vtkSetMacro(CopyCellData, int); 00222 vtkGetMacro(CopyCellData, int); 00223 vtkBooleanMacro(CopyCellData, int); 00225 00227 00231 vtkSetMacro(PreventDuplicateCells,int); 00232 vtkGetMacro(PreventDuplicateCells,int); 00233 vtkBooleanMacro(PreventDuplicateCells,int); 00235 00236 protected: 00237 vtkQuadricClustering(); 00238 ~vtkQuadricClustering(); 00239 00240 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00241 int FillInputPortInformation(int, vtkInformation *); 00242 00244 vtkIdType HashPoint(double point[3]); 00245 00247 00248 void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, 00249 double point[3]); 00251 00253 00255 void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag, 00256 vtkPolyData *input, vtkPolyData *output); 00257 void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag, 00258 vtkPolyData *input, vtkPolyData *output); 00259 void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2, 00260 int geometeryFlag, vtkPolyData *input, vtkPolyData *output); 00262 00264 00266 void AddEdges(vtkCellArray *edges, vtkPoints *points, 00267 int geometryFlag, 00268 vtkPolyData *input, vtkPolyData *output); 00269 void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag, 00270 vtkPolyData *input, vtkPolyData *output); 00272 00274 00276 void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag, 00277 vtkPolyData *input, vtkPolyData *output); 00278 void AddVertex(vtkIdType binId, double *pt, int geometryFlag, 00279 vtkPolyData *input, vtkPolyData *output); 00281 00283 void InitializeQuadric(double quadric[9]); 00284 00286 void AddQuadric(vtkIdType binId, double quadric[9]); 00287 00292 void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle); 00293 00295 00297 void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output); 00298 int UseInputPoints; 00300 00303 void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output); 00304 00305 // Unfinished option to handle boundary edges differently. 00306 void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output); 00307 int UseFeatureEdges; 00308 int UseFeaturePoints; 00309 int UseInternalTriangles; 00310 00311 int NumberOfXDivisions; 00312 int NumberOfYDivisions; 00313 int NumberOfZDivisions; 00314 00315 // Set this to eliminate duplicate cells 00316 int PreventDuplicateCells; 00317 vtkQuadricClusteringCellSet *CellSet; //PIMPLd stl set for tracking inserted cells 00318 vtkIdType NumberOfBins; 00319 00320 // Used internally. 00321 // can be smaller than user values when input numb er of points is small. 00322 int NumberOfDivisions[3]; 00323 00324 // Since there are two was of specifing the grid, we have this flag 00325 // to indicate which the user has set. When this flag is on, 00326 // the bin sizes are computed from the DivisionOrigin and DivisionSpacing. 00327 int ComputeNumberOfDivisions; 00328 00329 double DivisionOrigin[3]; 00330 double DivisionSpacing[3]; 00331 int AutoAdjustNumberOfDivisions; 00332 00333 double Bounds[6]; 00334 double XBinSize; 00335 double YBinSize; 00336 double ZBinSize; 00337 double XBinStep; //replace some divisions with multiplication 00338 double YBinStep; 00339 double ZBinStep; 00340 vtkIdType SliceSize; //eliminate one multiplication 00341 00342 //BTX 00343 struct PointQuadric 00344 { 00345 PointQuadric():VertexId(-1),Dimension(255) {} 00346 00347 vtkIdType VertexId; 00348 // Dimension is supposed to be a flag representing the dimension of the 00349 // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points 00350 // 0 in the future?) 00351 unsigned char Dimension; 00352 double Quadric[9]; 00353 }; 00354 //ETX 00355 00356 PointQuadric* QuadricArray; 00357 vtkIdType NumberOfBinsUsed; 00358 00359 // Have to make these instance variables if we are going to allow 00360 // the algorithm to be driven by the Append methods. 00361 vtkCellArray *OutputTriangleArray; 00362 vtkCellArray *OutputLines; 00363 00364 vtkFeatureEdges *FeatureEdges; 00365 vtkPoints *FeaturePoints; 00366 double FeaturePointsAngle; 00367 00368 int CopyCellData; 00369 int InCellCount; 00370 int OutCellCount; 00371 00372 private: 00373 vtkQuadricClustering(const vtkQuadricClustering&); // Not implemented. 00374 void operator=(const vtkQuadricClustering&); // Not implemented. 00375 }; 00376 00377 #endif