Ponca  19ef58fd3760f23a8af99a5eeac4f934757e30d9
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 "./curvature.h"
11
12namespace Ponca
13{
14
40 template <class DataPoint, class _NFilter, typename T>
41 class GLSParam : public T
42 {
43 PONCA_FITTING_DECLARE_DEFAULT_TYPES
44
46 protected:
47 enum
48 {
49 Check = Base::PROVIDES_ALGEBRAIC_SPHERE,
50 PROVIDES_GLS_PARAMETRIZATION
51 };
53
54 protected:
57 public:
58 PONCA_EXPLICIT_CAST_OPERATORS(GLSParam, glsParam)
59 PONCA_FITTING_DECLARE_FINALIZE
60
61 /**************************************************************************/
62 /* Use results */
63 /**************************************************************************/
65 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau() const
66 {
67 return Base::isNormalized() ? Base::m_uc : Base::m_uc / Base::prattNorm();
68 }
69
71 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta() const { return Base::primitiveGradient(); }
72
74 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa() const
75 {
76 return Scalar(2.) * (Base::isNormalized() ? Base::m_uq : Base::m_uq / Base::prattNorm());
77 }
78
80 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau_normalized() const
81 {
82 return tau() / Base::getNeighborFilter().evalScale();
83 }
84
86 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta_normalized() const { return eta(); }
87
89 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa_normalized() const
90 {
91 return kappa() * Base::getNeighborFilter().evalScale();
92 }
93
95 PONCA_MULTIARCH [[nodiscard]] inline Scalar fitness() const { return m_fitness; }
96
102 PONCA_MULTIARCH [[nodiscard]] inline Scalar compareTo(const GLSParam<DataPoint, _NFilter, T>& _other,
103 bool _useFitness = true) const
104 {
105 Scalar nTau = this->tau_normalized() - _other.tau_normalized();
106 Scalar nKappa = this->kappa_normalized() - _other.kappa_normalized();
107 Scalar nFitness = _useFitness ? this->fitness() - _other.fitness() : Scalar(0.);
108
109 return nTau * nTau + nKappa * nKappa + nFitness * nFitness;
110 }
111
112 }; // class GLSParam
113
120 template <class DataPoint, class _NFilter, int DiffType, typename T>
121 class GLSDer : public T
122 {
123 PONCA_FITTING_DECLARE_DEFAULT_TYPES
124 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
125
126 protected:
127 enum
128 {
129 Check = Base::PROVIDES_GLS_PARAMETRIZATION & Base::PROVIDES_PRIMITIVE_DERIVATIVE &
130 Base::PROVIDES_ALGEBRAIC_SPHERE_DERIVATIVE,
131 PROVIDES_GLS_DERIVATIVE,
132 PROVIDES_GLS_GEOM_VAR
133 };
134
135 public:
136 PONCA_EXPLICIT_CAST_OPERATORS_DER(GLSDer, glsDer)
137
138 PONCA_MULTIARCH inline ScalarArray dtau() const;
139 PONCA_MULTIARCH inline VectorArray deta() const;
140 PONCA_MULTIARCH inline ScalarArray dkappa() const;
142 PONCA_MULTIARCH inline ScalarArray dtau_normalized()
143 const;
144 PONCA_MULTIARCH inline VectorArray deta_normalized() const;
145 PONCA_MULTIARCH inline ScalarArray dkappa_normalized()
146 const;
163 PONCA_MULTIARCH inline Scalar geomVar(Scalar wtau = Scalar(1), Scalar weta = Scalar(1),
164 Scalar wkappa = Scalar(1)) const;
165 }; // class GLSScaleDer
166
167#include "gls.hpp"
168
169} // namespace Ponca
Differentiation of GLSParam.
Definition gls.h:122
GLSDer< DataPoint, _NFilter, DiffType, T > & glsDer()
Explicit conversion to GLSDer , to access methods potentially hidden by heritage.
Definition gls.h:136
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
VectorArray deta_normalized() const
Compute and return .
Definition gls.hpp:64
VectorArray deta() const
Compute and return derivatives.
Definition gls.hpp:38
ScalarArray dkappa_normalized() const
Compute and return .
Definition gls.hpp:71
ScalarArray dtau() const
Compute and return derivatives.
Definition gls.hpp:21
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:123
Scalar geomVar(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...
Definition gls.hpp:77
ScalarArray dtau_normalized() const
Compute and return derivatives.
Definition gls.hpp:57
ScalarArray dkappa() const
Compute and return derivatives.
Definition gls.hpp:44
Growing Least Squares reparametrization of the OrientedSphereFit.
Definition gls.h:42
VectorType eta() const
Compute and return .
Definition gls.h:71
GLSParam< DataPoint, _NFilter, T > & glsParam()
Explicit conversion to GLSParam , to access methods potentially hidden by heritage.
Definition gls.h:58
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:43
Scalar kappa() const
Compute and return .
Definition gls.h:74
Scalar tau_normalized() const
Compute and return .
Definition gls.h:80
VectorType eta_normalized() const
Compute and return .
Definition gls.h:86
Scalar tau() const
Compute and return .
Definition gls.h:65
Scalar kappa_normalized() const
Compute and return .
Definition gls.h:89
Scalar compareTo(const GLSParam< DataPoint, _NFilter, T > &_other, bool _useFitness=true) const
Compare current instance with other.
Definition gls.h:102
Scalar m_fitness
[Requirements]
Definition gls.h:55
typename Base::VectorType VectorType
Alias to vector type.
Definition gls.h:43
Scalar fitness() const
Return the fitness, e.g.
Definition gls.h:95
This Source Code Form is subject to the terms of the Mozilla Public License, v.