ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
GeometricalAnalysisTools.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "DgmOctree.h"
12 #include "Neighbourhood.h"
13 
14 namespace cloudViewer {
15 
16 class GenericProgressCallback;
17 class GenericCloud;
18 class ScalarField;
19 
23 public:
27  LocalDensity,
29  ApproxLocalDensity,
32  MomentOrder1
33  };
34 
36  enum Density {
37  DENSITY_KNN =
38  1,
39  DENSITY_2D,
42  DENSITY_3D,
44  };
45 
46  enum ErrorCode {
47  NoError = 0,
48  InvalidInput = -1,
49  NotEnoughPoints = -2,
50  OctreeComputationFailed = -3,
51  ProcessFailed = -4,
52  UnhandledCharacteristic = -5,
53  NotEnoughMemory = -6,
54  ProcessCancelledByUser = -7
55  };
57 
68  static ErrorCode ComputeCharactersitic(
69  GeomCharacteristic c,
70  int subOption,
72  PointCoordinateType kernelRadius,
73  const CCVector3* roughnessUpDir = nullptr,
74  GenericProgressCallback* progressCb = nullptr,
75  DgmOctree* inputOctree = nullptr);
76 
78 
88  static ErrorCode ComputeLocalDensityApprox(
90  Density densityType,
91  GenericProgressCallback* progressCb = nullptr,
92  DgmOctree* inputOctree = nullptr);
93 
95 
99  static CCVector3 ComputeGravityCenter(const GenericCloud* theCloud);
100 
102 
107  static CCVector3 ComputeWeightedGravityCenter(GenericCloud* theCloud,
108  ScalarField* weights);
109 
111 
117  static SquareMatrixd ComputeCrossCovarianceMatrix(
118  GenericCloud* P,
119  GenericCloud* Q,
120  const CCVector3& pGravityCenter,
121  const CCVector3& qGravityCenter);
122 
125 
132  static SquareMatrixd ComputeWeightedCrossCovarianceMatrix(
133  GenericCloud* P,
134  GenericCloud* Q,
135  const CCVector3& pGravityCenter,
136  const CCVector3& qGravityCenter,
137  ScalarField* coupleWeights = nullptr);
138 
140 
145  static cloudViewer::SquareMatrixd ComputeCovarianceMatrix(
146  const GenericCloud* theCloud,
147  const PointCoordinateType* _gravityCenter = nullptr);
148 
150 
158  static ErrorCode FlagDuplicatePoints(
159  GenericIndexedCloudPersist* theCloud,
160  double minDistanceBetweenPoints =
161  std::numeric_limits<double>::epsilon(),
162  GenericProgressCallback* progressCb = nullptr,
163  DgmOctree* inputOctree = nullptr);
164 
166 
180  static ErrorCode DetectSphereRobust(
182  double outliersRatio,
183  CCVector3& center,
184  PointCoordinateType& radius,
185  double& rms,
186  GenericProgressCallback* progressCb = nullptr,
187  double confidence = 0.99,
188  unsigned seed = 0);
189 
191 
199  static ErrorCode ComputeSphereFrom4(const CCVector3& A,
200  const CCVector3& B,
201  const CCVector3& C,
202  const CCVector3& D,
203  CCVector3& center,
204  PointCoordinateType& radius);
205 
207 
214  static ErrorCode DetectCircle(
216  CCVector3& center,
217  CCVector3& normal,
218  PointCoordinateType& radius,
219  double& rms,
220  GenericProgressCallback* progressCb = nullptr);
221 
222 protected:
224 
229  static bool ComputeGeomCharacteristicAtLevel(
230  const DgmOctree::octreeCell& cell,
231  void** additionalParameters,
232  NormalizedProgress* nProgress = nullptr);
234 
239  static bool ComputeApproxPointsDensityInACellAtLevel(
240  const DgmOctree::octreeCell& cell,
241  void** additionalParameters,
242  NormalizedProgress* nProgress = nullptr);
243 
245 
250  static bool FlagDuplicatePointsInACellAtLevel(
251  const DgmOctree::octreeCell& cell,
252  void** additionalParameters,
253  NormalizedProgress* nProgress = nullptr);
254 
256  static bool RefineSphereLS(GenericIndexedCloudPersist* cloud,
257  CCVector3& center,
258  PointCoordinateType& radius,
259  double minReltaiveCenterShift = 1.0e-3);
260 };
261 
262 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
double normal[3]
Empty class - for classification purpose only.
Definition: CVToolbox.h:15
The octree structure used throughout the library.
Definition: DgmOctree.h:39
A generic 3D point cloud with index-based and presistent access to points.
A simple scalar field (to be associated to a point cloud)
Definition: ScalarField.h:25
Generic file read and write utility for python interface.
ErrorCode
Numeric error identifiers used in E57Exception.
Definition: E57Exception.h:40
cloudViewer::NormalizedProgress * nProgress
Octree cell descriptor.
Definition: DgmOctree.h:354