VTK  9.1.0
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 =========================================================================*/
90 #ifndef vtkQuadricClustering_h
91 #define vtkQuadricClustering_h
92 
93 #include "vtkFiltersCoreModule.h" // For export macro
94 #include "vtkPolyDataAlgorithm.h"
95 
96 class vtkCellArray;
97 class vtkFeatureEdges;
98 class vtkPoints;
99 class vtkQuadricClusteringCellSet;
100 
101 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
102 {
103 public:
105 
110  void PrintSelf(ostream& os, vtkIndent indent) override;
112 
114 
121  void SetNumberOfXDivisions(int num);
122  void SetNumberOfYDivisions(int num);
123  void SetNumberOfZDivisions(int num);
124  vtkGetMacro(NumberOfXDivisions, int);
125  vtkGetMacro(NumberOfYDivisions, int);
126  vtkGetMacro(NumberOfZDivisions, int);
127  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
128  void SetNumberOfDivisions(int div0, int div1, int div2);
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]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
153  vtkGetVector3Macro(DivisionOrigin, double);
154  void SetDivisionSpacing(double x, double y, double z);
155  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
156  vtkGetVector3Macro(DivisionSpacing, double);
158 
160 
168  vtkSetMacro(UseInputPoints, vtkTypeBool);
169  vtkGetMacro(UseInputPoints, vtkTypeBool);
170  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
172 
174 
180  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
181  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
182  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
183  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
185 
187 
194  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
195  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
196  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
198 
200 
204  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
205  vtkGetMacro(FeaturePointsAngle, double);
207 
209 
215  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
216  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
217  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
219 
221 
227  void StartAppend(double* bounds);
228  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
229  {
230  double b[6];
231  b[0] = x0;
232  b[1] = x1;
233  b[2] = y0;
234  b[3] = y1;
235  b[4] = z0;
236  b[5] = z1;
237  this->StartAppend(b);
238  }
239  void Append(vtkPolyData* piece);
240  void EndAppend();
242 
244 
250  vtkSetMacro(CopyCellData, vtkTypeBool);
251  vtkGetMacro(CopyCellData, vtkTypeBool);
252  vtkBooleanMacro(CopyCellData, vtkTypeBool);
254 
256 
262  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
263  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
264  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
266 
267 protected:
270 
273 
278 
282  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
283 
285 
289  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
290  vtkPolyData* output);
291  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
292  vtkPolyData* output);
293  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
294  vtkPolyData* input, vtkPolyData* output);
296 
298 
302  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
303  vtkPolyData* output);
304  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
305  vtkPolyData* output);
307 
309 
313  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
314  vtkPolyData* output);
315  void AddVertex(
316  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
318 
322  void InitializeQuadric(double quadric[9]);
323 
327  void AddQuadric(vtkIdType binId, double quadric[9]);
328 
335  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
336 
338 
345 
351 
352  // Unfinished option to handle boundary edges differently.
357 
361 
362  // Set this to eliminate duplicate cells
364  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
366 
367  // Used internally.
368  // can be smaller than user values when input numb er of points is small.
369  int NumberOfDivisions[3];
370 
371  // Since there are two was of specifying the grid, we have this flag
372  // to indicate which the user has set. When this flag is on,
373  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
375 
376  double DivisionOrigin[3];
377  double DivisionSpacing[3];
379 
380  double Bounds[6];
381  double XBinSize;
382  double YBinSize;
383  double ZBinSize;
384  double XBinStep; // replace some divisions with multiplication
385  double YBinStep;
386  double ZBinStep;
387  vtkIdType SliceSize; // eliminate one multiplication
388 
390  {
392  : VertexId(-1)
393  , Dimension(255)
394  {
395  }
396 
398  // Dimension is supposed to be a flag representing the dimension of the
399  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
400  // 0 in the future?)
401  unsigned char Dimension;
402  double Quadric[9];
403  };
404 
407 
408  // Have to make these instance variables if we are going to allow
409  // the algorithm to be driven by the Append methods.
412 
416 
420 
421 private:
423  void operator=(const vtkQuadricClustering&) = delete;
424 };
425 
426 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:181
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:34
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
reduce the number of triangles in a mesh
void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add triangles to the quadric array.
~vtkQuadricClustering() override
void SetNumberOfZDivisions(int num)
Set/Get the number of divisions along each axis for the spatial bins.
vtkQuadricClusteringCellSet * CellSet
vtkCellArray * OutputTriangleArray
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
vtkIdType HashPoint(double point[3])
Given a point, determine what bin it falls into.
vtkTypeBool UseInputPoints
This method will rep[lace the quadric generated points with the input points with the lowest error.
vtkFeatureEdges * GetFeatureEdges()
By default, this flag is off.
void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output)
void EndAppend()
These methods provide an alternative way of executing the filter.
void SetDivisionSpacing(double s[3])
This is an alternative way to set up the bins.
void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle)
Find the feature points of a given set of edges.
void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output)
This method sets the vertices of the output.
void SetDivisionOrigin(double o[3])
This is an alternative way to set up the bins.
void SetNumberOfDivisions(int div[3])
Set/Get the number of divisions along each axis for the spatial bins.
void InitializeQuadric(double quadric[9])
Initialize the quadric matrix to 0's.
void SetDivisionSpacing(double x, double y, double z)
This is an alternative way to set up the bins.
void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3])
Determine the representative point for this bin.
vtkFeatureEdges * FeatureEdges
void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add vertices to the quadric array.
void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
These methods provide an alternative way of executing the filter.
void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add triangles to the quadric array.
void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output)
This method will rep[lace the quadric generated points with the input points with the lowest error.
void StartAppend(double *bounds)
These methods provide an alternative way of executing the filter.
int * GetNumberOfDivisions()
Set/Get the number of divisions along each axis for the spatial bins.
void AddQuadric(vtkIdType binId, double quadric[9])
Add this quadric to the quadric already associated with this bin.
void SetNumberOfYDivisions(int num)
Set/Get the number of divisions along each axis for the spatial bins.
static vtkQuadricClustering * New()
Standard instantiation, type and print methods.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard instantiation, type and print methods.
void AddEdges(vtkCellArray *edges, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add edges to the quadric array.
vtkTypeBool AutoAdjustNumberOfDivisions
void Append(vtkPolyData *piece)
These methods provide an alternative way of executing the filter.
void SetNumberOfDivisions(int div0, int div1, int div2)
Set/Get the number of divisions along each axis for the spatial bins.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void AddVertex(vtkIdType binId, double *pt, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add vertices to the quadric array.
void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag, vtkPolyData *input, vtkPolyData *output)
Add edges to the quadric array.
void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2, int geometeryFlag, vtkPolyData *input, vtkPolyData *output)
Add triangles to the quadric array.
void SetNumberOfXDivisions(int num)
Set/Get the number of divisions along each axis for the spatial bins.
@ point
Definition: vtkX3D.h:242
@ points
Definition: vtkX3D.h:452
int vtkTypeBool
Definition: vtkABI.h:69
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
int vtkIdType
Definition: vtkType.h:332
#define VTK_SIZEHINT(...)