VTK
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;
105  static vtkQuadricClustering* New();
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);
124  int* GetNumberOfDivisions() VTK_SIZEHINT(3);
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:
264  ~vtkQuadricClustering() override;
265 
267  int FillInputPortInformation(int, vtkInformation*) override;
268 
272  vtkIdType HashPoint(double point[3]);
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 
337  void EndAppendUsingPoints(vtkPolyData* input, vtkPolyData* output);
340 
345  void EndAppendVertexGeometry(vtkPolyData* input, vtkPolyData* output);
346 
347  // Unfinished option to handle boundary edges differently.
348  void AppendFeatureQuadrics(vtkPolyData* pd, vtkPolyData* output);
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
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkQuadricClustering::QuadricArray
PointQuadric * QuadricArray
Definition: vtkQuadricClustering.h:400
vtkQuadricClustering::NumberOfZDivisions
int NumberOfZDivisions
Definition: vtkQuadricClustering.h:355
vtkQuadricClustering::UseInternalTriangles
vtkTypeBool UseInternalTriangles
Definition: vtkQuadricClustering.h:351
vtkQuadricClustering::UseFeaturePoints
vtkTypeBool UseFeaturePoints
Definition: vtkQuadricClustering.h:350
vtkIdType
int vtkIdType
Definition: vtkType.h:343
vtkQuadricClustering::UseInputPoints
vtkTypeBool UseInputPoints
Definition: vtkQuadricClustering.h:338
vtkQuadricClustering::ZBinSize
double ZBinSize
Definition: vtkQuadricClustering.h:378
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkQuadricClustering::OutCellCount
int OutCellCount
Definition: vtkQuadricClustering.h:414
vtkQuadricClustering::NumberOfYDivisions
int NumberOfYDivisions
Definition: vtkQuadricClustering.h:354
vtkQuadricClustering::FeatureEdges
vtkFeatureEdges * FeatureEdges
Definition: vtkQuadricClustering.h:408
vtkQuadricClustering::OutputTriangleArray
vtkCellArray * OutputTriangleArray
Definition: vtkQuadricClustering.h:405
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:392
vtkPolyDataAlgorithm.h
vtkQuadricClustering::PointQuadric::PointQuadric
PointQuadric()
Definition: vtkQuadricClustering.h:386
vtkQuadricClustering::CopyCellData
vtkTypeBool CopyCellData
Definition: vtkQuadricClustering.h:412
vtkQuadricClustering::SetNumberOfDivisions
void SetNumberOfDivisions(int div[3])
Definition: vtkQuadricClustering.h:122
vtkX3D::points
Definition: vtkX3D.h:452
vtkQuadricClustering::AutoAdjustNumberOfDivisions
vtkTypeBool AutoAdjustNumberOfDivisions
Definition: vtkQuadricClustering.h:373
vtkX3D::point
Definition: vtkX3D.h:242
vtkQuadricClustering::PointQuadric
Definition: vtkQuadricClustering.h:384
vtkQuadricClustering::NumberOfXDivisions
int NumberOfXDivisions
Definition: vtkQuadricClustering.h:353
vtkQuadricClustering::SetDivisionSpacing
void SetDivisionSpacing(double s[3])
Definition: vtkQuadricClustering.h:150
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:382
vtkQuadricClustering::YBinStep
double YBinStep
Definition: vtkQuadricClustering.h:380
vtkQuadricClustering::GetFeatureEdges
vtkFeatureEdges * GetFeatureEdges()
Definition: vtkQuadricClustering.h:178
vtkQuadricClustering
reduce the number of triangles in a mesh
Definition: vtkQuadricClustering.h:96
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:179
vtkFeatureEdges
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:47
vtkQuadricClustering::NumberOfBinsUsed
vtkIdType NumberOfBinsUsed
Definition: vtkQuadricClustering.h:401
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:410
vtkQuadricClustering::StartAppend
void StartAppend(double x0, double x1, double y0, double y1, double z0, double z1)
Definition: vtkQuadricClustering.h:223
vtkQuadricClustering::CellSet
vtkQuadricClusteringCellSet * CellSet
Definition: vtkQuadricClustering.h:359
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:64
vtkQuadricClustering::SetDivisionOrigin
void SetDivisionOrigin(double o[3])
Definition: vtkQuadricClustering.h:147
vtkQuadricClustering::YBinSize
double YBinSize
Definition: vtkQuadricClustering.h:377
vtkQuadricClustering::UseFeatureEdges
vtkTypeBool UseFeatureEdges
Definition: vtkQuadricClustering.h:349
vtkQuadricClustering::XBinSize
double XBinSize
Definition: vtkQuadricClustering.h:376
vtkQuadricClustering::OutputLines
vtkCellArray * OutputLines
Definition: vtkQuadricClustering.h:406
vtkQuadricClustering::NumberOfBins
vtkIdType NumberOfBins
Definition: vtkQuadricClustering.h:360
vtkQuadricClustering::PreventDuplicateCells
vtkTypeBool PreventDuplicateCells
Definition: vtkQuadricClustering.h:358
vtkQuadricClustering::InCellCount
int InCellCount
Definition: vtkQuadricClustering.h:413
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
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:369
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPolyDataAlgorithm::New
static vtkPolyDataAlgorithm * New()
vtkQuadricClustering::XBinStep
double XBinStep
Definition: vtkQuadricClustering.h:379
vtkQuadricClustering::PointQuadric::Dimension
unsigned char Dimension
Definition: vtkQuadricClustering.h:396
vtkQuadricClustering::ZBinStep
double ZBinStep
Definition: vtkQuadricClustering.h:381
vtkQuadricClustering::FeaturePoints
vtkPoints * FeaturePoints
Definition: vtkQuadricClustering.h:409
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41