VTK  9.2.6
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 =========================================================================*/
102 #ifndef vtkQuadricClustering_h
103 #define vtkQuadricClustering_h
104 
105 #include "vtkFiltersCoreModule.h" // For export macro
106 #include "vtkPolyDataAlgorithm.h"
107 
108 class vtkCellArray;
109 class vtkFeatureEdges;
110 class vtkPoints;
111 class vtkQuadricClusteringCellSet;
112 
113 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
114 {
115 public:
117 
122  void PrintSelf(ostream& os, vtkIndent indent) override;
124 
126 
133  void SetNumberOfXDivisions(int num);
134  void SetNumberOfYDivisions(int num);
135  void SetNumberOfZDivisions(int num);
136  vtkGetMacro(NumberOfXDivisions, int);
137  vtkGetMacro(NumberOfYDivisions, int);
138  vtkGetMacro(NumberOfZDivisions, int);
139  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
140  void SetNumberOfDivisions(int div0, int div1, int div2);
142  void GetNumberOfDivisions(int div[3]);
144 
146 
151  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
152  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
153  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
155 
157 
163  void SetDivisionOrigin(double x, double y, double z);
164  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
165  vtkGetVector3Macro(DivisionOrigin, double);
166  void SetDivisionSpacing(double x, double y, double z);
167  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
168  vtkGetVector3Macro(DivisionSpacing, double);
170 
172 
180  vtkSetMacro(UseInputPoints, vtkTypeBool);
181  vtkGetMacro(UseInputPoints, vtkTypeBool);
182  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
184 
186 
192  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
193  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
194  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
195  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
197 
199 
206  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
207  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
208  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
210 
212 
216  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
217  vtkGetMacro(FeaturePointsAngle, double);
219 
221 
227  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
228  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
229  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
231 
233 
239  void StartAppend(double* bounds);
240  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
241  {
242  double b[6];
243  b[0] = x0;
244  b[1] = x1;
245  b[2] = y0;
246  b[3] = y1;
247  b[4] = z0;
248  b[5] = z1;
249  this->StartAppend(b);
250  }
251  void Append(vtkPolyData* piece);
252  void EndAppend();
254 
256 
262  vtkSetMacro(CopyCellData, vtkTypeBool);
263  vtkGetMacro(CopyCellData, vtkTypeBool);
264  vtkBooleanMacro(CopyCellData, vtkTypeBool);
266 
268 
274  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
275  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
276  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
278 
279 protected:
282 
285 
290 
294  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
295 
297 
301  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
302  vtkPolyData* output);
303  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
304  vtkPolyData* output);
305  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
306  vtkPolyData* input, vtkPolyData* output);
308 
310 
314  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
315  vtkPolyData* output);
316  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
317  vtkPolyData* output);
319 
321 
325  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
326  vtkPolyData* output);
327  void AddVertex(
328  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
330 
334  void InitializeQuadric(double quadric[9]);
335 
339  void AddQuadric(vtkIdType binId, double quadric[9]);
340 
347  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
348 
350 
357 
363 
364  // Unfinished option to handle boundary edges differently.
369 
373 
374  // Set this to eliminate duplicate cells
376  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
378 
379  // Used internally.
380  // can be smaller than user values when input numb er of points is small.
381  int NumberOfDivisions[3];
382 
383  // Since there are two was of specifying the grid, we have this flag
384  // to indicate which the user has set. When this flag is on,
385  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
387 
388  double DivisionOrigin[3];
389  double DivisionSpacing[3];
391 
392  double Bounds[6];
393  double XBinSize;
394  double YBinSize;
395  double ZBinSize;
396  double XBinStep; // replace some divisions with multiplication
397  double YBinStep;
398  double ZBinStep;
399  vtkIdType SliceSize; // eliminate one multiplication
400 
402  {
404  : VertexId(-1)
405  , Dimension(255)
406  {
407  }
408 
410  // Dimension is supposed to be a flag representing the dimension of the
411  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
412  // 0 in the future?)
413  unsigned char Dimension;
414  double Quadric[9];
415  };
416 
419 
420  // Have to make these instance variables if we are going to allow
421  // the algorithm to be driven by the Append methods.
424 
428 
432 
433 private:
435  void operator=(const vtkQuadricClustering&) = delete;
436 };
437 
438 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:196
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
a simple class to control print indentation
Definition: vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:49
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:100
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:242
@ points
Definition: vtkX3D.h:452
int vtkTypeBool
Definition: vtkABI.h:69
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
int vtkIdType
Definition: vtkType.h:332
#define VTK_SIZEHINT(...)