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) 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() VTK_SIZEHINT(3);
130  void GetNumberOfDivisions(int div[3]);
132 
134 
139  vtkSetMacro(AutoAdjustNumberOfDivisions,vtkTypeBool);
140  vtkGetMacro(AutoAdjustNumberOfDivisions,vtkTypeBool);
141  vtkBooleanMacro(AutoAdjustNumberOfDivisions,vtkTypeBool);
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, vtkTypeBool);
171  vtkGetMacro(UseInputPoints, vtkTypeBool);
172  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
174 
176 
182  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
183  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
184  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
185  vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;}
187 
189 
196  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
197  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
198  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
200 
202 
206  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
207  vtkGetMacro(FeaturePointsAngle, double);
209 
211 
217  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
218  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
219  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
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, vtkTypeBool);
245  vtkGetMacro(CopyCellData, vtkTypeBool);
246  vtkBooleanMacro(CopyCellData, vtkTypeBool);
248 
250 
256  vtkSetMacro(PreventDuplicateCells,vtkTypeBool);
257  vtkGetMacro(PreventDuplicateCells,vtkTypeBool);
258  vtkBooleanMacro(PreventDuplicateCells,vtkTypeBool);
260 
261 protected:
263  ~vtkQuadricClustering() override;
264 
266  int FillInputPortInformation(int, vtkInformation *) 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);
341 
346  void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output);
347 
348  // Unfinished option to handle boundary edges differently.
349  void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output);
353 
357 
358  // Set this to eliminate duplicate cells
360  vtkQuadricClusteringCellSet *CellSet; //PIMPLd stl set for tracking inserted cells
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 specifying 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.
371 
372  double DivisionOrigin[3];
373  double DivisionSpacing[3];
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:
415  void operator=(const vtkQuadricClustering&) = delete;
416 };
417 
418 #endif
void SetDivisionOrigin(double o[3])
This is an alternative way to set up the bins.
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
vtkCellArray * OutputTriangleArray
int vtkIdType
Definition: vtkType.h:347
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()
int vtkTypeBool
Definition: vtkABI.h:69
vtkQuadricClusteringCellSet * CellSet
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.
#define VTK_SIZEHINT(...)
vtkTypeBool AutoAdjustNumberOfDivisions
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkFeatureEdges * GetFeatureEdges()
By default, this flag is off.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkTypeBool UseInputPoints
This method will rep[lace the quadric generated points with the input points with the lowest error...
Store zero or more vtkInformation instances.
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