VTK: Filters/Core/vtkQuadricClustering.h Source File

| 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
90 #ifndef vtkQuadricClustering_h
91 #define vtkQuadricClustering_h
92
93 #include "vtkFiltersCoreModule.h" // For export macro
94 #include "vtkPolyDataAlgorithm.h"
95
96 VTK_ABI_NAMESPACE_BEGIN
97 class vtkCellArray;
98 class vtkFeatureEdges;
99 class vtkPoints;
100 class vtkQuadricClusteringCellSet;
101
102 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
103 {
104 public:
106
109 static vtkQuadricClustering* New();
110 vtkTypeMacro(vtkQuadricClustering, vtkPolyDataAlgorithm);
111 void PrintSelf(ostream& os, vtkIndent indent) override;
113
115
122 void SetNumberOfXDivisions(int num);
123 void SetNumberOfYDivisions(int num);
124 void SetNumberOfZDivisions(int num);
125 vtkGetMacro(NumberOfXDivisions, int);
126 vtkGetMacro(NumberOfYDivisions, int);
127 vtkGetMacro(NumberOfZDivisions, int);
128 void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
129 void SetNumberOfDivisions(int div0, int div1, int div2);
130 int* GetNumberOfDivisions() VTK_SIZEHINT(3);
131 void GetNumberOfDivisions(int div[3]);
133
135
140 vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
141 vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
142 vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
144
146
152 void SetDivisionOrigin(double x, double y, double z);
153 void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
154 vtkGetVector3Macro(DivisionOrigin, double);
155 void SetDivisionSpacing(double x, double y, double z);
156 void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
157 vtkGetVector3Macro(DivisionSpacing, double);
159
161
169 vtkSetMacro(UseInputPoints, vtkTypeBool);
170 vtkGetMacro(UseInputPoints, vtkTypeBool);
171 vtkBooleanMacro(UseInputPoints, vtkTypeBool);
173
175
181 vtkSetMacro(UseFeatureEdges, vtkTypeBool);
182 vtkGetMacro(UseFeatureEdges, vtkTypeBool);
183 vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
184 vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
186
188
195 vtkSetMacro(UseFeaturePoints, vtkTypeBool);
196 vtkGetMacro(UseFeaturePoints, vtkTypeBool);
197 vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
199
201
205 vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
206 vtkGetMacro(FeaturePointsAngle, double);
208
210
216 vtkSetMacro(UseInternalTriangles, vtkTypeBool);
217 vtkGetMacro(UseInternalTriangles, vtkTypeBool);
218 vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
220
222
228 void StartAppend(double* bounds);
229 void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
230 {
231 double b[6];
232 b[0] = x0;
233 b[1] = x1;
234 b[2] = y0;
235 b[3] = y1;
236 b[4] = z0;
237 b[5] = z1;
238 this->StartAppend(b);
239 }
240 void Append(vtkPolyData* piece);
241 void EndAppend();
243
245
251 vtkSetMacro(CopyCellData, vtkTypeBool);
252 vtkGetMacro(CopyCellData, vtkTypeBool);
253 vtkBooleanMacro(CopyCellData, vtkTypeBool);
255
257
263 vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
264 vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
265 vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
267
268 protected:
269 vtkQuadricClustering();
270 ~vtkQuadricClustering() override;
271
272 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
273 int FillInputPortInformation(int, vtkInformation*) override;
274
278 vtkIdType HashPoint(double point[3]);
279
283 void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
284
286
290 void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
291 vtkPolyData* output);
292 void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
293 vtkPolyData* output);
294 void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
295 vtkPolyData* input, vtkPolyData* output);
297
299
303 void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
304 vtkPolyData* output);
305 void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
306 vtkPolyData* output);
308
310
314 void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
315 vtkPolyData* output);
316 void AddVertex(
317 vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
319
323 void InitializeQuadric(double quadric[9]);
324
328 void AddQuadric(vtkIdType binId, double quadric[9]);
329
336 void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
337
339
343 void EndAppendUsingPoints(vtkPolyData* input, vtkPolyData* output);
344 vtkTypeBool UseInputPoints;
346
351 void EndAppendVertexGeometry(vtkPolyData* input, vtkPolyData* output);
352
353 // Unfinished option to handle boundary edges differently.
354 void AppendFeatureQuadrics(vtkPolyData* pd, vtkPolyData* output);
355 vtkTypeBool UseFeatureEdges;
356 vtkTypeBool UseFeaturePoints;
357 vtkTypeBool UseInternalTriangles;
358
359 int NumberOfXDivisions;
360 int NumberOfYDivisions;
361 int NumberOfZDivisions;
362
363 // Set this to eliminate duplicate cells
364 vtkTypeBool PreventDuplicateCells;
365 vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
366 vtkIdType NumberOfBins;
367
368 // Used internally.
369 // can be smaller than user values when input numb er of points is small.
370 int NumberOfDivisions[3];
371
372 // Since there are two ways of specifying the grid, we have this flag
373 // to indicate which the user has set. When this flag is on,
374 // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
375 vtkTypeBool ComputeNumberOfDivisions;
376
377 double DivisionOrigin[3];
378 double DivisionSpacing[3];
379 vtkTypeBool AutoAdjustNumberOfDivisions;
380
381 double Bounds[6];
382 double XBinSize;
383 double YBinSize;
384 double ZBinSize;
385 double XBinStep; // replace some divisions with multiplication
386 double YBinStep;
387 double ZBinStep;
388 vtkIdType SliceSize; // eliminate one multiplication
389
390 struct PointQuadric
391 {
392 PointQuadric()
393 : VertexId(-1)
394 , Dimension(255)
395 {
396 }
397
398 vtkIdType VertexId;
399 // Dimension is supposed to be a flag representing the dimension of the
400 // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
401 // 0 in the future?)
402 unsigned char Dimension;
403 double Quadric[9];
404 };
405
406 PointQuadric* QuadricArray;
407 vtkIdType NumberOfBinsUsed;
408
409 // Have to make these instance variables if we are going to allow
410 // the algorithm to be driven by the Append methods.
411 vtkCellArray* OutputTriangleArray;
412 vtkCellArray* OutputLines;
413
414 vtkFeatureEdges* FeatureEdges;
415 vtkPoints* FeaturePoints;
416 double FeaturePointsAngle;
417
418 vtkTypeBool CopyCellData;
419 int InCellCount;
420 int OutCellCount;
421
422 private:
423 vtkQuadricClustering(const vtkQuadricClustering&) = delete;
424 void operator=(const vtkQuadricClustering&) = delete;
425 };
426
427 VTK_ABI_NAMESPACE_END
428 #endif
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:185
vtkFeatureEdges
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:49
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:43
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
vtkQuadricClustering
reduce the number of triangles in a mesh
Definition: vtkQuadricClustering.h:103
vtkQuadricClustering::OutCellCount
int OutCellCount
Definition: vtkQuadricClustering.h:420
vtkQuadricClustering::AddPolygons
void AddPolygons(vtkCellArray *polys, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add triangles to the quadric array.
vtkQuadricClustering::~vtkQuadricClustering
~vtkQuadricClustering() override
vtkQuadricClustering::SetNumberOfZDivisions
void SetNumberOfZDivisions(int num)
Set/Get the number of divisions along each axis for the spatial bins.
vtkQuadricClustering::CellSet
vtkQuadricClusteringCellSet * CellSet
Definition: vtkQuadricClustering.h:365
vtkQuadricClustering::OutputTriangleArray
vtkCellArray * OutputTriangleArray
Definition: vtkQuadricClustering.h:411
vtkQuadricClustering::UseFeatureEdges
vtkTypeBool UseFeatureEdges
Definition: vtkQuadricClustering.h:355
vtkQuadricClustering::FillInputPortInformation
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
vtkQuadricClustering::HashPoint
vtkIdType HashPoint(double point[3])
Given a point, determine what bin it falls into.
vtkQuadricClustering::FeaturePointsAngle
double FeaturePointsAngle
Definition: vtkQuadricClustering.h:416
vtkQuadricClustering::UseInputPoints
vtkTypeBool UseInputPoints
This method will rep[lace the quadric generated points with the input points with the lowest error.
Definition: vtkQuadricClustering.h:344
vtkQuadricClustering::GetFeatureEdges
vtkFeatureEdges * GetFeatureEdges()
By default, this flag is off.
Definition: vtkQuadricClustering.h:184
vtkQuadricClustering::AppendFeatureQuadrics
void AppendFeatureQuadrics(vtkPolyData *pd, vtkPolyData *output)
vtkQuadricClustering::EndAppend
void EndAppend()
These methods provide an alternative way of executing the filter.
vtkQuadricClustering::NumberOfYDivisions
int NumberOfYDivisions
Definition: vtkQuadricClustering.h:360
vtkQuadricClustering::SetDivisionSpacing
void SetDivisionSpacing(double s[3])
This is an alternative way to set up the bins.
Definition: vtkQuadricClustering.h:156
vtkQuadricClustering::FindFeaturePoints
void FindFeaturePoints(vtkCellArray *edges, vtkPoints *edgePts, double angle)
Find the feature points of a given set of edges.
vtkQuadricClustering::vtkQuadricClustering
vtkQuadricClustering()
vtkQuadricClustering::EndAppendVertexGeometry
void EndAppendVertexGeometry(vtkPolyData *input, vtkPolyData *output)
This method sets the vertices of the output.
vtkQuadricClustering::SetDivisionOrigin
void SetDivisionOrigin(double o[3])
This is an alternative way to set up the bins.
Definition: vtkQuadricClustering.h:153
vtkQuadricClustering::FeaturePoints
vtkPoints * FeaturePoints
Definition: vtkQuadricClustering.h:415
vtkQuadricClustering::SetNumberOfDivisions
void SetNumberOfDivisions(int div[3])
Set/Get the number of divisions along each axis for the spatial bins.
Definition: vtkQuadricClustering.h:128
vtkQuadricClustering::InitializeQuadric
void InitializeQuadric(double quadric[9])
Initialize the quadric matrix to 0's.
vtkQuadricClustering::InCellCount
int InCellCount
Definition: vtkQuadricClustering.h:419
vtkQuadricClustering::SetDivisionSpacing
void SetDivisionSpacing(double x, double y, double z)
This is an alternative way to set up the bins.
vtkQuadricClustering::ComputeRepresentativePoint
void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3])
Determine the representative point for this bin.
vtkQuadricClustering::FeatureEdges
vtkFeatureEdges * FeatureEdges
Definition: vtkQuadricClustering.h:414
vtkQuadricClustering::AddVertices
void AddVertices(vtkCellArray *verts, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add vertices to the quadric array.
vtkQuadricClustering::NumberOfBins
vtkIdType NumberOfBins
Definition: vtkQuadricClustering.h:366
vtkQuadricClustering::YBinStep
double YBinStep
Definition: vtkQuadricClustering.h:386
vtkQuadricClustering::ZBinStep
double ZBinStep
Definition: vtkQuadricClustering.h:387
vtkQuadricClustering::ZBinSize
double ZBinSize
Definition: vtkQuadricClustering.h:384
vtkQuadricClustering::StartAppend
void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
These methods provide an alternative way of executing the filter.
Definition: vtkQuadricClustering.h:229
vtkQuadricClustering::AddStrips
void AddStrips(vtkCellArray *strips, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add triangles to the quadric array.
vtkQuadricClustering::EndAppendUsingPoints
void EndAppendUsingPoints(vtkPolyData *input, vtkPolyData *output)
This method will rep[lace the quadric generated points with the input points with the lowest error.
vtkQuadricClustering::StartAppend
void StartAppend(double *bounds)
These methods provide an alternative way of executing the filter.
vtkQuadricClustering::GetNumberOfDivisions
int * GetNumberOfDivisions()
Set/Get the number of divisions along each axis for the spatial bins.
vtkQuadricClustering::AddQuadric
void AddQuadric(vtkIdType binId, double quadric[9])
Add this quadric to the quadric already associated with this bin.
vtkQuadricClustering::SetNumberOfYDivisions
void SetNumberOfYDivisions(int num)
Set/Get the number of divisions along each axis for the spatial bins.
vtkQuadricClustering::YBinSize
double YBinSize
Definition: vtkQuadricClustering.h:383
vtkQuadricClustering::New
static vtkQuadricClustering * New()
Standard instantiation, type and print methods.
vtkQuadricClustering::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard instantiation, type and print methods.
vtkQuadricClustering::AddEdges
void AddEdges(vtkCellArray *edges, vtkPoints *points, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add edges to the quadric array.
vtkQuadricClustering::AutoAdjustNumberOfDivisions
vtkTypeBool AutoAdjustNumberOfDivisions
Definition: vtkQuadricClustering.h:379
vtkQuadricClustering::UseFeaturePoints
vtkTypeBool UseFeaturePoints
Definition: vtkQuadricClustering.h:356
vtkQuadricClustering::PreventDuplicateCells
vtkTypeBool PreventDuplicateCells
Definition: vtkQuadricClustering.h:364
vtkQuadricClustering::ComputeNumberOfDivisions
vtkTypeBool ComputeNumberOfDivisions
Definition: vtkQuadricClustering.h:375
vtkQuadricClustering::Append
void Append(vtkPolyData *piece)
These methods provide an alternative way of executing the filter.
vtkQuadricClustering::SetNumberOfDivisions
void SetNumberOfDivisions(int div0, int div1, int div2)
Set/Get the number of divisions along each axis for the spatial bins.
vtkQuadricClustering::XBinSize
double XBinSize
Definition: vtkQuadricClustering.h:382
vtkQuadricClustering::NumberOfXDivisions
int NumberOfXDivisions
Definition: vtkQuadricClustering.h:359
vtkQuadricClustering::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkQuadricClustering::XBinStep
double XBinStep
Definition: vtkQuadricClustering.h:385
vtkQuadricClustering::SliceSize
vtkIdType SliceSize
Definition: vtkQuadricClustering.h:388
vtkQuadricClustering::AddVertex
void AddVertex(vtkIdType binId, double *pt, int geometryFlag, vtkPolyData *input, vtkPolyData *output)
Add vertices to the quadric array.
vtkQuadricClustering::NumberOfBinsUsed
vtkIdType NumberOfBinsUsed
Definition: vtkQuadricClustering.h:407
vtkQuadricClustering::AddEdge
void AddEdge(vtkIdType *binIds, double *pt0, double *pt1, int geometeryFlag, vtkPolyData *input, vtkPolyData *output)
Add edges to the quadric array.
vtkQuadricClustering::CopyCellData
vtkTypeBool CopyCellData
Definition: vtkQuadricClustering.h:418
vtkQuadricClustering::QuadricArray
PointQuadric * QuadricArray
Definition: vtkQuadricClustering.h:406
vtkQuadricClustering::UseInternalTriangles
vtkTypeBool UseInternalTriangles
Definition: vtkQuadricClustering.h:357
vtkQuadricClustering::OutputLines
vtkCellArray * OutputLines
Definition: vtkQuadricClustering.h:412
vtkQuadricClustering::AddTriangle
void AddTriangle(vtkIdType *binIds, double *pt0, double *pt1, double *pt2, int geometeryFlag, vtkPolyData *input, vtkPolyData *output)
Add triangles to the quadric array.
vtkQuadricClustering::NumberOfZDivisions
int NumberOfZDivisions
Definition: vtkQuadricClustering.h:361
vtkQuadricClustering::SetNumberOfXDivisions
void SetNumberOfXDivisions(int num)
Set/Get the number of divisions along each axis for the spatial bins.
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkX3D::points
@ points
Definition: vtkX3D.h:446
vtkQuadricClustering::PointQuadric
Definition: vtkQuadricClustering.h:391
vtkQuadricClustering::PointQuadric::VertexId
vtkIdType VertexId
Definition: vtkQuadricClustering.h:398
vtkQuadricClustering::PointQuadric::Dimension
unsigned char Dimension
Definition: vtkQuadricClustering.h:402
vtkQuadricClustering::PointQuadric::PointQuadric
PointQuadric()
Definition: vtkQuadricClustering.h:392
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
edges
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
Definition: vtkBoostGraphAdapter.h:993
vtkPolyDataAlgorithm.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:36