VTK  9.7.1
vtkPCANormalEstimation.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
65 #ifndef vtkPCANormalEstimation_h
66 #define vtkPCANormalEstimation_h
67 
68 #include "vtkConvertToPointCloud.h" // For adding cells to output polydata
69 #include "vtkFiltersPointsModule.h" // For export macro
70 #include "vtkPolyDataAlgorithm.h"
71 #include "vtkSmartPointer.h" // For vtkSmartPointer
72 #include "vtkStaticPointLocator.h" // For default locator
73 
74 VTK_ABI_NAMESPACE_BEGIN
76 class vtkIdList;
77 struct vtkOrientNormalsWorker;
78 
79 class VTKFILTERSPOINTS_EXPORT vtkPCANormalEstimation : public vtkPolyDataAlgorithm
80 {
81 public:
83 
87  static vtkPCANormalEstimation* New();
89  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
95  typedef enum
96  {
97  KNN = 0,
98  RADIUS = 1
99  } NeighborSearchMode;
100 
102 
116  vtkSetMacro(SearchMode, int);
117  vtkGetMacro(SearchMode, int);
118  void SetSearchModeToKNN() { this->SetSearchMode(KNN); }
119  void SetSearchModeToRadius() { this->SetSearchMode(RADIUS); }
121 
123 
129  vtkSetClampMacro(SampleSize, int, 1, VTK_INT_MAX);
130  vtkGetMacro(SampleSize, int);
132 
134 
140  vtkSetMacro(Radius, double);
141  vtkGetMacro(Radius, double);
143 
147  enum Style
148  {
149  AS_COMPUTED = 0,
150  POINT = 1,
151  GRAPH_TRAVERSAL = 3
152  };
153 
155 
167  vtkSetMacro(NormalOrientation, int);
168  vtkGetMacro(NormalOrientation, int);
169  void SetNormalOrientationToAsComputed() { this->SetNormalOrientation(AS_COMPUTED); }
170  void SetNormalOrientationToPoint() { this->SetNormalOrientation(POINT); }
171  void SetNormalOrientationToGraphTraversal() { this->SetNormalOrientation(GRAPH_TRAVERSAL); }
173 
175 
181  vtkSetVector3Macro(OrientationPoint, double);
182  vtkGetVectorMacro(OrientationPoint, double, 3);
184 
186 
189  vtkSetMacro(FlipNormals, bool);
190  vtkGetMacro(FlipNormals, bool);
191  vtkBooleanMacro(FlipNormals, bool);
193 
195 
200  void SetLocator(vtkAbstractPointLocator* locator);
201  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
203 
205 
215  vtkSetMacro(CellGenerationMode, int);
216  vtkGetMacro(CellGenerationMode, int);
218 
219 protected:
220  vtkPCANormalEstimation() = default;
221  ~vtkPCANormalEstimation() override;
222 
223  // IVars
224  int SampleSize = 25;
225  double Radius = 0.; // Radius is not checked by default (in meter)
227  int SearchMode = vtkPCANormalEstimation::KNN;
228  int NormalOrientation = vtkPCANormalEstimation::POINT;
229  double OrientationPoint[3] = { 0. };
230  bool FlipNormals = false;
231  int CellGenerationMode = vtkConvertToPointCloud::NO_CELLS;
232 
233  // Methods used to produce consistent normal orientations
234  template <typename TPointsRange>
235  void TraverseAndFlip(
236  TPointsRange& inPts, float* normals, char* pointMap, vtkIdList* wave, vtkIdList* wave2);
237 
238  // Pipeline management
240  int FillInputPortInformation(int port, vtkInformation* info) override;
241 
242 private:
244  void operator=(const vtkPCANormalEstimation&) = delete;
245 
246  friend struct vtkOrientNormalsWorker;
247 };
248 
249 VTK_ABI_NAMESPACE_END
250 #endif
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
#define VTK_INT_MAX
Definition: vtkType.h:192
void SetNormalOrientationToPoint()
Configure how the filter addresses consistency in normal oreientation.
static vtkPolyDataAlgorithm * New()
void SetNormalOrientationToGraphTraversal()
Configure how the filter addresses consistency in normal oreientation.
Superclass for algorithms that produce only polydata as output.
generate point normals using local tangent planes
void SetSearchModeToKNN()
Configure how the filter selects the neighbor points used to calculate the PCA.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:25
static vtkStaticPointLocator * New()
Construct with automatic computation of divisions, averaging 5 points per bucket. ...
void SetNormalOrientationToAsComputed()
Configure how the filter addresses consistency in normal oreientation.
Style
This enum is used to control how normals oriented is controlled.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store zero or more vtkInformation instances.
void SetSearchModeToRadius()
Configure how the filter selects the neighbor points used to calculate the PCA.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.