Ponca  4a9354998d048bf882a3ee9bac8105216fa08d13
Point Cloud Analysis library
Loading...
Searching...
No Matches
mongePatch.hpp
1
2template <class DataPoint, class _NFilter, typename T>
3 requires MONGE_PATCH_FIT_REQUIREMENTS
5{
6 Base::init();
7
8 m_A = SampleMatrix(6, 6);
9 m_A.setZero();
10 m_b.setZero();
11}
12
13template <class DataPoint, class _NFilter, typename T>
14 requires MONGE_PATCH_FIT_REQUIREMENTS
16 const DataPoint& attributes)
17{
18 if (!Status::ready())
19 {
20 Base::addLocalNeighbor(w, localQ, attributes);
21 }
22 else // base plane is ready, we can now fit the patch
23 {
24 // express neighbor in local coordinate frame
25 const VectorType local = Base::worldToTangentPlane(attributes.pos());
26 const Scalar& h = Base::getHFromLocalCoordinates(local);
27 const Scalar& u = Base::getUFromLocalCoordinates(local);
28 const Scalar& v = Base::getVFromLocalCoordinates(local);
29
30 Eigen::Matrix<Scalar, 6, 1> p;
31 p << u * u, v * v, u * v, u, v, 1;
32 m_A += w * p * p.transpose();
33 m_b += w * h * p;
34 }
35}
36
37template <class DataPoint, class _NFilter, typename T>
38 requires MONGE_PATCH_FIT_REQUIREMENTS
40{
41 // end of the fitting process, check plane is ready
42 if (!Status::ready())
43 {
44 return Base::finalize();
45 }
46
47 // end of the monge patch fitting process
48 // we use BDCSVD as the matrix size is 36
49 // http://eigen.tuxfamily.org/dox/classEigen_1_1BDCSVD.html
50 Base::quadraticHeightField().setQuadric(
51 m_A.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV | Eigen::NoQRPreconditioner).solve(m_b));
52
53 return Base::m_eCurrentState = STABLE;
54}
55
56template <class DataPoint, class _NFilter, typename T>
57 requires MONGE_PATCH_FIT_REQUIREMENTS
59{
60 Base::init();
61
62 m_A = SampleMatrix(4, 4);
63 m_A.setZero();
64 m_b.setZero();
65}
66
67template <class DataPoint, class _NFilter, typename T>
68 requires MONGE_PATCH_FIT_REQUIREMENTS
70 const DataPoint& attributes)
71{
72 if (!Status::ready())
73 {
74 Base::addLocalNeighbor(w, localQ, attributes);
75 }
76 else // base plane is ready, we can now fit the patch
77 {
78 // express neighbor in local coordinate frame
79 const VectorType local = Base::worldToTangentPlane(attributes.pos());
80 const Scalar& h = Base::getHFromLocalCoordinates(local);
81 const Scalar& u = Base::getUFromLocalCoordinates(local);
82 const Scalar& v = Base::getVFromLocalCoordinates(local);
83
84 Eigen::Matrix<Scalar, 4, 1> p;
85 p << u * u, v * v, u * v, 1;
86 m_A += w * p * p.transpose();
87 m_b += w * h * p;
88 }
89}
90
91template <class DataPoint, class _NFilter, typename T>
92 requires MONGE_PATCH_FIT_REQUIREMENTS
94{
95 // end of the fitting process, check plane is ready
96 if (!Status::ready())
97 {
98 return Base::finalize();
99 }
100
101 // end of the monge patch fitting process
102 // we use SVD as the matrix size is 4x4, and skip preconditioner as it is squared
103 Base::quadraticHeightField().setQuadric(
104 m_A.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV | Eigen::NoQRPreconditioner).solve(m_b));
105
106 return Base::m_eCurrentState = STABLE;
107}
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:294
Extension to compute the best fit quadric on 3d points expressed as .
Definition mongePatch.h:137
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition mongePatch.h:138
typename Base::VectorType VectorType
Alias to vector type.
Definition mongePatch.h:138
Extension to compute the best fit restricted quadric on 3d points expressed as .
Definition mongePatch.h:163
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition mongePatch.h:164
typename Base::VectorType VectorType
Alias to vector type.
Definition mongePatch.h:164
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
Definition enums.h:15
@ STABLE
The fitting is stable and ready to use.
Definition enums.h:17