Ponca  7b3f8ad3fde25a027e6452783ccee143798a71b8
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
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:
56 public:
57 PONCA_EXPLICIT_CAST_OPERATORS(GLSParam, glsParam)
58 PONCA_FITTING_DECLARE_FINALIZE
59
60 /**************************************************************************/
61 /* Use results */
62 /**************************************************************************/
64 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau() const
65 {
66 return Base::isNormalized() ? Base::m_uc : Base::m_uc / Base::prattNorm();
67 }
68
70 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta() const { return Base::primitiveGradient(); }
71
73 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa() const
74 {
75 return Scalar(2.) * (Base::isNormalized() ? Base::m_uq : Base::m_uq / Base::prattNorm());
76 }
77
79 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau_normalized() const
80 {
81 return tau() / Base::getNeighborFilter().evalScale();
82 }
83
85 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta_normalized() const { return eta(); }
86
88 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa_normalized() const
89 {
90 return kappa() * Base::getNeighborFilter().evalScale();
91 }
92
94 PONCA_MULTIARCH [[nodiscard]] inline Scalar fitness() const { return m_fitness; }
95
102 bool _useFitness = true) const
103 {
104 Scalar nTau = this->tau_normalized() - _other.tau_normalized();
105 Scalar nKappa = this->kappa_normalized() - _other.kappa_normalized();
106 Scalar nFitness = _useFitness ? this->fitness() - _other.fitness() : Scalar(0.);
107
108 return nTau * nTau + nKappa * nKappa + nFitness * nFitness;
109 }
110
111 }; // class GLSParam
112
119 template <class DataPoint, class _NFilter, int DiffType, typename T>
120 requires GLS_DER_REQUIREMENTS
121 class GLSDer : public T
122 {
123 PONCA_FITTING_DECLARE_DEFAULT_TYPES
124 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
125 public:
126 PONCA_EXPLICIT_CAST_OPERATORS_DER(GLSDer, glsDer)
127 PONCA_EXPLICIT_CAST_OPERATORS_DER(GLSDer, geomVar)
128
129 PONCA_MULTIARCH inline ScalarArray dtau() const;
130 PONCA_MULTIARCH inline VectorArray deta() const;
131 PONCA_MULTIARCH inline ScalarArray dkappa() const;
133 PONCA_MULTIARCH inline ScalarArray dtau_normalized()
134 const;
135 PONCA_MULTIARCH inline VectorArray deta_normalized() const;
136 PONCA_MULTIARCH inline ScalarArray dkappa_normalized()
137 const;
154 PONCA_MULTIARCH inline Scalar geomVar(Scalar wtau = Scalar(1), Scalar weta = Scalar(1),
156 }; // class GLSScaleDer
157
158#include "gls.hpp"
159
160} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:294
Differentiation of GLSParam.
Definition gls.h:122
ScalarArray dkappa_normalized() const
Compute and return .
Definition gls.hpp:78
GLSDer< DataPoint, _NFilter, DiffType, T > & geomVar()
Explicit conversion to GLSDer , to access methods potentially hidden by heritage.
Definition gls.h:127
VectorArray deta_normalized() const
Compute and return .
Definition gls.hpp:70
GLSDer< DataPoint, _NFilter, DiffType, T > & glsDer()
Explicit conversion to GLSDer , to access methods potentially hidden by heritage.
Definition gls.h:126
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition gls.h:124
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
Definition gls.h:124
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:123
VectorArray deta() const
Compute and return derivatives.
Definition gls.hpp:41
ScalarArray dtau_normalized() const
Compute and return derivatives.
Definition gls.hpp:62
ScalarArray dtau() const
Compute and return derivatives.
Definition gls.hpp:23
ScalarArray dkappa() const
Compute and return derivatives.
Definition gls.hpp:48
Growing Least Squares reparametrization of the OrientedSphereFit.
Definition gls.h:51
VectorType eta() const
Compute and return .
Definition gls.h:70
GLSParam< DataPoint, _NFilter, T > & glsParam()
Explicit conversion to GLSParam , 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:73
Scalar tau_normalized() const
Compute and return .
Definition gls.h:79
VectorType eta_normalized() const
Compute and return .
Definition gls.h:85
Scalar tau() const
Compute and return .
Definition gls.h:64
Scalar kappa_normalized() const
Compute and return .
Definition gls.h:88
Scalar compareTo(const GLSParam< DataPoint, _NFilter, T > &_other, bool _useFitness=true) const
Compare current instance with other.
Definition gls.h:101
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:94
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11