Ponca  aa50bfdf187919869239c5b44b748842569114c1
Point Cloud Analysis library
Loading...
Searching...
No Matches
mongePatch.h
1/*
2 This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8
9#include "./defines.h"
10
11#include <Eigen/Dense>
12
13namespace Ponca
14{
15
26template < class DataPoint, class _WFunctor, typename T>
27class MongePatch : public T
28{
29PONCA_FITTING_DECLARE_DEFAULT_TYPES
30
31protected:
32 enum { Check = Base::PROVIDES_PLANE && Base::PROVIDES_TANGENT_PLANE_BASIS };
33
34public:
35 using SampleMatrix = Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>;
36 using Vector6 = Eigen::Matrix<Scalar,6,1>;
37
38protected:
39 SampleMatrix m_A;
40 Vector6 m_x {Vector6::Zero()};
41 Vector6 m_b {Vector6::Zero()};
43 bool m_planeIsReady {false};
44public:
45 PONCA_EXPLICIT_CAST_OPERATORS(MongePatch,mongePatch)
46 PONCA_FITTING_DECLARE_INIT_ADD_FINALIZE
47
49 PONCA_MULTIARCH inline Scalar kMean() const;
50
52 PONCA_MULTIARCH inline Scalar GaussianCurvature() const;
53
54 PONCA_MULTIARCH inline Scalar evalUV(Scalar u, Scalar v) const {
55 return h_uu()*u*u + h_vv()*v*v + h_uv()*u*v + h_u()*u + h_v()*v + h_c();
56 }
57
60 PONCA_MULTIARCH inline Scalar potential(const VectorType& _q) const {
61 VectorType x = Base::worldToTangentPlane(_q);
62 return evalUV(*(x.data()+1),*(x.data()+2)) - *(x.data());
63 }
64
66 PONCA_MULTIARCH inline VectorType project (const VectorType& _q) const
67 {
68 VectorType x = Base::worldToTangentPlane(_q);
69 *(x.data()) = evalUV(*(x.data()+1),*(x.data()+2));
70 return Base::tangentPlaneToWorld(x);
71 }
72
73 PONCA_MULTIARCH inline const Scalar & h_uu () const { return *(m_x.data()); }
74 PONCA_MULTIARCH inline const Scalar & h_vv () const { return *(m_x.data()+1); }
75 PONCA_MULTIARCH inline const Scalar & h_uv () const { return *(m_x.data()+2); }
76 PONCA_MULTIARCH inline const Scalar & h_u () const { return *(m_x.data()+3); }
77 PONCA_MULTIARCH inline const Scalar & h_v () const { return *(m_x.data()+4); }
78 PONCA_MULTIARCH inline const Scalar & h_c () const { return *(m_x.data()+5); }
79
80};
81
82#include "mongePatch.hpp"
83
84} //namespace Ponca
Extension to compute the best fit quadric on 3d points expressed as .
Definition: mongePatch.h:28
MongePatch< DataPoint, _WFunctor, T > & mongePatch()
Explicit conversion to MongePatch , to access methods potentially hidden by heritage.
Definition: mongePatch.h:45
typename Base::VectorType VectorType
Alias to vector type.
Definition: mongePatch.h:29
Scalar GaussianCurvature() const
Returns an estimate of the Gaussian curvature.
Definition: mongePatch.hpp:84
SampleMatrix m_A
Quadric input samples.
Definition: mongePatch.h:39
Vector6 m_b
Observations.
Definition: mongePatch.h:41
Scalar kMean() const
Returns an estimate of the mean curvature.
Definition: mongePatch.hpp:73
VectorType project(const VectorType &_q) const
Orthogonal projecting on the patch, such that h = f(u,v)
Definition: mongePatch.h:66
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition: mongePatch.h:29
Vector6 m_x
Quadric parameters.
Definition: mongePatch.h:40
Scalar potential(const VectorType &_q) const
Value of the scalar field at the evaluation point.
Definition: mongePatch.h:60
This Source Code Form is subject to the terms of the Mozilla Public License, v.