VTK  9.0.2
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 =========================================================================*/
85 #ifndef vtkQuadricClustering_h
86 #define vtkQuadricClustering_h
87 
88 #include "vtkFiltersCoreModule.h" // For export macro
89 #include "vtkPolyDataAlgorithm.h"
90 
91 class vtkCellArray;
92 class vtkFeatureEdges;
93 class vtkPoints;
94 class vtkQuadricClusteringCellSet;
95 
96 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
97 {
98 public:
100 
104  void PrintSelf(ostream& os, vtkIndent indent) override;
107 
109 
116  void SetNumberOfXDivisions(int num);
117  void SetNumberOfYDivisions(int num);
118  void SetNumberOfZDivisions(int num);
119  vtkGetMacro(NumberOfXDivisions, int);
120  vtkGetMacro(NumberOfYDivisions, int);
121  vtkGetMacro(NumberOfZDivisions, int);
122  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
123  void SetNumberOfDivisions(int div0, int div1, int div2);
125  void GetNumberOfDivisions(int div[3]);
127 
129 
134  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
135  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
136  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
138 
140 
146  void SetDivisionOrigin(double x, double y, double z);
147  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
148  vtkGetVector3Macro(DivisionOrigin, double);
149  void SetDivisionSpacing(double x, double y, double z);
150  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
151  vtkGetVector3Macro(DivisionSpacing, double);
153 
155 
163  vtkSetMacro(UseInputPoints, vtkTypeBool);
164  vtkGetMacro(UseInputPoints, vtkTypeBool);
165  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
167 
169 
175  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
176  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
177  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
178  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
180 
182 
189  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
190  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
191  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
193 
195 
199  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
200  vtkGetMacro(FeaturePointsAngle, double);
202 
204 
210  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
211  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
212  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
214 
216 
222  void StartAppend(double* bounds);
223  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
224  {
225  double b[6];
226  b[0] = x0;
227  b[1] = x1;
228  b[2] = y0;
229  b[3] = y1;
230  b[4] = z0;
231  b[5] = z1;
232  this->StartAppend(b);
233  }
234  void Append(vtkPolyData* piece);
235  void EndAppend();
237 
239 
245  vtkSetMacro(CopyCellData, vtkTypeBool);
246  vtkGetMacro(CopyCellData, vtkTypeBool);
247  vtkBooleanMacro(CopyCellData, vtkTypeBool);
249 
251 
257  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
258  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
259  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
261 
262 protected:
265 
268 
273 
277  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
278 
280 
284  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
285  vtkPolyData* output);
286  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
287  vtkPolyData* output);
288  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
289  vtkPolyData* input, vtkPolyData* output);
291 
293 
297  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
298  vtkPolyData* output);
299  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
300  vtkPolyData* output);
302 
304 
308  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
309  vtkPolyData* output);
310  void AddVertex(
311  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
313 
317  void InitializeQuadric(double quadric[9]);
318 
322  void AddQuadric(vtkIdType binId, double quadric[9]);
323 
330  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
331 
333 
340 
346 
347  // Unfinished option to handle boundary edges differently.
352 
356 
357  // Set this to eliminate duplicate cells
359  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
361 
362  // Used internally.
363  // can be smaller than user values when input numb er of points is small.
364  int NumberOfDivisions[3];
365 
366  // Since there are two was of specifying the grid, we have this flag
367  // to indicate which the user has set. When this flag is on,
368  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
370 
371  double DivisionOrigin[3];
372  double DivisionSpacing[3];
374 
375  double Bounds[6];
376  double XBinSize;
377  double YBinSize;
378  double ZBinSize;
379  double XBinStep; // replace some divisions with multiplication
380  double YBinStep;
381  double ZBinStep;
382  vtkIdType SliceSize; // eliminate one multiplication
383 
385  {
387  : VertexId(-1)
388  , Dimension(255)
389  {
390  }
391 
393  // Dimension is supposed to be a flag representing the dimension of the
394  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
395  // 0 in the future?)
396  unsigned char Dimension;
397  double Quadric[9];
398  };
399 
402 
403  // Have to make these instance variables if we are going to allow
404  // the algorithm to be driven by the Append methods.
407 
411 
415 
416 private:
418  void operator=(const vtkQuadricClustering&) = delete;
419 };
420 
421 #endif
object to represent cell connectivity
Definition: vtkCellArray.h:180
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:34
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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)
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.
vtkFeatureEdges * GetFeatureEdges()
void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output)
void SetDivisionSpacing(double s[3])
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])
void SetNumberOfDivisions(int div[3])
void InitializeQuadric(double quadric[9])
Initialize the quadric matrix to 0's.
void SetDivisionSpacing(double x, double y, double z)
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)
void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
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()
void AddQuadric(vtkIdType binId, double quadric[9])
Add this quadric to the quadric already associated with this bin.
void SetNumberOfYDivisions(int num)
static vtkQuadricClustering * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void AddEdges(vtkCellArray *edges, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add edges to the quadric array.
vtkTypeBool AutoAdjustNumberOfDivisions
void Append(vtkPolyData *piece)
void SetNumberOfDivisions(int div0, int div1, int div2)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void AddVertex(vtkIdType binId, double *pt, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag, vtkPolyData *input, vtkPolyData *output)
void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2, int geometeryFlag, vtkPolyData *input, vtkPolyData *output)
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:338
#define VTK_SIZEHINT(...)