Ponca  82fc77e8c6294111c6f00670e92ec58a24e2ecf2
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_CAST_OPERATORS_DER(NormalDerivativeWeingartenEstimator, normalDerivativeWeingartenEstimator)
122 PONCA_EXPLICIT_CAST_OPERATORS_DER(NormalDerivativeWeingartenEstimator, tangentPlaneBasis)
123 PONCA_FITTING_DECLARE_FINALIZE
124
129 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 weingartenMap() const;
130
133 template <typename Matrix2Derived>
134 PONCA_MULTIARCH inline void weingartenMap(Matrix2Derived& w) const;
135
137 PONCA_MULTIARCH inline VectorType worldToTangentPlane(const VectorType& _q,
138 bool _isPositionVector = true) const;
139
141 PONCA_MULTIARCH inline VectorType tangentPlaneToWorld(const VectorType& _q,
142 bool _isPositionVector = true) const;
143 };
144
145 namespace internal
146 {
164 template <class DataPoint, class _NFilter, typename T>
165 requires WIENGARTEN_CURVATURE_ESTIMATOR_REQUIREMENTS
167 {
168 PONCA_FITTING_DECLARE_DEFAULT_TYPES
169 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
170
171 private:
172 Eigen::SelfAdjointEigenSolver<Matrix2> m_solver;
173
174 public:
175 PONCA_FITTING_DECLARE_FINALIZE
176
178 PONCA_MULTIARCH [[nodiscard]] inline Scalar kmin() const { return m_solver.eigenvalues().x(); }
179
181 PONCA_MULTIARCH [[nodiscard]] inline Scalar kmax() const { return m_solver.eigenvalues().y(); }
182
184 PONCA_MULTIARCH [[nodiscard]] inline VectorType kminDirection() const
185 {
186 VectorType vmin;
187 vmin(0) = Scalar(0); // set height
188 vmin.template bottomRows<2>() = m_solver.eigenvectors().col(0);
189 vmin = Base::tangentPlaneToWorld(vmin, false);
190 return vmin;
191 }
192
194 PONCA_MULTIARCH [[nodiscard]] inline VectorType kmaxDirection() const
195 {
196 VectorType vmax;
197 vmax(0) = Scalar(0); // set height
198 vmax.template bottomRows<2>() = m_solver.eigenvectors().col(1);
199 vmax = Base::tangentPlaneToWorld(vmax, false);
200 return vmax;
201 }
202
204 PONCA_MULTIARCH [[nodiscard]] inline Scalar kMean() const { return (kmin() + kmax()) / Scalar(2); }
205
207 PONCA_MULTIARCH [[nodiscard]] inline Scalar GaussianCurvature() const { return kmin() * kmax(); }
208 };
209 } // namespace internal
210
212 template <class DataPoint, class _NFilter, typename T>
214 {
215 PONCA_FITTING_DECLARE_DEFAULT_TYPES
216 PONCA_EXPLICIT_CAST_OPERATORS(WeingartenCurvatureEstimator, meanCurvature)
217 PONCA_EXPLICIT_CAST_OPERATORS(WeingartenCurvatureEstimator, curvatureTensor)
218 };
219
221 template <class DataPoint, class _NFilter, int DiffType, typename T>
222 struct WeingartenCurvatureEstimatorDer : public internal::WeingartenCurvatureEstimatorBase<DataPoint, _NFilter, T>
223 {
224 PONCA_FITTING_DECLARE_DEFAULT_TYPES
225 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
226 PONCA_EXPLICIT_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, meanCurvature)
227 PONCA_EXPLICIT_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, curvatureTensor)
228 };
229
230} // namespace Ponca
231
232#include "weingarten.hpp"
233
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 FundamentalFormWeingartenEstimator , to access methods potentially hidden by h...
Definition weingarten.h:48
FundamentalFormWeingartenEstimator< DataPoint, _NFilter, T > & fundamentalFormWeingartenEstimator()
Explicit conversion to FundamentalFormWeingartenEstimator , to access methods potentially hidden by h...
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 FundamentalFormWeingartenEstimator , to access methods potentially hidden by h...
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:167
Scalar GaussianCurvature() const
Returns an estimate of the Gaussian curvature.
Definition weingarten.h:207
typename Base::VectorType VectorType
Alias to vector type.
Definition weingarten.h:168
Scalar kmax() const
Returns an estimate of the maximal principal curvature value.
Definition weingarten.h:181
Scalar kmin() const
Returns an estimate of the minimal principal curvature value.
Definition weingarten.h:178
VectorType kmaxDirection() const
Returns an estimate of the maximal principal curvature direction.
Definition weingarten.h:194
Scalar kMean() const
Returns an estimate of the mean curvature.
Definition weingarten.h:204
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition weingarten.h:168
VectorType kminDirection() const
Returns an estimate of the minimal principal curvature direction.
Definition weingarten.h:184
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:223
Compute principal curvatures from a base class providing fundamental forms.
Definition weingarten.h:214