VTK  9.2.20230321
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 =========================================================================*/
112 #ifndef vtkQuadricClustering_h
113 #define vtkQuadricClustering_h
114 
115 #include "vtkFiltersCoreModule.h" // For export macro
116 #include "vtkPolyDataAlgorithm.h"
117 
118 VTK_ABI_NAMESPACE_BEGIN
119 class vtkCellArray;
120 class vtkFeatureEdges;
121 class vtkPoints;
122 class vtkQuadricClusteringCellSet;
123 
124 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
125 {
126 public:
128 
133  void PrintSelf(ostream& os, vtkIndent indent) override;
135 
137 
144  void SetNumberOfXDivisions(int num);
145  void SetNumberOfYDivisions(int num);
146  void SetNumberOfZDivisions(int num);
147  vtkGetMacro(NumberOfXDivisions, int);
148  vtkGetMacro(NumberOfYDivisions, int);
149  vtkGetMacro(NumberOfZDivisions, int);
150  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
151  void SetNumberOfDivisions(int div0, int div1, int div2);
153  void GetNumberOfDivisions(int div[3]);
155 
157 
162  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
163  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
164  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
166 
168 
174  void SetDivisionOrigin(double x, double y, double z);
175  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
176  vtkGetVector3Macro(DivisionOrigin, double);
177  void SetDivisionSpacing(double x, double y, double z);
178  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
179  vtkGetVector3Macro(DivisionSpacing, double);
181 
183 
191  vtkSetMacro(UseInputPoints, vtkTypeBool);
192  vtkGetMacro(UseInputPoints, vtkTypeBool);
193  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
195 
197 
203  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
204  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
205  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
206  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
208 
210 
217  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
218  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
219  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
221 
223 
227  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
228  vtkGetMacro(FeaturePointsAngle, double);
230 
232 
238  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
239  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
240  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
242 
244 
250  void StartAppend(double* bounds);
251  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
252  {
253  double b[6];
254  b[0] = x0;
255  b[1] = x1;
256  b[2] = y0;
257  b[3] = y1;
258  b[4] = z0;
259  b[5] = z1;
260  this->StartAppend(b);
261  }
262  void Append(vtkPolyData* piece);
263  void EndAppend();
265 
267 
273  vtkSetMacro(CopyCellData, vtkTypeBool);
274  vtkGetMacro(CopyCellData, vtkTypeBool);
275  vtkBooleanMacro(CopyCellData, vtkTypeBool);
277 
279 
285  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
286  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
287  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
289 
290 protected:
293 
296 
301 
305  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
306 
308 
312  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
313  vtkPolyData* output);
314  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
315  vtkPolyData* output);
316  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
317  vtkPolyData* input, vtkPolyData* output);
319 
321 
325  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
326  vtkPolyData* output);
327  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
328  vtkPolyData* output);
330 
332 
336  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
337  vtkPolyData* output);
338  void AddVertex(
339  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
341 
345  void InitializeQuadric(double quadric[9]);
346 
350  void AddQuadric(vtkIdType binId, double quadric[9]);
351 
358  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
359 
361 
368 
374 
375  // Unfinished option to handle boundary edges differently.
380 
384 
385  // Set this to eliminate duplicate cells
387  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
389 
390  // Used internally.
391  // can be smaller than user values when input numb er of points is small.
392  int NumberOfDivisions[3];
393 
394  // Since there are two was of specifying the grid, we have this flag
395  // to indicate which the user has set. When this flag is on,
396  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
398 
399  double DivisionOrigin[3];
400  double DivisionSpacing[3];
402 
403  double Bounds[6];
404  double XBinSize;
405  double YBinSize;
406  double ZBinSize;
407  double XBinStep; // replace some divisions with multiplication
408  double YBinStep;
409  double ZBinStep;
410  vtkIdType SliceSize; // eliminate one multiplication
411 
413  {
415  : VertexId(-1)
416  , Dimension(255)
417  {
418  }
419 
421  // Dimension is supposed to be a flag representing the dimension of the
422  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
423  // 0 in the future?)
424  unsigned char Dimension;
425  double Quadric[9];
426  };
427 
430 
431  // Have to make these instance variables if we are going to allow
432  // the algorithm to be driven by the Append methods.
435 
439 
443 
444 private:
446  void operator=(const vtkQuadricClustering&) = delete;
447 };
448 
449 VTK_ABI_NAMESPACE_END
450 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:297
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
a simple class to control print indentation
Definition: vtkIndent.h:120
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:150
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:201
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:248
@ points
Definition: vtkX3D.h:458
int vtkTypeBool
Definition: vtkABI.h:71
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
int vtkIdType
Definition: vtkType.h:327
#define VTK_SIZEHINT(...)