Ponca  cb266528645085a12930c827fbb8336cd937ecbb
Point Cloud Analysis library
Loading...
Searching...
No Matches
gls.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#include "../concepts.h"
11
13#define GLS_PARAM_REQUIREMENTS ProvidesAlgebraicSphere<T>
15
16#define GLS_DER_REQUIREMENTS ProvidesAlgebraicSphere<T>&& ProvidesImplicitPrimitiveDerivative<T>&& ProvidesGLSParam<T>
17
18namespace Ponca
19{
20
25 Method published in \cite Mellado:2012:GLS
26
27 This class assumes that the WeightFunc defines the accessor
28 \code
29 w.evalScale();
30 \endcode
31 in order to access to the evaluation scale, needed to compute the
32 scale invariant GLS reparametrization (all *_normalized methods).
33
34 Computed values:
35 - tau(), eta() and kappa(): the GLS descriptor
36 \f$ \left[ \tau \; \eta \; \kappa \right]\f$
37 - tau_normalized(), eta_normalized() and kappa_normalized():
38 the scale invariant GLS descriptor
39 \f$ \left[ \frac{\tau}{t} \; \eta \; t\kappa \right]\f$
40
41 Requirements:
42 \verbatim ProvidesAlgebraicSphere \endverbatim
43 Respects:
44 \verbatim ProvidesGLSParam \endverbatim
45 */
46
47 template <class DataPoint, class _NFilter, typename T>
48 requires GLS_PARAM_REQUIREMENTS
49 class GLSParam : public T
51 {
52 PONCA_FITTING_DECLARE_DEFAULT_TYPES
53 protected:
55
56 public:
57 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(GLSParam, glsParam)
58 PONCA_FITTING_DECLARE_FINALIZE
59
60 PONCA_MULTIARCH inline void init()
61 {
62 Base::init();
64 }
65
66 /**************************************************************************/
67 /* Use results */
68 /**************************************************************************/
70 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau() const
71 {
72 return Base::isNormalized() ? Base::uc() : Base::uc() / Base::prattNorm();
73 }
74
75
76 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta() const
77 {
78 return Base::primitiveGradient(Base::getNeighborFilter().center());
79 }
80
82 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa() const
83 {
84 return Scalar(2.) * (Base::isNormalized() ? Base::m_uq : Base::m_uq / Base::prattNorm());
85 }
86
88 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau_normalized() const
89 {
90 return tau() / Base::getNeighborFilter().evalScale();
91 }
92
94 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta_normalized() const { return eta(); }
95
97 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa_normalized() const
98 {
99 return kappa() * Base::getNeighborFilter().evalScale();
100 }
101
103 PONCA_MULTIARCH [[nodiscard]] inline Scalar fitness() const { return m_fitness; }
104
110 PONCA_MULTIARCH [[nodiscard]] inline Scalar compareTo(const GLSParam<DataPoint, _NFilter, T>& _other,
111 bool _useFitness = true) const
112 {
113 Scalar nTau = this->tau_normalized() - _other.tau_normalized();
114 Scalar nKappa = this->kappa_normalized() - _other.kappa_normalized();
115 Scalar nFitness = _useFitness ? this->fitness() - _other.fitness() : Scalar(0.);
116
117 return nTau * nTau + nKappa * nKappa + nFitness * nFitness;
118 }
119
120 PONCA_MULTIARCH [[nodiscard]] inline bool operator==(const GLSParam<DataPoint, _NFilter, T>& _other) const
121 {
122 return Base::operator==(_other) && internal::isApprox(compareTo(_other), Scalar(0.));
123 }
124 }; // class GLSParam
125
132 template <class DataPoint, class _NFilter, int DiffType, typename T>
133 requires GLS_DER_REQUIREMENTS
134 class GLSDer : public T
135 {
136 PONCA_FITTING_DECLARE_DEFAULT_TYPES
137 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
138 public:
139 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(GLSDer, glsDer)
140 PONCA_EXPLICIT_BASKET_CAST_OPERATORS_DER(GLSDer, geomVar)
141
142 PONCA_MULTIARCH inline ScalarArray dtau() const;
143 PONCA_MULTIARCH inline VectorArray deta() const;
144 PONCA_MULTIARCH inline ScalarArray dkappa() const;
145
146 PONCA_MULTIARCH inline ScalarArray dtau_normalized()
147 const;
148 PONCA_MULTIARCH inline VectorArray deta_normalized() const;
149 PONCA_MULTIARCH inline ScalarArray dkappa_normalized()
150 const;
151
167 PONCA_MULTIARCH inline Scalar geometric_variation(Scalar wtau = Scalar(1), Scalar weta = Scalar(1),
168 Scalar wkappa = Scalar(1)) const
169 requires ProvidesScaleDerivative<T>;
170 }; // class GLSScaleDer
171
172#include "gls.hpp"
173
174} // namespace Ponca
Differentiation of GLSParam.
Definition gls.h:135
GLSDer< DataPoint, _NFilter, DiffType, T > & geomVar()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition gls.h:140
GLSDer< DataPoint, _NFilter, DiffType, T > & glsDer()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition gls.h:139
ScalarArray dtau() const
Compute and return derivatives.
Definition gls.h:24
ScalarArray dkappa() const
Compute and return derivatives.
Definition gls.h:49
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition gls.h:137
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
Definition gls.h:137
ScalarArray dtau_normalized() const
Compute and return derivatives.
Definition gls.h:63
VectorArray deta_normalized() const
Compute and return .
Definition gls.h:71
VectorArray deta() const
Compute and return derivatives.
Definition gls.h:42
ScalarArray dkappa_normalized() const
Compute and return .
Definition gls.h:79
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:136
Scalar geometric_variation(Scalar wtau=Scalar(1), Scalar weta=Scalar(1), Scalar wkappa=Scalar(1)) const
The Geometric Variation is computed as the weighted sum of the GLS scale-invariant partial derivative...
Growing Least Squares reparametrization of the OrientedSphereFit.
Definition gls.h:51
VectorType eta() const
Compute and return .
Definition gls.h:76
GLSParam< DataPoint, _NFilter, T > & glsParam()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Definition gls.h:57
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:52
Scalar kappa() const
Compute and return .
Definition gls.h:82
Scalar tau_normalized() const
Compute and return .
Definition gls.h:88
VectorType eta_normalized() const
Compute and return .
Definition gls.h:94
Scalar tau() const
Compute and return .
Definition gls.h:70
Scalar kappa_normalized() const
Compute and return .
Definition gls.h:97
Scalar compareTo(const GLSParam< DataPoint, _NFilter, T > &_other, bool _useFitness=true) const
Compare current instance with other.
Definition gls.h:110
Scalar m_fitness
Save the fitness value to avoid side effect with Pratt normalization.
Definition gls.h:54
typename Base::VectorType VectorType
Alias to vector type.
Definition gls.h:52
Scalar fitness() const
Return the fitness, e.g.
Definition gls.h:103
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11