VTK  9.1.0
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=========================================================================*/
99#ifndef vtkQuadricClustering_h
100#define vtkQuadricClustering_h
101
102#include "vtkFiltersCoreModule.h" // For export macro
103#include "vtkPolyDataAlgorithm.h"
104
105class vtkCellArray;
106class vtkFeatureEdges;
107class vtkPoints;
108class vtkQuadricClusteringCellSet;
109
110class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
111{
112public:
114
119 void PrintSelf(ostream& os, vtkIndent indent) override;
121
123
133 vtkGetMacro(NumberOfXDivisions, int);
134 vtkGetMacro(NumberOfYDivisions, int);
135 vtkGetMacro(NumberOfZDivisions, int);
136 void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
137 void SetNumberOfDivisions(int div0, int div1, int div2);
139 void GetNumberOfDivisions(int div[3]);
141
143
148 vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
149 vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
150 vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
152
154
160 void SetDivisionOrigin(double x, double y, double z);
161 void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
162 vtkGetVector3Macro(DivisionOrigin, double);
163 void SetDivisionSpacing(double x, double y, double z);
164 void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
165 vtkGetVector3Macro(DivisionSpacing, double);
167
169
177 vtkSetMacro(UseInputPoints, vtkTypeBool);
178 vtkGetMacro(UseInputPoints, vtkTypeBool);
179 vtkBooleanMacro(UseInputPoints, vtkTypeBool);
181
183
189 vtkSetMacro(UseFeatureEdges, vtkTypeBool);
190 vtkGetMacro(UseFeatureEdges, vtkTypeBool);
191 vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
192 vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
194
196
203 vtkSetMacro(UseFeaturePoints, vtkTypeBool);
204 vtkGetMacro(UseFeaturePoints, vtkTypeBool);
205 vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
207
209
213 vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
214 vtkGetMacro(FeaturePointsAngle, double);
216
218
224 vtkSetMacro(UseInternalTriangles, vtkTypeBool);
225 vtkGetMacro(UseInternalTriangles, vtkTypeBool);
226 vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
228
230
236 void StartAppend(double* bounds);
237 void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
238 {
239 double b[6];
240 b[0] = x0;
241 b[1] = x1;
242 b[2] = y0;
243 b[3] = y1;
244 b[4] = z0;
245 b[5] = z1;
246 this->StartAppend(b);
247 }
248 void Append(vtkPolyData* piece);
249 void EndAppend();
251
253
259 vtkSetMacro(CopyCellData, vtkTypeBool);
260 vtkGetMacro(CopyCellData, vtkTypeBool);
261 vtkBooleanMacro(CopyCellData, vtkTypeBool);
263
265
271 vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
272 vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
273 vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
275
276protected:
279
282
287
291 void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
292
294
298 void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
299 vtkPolyData* output);
300 void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
301 vtkPolyData* output);
302 void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
303 vtkPolyData* input, vtkPolyData* output);
305
307
311 void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
312 vtkPolyData* output);
313 void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
314 vtkPolyData* output);
316
318
322 void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
323 vtkPolyData* output);
325 vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
327
331 void InitializeQuadric(double quadric[9]);
332
336 void AddQuadric(vtkIdType binId, double quadric[9]);
337
344 void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
345
347
354
360
361 // Unfinished option to handle boundary edges differently.
366
370
371 // Set this to eliminate duplicate cells
373 vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
375
376 // Used internally.
377 // can be smaller than user values when input numb er of points is small.
378 int NumberOfDivisions[3];
379
380 // Since there are two was of specifying the grid, we have this flag
381 // to indicate which the user has set. When this flag is on,
382 // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
384
385 double DivisionOrigin[3];
386 double DivisionSpacing[3];
388
389 double Bounds[6];
390 double XBinSize;
391 double YBinSize;
392 double ZBinSize;
393 double XBinStep; // replace some divisions with multiplication
394 double YBinStep;
395 double ZBinStep;
396 vtkIdType SliceSize; // eliminate one multiplication
397
399 {
401 : VertexId(-1)
402 , Dimension(255)
403 {
404 }
405
407 // Dimension is supposed to be a flag representing the dimension of the
408 // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
409 // 0 in the future?)
410 unsigned char Dimension;
411 double Quadric[9];
412 };
413
416
417 // Have to make these instance variables if we are going to allow
418 // the algorithm to be driven by the Append methods.
421
425
429
430private:
432 void operator=(const vtkQuadricClustering&) = delete;
433};
434
435#endif
object to represent cell connectivity
Definition: vtkCellArray.h:190
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
a simple class to control print indentation
Definition: vtkIndent.h:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:43
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
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.
void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output)
static vtkQuadricClustering * New()
Standard instantiation, type and print methods.
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.
vtkFeatureEdges * GetFeatureEdges()
By default, this flag is off.
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.
int * GetNumberOfDivisions()
Set/Get the number of divisions along each axis for the spatial bins.
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.
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.
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(...)