VTK
vtkQuadricClustering.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQuadricClustering.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
87 #ifndef __vtkQuadricClustering_h
88 #define __vtkQuadricClustering_h
89 
90 #include "vtkPolyDataAlgorithm.h"
91 
92 class vtkCellArray;
93 class vtkFeatureEdges;
94 class vtkPoints;
95 class vtkQuadricClusteringCellSet;
96 
97 
99 {
100 public:
102 
104  void PrintSelf(ostream& os, vtkIndent indent);
105  static vtkQuadricClustering *New();
107 
109 
114  void SetNumberOfXDivisions(int num);
115  void SetNumberOfYDivisions(int num);
116  void SetNumberOfZDivisions(int num);
117  vtkGetMacro(NumberOfXDivisions, int);
118  vtkGetMacro(NumberOfYDivisions, int);
119  vtkGetMacro(NumberOfZDivisions, int);
120  void SetNumberOfDivisions(int div[3])
121  { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
122  void SetNumberOfDivisions(int div0, int div1, int div2);
123  int *GetNumberOfDivisions();
124  void GetNumberOfDivisions(int div[3]);
126 
128 
131  vtkSetMacro(AutoAdjustNumberOfDivisions,int);
132  vtkGetMacro(AutoAdjustNumberOfDivisions,int);
133  vtkBooleanMacro(AutoAdjustNumberOfDivisions,int);
135 
137 
141  void SetDivisionOrigin(double x, double y, double z);
142  void SetDivisionOrigin(double o[3])
143  {this->SetDivisionOrigin(o[0],o[1],o[2]);}
144  vtkGetVector3Macro(DivisionOrigin, double);
145  void SetDivisionSpacing(double x, double y, double z);
146  void SetDivisionSpacing(double s[3])
147  {this->SetDivisionSpacing(s[0],s[1],s[2]);}
148  vtkGetVector3Macro(DivisionSpacing, double);
150 
152 
158  vtkSetMacro(UseInputPoints, int);
159  vtkGetMacro(UseInputPoints, int);
160  vtkBooleanMacro(UseInputPoints, int);
162 
164 
168  vtkSetMacro(UseFeatureEdges, int);
169  vtkGetMacro(UseFeatureEdges, int);
170  vtkBooleanMacro(UseFeatureEdges, int);
171  vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;}
173 
175 
180  vtkSetMacro(UseFeaturePoints, int);
181  vtkGetMacro(UseFeaturePoints, int);
182  vtkBooleanMacro(UseFeaturePoints, int);
184 
186 
188  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
189  vtkGetMacro(FeaturePointsAngle, double);
191 
193 
197  vtkSetMacro(UseInternalTriangles, int);
198  vtkGetMacro(UseInternalTriangles, int);
199  vtkBooleanMacro(UseInternalTriangles, int);
201 
203 
207  void StartAppend(double *bounds);
208  void StartAppend(double x0,double x1,double y0,double y1,double z0,double z1)
209  {double b[6]; b[0]=x0; b[1]=x1; b[2]=y0; b[3]=y1; b[4]=z0; b[5]=z1;
210  this->StartAppend(b);}
211  void Append(vtkPolyData *piece);
212  void EndAppend();
214 
216 
220  vtkSetMacro(CopyCellData, int);
221  vtkGetMacro(CopyCellData, int);
222  vtkBooleanMacro(CopyCellData, int);
224 
226 
230  vtkSetMacro(PreventDuplicateCells,int);
231  vtkGetMacro(PreventDuplicateCells,int);
232  vtkBooleanMacro(PreventDuplicateCells,int);
234 
235 protected:
238 
241 
243  vtkIdType HashPoint(double point[3]);
244 
246 
247  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId,
248  double point[3]);
250 
252 
254  void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag,
255  vtkPolyData *input, vtkPolyData *output);
256  void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag,
257  vtkPolyData *input, vtkPolyData *output);
258  void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2,
259  int geometeryFlag, vtkPolyData *input, vtkPolyData *output);
261 
263 
265  void AddEdges(vtkCellArray *edges, vtkPoints *points,
266  int geometryFlag,
267  vtkPolyData *input, vtkPolyData *output);
268  void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag,
269  vtkPolyData *input, vtkPolyData *output);
271 
273 
275  void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag,
276  vtkPolyData *input, vtkPolyData *output);
277  void AddVertex(vtkIdType binId, double *pt, int geometryFlag,
278  vtkPolyData *input, vtkPolyData *output);
280 
282  void InitializeQuadric(double quadric[9]);
283 
285  void AddQuadric(vtkIdType binId, double quadric[9]);
286 
291  void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle);
292 
294 
296  void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output);
299 
302  void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output);
303 
304  // Unfinished option to handle boundary edges differently.
305  void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output);
309 
313 
314  // Set this to eliminate duplicate cells
316  vtkQuadricClusteringCellSet *CellSet; //PIMPLd stl set for tracking inserted cells
318 
319  // Used internally.
320  // can be smaller than user values when input numb er of points is small.
321  int NumberOfDivisions[3];
322 
323  // Since there are two was of specifing the grid, we have this flag
324  // to indicate which the user has set. When this flag is on,
325  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
327 
328  double DivisionOrigin[3];
329  double DivisionSpacing[3];
331 
332  double Bounds[6];
333  double XBinSize;
334  double YBinSize;
335  double ZBinSize;
336  double XBinStep; //replace some divisions with multiplication
337  double YBinStep;
338  double ZBinStep;
339  vtkIdType SliceSize; //eliminate one multiplication
340 
341  //BTX
342  struct PointQuadric
343  {
344  PointQuadric():VertexId(-1),Dimension(255) {}
345 
347  // Dimension is supposed to be a flag representing the dimension of the
348  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
349  // 0 in the future?)
350  unsigned char Dimension;
351  double Quadric[9];
352  };
353  //ETX
354 
357 
358  // Have to make these instance variables if we are going to allow
359  // the algorithm to be driven by the Append methods.
362 
366 
370 
371 private:
372  vtkQuadricClustering(const vtkQuadricClustering&); // Not implemented.
373  void operator=(const vtkQuadricClustering&); // Not implemented.
374 };
375 
376 #endif