VTK  9.3.20240417
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
100 #ifndef vtkQuadricClustering_h
101 #define vtkQuadricClustering_h
102 
103 #include "vtkFiltersCoreModule.h" // For export macro
104 #include "vtkPolyDataAlgorithm.h"
105 
106 VTK_ABI_NAMESPACE_BEGIN
107 class vtkCellArray;
108 class vtkFeatureEdges;
109 class vtkPoints;
110 class vtkQuadricClusteringCellSet;
111 
112 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
113 {
114 public:
116 
121  void PrintSelf(ostream& os, vtkIndent indent) override;
123 
125 
132  void SetNumberOfXDivisions(int num);
133  void SetNumberOfYDivisions(int num);
134  void SetNumberOfZDivisions(int num);
135  vtkGetMacro(NumberOfXDivisions, int);
136  vtkGetMacro(NumberOfYDivisions, int);
137  vtkGetMacro(NumberOfZDivisions, int);
138  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
139  void SetNumberOfDivisions(int div0, int div1, int div2);
141  void GetNumberOfDivisions(int div[3]);
143 
145 
150  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
151  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
152  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
154 
156 
162  void SetDivisionOrigin(double x, double y, double z);
163  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
164  vtkGetVector3Macro(DivisionOrigin, double);
165  void SetDivisionSpacing(double x, double y, double z);
166  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
167  vtkGetVector3Macro(DivisionSpacing, double);
169 
171 
179  vtkSetMacro(UseInputPoints, vtkTypeBool);
180  vtkGetMacro(UseInputPoints, vtkTypeBool);
181  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
183 
185 
191  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
192  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
193  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
194  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
196 
198 
205  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
206  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
207  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
209 
211 
215  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
216  vtkGetMacro(FeaturePointsAngle, double);
218 
220 
226  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
227  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
228  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
230 
232 
238  void StartAppend(double* bounds);
239  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
240  {
241  double b[6];
242  b[0] = x0;
243  b[1] = x1;
244  b[2] = y0;
245  b[3] = y1;
246  b[4] = z0;
247  b[5] = z1;
248  this->StartAppend(b);
249  }
250  void Append(vtkPolyData* piece);
251  void EndAppend();
253 
255 
261  vtkSetMacro(CopyCellData, vtkTypeBool);
262  vtkGetMacro(CopyCellData, vtkTypeBool);
263  vtkBooleanMacro(CopyCellData, vtkTypeBool);
265 
267 
273  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
274  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
275  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
277 
278 protected:
281 
284 
289 
293  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
294 
296 
300  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
301  vtkPolyData* output);
302  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
303  vtkPolyData* output);
304  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
305  vtkPolyData* input, vtkPolyData* output);
307 
309 
313  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
314  vtkPolyData* output);
315  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
316  vtkPolyData* output);
318 
320 
324  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
325  vtkPolyData* output);
326  void AddVertex(
327  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
329 
333  void InitializeQuadric(double quadric[9]);
334 
338  void AddQuadric(vtkIdType binId, double quadric[9]);
339 
346  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
347 
349 
356 
362 
363  // Unfinished option to handle boundary edges differently.
368 
372 
373  // Set this to eliminate duplicate cells
375  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
377 
378  // Used internally.
379  // can be smaller than user values when input numb er of points is small.
380  int NumberOfDivisions[3];
381 
382  // Since there are two ways of specifying the grid, we have this flag
383  // to indicate which the user has set. When this flag is on,
384  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
386 
387  double DivisionOrigin[3];
388  double DivisionSpacing[3];
390 
391  double Bounds[6];
392  double XBinSize;
393  double YBinSize;
394  double ZBinSize;
395  double XBinStep; // replace some divisions with multiplication
396  double YBinStep;
397  double ZBinStep;
398  vtkIdType SliceSize; // eliminate one multiplication
399 
401  {
403  : VertexId(-1)
404  , Dimension(255)
405  {
406  }
407 
409  // Dimension is supposed to be a flag representing the dimension of the
410  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
411  // 0 in the future?)
412  unsigned char Dimension;
413  double Quadric[9];
414  };
415 
418 
419  // Have to make these instance variables if we are going to allow
420  // the algorithm to be driven by the Append methods.
423 
427 
431 
432 private:
434  void operator=(const vtkQuadricClustering&) = delete;
435 };
436 
437 VTK_ABI_NAMESPACE_END
438 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:286
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
a simple class to control print indentation
Definition: vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:139
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:181
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(...)