Ponca  fd5150bf9079aabdb82a6f05e419b76111c1f788
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#define FUNDAMENTAL_FORM_WEINGARTEN_ESTIMATOR_REQUIREMENTS \
13 ProvidesFirstFondamentalFormComponents<T>&& ProvidesSecondFondamentalFormComponents<T>&& Is3D<DataPoint>
14#define NORMAL_DERIVATIVE_WEINGARTEN_ESTIMATOR_REQUIREMENTS Is3D<DataPoint>&& ProvidesSpaceDerivative<T>
15#define WIENGARTEN_CURVATURE_ESTIMATOR_REQUIREMENTS \
16 ProvidesTangentPlaneBasis<T>&& ProvidesWeingartenMap<T>&& Is3D<DataPoint>
17
18namespace Ponca
19{
39 template <class DataPoint, class _NFilter, typename T>
40 requires FUNDAMENTAL_FORM_WEINGARTEN_ESTIMATOR_REQUIREMENTS
42 {
43 PONCA_FITTING_DECLARE_DEFAULT_TYPES
44 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
45
46 public:
50
55 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 firstFundamentalForm() const;
56
59 template <typename Matrix2Derived>
60 PONCA_MULTIARCH inline void firstFundamentalForm(Matrix2Derived& first) const;
61
66 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 secondFundamentalForm() const;
67
70 template <typename Matrix2Derived>
71 PONCA_MULTIARCH inline void secondFundamentalForm(Matrix2Derived& second) const;
72
77 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 weingartenMap() const;
78
81 template <typename Matrix2Derived>
82 PONCA_MULTIARCH inline void weingartenMap(Matrix2Derived& w) const;
83
85 PONCA_MULTIARCH inline Scalar kMean() const;
86
88 PONCA_MULTIARCH inline Scalar GaussianCurvature() const;
89 };
90
108 template <class DataPoint, class _NFilter, int DiffType, typename T>
109 requires NORMAL_DERIVATIVE_WEINGARTEN_ESTIMATOR_REQUIREMENTS
111 {
112 PONCA_FITTING_DECLARE_DEFAULT_TYPES
113 PONCA_FITTING_DECLARE_MATRIX_TYPE
114 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
115 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
116
117 private:
118 MatrixType m_tangentBasis{MatrixType::Zero()};
119
120 public:
121 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(NormalDerivativeWeingartenEstimator,
122 normalDerivativeWeingartenEstimator)
123 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(NormalDerivativeWeingartenEstimator, tangentPlaneBasis)
124 PONCA_FITTING_DECLARE_FINALIZE
125
130 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 weingartenMap() const;
131
134 template <typename Matrix2Derived>
135 PONCA_MULTIARCH inline void weingartenMap(Matrix2Derived& w) const;
136
138 PONCA_MULTIARCH inline VectorType worldToTangentPlane(const VectorType& _q,
139 bool _isPositionVector = true) const;
140
142 PONCA_MULTIARCH inline VectorType tangentPlaneToWorld(const VectorType& _q,
143 bool _isPositionVector = true) const;
144 };
145
146 namespace internal
147 {
165 template <class DataPoint, class _NFilter, typename T>
166 requires WIENGARTEN_CURVATURE_ESTIMATOR_REQUIREMENTS
168 {
169 PONCA_FITTING_DECLARE_DEFAULT_TYPES
170 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
171
172 private:
173 Eigen::SelfAdjointEigenSolver<Matrix2> m_solver;
174
175 public:
176 PONCA_FITTING_DECLARE_FINALIZE
177
179 PONCA_MULTIARCH [[nodiscard]] inline Scalar kmin() const { return m_solver.eigenvalues().x(); }
180
182 PONCA_MULTIARCH [[nodiscard]] inline Scalar kmax() const { return m_solver.eigenvalues().y(); }
183
185 PONCA_MULTIARCH [[nodiscard]] inline VectorType kminDirection() const
186 {
187 VectorType vmin;
188 vmin(0) = Scalar(0); // set height
189 vmin.template bottomRows<2>() = m_solver.eigenvectors().col(0);
190 vmin = Base::tangentPlaneToWorld(vmin, false);
191 return vmin;
192 }
193
195 PONCA_MULTIARCH [[nodiscard]] inline VectorType kmaxDirection() const
196 {
197 VectorType vmax;
198 vmax(0) = Scalar(0); // set height
199 vmax.template bottomRows<2>() = m_solver.eigenvectors().col(1);
200 vmax = Base::tangentPlaneToWorld(vmax, false);
201 return vmax;
202 }
203
205 PONCA_MULTIARCH [[nodiscard]] inline Scalar kMean() const { return (kmin() + kmax()) / Scalar(2); }
206
208 PONCA_MULTIARCH [[nodiscard]] inline Scalar GaussianCurvature() const { return kmin() * kmax(); }
209 };
210 } // namespace internal
211
213 template <class DataPoint, class _NFilter, typename T>
215 {
216 PONCA_FITTING_DECLARE_DEFAULT_TYPES
217 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(WeingartenCurvatureEstimator, meanCurvature)
218 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(WeingartenCurvatureEstimator, curvatureTensor)
219 };
220
222 template <class DataPoint, class _NFilter, int DiffType, typename T>
223 struct WeingartenCurvatureEstimatorDer : public internal::WeingartenCurvatureEstimatorBase<DataPoint, _NFilter, T>
224 {
225 PONCA_FITTING_DECLARE_DEFAULT_TYPES
226 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
227 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, meanCurvature)
228 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, curvatureTensor)
229 };
230
231} // namespace Ponca
232
233#include "weingarten.hpp"
234
Compute a Weingarten map from fundamental forms.
Definition weingarten.h:42
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:48
FundamentalFormWeingartenEstimator< DataPoint, _NFilter, T > & fundamentalFormWeingartenEstimator()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition weingarten.h:47
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:43
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:49
Compute a Weingarten map from the spatial derivatives of the normal field .
Definition weingarten.h:111
typename Base::VectorType VectorType
Alias to vector type.
Definition weingarten.h:112
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Definition weingarten.h:113
Compute principal curvatures from a base class providing fundamental forms.
Definition weingarten.h:168
Scalar GaussianCurvature() const
Returns an estimate of the Gaussian curvature.
Definition weingarten.h:208
typename Base::VectorType VectorType
Alias to vector type.
Definition weingarten.h:169
Scalar kmax() const
Returns an estimate of the maximal principal curvature value.
Definition weingarten.h:182
Scalar kmin() const
Returns an estimate of the minimal principal curvature value.
Definition weingarten.h:179
VectorType kmaxDirection() const
Returns an estimate of the maximal principal curvature direction.
Definition weingarten.h:195
Scalar kMean() const
Returns an estimate of the mean curvature.
Definition weingarten.h:205
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition weingarten.h:169
VectorType kminDirection() const
Returns an estimate of the minimal principal curvature direction.
Definition weingarten.h:185
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:224
Compute principal curvatures from a base class providing fundamental forms.
Definition weingarten.h:215