VTK  9.3.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 
87 VTK_ABI_NAMESPACE_BEGIN
88 class vtkCellArray;
89 class vtkFeatureEdges;
90 class vtkPoints;
91 class vtkQuadricClusteringCellSet;
92 
93 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
94 {
95 public:
97 
100  static vtkQuadricClustering* New();
102  void PrintSelf(ostream& os, vtkIndent indent) override;
104 
106 
113  void SetNumberOfXDivisions(int num);
114  void SetNumberOfYDivisions(int num);
115  void SetNumberOfZDivisions(int num);
116  vtkGetMacro(NumberOfXDivisions, int);
117  vtkGetMacro(NumberOfYDivisions, int);
118  vtkGetMacro(NumberOfZDivisions, int);
119  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
120  void SetNumberOfDivisions(int div0, int div1, int div2);
121  int* GetNumberOfDivisions() VTK_SIZEHINT(3);
122  void GetNumberOfDivisions(int div[3]);
124 
126 
131  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
132  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
133  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
135 
137 
143  void SetDivisionOrigin(double x, double y, double z);
144  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
145  vtkGetVector3Macro(DivisionOrigin, double);
146  void SetDivisionSpacing(double x, double y, double z);
147  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
148  vtkGetVector3Macro(DivisionSpacing, double);
150 
152 
160  vtkSetMacro(UseInputPoints, vtkTypeBool);
161  vtkGetMacro(UseInputPoints, vtkTypeBool);
162  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
164 
166 
172  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
173  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
174  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
175  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
177 
179 
186  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
187  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
188  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
190 
192 
196  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
197  vtkGetMacro(FeaturePointsAngle, double);
199 
201 
207  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
208  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
209  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
211 
213 
219  void StartAppend(double* bounds);
220  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
221  {
222  double b[6];
223  b[0] = x0;
224  b[1] = x1;
225  b[2] = y0;
226  b[3] = y1;
227  b[4] = z0;
228  b[5] = z1;
229  this->StartAppend(b);
230  }
231  void Append(vtkPolyData* piece);
232  void EndAppend();
234 
236 
242  vtkSetMacro(CopyCellData, vtkTypeBool);
243  vtkGetMacro(CopyCellData, vtkTypeBool);
244  vtkBooleanMacro(CopyCellData, vtkTypeBool);
246 
248 
254  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
255  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
256  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
258 
259 protected:
261  ~vtkQuadricClustering() override;
262 
264  int FillInputPortInformation(int, vtkInformation*) override;
265 
269  vtkIdType HashPoint(double point[3]);
270 
274  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
275 
277 
281  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
282  vtkPolyData* output);
283  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
284  vtkPolyData* output);
285  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
286  vtkPolyData* input, vtkPolyData* output);
288 
290 
294  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
295  vtkPolyData* output);
296  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
297  vtkPolyData* output);
299 
301 
305  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
306  vtkPolyData* output);
307  void AddVertex(
308  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
310 
314  void InitializeQuadric(double quadric[9]);
315 
319  void AddQuadric(vtkIdType binId, double quadric[9]);
320 
327  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
328 
330 
334  void EndAppendUsingPoints(vtkPolyData* input, vtkPolyData* output);
337 
342  void EndAppendVertexGeometry(vtkPolyData* input, vtkPolyData* output);
343 
344  // Unfinished option to handle boundary edges differently.
345  void AppendFeatureQuadrics(vtkPolyData* pd, vtkPolyData* output);
349 
353 
354  // Set this to eliminate duplicate cells
356  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
358 
359  // Used internally.
360  // can be smaller than user values when input numb er of points is small.
361  int NumberOfDivisions[3];
362 
363  // Since there are two ways of specifying the grid, we have this flag
364  // to indicate which the user has set. When this flag is on,
365  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
367 
368  double DivisionOrigin[3];
369  double DivisionSpacing[3];
371 
372  double Bounds[6];
373  double XBinSize;
374  double YBinSize;
375  double ZBinSize;
376  double XBinStep; // replace some divisions with multiplication
377  double YBinStep;
378  double ZBinStep;
379  vtkIdType SliceSize; // eliminate one multiplication
380 
382  {
384  : VertexId(-1)
385  , Dimension(255)
386  {
387  }
388 
390  // Dimension is supposed to be a flag representing the dimension of the
391  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
392  // 0 in the future?)
393  unsigned char Dimension;
394  double Quadric[9];
395  };
396 
399 
400  // Have to make these instance variables if we are going to allow
401  // the algorithm to be driven by the Append methods.
404 
408 
412 
413 private:
415  void operator=(const vtkQuadricClustering&) = delete;
416 };
417 
418 VTK_ABI_NAMESPACE_END
419 #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:315
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:175
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:28
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)