MeshLib C++ Docs
Loading...
Searching...
No Matches
MRCylinderApproximator.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include <MRPch/MREigenCore.h>
5
7
8namespace MR
9{
12
13
14template <typename T>
16{
17private:
18 enum class CylinderFitterType
19 {
23
26 SpecificAxisFit
27
31 };
32
33 CylinderFitterType fitter_ = CylinderFitterType::HemisphereSearchFit;
34
36 Eigen::Vector<T, 3> baseCylinderAxis_;
37
39 size_t thetaResolution_ = 0;
40 size_t phiResolution_ = 0;
41 bool isMultithread_ = true;
42
44 std::vector<Eigen::Vector<T, 3>> normalizedPoints_ = {};
45
53
54 Eigen::Vector <T, 6> precomputedMu_ = {};
55 Eigen::Matrix <T, 3, 3> precomputedF0_ = {};
56 Eigen::Matrix <T, 3, 6> precomputedF1_ = {};
57 Eigen::Matrix <T, 6, 6> precomputedF2_ = {};
58
59public:
61
62 MRMESH_API void reset();
63
66 MRMESH_API T solveGeneral( const std::vector<MR::Vector3<T>>& points, Cylinder3<T>& cylinder, size_t theta = 180, size_t phi = 90, bool isMultithread = true );
67
70 MRMESH_API T solveSpecificAxis( const std::vector<MR::Vector3<T>>& points, Cylinder3<T>& cylinder, MR::Vector3<T> const& cylinderAxis );
71
72private:
74 T solve( const std::vector<MR::Vector3<T>>& points, Cylinder3<T>& cylinder );
75
76 void updatePrecomputeParams( const std::vector <MR::Vector3<T>>& points, Vector3<T>& average );
77
82 T G( const Eigen::Vector<T, 3>& W, Eigen::Vector<T, 3>& PC, T& rsqr ) const;
83
84 T fitCylindeHemisphereSingleThreaded( Eigen::Vector<T, 3>& PC, Eigen::Vector<T, 3>& W, T& resultedRootSquare ) const;
85
86 class BestHemisphereStoredData
87 {
88 public:
89 T error = std::numeric_limits<T>::max();
90 T rootSquare = std::numeric_limits<T>::max();
91 Eigen::Vector<T, 3> W;
92 Eigen::Vector<T, 3> PC;
93 };
94
95 T fitCylindeHemisphereMultiThreaded( Eigen::Vector<T, 3>& PC, Eigen::Vector<T, 3>& W, T& resultedRootSquare ) const;
96
97 T SpecificAxisFit( Eigen::Vector<T, 3>& PC, Eigen::Vector<T, 3>& W, T& resultedRootSquare );
98};
99
100}
Definition MRCylinderApproximator.h:16
Definition MRCylinder3.h:15
T rootSquare
Definition MRCylinderApproximator.h:90
MRMESH_API T solveSpecificAxis(const std::vector< MR::Vector3< T > > &points, Cylinder3< T > &cylinder, MR::Vector3< T > const &cylinderAxis)
Eigen::Vector< T, 3 > PC
Definition MRCylinderApproximator.h:92
T error
Definition MRCylinderApproximator.h:89
Eigen::Vector< T, 3 > W
Definition MRCylinderApproximator.h:91
MRMESH_API void reset()
MRMESH_API Cylinder3Approximation()
MRMESH_API T solveGeneral(const std::vector< MR::Vector3< T > > &points, Cylinder3< T > &cylinder, size_t theta=180, size_t phi=90, bool isMultithread=true)
@ HemisphereSearchFit
approximation of cone axis by principal component method
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRVector3.h:33