VTK  9.3.0
vtkQuadricClustering.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
90 #ifndef vtkQuadricClustering_h
91 #define vtkQuadricClustering_h
92 
93 #include "vtkFiltersCoreModule.h" // For export macro
94 #include "vtkPolyDataAlgorithm.h"
95 
96 VTK_ABI_NAMESPACE_BEGIN
97 class vtkCellArray;
98 class vtkFeatureEdges;
99 class vtkPoints;
100 class vtkQuadricClusteringCellSet;
101 
102 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
103 {
104 public:
106 
111  void PrintSelf(ostream& os, vtkIndent indent) override;
113 
115 
122  void SetNumberOfXDivisions(int num);
123  void SetNumberOfYDivisions(int num);
124  void SetNumberOfZDivisions(int num);
125  vtkGetMacro(NumberOfXDivisions, int);
126  vtkGetMacro(NumberOfYDivisions, int);
127  vtkGetMacro(NumberOfZDivisions, int);
128  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
129  void SetNumberOfDivisions(int div0, int div1, int div2);
131  void GetNumberOfDivisions(int div[3]);
133 
135 
140  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
141  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
142  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
144 
146 
152  void SetDivisionOrigin(double x, double y, double z);
153  void SetDivisionOrigin(double o[3]) { 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]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
157  vtkGetVector3Macro(DivisionSpacing, double);
159 
161 
169  vtkSetMacro(UseInputPoints, vtkTypeBool);
170  vtkGetMacro(UseInputPoints, vtkTypeBool);
171  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
173 
175 
181  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
182  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
183  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
184  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
186 
188 
195  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
196  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
197  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
199 
201 
205  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
206  vtkGetMacro(FeaturePointsAngle, double);
208 
210 
216  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
217  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
218  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
220 
222 
228  void StartAppend(double* bounds);
229  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
230  {
231  double b[6];
232  b[0] = x0;
233  b[1] = x1;
234  b[2] = y0;
235  b[3] = y1;
236  b[4] = z0;
237  b[5] = z1;
238  this->StartAppend(b);
239  }
240  void Append(vtkPolyData* piece);
241  void EndAppend();
243 
245 
251  vtkSetMacro(CopyCellData, vtkTypeBool);
252  vtkGetMacro(CopyCellData, vtkTypeBool);
253  vtkBooleanMacro(CopyCellData, vtkTypeBool);
255 
257 
263  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
264  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
265  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
267 
268 protected:
271 
274 
279 
283  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
284 
286 
290  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
291  vtkPolyData* output);
292  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
293  vtkPolyData* output);
294  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
295  vtkPolyData* input, vtkPolyData* output);
297 
299 
303  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
304  vtkPolyData* output);
305  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
306  vtkPolyData* output);
308 
310 
314  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
315  vtkPolyData* output);
316  void AddVertex(
317  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
319 
323  void InitializeQuadric(double quadric[9]);
324 
328  void AddQuadric(vtkIdType binId, double quadric[9]);
329 
336  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
337 
339 
346 
352 
353  // Unfinished option to handle boundary edges differently.
358 
362 
363  // Set this to eliminate duplicate cells
365  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
367 
368  // Used internally.
369  // can be smaller than user values when input numb er of points is small.
370  int NumberOfDivisions[3];
371 
372  // Since there are two ways of specifying the grid, we have this flag
373  // to indicate which the user has set. When this flag is on,
374  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
376 
377  double DivisionOrigin[3];
378  double DivisionSpacing[3];
380 
381  double Bounds[6];
382  double XBinSize;
383  double YBinSize;
384  double ZBinSize;
385  double XBinStep; // replace some divisions with multiplication
386  double YBinStep;
387  double ZBinStep;
388  vtkIdType SliceSize; // eliminate one multiplication
389 
391  {
393  : VertexId(-1)
394  , Dimension(255)
395  {
396  }
397 
399  // Dimension is supposed to be a flag representing the dimension of the
400  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
401  // 0 in the future?)
402  unsigned char Dimension;
403  double Quadric[9];
404  };
405 
408 
409  // Have to make these instance variables if we are going to allow
410  // the algorithm to be driven by the Append methods.
413 
417 
421 
422 private:
424  void operator=(const vtkQuadricClustering&) = delete;
425 };
426 
427 VTK_ABI_NAMESPACE_END
428 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:185
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:38
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
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
vtkTypeBool ComputeNumberOfDivisions
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:236
@ points
Definition: vtkX3D.h:446
int vtkTypeBool
Definition: vtkABI.h:64
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
int vtkIdType
Definition: vtkType.h:315
#define VTK_SIZEHINT(...)