VTK  9.7.1
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
81 #ifndef vtkQuadricClustering_h
82 #define vtkQuadricClustering_h
83 
84 #include "vtkFiltersCoreModule.h" // For export macro
85 #include "vtkPolyDataAlgorithm.h"
86 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
87 
88 VTK_ABI_NAMESPACE_BEGIN
89 class vtkCellArray;
90 class vtkFeatureEdges;
91 class vtkPoints;
92 class vtkQuadricClusteringCellSet;
93 
94 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkQuadricClustering : public vtkPolyDataAlgorithm
95 {
96 public:
98 
101  static vtkQuadricClustering* New();
103  void PrintSelf(ostream& os, vtkIndent indent) override;
105 
107 
114  void SetNumberOfXDivisions(int num);
115  void SetNumberOfYDivisions(int num);
116  void SetNumberOfZDivisions(int num);
117  vtkGetMacro(NumberOfXDivisions, int);
118  vtkGetMacro(NumberOfYDivisions, int);
119  vtkGetMacro(NumberOfZDivisions, int);
120  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
121  void SetNumberOfDivisions(int div0, int div1, int div2);
122  int* GetNumberOfDivisions() VTK_SIZEHINT(3);
123  void GetNumberOfDivisions(int div[3]);
125 
127 
132  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
133  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
134  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
136 
138 
144  void SetDivisionOrigin(double x, double y, double z);
145  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
146  vtkGetVector3Macro(DivisionOrigin, double);
147  void SetDivisionSpacing(double x, double y, double z);
148  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
149  vtkGetVector3Macro(DivisionSpacing, double);
151 
153 
161  vtkSetMacro(UseInputPoints, vtkTypeBool);
162  vtkGetMacro(UseInputPoints, vtkTypeBool);
163  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
165 
167 
173  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
174  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
175  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
176  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
178 
180 
187  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
188  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
189  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
191 
193 
197  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
198  vtkGetMacro(FeaturePointsAngle, double);
200 
202 
208  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
209  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
210  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
212 
214 
220  void StartAppend(double* bounds);
221  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
222  {
223  double b[6];
224  b[0] = x0;
225  b[1] = x1;
226  b[2] = y0;
227  b[3] = y1;
228  b[4] = z0;
229  b[5] = z1;
230  this->StartAppend(b);
231  }
232  void Append(vtkPolyData* piece);
233  void EndAppend();
235 
237 
243  vtkSetMacro(CopyCellData, vtkTypeBool);
244  vtkGetMacro(CopyCellData, vtkTypeBool);
245  vtkBooleanMacro(CopyCellData, vtkTypeBool);
247 
249 
255  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
256  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
257  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
259 
260 protected:
262  ~vtkQuadricClustering() override;
263 
265  int FillInputPortInformation(int, vtkInformation*) override;
266 
270  vtkIdType HashPoint(double point[3]);
271 
275  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
276 
278 
282  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
283  vtkPolyData* output);
284  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
285  vtkPolyData* output);
286  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
287  vtkPolyData* input, vtkPolyData* output);
289 
291 
295  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
296  vtkPolyData* output);
297  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
298  vtkPolyData* output);
300 
302 
306  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
307  vtkPolyData* output);
308  void AddVertex(
309  vtkIdType binId, double* pt, int geometryFlag, 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 ways of specifying 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  {
385  : VertexId(-1)
386  , Dimension(255)
387  {
388  }
389 
391  // Dimension is supposed to be a flag representing the dimension of the
392  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
393  // 0 in the future?)
394  unsigned char Dimension;
395  double Quadric[9];
396  };
397 
400 
401  // Have to make these instance variables if we are going to allow
402  // the algorithm to be driven by the Append methods.
405 
409 
413 
414 private:
416  void operator=(const vtkQuadricClustering&) = delete;
417 };
418 
419 VTK_ABI_NAMESPACE_END
420 #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:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
void SetNumberOfDivisions(int div[3])
Set/Get the number of divisions along each axis for the spatial bins.
vtkFeatureEdges * FeatureEdges
vtkTypeBool ComputeNumberOfDivisions
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:64
vtkQuadricClusteringCellSet * CellSet
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:28
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:177
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.
#define VTK_MARSHALAUTO
void SetDivisionSpacing(double s[3])
This is an alternative way to set up the bins.
represent and manipulate 3D points
Definition: vtkPoints.h:30
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)