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) VTK_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();
127  void GetNumberOfDivisions(int div[3]);
129 
131 
136  vtkSetMacro(AutoAdjustNumberOfDivisions,int);
137  vtkGetMacro(AutoAdjustNumberOfDivisions,int);
138  vtkBooleanMacro(AutoAdjustNumberOfDivisions,int);
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, int);
168  vtkGetMacro(UseInputPoints, int);
169  vtkBooleanMacro(UseInputPoints, int);
171 
173 
179  vtkSetMacro(UseFeatureEdges, int);
180  vtkGetMacro(UseFeatureEdges, int);
181  vtkBooleanMacro(UseFeatureEdges, int);
182  vtkFeatureEdges *GetFeatureEdges() {return this->FeatureEdges;}
184 
186 
193  vtkSetMacro(UseFeaturePoints, int);
194  vtkGetMacro(UseFeaturePoints, int);
195  vtkBooleanMacro(UseFeaturePoints, int);
197 
199 
203  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
204  vtkGetMacro(FeaturePointsAngle, double);
206 
208 
214  vtkSetMacro(UseInternalTriangles, int);
215  vtkGetMacro(UseInternalTriangles, int);
216  vtkBooleanMacro(UseInternalTriangles, int);
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, int);
242  vtkGetMacro(CopyCellData, int);
243  vtkBooleanMacro(CopyCellData, int);
245 
247 
253  vtkSetMacro(PreventDuplicateCells,int);
254  vtkGetMacro(PreventDuplicateCells,int);
255  vtkBooleanMacro(PreventDuplicateCells,int);
257 
258 protected:
260  ~vtkQuadricClustering() VTK_OVERRIDE;
261 
263  int FillInputPortInformation(int, vtkInformation *) VTK_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 specifing 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:
411  vtkQuadricClustering(const vtkQuadricClustering&) VTK_DELETE_FUNCTION;
412  void operator=(const vtkQuadricClustering&) VTK_DELETE_FUNCTION;
413 };
414 
415 #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: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()
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.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int UseInputPoints
This method will rep[lace the quadric generated points with the input points with the lowest error...
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