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 =========================================================================*/
85 #ifndef vtkQuadricClustering_h
86 #define vtkQuadricClustering_h
87 
88 #include "vtkFiltersCoreModule.h" // For export macro
89 #include "vtkPolyDataAlgorithm.h"
90 
91 class vtkCellArray;
92 class vtkFeatureEdges;
93 class vtkPoints;
94 class vtkQuadricClusteringCellSet;
95 
96 
97 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
98 {
99 public:
101 
105  void PrintSelf(ostream& os, vtkIndent indent) override;
106  static vtkQuadricClustering *New();
108 
110 
117  void SetNumberOfXDivisions(int num);
118  void SetNumberOfYDivisions(int num);
119  void SetNumberOfZDivisions(int num);
120  vtkGetMacro(NumberOfXDivisions, int);
121  vtkGetMacro(NumberOfYDivisions, int);
122  vtkGetMacro(NumberOfZDivisions, int);
123  void SetNumberOfDivisions(int div[3])
124  { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
125  void SetNumberOfDivisions(int div0, int div1, int div2);
126  int *GetNumberOfDivisions() VTK_SIZEHINT(3);
127  void GetNumberOfDivisions(int div[3]);
129 
131 
136  vtkSetMacro(AutoAdjustNumberOfDivisions,vtkTypeBool);
137  vtkGetMacro(AutoAdjustNumberOfDivisions,vtkTypeBool);
138  vtkBooleanMacro(AutoAdjustNumberOfDivisions,vtkTypeBool);
140 
142 
148  void SetDivisionOrigin(double x, double y, double z);
149  void SetDivisionOrigin(double o[3])
150  {this->SetDivisionOrigin(o[0],o[1],o[2]);}
151  vtkGetVector3Macro(DivisionOrigin, double);
152  void SetDivisionSpacing(double x, double y, double z);
153  void SetDivisionSpacing(double s[3])
154  {this->SetDivisionSpacing(s[0],s[1],s[2]);}
155  vtkGetVector3Macro(DivisionSpacing, double);
157 
159 
167  vtkSetMacro(UseInputPoints, vtkTypeBool);
168  vtkGetMacro(UseInputPoints, vtkTypeBool);
169  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
171 
173 
179  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
180  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
181  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
182  vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;}
184 
186 
193  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
194  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
195  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
197 
199 
203  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
204  vtkGetMacro(FeaturePointsAngle, double);
206 
208 
214  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
215  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
216  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
218 
220 
226  void StartAppend(double *bounds);
227  void StartAppend(double x0,double x1,double y0,double y1,double z0,double z1)
228  {double b[6]; b[0]=x0; b[1]=x1; b[2]=y0; b[3]=y1; b[4]=z0; b[5]=z1;
229  this->StartAppend(b);}
230  void Append(vtkPolyData *piece);
231  void EndAppend();
233 
235 
241  vtkSetMacro(CopyCellData, vtkTypeBool);
242  vtkGetMacro(CopyCellData, vtkTypeBool);
243  vtkBooleanMacro(CopyCellData, vtkTypeBool);
245 
247 
253  vtkSetMacro(PreventDuplicateCells,vtkTypeBool);
254  vtkGetMacro(PreventDuplicateCells,vtkTypeBool);
255  vtkBooleanMacro(PreventDuplicateCells,vtkTypeBool);
257 
258 protected:
260  ~vtkQuadricClustering() override;
261 
263  int FillInputPortInformation(int, vtkInformation *) override;
264 
268  vtkIdType HashPoint(double point[3]);
269 
273  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId,
274  double point[3]);
275 
277 
281  void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag,
282  vtkPolyData *input, vtkPolyData *output);
283  void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag,
284  vtkPolyData *input, vtkPolyData *output);
285  void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2,
286  int geometeryFlag, vtkPolyData *input, vtkPolyData *output);
288 
290 
294  void AddEdges(vtkCellArray *edges, vtkPoints *points,
295  int geometryFlag,
296  vtkPolyData *input, vtkPolyData *output);
297  void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag,
298  vtkPolyData *input, vtkPolyData *output);
300 
302 
306  void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag,
307  vtkPolyData *input, vtkPolyData *output);
308  void AddVertex(vtkIdType binId, double *pt, int geometryFlag,
309  vtkPolyData *input, vtkPolyData *output);
311 
315  void InitializeQuadric(double quadric[9]);
316 
320  void AddQuadric(vtkIdType binId, double quadric[9]);
321 
328  void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle);
329 
331 
335  void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output);
338 
343  void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output);
344 
345  // Unfinished option to handle boundary edges differently.
346  void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output);
350 
354 
355  // Set this to eliminate duplicate cells
357  vtkQuadricClusteringCellSet *CellSet; //PIMPLd stl set for tracking inserted cells
359 
360  // Used internally.
361  // can be smaller than user values when input numb er of points is small.
362  int NumberOfDivisions[3];
363 
364  // Since there are two was of specifying the grid, we have this flag
365  // to indicate which the user has set. When this flag is on,
366  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
368 
369  double DivisionOrigin[3];
370  double DivisionSpacing[3];
372 
373  double Bounds[6];
374  double XBinSize;
375  double YBinSize;
376  double ZBinSize;
377  double XBinStep; //replace some divisions with multiplication
378  double YBinStep;
379  double ZBinStep;
380  vtkIdType SliceSize; //eliminate one multiplication
381 
383  {
384  PointQuadric():VertexId(-1),Dimension(255) {}
385 
387  // Dimension is supposed to be a flag representing the dimension of the
388  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
389  // 0 in the future?)
390  unsigned char Dimension;
391  double Quadric[9];
392  };
393 
396 
397  // Have to make these instance variables if we are going to allow
398  // the algorithm to be driven by the Append methods.
401 
405 
409 
410 private:
412  void operator=(const vtkQuadricClustering&) = delete;
413 };
414 
415 #endif
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:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:33
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:44
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:33
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