Ponca  292d8d7132745e0d4242ff9a01e93697fc96b204
Point Cloud Analysis library
Loading...
Searching...
No Matches
weingarten.h
1/*
2This 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#include "../concepts.h"
11
12#include "../../../Common/Solver/Eigen2x2Solver.h"
13
14#define FUNDAMENTAL_FORM_WEINGARTEN_ESTIMATOR_REQUIREMENTS \
15 ProvidesFirstFondamentalFormComponents<T>&& ProvidesSecondFondamentalFormComponents<T>&& Is3D<DataPoint>
16#define NORMAL_DERIVATIVE_WEINGARTEN_ESTIMATOR_REQUIREMENTS Is3D<DataPoint>&& ProvidesSpaceDerivative<T>
17#define WIENGARTEN_CURVATURE_ESTIMATOR_REQUIREMENTS \
18 ProvidesTangentPlaneBasis<T>&& ProvidesWeingartenMap<T>&& Is3D<DataPoint>
19
20namespace Ponca
21{
41 template <class DataPoint, class _NFilter, typename T>
42 requires FUNDAMENTAL_FORM_WEINGARTEN_ESTIMATOR_REQUIREMENTS
44 {
45 PONCA_FITTING_DECLARE_DEFAULT_TYPES
46 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
47
48 public:
52
57 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 firstFundamentalForm() const;
58
61 template <typename Matrix2Derived>
62 PONCA_MULTIARCH inline void firstFundamentalForm(Matrix2Derived& first) const;
63
68 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 secondFundamentalForm() const;
69
72 template <typename Matrix2Derived>
73 PONCA_MULTIARCH inline void secondFundamentalForm(Matrix2Derived& second) const;
74
79 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 weingartenMap() const;
80
83 template <typename Matrix2Derived>
84 PONCA_MULTIARCH inline void weingartenMap(Matrix2Derived& w) const;
85
87 PONCA_MULTIARCH inline Scalar kMean() const;
88
90 PONCA_MULTIARCH inline Scalar GaussianCurvature() const;
91 };
92
110 template <class DataPoint, class _NFilter, int DiffType, typename T>
111 requires NORMAL_DERIVATIVE_WEINGARTEN_ESTIMATOR_REQUIREMENTS
113 {
114 PONCA_FITTING_DECLARE_DEFAULT_TYPES
115 PONCA_FITTING_DECLARE_MATRIX_TYPE
116 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
117 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
118
119 private:
120 MatrixType m_tangentBasis{MatrixType::Zero()};
121
122 public:
123 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(NormalDerivativeWeingartenEstimator,
125 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(NormalDerivativeWeingartenEstimator, tangentPlaneBasis)
126 PONCA_FITTING_DECLARE_FINALIZE
127
128 PONCA_MULTIARCH inline void init()
129 {
130 Base::init();
131
132 // Reset basis to avoid dirty sharing
133 m_tangentBasis.setZero();
134 }
135
140 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 weingartenMap() const;
141
144 template <typename Matrix2Derived>
145 PONCA_MULTIARCH inline void weingartenMap(Matrix2Derived& w) const;
146
148 PONCA_MULTIARCH inline VectorType worldToTangentPlane(const VectorType& _q,
149 bool _isPositionVector = true) const;
150
152 PONCA_MULTIARCH inline VectorType tangentPlaneToWorld(const VectorType& _q,
153 bool _isPositionVector = true) const;
154
155 PONCA_MULTIARCH [[nodiscard]] inline bool operator==(
157 {
158 return Base::operator==(_other) && internal::isApprox(m_tangentBasis, _other.m_tangentBasis);
159 }
160 };
161
162 namespace internal
163 {
164
182 template <class DataPoint, class _NFilter, typename T>
183 requires WIENGARTEN_CURVATURE_ESTIMATOR_REQUIREMENTS
185 {
186 PONCA_FITTING_DECLARE_DEFAULT_TYPES
187 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
188
189 private:
190 Eigen2x2Solver<Scalar> m_solver; // W is not necessarily symmetric, see Eigen2x2Solver
191
192 public:
193 PONCA_FITTING_DECLARE_FINALIZE
194
195 PONCA_MULTIARCH inline void init()
196 {
197 Base::init();
198
199 // Reset solver to avoid dirty sharing
200 m_solver.computeDirect(Matrix2::Zero());
201 }
202
204 PONCA_MULTIARCH [[nodiscard]] inline Scalar kmin() const { return m_solver.eigenvalues().x(); }
205
207 PONCA_MULTIARCH [[nodiscard]] inline Scalar kmax() const { return m_solver.eigenvalues().y(); }
208
210 PONCA_MULTIARCH [[nodiscard]] inline VectorType kminDirection() const
211 {
212 VectorType vmin;
213 vmin(0) = Scalar(0); // set height
214 vmin.template bottomRows<2>() = m_solver.eigenvectors().col(0);
215 vmin = Base::tangentPlaneToWorld(vmin, false);
216 return vmin;
217 }
218
220 PONCA_MULTIARCH [[nodiscard]] inline VectorType kmaxDirection() const
221 {
222 VectorType vmax;
223 vmax(0) = Scalar(0); // set height
224 vmax.template bottomRows<2>() = m_solver.eigenvectors().col(1);
225 vmax = Base::tangentPlaneToWorld(vmax, false);
226 return vmax;
227 }
228
230 PONCA_MULTIARCH [[nodiscard]] inline Scalar kMean() const { return (kmin() + kmax()) / Scalar(2); }
231
233 PONCA_MULTIARCH [[nodiscard]] inline Scalar GaussianCurvature() const { return kmin() * kmax(); }
234
235 PONCA_MULTIARCH [[nodiscard]] inline bool operator==(
237 {
238 return Base::operator==(_other) && m_solver == _other.m_solver;
239 }
240 };
241 } // namespace internal
242
244 template <class DataPoint, class _NFilter, typename T>
246 {
247 PONCA_FITTING_DECLARE_DEFAULT_TYPES
248 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(WeingartenCurvatureEstimator, meanCurvature)
249 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(WeingartenCurvatureEstimator, curvatureTensor)
250 };
251
253 template <class DataPoint, class _NFilter, int DiffType, typename T>
254 struct WeingartenCurvatureEstimatorDer : public internal::WeingartenCurvatureEstimatorBase<DataPoint, _NFilter, T>
255 {
256 PONCA_FITTING_DECLARE_DEFAULT_TYPES
257 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
258 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, meanCurvature)
259 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, curvatureTensor)
260 };
261
262} // namespace Ponca
263
264#include "weingarten.hpp"
265
Compute a Weingarten map from fundamental forms.
Definition weingarten.h:44
Scalar GaussianCurvature() const
Returns an estimate of the Gaussian curvature directly from the fundamental forms.
FundamentalFormWeingartenEstimator< DataPoint, _NFilter, T > & firstFondamentalFormComponent()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:50
FundamentalFormWeingartenEstimator< DataPoint, _NFilter, T > & fundamentalFormWeingartenEstimator()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:49
Scalar kMean() const
Returns an estimate of the mean curvature directly from the fundamental forms.
Matrix2 weingartenMap() const
Returns the Weingarten Map.
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition weingarten.h:45
Matrix2 secondFundamentalForm() const
Assembles and returns the second fundamental form from the base class.
Matrix2 firstFundamentalForm() const
Assembles and returns the first fundamental form from the base class.
FundamentalFormWeingartenEstimator< DataPoint, _NFilter, T > & secondFondamentalFormComponent()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:51
Compute a Weingarten map from the spatial derivatives of the normal field .
Definition weingarten.h:113
NormalDerivativeWeingartenEstimator< DataPoint, _NFilter, DiffType, T > & tangentPlaneBasis()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:125
NormalDerivativeWeingartenEstimator< DataPoint, _NFilter, DiffType, T > & normalDerivativeWeingartenEstimator()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:124
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Definition weingarten.h:115
Closed-form eigen decomposition of a 2x2 matrix with real eigenvalues, not necessarily symmetric.
Compute principal curvatures from a base class providing fundamental forms.
Definition weingarten.h:185
Scalar GaussianCurvature() const
Returns an estimate of the Gaussian curvature.
Definition weingarten.h:233
typename Base::VectorType VectorType
Alias to vector type.
Definition weingarten.h:186
Scalar kmax() const
Returns an estimate of the maximal principal curvature value.
Definition weingarten.h:207
Scalar kmin() const
Returns an estimate of the minimal principal curvature value.
Definition weingarten.h:204
VectorType kmaxDirection() const
Returns an estimate of the maximal principal curvature direction.
Definition weingarten.h:220
Scalar kMean() const
Returns an estimate of the mean curvature.
Definition weingarten.h:230
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition weingarten.h:186
VectorType kminDirection() const
Returns an estimate of the minimal principal curvature direction.
Definition weingarten.h:210
Copyright (c) 2022 Jacques-Olivier Lachaud (jacques-olivier.lachaud@univ-savoie.fr) Laboratory of Mat...
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11
DiffType
Flags defining which derivatives need to be computed.
Definition enums.h:34
Compute principal curvatures from a base class providing fundamental forms.
Definition weingarten.h:255
WeingartenCurvatureEstimatorDer< DataPoint, _NFilter, DiffType, T > & curvatureTensor()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:259
WeingartenCurvatureEstimatorDer< DataPoint, _NFilter, DiffType, T > & meanCurvature()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:258
Compute principal curvatures from a base class providing fundamental forms.
Definition weingarten.h:246