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 =========================================================================*/
88 #ifndef vtkQuadricClustering_h
89 #define vtkQuadricClustering_h
90 
91 #include "vtkFiltersCoreModule.h" // For export macro
92 #include "vtkPolyDataAlgorithm.h"
93 
94 class vtkCellArray;
95 class vtkFeatureEdges;
96 class vtkPoints;
97 class vtkQuadricClusteringCellSet;
98 
99 
100 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
101 {
102 public:
104 
108  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
109  static vtkQuadricClustering *New();
111 
113 
120  void SetNumberOfXDivisions(int num);
121  void SetNumberOfYDivisions(int num);
122  void SetNumberOfZDivisions(int num);
123  vtkGetMacro(NumberOfXDivisions, int);
124  vtkGetMacro(NumberOfYDivisions, int);
125  vtkGetMacro(NumberOfZDivisions, int);
126  void SetNumberOfDivisions(int div[3])
127  { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
128  void SetNumberOfDivisions(int div0, int div1, int div2);
129  int *GetNumberOfDivisions();
130  void GetNumberOfDivisions(int div[3]);
132 
134 
139  vtkSetMacro(AutoAdjustNumberOfDivisions,int);
140  vtkGetMacro(AutoAdjustNumberOfDivisions,int);
141  vtkBooleanMacro(AutoAdjustNumberOfDivisions,int);
143 
145 
151  void SetDivisionOrigin(double x, double y, double z);
152  void SetDivisionOrigin(double o[3])
153  {this->SetDivisionOrigin(o[0],o[1],o[2]);}
154  vtkGetVector3Macro(DivisionOrigin, double);
155  void SetDivisionSpacing(double x, double y, double z);
156  void SetDivisionSpacing(double s[3])
157  {this->SetDivisionSpacing(s[0],s[1],s[2]);}
158  vtkGetVector3Macro(DivisionSpacing, double);
160 
162 
170  vtkSetMacro(UseInputPoints, int);
171  vtkGetMacro(UseInputPoints, int);
172  vtkBooleanMacro(UseInputPoints, int);
174 
176 
182  vtkSetMacro(UseFeatureEdges, int);
183  vtkGetMacro(UseFeatureEdges, int);
184  vtkBooleanMacro(UseFeatureEdges, int);
185  vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;}
187 
189 
196  vtkSetMacro(UseFeaturePoints, int);
197  vtkGetMacro(UseFeaturePoints, int);
198  vtkBooleanMacro(UseFeaturePoints, int);
200 
202 
206  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
207  vtkGetMacro(FeaturePointsAngle, double);
209 
211 
217  vtkSetMacro(UseInternalTriangles, int);
218  vtkGetMacro(UseInternalTriangles, int);
219  vtkBooleanMacro(UseInternalTriangles, int);
221 
223 
229  void StartAppend(double *bounds);
230  void StartAppend(double x0,double x1,double y0,double y1,double z0,double z1)
231  {double b[6]; b[0]=x0; b[1]=x1; b[2]=y0; b[3]=y1; b[4]=z0; b[5]=z1;
232  this->StartAppend(b);}
233  void Append(vtkPolyData *piece);
234  void EndAppend();
236 
238 
244  vtkSetMacro(CopyCellData, int);
245  vtkGetMacro(CopyCellData, int);
246  vtkBooleanMacro(CopyCellData, int);
248 
250 
256  vtkSetMacro(PreventDuplicateCells,int);
257  vtkGetMacro(PreventDuplicateCells,int);
258  vtkBooleanMacro(PreventDuplicateCells,int);
260 
261 protected:
263  ~vtkQuadricClustering() VTK_OVERRIDE;
264 
265  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
266  int FillInputPortInformation(int, vtkInformation *) VTK_OVERRIDE;
267 
271  vtkIdType HashPoint(double point[3]);
272 
276  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId,
277  double point[3]);
278 
280 
284  void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag,
285  vtkPolyData *input, vtkPolyData *output);
286  void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag,
287  vtkPolyData *input, vtkPolyData *output);
288  void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2,
289  int geometeryFlag, vtkPolyData *input, vtkPolyData *output);
291 
293 
297  void AddEdges(vtkCellArray *edges, vtkPoints *points,
298  int geometryFlag,
299  vtkPolyData *input, vtkPolyData *output);
300  void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag,
301  vtkPolyData *input, vtkPolyData *output);
303 
305 
309  void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag,
310  vtkPolyData *input, vtkPolyData *output);
311  void AddVertex(vtkIdType binId, double *pt, int geometryFlag,
312  vtkPolyData *input, vtkPolyData *output);
314 
318  void InitializeQuadric(double quadric[9]);
319 
323  void AddQuadric(vtkIdType binId, double quadric[9]);
324 
331  void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle);
332 
334 
338  void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output);
339  int UseInputPoints;
341 
346  void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output);
347 
348  // Unfinished option to handle boundary edges differently.
349  void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output);
350  int UseFeatureEdges;
351  int UseFeaturePoints;
352  int UseInternalTriangles;
353 
354  int NumberOfXDivisions;
355  int NumberOfYDivisions;
356  int NumberOfZDivisions;
357 
358  // Set this to eliminate duplicate cells
359  int PreventDuplicateCells;
360  vtkQuadricClusteringCellSet *CellSet; //PIMPLd stl set for tracking inserted cells
361  vtkIdType NumberOfBins;
362 
363  // Used internally.
364  // can be smaller than user values when input numb er of points is small.
365  int NumberOfDivisions[3];
366 
367  // Since there are two was of specifing the grid, we have this flag
368  // to indicate which the user has set. When this flag is on,
369  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
370  int ComputeNumberOfDivisions;
371 
372  double DivisionOrigin[3];
373  double DivisionSpacing[3];
374  int AutoAdjustNumberOfDivisions;
375 
376  double Bounds[6];
377  double XBinSize;
378  double YBinSize;
379  double ZBinSize;
380  double XBinStep; //replace some divisions with multiplication
381  double YBinStep;
382  double ZBinStep;
383  vtkIdType SliceSize; //eliminate one multiplication
384 
386  {
387  PointQuadric():VertexId(-1),Dimension(255) {}
388 
390  // Dimension is supposed to be a flag representing the dimension of the
391  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
392  // 0 in the future?)
393  unsigned char Dimension;
394  double Quadric[9];
395  };
396 
399 
400  // Have to make these instance variables if we are going to allow
401  // the algorithm to be driven by the Append methods.
404 
408 
412 
413 private:
414  vtkQuadricClustering(const vtkQuadricClustering&) VTK_DELETE_FUNCTION;
415  void operator=(const vtkQuadricClustering&) VTK_DELETE_FUNCTION;
416 };
417 
418 #endif
void SetDivisionOrigin(double o[3])
This is an alternative way to set up the bins.
Store vtkAlgorithm input/output information.
vtkCellArray * OutputTriangleArray
int vtkIdType
Definition: vtkType.h:287
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
void SetNumberOfDivisions(int div[3])
Set/Get the number of divisions along each axis for the spatial bins.
vtkFeatureEdges * FeatureEdges
static vtkPolyDataAlgorithm * New()
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
extract boundary, non-manifold, and/or sharp edges from polygonal data
void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
These methods provide an alternative way of executing the filter.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkFeatureEdges * GetFeatureEdges()
By default, this flag is off.
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetDivisionSpacing(double s[3])
This is an alternative way to set up the bins.
represent and manipulate 3D points
Definition: vtkPoints.h:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
reduce the number of triangles in a mesh