VTK  9.0.20200714
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 =========================================================================*/
90 #ifndef vtkQuadricClustering_h
91 #define vtkQuadricClustering_h
92 
93 #include "vtkFiltersCoreModule.h" // For export macro
94 #include "vtkPolyDataAlgorithm.h"
95 
96 class vtkCellArray;
97 class vtkFeatureEdges;
98 class vtkPoints;
99 class vtkQuadricClusteringCellSet;
100 
101 class VTKFILTERSCORE_EXPORT vtkQuadricClustering : public vtkPolyDataAlgorithm
102 {
103 public:
105 
108  static vtkQuadricClustering* New();
110  void PrintSelf(ostream& os, vtkIndent indent) override;
112 
114 
121  void SetNumberOfXDivisions(int num);
122  void SetNumberOfYDivisions(int num);
123  void SetNumberOfZDivisions(int num);
124  vtkGetMacro(NumberOfXDivisions, int);
125  vtkGetMacro(NumberOfYDivisions, int);
126  vtkGetMacro(NumberOfZDivisions, int);
127  void SetNumberOfDivisions(int div[3]) { this->SetNumberOfDivisions(div[0], div[1], div[2]); }
128  void SetNumberOfDivisions(int div0, int div1, int div2);
129  int* GetNumberOfDivisions() VTK_SIZEHINT(3);
130  void GetNumberOfDivisions(int div[3]);
132 
134 
139  vtkSetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
140  vtkGetMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
141  vtkBooleanMacro(AutoAdjustNumberOfDivisions, vtkTypeBool);
143 
145 
151  void SetDivisionOrigin(double x, double y, double z);
152  void SetDivisionOrigin(double o[3]) { this->SetDivisionOrigin(o[0], o[1], o[2]); }
153  vtkGetVector3Macro(DivisionOrigin, double);
154  void SetDivisionSpacing(double x, double y, double z);
155  void SetDivisionSpacing(double s[3]) { this->SetDivisionSpacing(s[0], s[1], s[2]); }
156  vtkGetVector3Macro(DivisionSpacing, double);
158 
160 
168  vtkSetMacro(UseInputPoints, vtkTypeBool);
169  vtkGetMacro(UseInputPoints, vtkTypeBool);
170  vtkBooleanMacro(UseInputPoints, vtkTypeBool);
172 
174 
180  vtkSetMacro(UseFeatureEdges, vtkTypeBool);
181  vtkGetMacro(UseFeatureEdges, vtkTypeBool);
182  vtkBooleanMacro(UseFeatureEdges, vtkTypeBool);
183  vtkFeatureEdges* GetFeatureEdges() { return this->FeatureEdges; }
185 
187 
194  vtkSetMacro(UseFeaturePoints, vtkTypeBool);
195  vtkGetMacro(UseFeaturePoints, vtkTypeBool);
196  vtkBooleanMacro(UseFeaturePoints, vtkTypeBool);
198 
200 
204  vtkSetClampMacro(FeaturePointsAngle, double, 0.0, 180.0);
205  vtkGetMacro(FeaturePointsAngle, double);
207 
209 
215  vtkSetMacro(UseInternalTriangles, vtkTypeBool);
216  vtkGetMacro(UseInternalTriangles, vtkTypeBool);
217  vtkBooleanMacro(UseInternalTriangles, vtkTypeBool);
219 
221 
227  void StartAppend(double* bounds);
228  void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
229  {
230  double b[6];
231  b[0] = x0;
232  b[1] = x1;
233  b[2] = y0;
234  b[3] = y1;
235  b[4] = z0;
236  b[5] = z1;
237  this->StartAppend(b);
238  }
239  void Append(vtkPolyData* piece);
240  void EndAppend();
242 
244 
250  vtkSetMacro(CopyCellData, vtkTypeBool);
251  vtkGetMacro(CopyCellData, vtkTypeBool);
252  vtkBooleanMacro(CopyCellData, vtkTypeBool);
254 
256 
262  vtkSetMacro(PreventDuplicateCells, vtkTypeBool);
263  vtkGetMacro(PreventDuplicateCells, vtkTypeBool);
264  vtkBooleanMacro(PreventDuplicateCells, vtkTypeBool);
266 
267 protected:
269  ~vtkQuadricClustering() override;
270 
272  int FillInputPortInformation(int, vtkInformation*) override;
273 
277  vtkIdType HashPoint(double point[3]);
278 
282  void ComputeRepresentativePoint(double quadric[9], vtkIdType binId, double point[3]);
283 
285 
289  void AddPolygons(vtkCellArray* polys, vtkPoints* points, int geometryFlag, vtkPolyData* input,
290  vtkPolyData* output);
291  void AddStrips(vtkCellArray* strips, vtkPoints* points, int geometryFlag, vtkPolyData* input,
292  vtkPolyData* output);
293  void AddTriangle(vtkIdType* binIds, double* pt0, double* pt1, double* pt2, int geometeryFlag,
294  vtkPolyData* input, vtkPolyData* output);
296 
298 
302  void AddEdges(vtkCellArray* edges, vtkPoints* points, int geometryFlag, vtkPolyData* input,
303  vtkPolyData* output);
304  void AddEdge(vtkIdType* binIds, double* pt0, double* pt1, int geometeryFlag, vtkPolyData* input,
305  vtkPolyData* output);
307 
309 
313  void AddVertices(vtkCellArray* verts, vtkPoints* points, int geometryFlag, vtkPolyData* input,
314  vtkPolyData* output);
315  void AddVertex(
316  vtkIdType binId, double* pt, int geometryFlag, vtkPolyData* input, vtkPolyData* output);
318 
322  void InitializeQuadric(double quadric[9]);
323 
327  void AddQuadric(vtkIdType binId, double quadric[9]);
328 
335  void FindFeaturePoints(vtkCellArray* edges, vtkPoints* edgePts, double angle);
336 
338 
342  void EndAppendUsingPoints(vtkPolyData* input, vtkPolyData* output);
345 
350  void EndAppendVertexGeometry(vtkPolyData* input, vtkPolyData* output);
351 
352  // Unfinished option to handle boundary edges differently.
353  void AppendFeatureQuadrics(vtkPolyData* pd, vtkPolyData* output);
357 
361 
362  // Set this to eliminate duplicate cells
364  vtkQuadricClusteringCellSet* CellSet; // PIMPLd stl set for tracking inserted cells
366 
367  // Used internally.
368  // can be smaller than user values when input numb er of points is small.
369  int NumberOfDivisions[3];
370 
371  // Since there are two was of specifying the grid, we have this flag
372  // to indicate which the user has set. When this flag is on,
373  // the bin sizes are computed from the DivisionOrigin and DivisionSpacing.
375 
376  double DivisionOrigin[3];
377  double DivisionSpacing[3];
379 
380  double Bounds[6];
381  double XBinSize;
382  double YBinSize;
383  double ZBinSize;
384  double XBinStep; // replace some divisions with multiplication
385  double YBinStep;
386  double ZBinStep;
387  vtkIdType SliceSize; // eliminate one multiplication
388 
390  {
392  : VertexId(-1)
393  , Dimension(255)
394  {
395  }
396 
398  // Dimension is supposed to be a flag representing the dimension of the
399  // cells contributing to the quadric. Lines: 1, Triangles: 2 (and points
400  // 0 in the future?)
401  unsigned char Dimension;
402  double Quadric[9];
403  };
404 
407 
408  // Have to make these instance variables if we are going to allow
409  // the algorithm to be driven by the Append methods.
412 
416 
420 
421 private:
423  void operator=(const vtkQuadricClustering&) = delete;
424 };
425 
426 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkQuadricClustering::QuadricArray
PointQuadric * QuadricArray
Definition: vtkQuadricClustering.h:405
vtkQuadricClustering::NumberOfZDivisions
int NumberOfZDivisions
Definition: vtkQuadricClustering.h:360
vtkQuadricClustering::UseInternalTriangles
vtkTypeBool UseInternalTriangles
Definition: vtkQuadricClustering.h:356
vtkQuadricClustering::UseFeaturePoints
vtkTypeBool UseFeaturePoints
Definition: vtkQuadricClustering.h:355
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkQuadricClustering::UseInputPoints
vtkTypeBool UseInputPoints
Definition: vtkQuadricClustering.h:343
vtkQuadricClustering::ZBinSize
double ZBinSize
Definition: vtkQuadricClustering.h:383
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkQuadricClustering::OutCellCount
int OutCellCount
Definition: vtkQuadricClustering.h:419
vtkQuadricClustering::NumberOfYDivisions
int NumberOfYDivisions
Definition: vtkQuadricClustering.h:359
vtkQuadricClustering::FeatureEdges
vtkFeatureEdges * FeatureEdges
Definition: vtkQuadricClustering.h:413
vtkQuadricClustering::OutputTriangleArray
vtkCellArray * OutputTriangleArray
Definition: vtkQuadricClustering.h:410
vtkPolyDataAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkQuadricClustering::PointQuadric::VertexId
vtkIdType VertexId
Definition: vtkQuadricClustering.h:397
vtkPolyDataAlgorithm.h
vtkQuadricClustering::PointQuadric::PointQuadric
PointQuadric()
Definition: vtkQuadricClustering.h:391
vtkQuadricClustering::CopyCellData
vtkTypeBool CopyCellData
Definition: vtkQuadricClustering.h:417
vtkQuadricClustering::SetNumberOfDivisions
void SetNumberOfDivisions(int div[3])
Definition: vtkQuadricClustering.h:127
vtkX3D::points
Definition: vtkX3D.h:452
vtkQuadricClustering::AutoAdjustNumberOfDivisions
vtkTypeBool AutoAdjustNumberOfDivisions
Definition: vtkQuadricClustering.h:378
vtkX3D::point
Definition: vtkX3D.h:242
vtkQuadricClustering::PointQuadric
Definition: vtkQuadricClustering.h:389
vtkQuadricClustering::NumberOfXDivisions
int NumberOfXDivisions
Definition: vtkQuadricClustering.h:358
vtkQuadricClustering::SetDivisionSpacing
void SetDivisionSpacing(double s[3])
Definition: vtkQuadricClustering.h:155
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkPolyDataAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
vtkQuadricClustering::SliceSize
vtkIdType SliceSize
Definition: vtkQuadricClustering.h:387
vtkQuadricClustering::YBinStep
double YBinStep
Definition: vtkQuadricClustering.h:385
vtkQuadricClustering::GetFeatureEdges
vtkFeatureEdges * GetFeatureEdges()
Definition: vtkQuadricClustering.h:183
vtkQuadricClustering
reduce the number of triangles in a mesh
Definition: vtkQuadricClustering.h:101
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:180
vtkFeatureEdges
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:47
vtkQuadricClustering::NumberOfBinsUsed
vtkIdType NumberOfBinsUsed
Definition: vtkQuadricClustering.h:406
vtkPolyDataAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkQuadricClustering::FeaturePointsAngle
double FeaturePointsAngle
Definition: vtkQuadricClustering.h:415
vtkQuadricClustering::StartAppend
void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
Definition: vtkQuadricClustering.h:228
vtkQuadricClustering::CellSet
vtkQuadricClusteringCellSet * CellSet
Definition: vtkQuadricClustering.h:364
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkQuadricClustering::SetDivisionOrigin
void SetDivisionOrigin(double o[3])
Definition: vtkQuadricClustering.h:152
vtkQuadricClustering::YBinSize
double YBinSize
Definition: vtkQuadricClustering.h:382
vtkQuadricClustering::UseFeatureEdges
vtkTypeBool UseFeatureEdges
Definition: vtkQuadricClustering.h:354
vtkQuadricClustering::XBinSize
double XBinSize
Definition: vtkQuadricClustering.h:381
vtkQuadricClustering::OutputLines
vtkCellArray * OutputLines
Definition: vtkQuadricClustering.h:411
vtkQuadricClustering::NumberOfBins
vtkIdType NumberOfBins
Definition: vtkQuadricClustering.h:365
vtkQuadricClustering::PreventDuplicateCells
vtkTypeBool PreventDuplicateCells
Definition: vtkQuadricClustering.h:363
vtkQuadricClustering::InCellCount
int InCellCount
Definition: vtkQuadricClustering.h:418
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
edges
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
Definition: vtkBoostGraphAdapter.h:988
vtkQuadricClustering::ComputeNumberOfDivisions
int ComputeNumberOfDivisions
Definition: vtkQuadricClustering.h:374
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPolyDataAlgorithm::New
static vtkPolyDataAlgorithm * New()
vtkQuadricClustering::XBinStep
double XBinStep
Definition: vtkQuadricClustering.h:384
vtkQuadricClustering::PointQuadric::Dimension
unsigned char Dimension
Definition: vtkQuadricClustering.h:401
vtkQuadricClustering::ZBinStep
double ZBinStep
Definition: vtkQuadricClustering.h:386
vtkQuadricClustering::FeaturePoints
vtkPoints * FeaturePoints
Definition: vtkQuadricClustering.h:414
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41