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