Ponca  6f9f1b59d7c8c4654a710cfcef7342f4f5c79ba1
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>
14#define WIENGARTEN_CURVATURE_ESTIMATOR_REQUIREMENTS ProvidesTangentPlaneBasis<T>&& ProvidesWeingartenMap<T>
15
16namespace Ponca
17{
37 template <class DataPoint, class _NFilter, typename T>
38 requires FUNDAMENTAL_FORM_WEINGARTEN_ESTIMATOR_REQUIREMENTS
40 {
41 PONCA_FITTING_DECLARE_DEFAULT_TYPES
42 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
43 static_assert(DataPoint::Dim == 3, "FundamentalFormWeingartenEstimator is only valid in 3D");
44
45 public:
49
54 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 firstFundamentalForm() const;
55
60
65 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 secondFundamentalForm() const;
66
71
76 PONCA_MULTIARCH [[nodiscard]] inline Matrix2 weingartenMap() const;
77
81 PONCA_MULTIARCH inline void weingartenMap(Matrix2Derived& w) const;
82
84 PONCA_MULTIARCH inline Scalar kMean() const;
85
87 PONCA_MULTIARCH inline Scalar GaussianCurvature() const;
88 };
89
107 template <class DataPoint, class _NFilter, int DiffType, typename T>
109 {
110 PONCA_FITTING_DECLARE_DEFAULT_TYPES
111 PONCA_FITTING_DECLARE_MATRIX_TYPE
112 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
113 using Matrix2 = Eigen::Matrix<Scalar, 2, 2>;
114 static_assert(DataPoint::Dim == 3, "NormalDerivativeWeingartenEstimator is only valid in 3D");
115 static_assert(Base::isSpaceDer(), "NormalDerivativeWeingartenEstimator requires spatial derivation");
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
134 PONCA_MULTIARCH inline void weingartenMap(Matrix2Derived& w) const;
135
137 PONCA_MULTIARCH inline VectorType worldToTangentPlane(const VectorType& _q,
139
141 PONCA_MULTIARCH inline VectorType tangentPlaneToWorld(const VectorType& _q,
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 static_assert(DataPoint::Dim == 3, "WeingartenCurvatureEstimator is only valid in 3D");
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 {
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 {
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_CAST_OPERATORS(WeingartenCurvatureEstimator, meanCurvature)
218 PONCA_EXPLICIT_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_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, meanCurvature)
228 PONCA_EXPLICIT_CAST_OPERATORS_DER(WeingartenCurvatureEstimatorDer, curvatureTensor)
229 };
230
231} // namespace Ponca
232
233#include "weingarten.hpp"
234
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:260
Compute a Weingarten map from fundamental forms.
Definition weingarten.h:40
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:47
FundamentalFormWeingartenEstimator< DataPoint, _NFilter, T > & fundamentalFormWeingartenEstimator()
Explicit conversion to FundamentalFormWeingartenEstimator , to access methods potentially hidden by h...
Definition weingarten.h:46
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:41
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:48
Compute a Weingarten map from the spatial derivatives of the normal field .
Definition weingarten.h:109
typename Base::VectorType VectorType
Alias to vector type.
Definition weingarten.h:110
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Definition weingarten.h:111
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:208
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: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:168
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