VTK  9.2.6
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 =========================================================================*/
93 #ifndef vtkQuadricClustering_h
94 #define vtkQuadricClustering_h
95 
96 #include "vtkFiltersCoreModule.h" // For export macro
97 #include "vtkPolyDataAlgorithm.h"
98 
99 class vtkCellArray;
100 class vtkFeatureEdges;
101 class vtkPoints;
102 class vtkQuadricClusteringCellSet;
103 
104 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
105 {
106 public:
108 
111  static vtkQuadricClustering* New();
113  void PrintSelf(ostream& os, vtkIndent indent) override;
115 
117 
124  void SetNumberOfXDivisions(int num);
125  void SetNumberOfYDivisions(int num);
126  void SetNumberOfZDivisions(int num);
127  vtkGetMacro(NumberOfXDivisions, int);
128  vtkGetMacro(NumberOfYDivisions, int);
129  vtkGetMacro(NumberOfZDivisions, int);
130  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
131  void SetNumberOfDivisions(int div0, int div1, int div2);
132  int* GetNumberOfDivisions() VTK_SIZEHINT(3);
133  void GetNumberOfDivisions(int div[3]);
135 
137 
142  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
143  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
144  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
146 
148 
154  void SetDivisionOrigin(double x, double y, double z);
155  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
156  vtkGetVector3Macro(DivisionOrigin, double);
157  void SetDivisionSpacing(double x, double y, double z);
158  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
159  vtkGetVector3Macro(DivisionSpacing, double);
161 
163 
171  vtkSetMacro(UseInputPoints, vtkTypeBool);
172  vtkGetMacro(UseInputPoints, vtkTypeBool);
173  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
175 
177 
183  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
184  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
185  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
186  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
188 
190 
197  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
198  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
199  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
201 
203 
207  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
208  vtkGetMacro(FeaturePointsAngle, double);
210 
212 
218  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
219  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
220  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
222 
224 
230  void StartAppend(double* bounds);
231  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
232  {
233  double b[6];
234  b[0] = x0;
235  b[1] = x1;
236  b[2] = y0;
237  b[3] = y1;
238  b[4] = z0;
239  b[5] = z1;
240  this->StartAppend(b);
241  }
242  void Append(vtkPolyData* piece);
243  void EndAppend();
245 
247 
253  vtkSetMacro(CopyCellData, vtkTypeBool);
254  vtkGetMacro(CopyCellData, vtkTypeBool);
255  vtkBooleanMacro(CopyCellData, vtkTypeBool);
257 
259 
265  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
266  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
267  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
269 
270 protected:
272  ~vtkQuadricClustering() override;
273 
275  int FillInputPortInformation(int, vtkInformation*) override;
276 
280  vtkIdType HashPoint(double point[3]);
281 
285  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
286 
288 
292  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
293  vtkPolyData* output);
294  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
295  vtkPolyData* output);
296  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
297  vtkPolyData* input, vtkPolyData* output);
299 
301 
305  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
306  vtkPolyData* output);
307  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
308  vtkPolyData* output);
310 
312 
316  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
317  vtkPolyData* output);
318  void AddVertex(
319  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
321 
325  void InitializeQuadric(double quadric[9]);
326 
330  void AddQuadric(vtkIdType binId, double quadric[9]);
331 
338  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
339 
341 
345  void EndAppendUsingPoints(vtkPolyData* input, vtkPolyData* output);
348 
353  void EndAppendVertexGeometry(vtkPolyData* input, vtkPolyData* output);
354 
355  // Unfinished option to handle boundary edges differently.
356  void AppendFeatureQuadrics(vtkPolyData* pd, vtkPolyData* output);
360 
364 
365  // Set this to eliminate duplicate cells
367  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
369 
370  // Used internally.
371  // can be smaller than user values when input numb er of points is small.
372  int NumberOfDivisions[3];
373 
374  // Since there are two was of specifying the grid, we have this flag
375  // to indicate which the user has set. When this flag is on,
376  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
378 
379  double DivisionOrigin[3];
380  double DivisionSpacing[3];
382 
383  double Bounds[6];
384  double XBinSize;
385  double YBinSize;
386  double ZBinSize;
387  double XBinStep; // replace some divisions with multiplication
388  double YBinStep;
389  double ZBinStep;
390  vtkIdType SliceSize; // eliminate one multiplication
391 
393  {
395  : VertexId(-1)
396  , Dimension(255)
397  {
398  }
399 
401  // Dimension is supposed to be a flag representing the dimension of the
402  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
403  // 0 in the future?)
404  unsigned char Dimension;
405  double Quadric[9];
406  };
407 
410 
411  // Have to make these instance variables if we are going to allow
412  // the algorithm to be driven by the Append methods.
415 
419 
423 
424 private:
426  void operator=(const vtkQuadricClustering&) = delete;
427 };
428 
429 #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:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
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 interior, 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:186
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.
reduce the number of triangles in a mesh
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)