27template <
class DataPo
int,
class _WFunctor,
typename T =
void >
36 using Scalar =
typename DataPoint::Scalar;
42 int m_nbNeighbors {0};
60 PONCA_FITTING_APIDOC_SETWFUNC
65 PONCA_FITTING_APIDOC_INIT
66 PONCA_MULTIARCH
inline void init(
const VectorType& _basisCenter = VectorType::Zero())
70 m_w.init( _basisCenter );
76 PONCA_MULTIARCH
inline bool isReady()
const
113 PONCA_FITTING_APIDOC_ADDNEIGHBOR
120 PONCA_FITTING_APIDOC_FINALIZE
123 if (m_sumW ==
Scalar(0.) || m_nbNeighbors < 1) {
151template <
class DataPo
int,
class _WFunctor,
int Type,
typename T>
159 Check = Base::PROVIDES_PRIMITIVE_BASE,
160 PROVIDES_PRIMITIVE_DERIVATIVE
164 static constexpr int NbDerivatives = ((Type &
FitScaleDer) ? 1 : 0 ) + ((Type &
FitSpaceDer) ? DataPoint::Dim : 0);
165 static constexpr int DerStorageOrder = (Type &
FitSpaceDer) ? Eigen::RowMajor : Eigen::ColMajor;
174 typedef Eigen::Matrix<Scalar, DataPoint::Dim, NbDerivatives, DerStorageOrder>
VectorArray;
190 { Base::init(_evalPos);
m_dSumW.setZero(); }
199 const DataPoint &attributes,
202 if( Base::addLocalNeighbor(w, localQ, attributes) ) {
206 dw[0] = Base::m_w.scaledw(attributes.pos(), attributes);
209 dw.template segment<int(DataPoint::Dim)>(spaceId) = -Base::m_w.spacedw(attributes.pos(), attributes).transpose();
225 PONCA_MULTIARCH
inline constexpr unsigned int derDimension()
const {
return NbDerivatives;}
const WFunctor & getWeightFunc() const
Read access to the WeightFunc.
WFunctor m_w
Weight function (must inherits BaseWeightFunc)
FIT_RESULT getCurrentState() const
void startNewPass()
To be called when starting a new processing pass, ie.
Scalar getWeightSum() const
Get the sum of the weights.
FIT_RESULT finalize()
Finalize the procedure.
void setWeightFunc(const WFunctor &_w)
Init the WeightFunc, without changing the other internal states.
_WFunctor WFunctor
Weight Function.
typename DataPoint::Scalar Scalar
Inherited scalar type.
@ PROVIDES_PRIMITIVE_BASE
Provides base API for primitives.
bool addLocalNeighbor(Scalar w, const VectorType &, const DataPoint &)
Add a neighbor to perform the fit.
bool isReady() const
Is the primitive well fitted an ready to use (finalize has been called)
typename DataPoint::VectorType VectorType
Inherited vector type.
int getNumNeighbors() const
Get number of points added in the neighborhood (with non negative weight)
bool needAnotherPass() const
Is another pass required for fitting (finalize has been called and the result is NEED_OTHER_PASS)
bool isStable() const
Is the fitted primitive ready to use (finalize has been called and the result is stable)
FIT_RESULT m_eCurrentState
Represent the current state of the fit (finalize function update the state)
void init(const VectorType &_basisCenter=VectorType::Zero())
Set the evaluation position and reset the internal states.
Generic class performing the Fit derivation.
typename Base::VectorType VectorType
Inherited vector type.
typename DataPoint::MatrixType MatrixType
Inherited matrix type.
Eigen::Matrix< Scalar, DataPoint::Dim, NbDerivatives, DerStorageOrder > VectorArray
Static array of scalars with a size adapted to the differentiation type.
Eigen::Matrix< Scalar, 1, NbDerivatives > ScalarArray
Static array of scalars with a size adapted to the differentiation type.
typename Base::WFunctor WFunctor
Weight Function.
typename Base::Scalar Scalar
Inherited scalar type.
constexpr unsigned int derDimension() const
Number of dimensions used for the differentiation.
constexpr bool isSpaceDer() const
State specified at compilation time to differenciate the fit in space.
@ Check
Provides base API for primitives.
constexpr bool isScaleDer() const
State specified at compilation time to differenciate the fit in scale.
ScalarArray m_dSumW
Sum of weight derivatives.
void init(const VectorType &_evalPos)
bool addLocalNeighbor(Scalar w, const VectorType &localQ, const DataPoint &attributes, ScalarArray &dw)
This Source Code Form is subject to the terms of the Mozilla Public License, v.
@ FitSpaceDer
Flag indicating a space differentiation.
@ FitScaleDer
Flag indicating a scale differentiation.
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
@ UNDEFINED
The fitting is undefined, you can't use it for valid results.
@ NEED_OTHER_PASS
The fitting procedure needs to analyse the neighborhood another time.
@ STABLE
The fitting is stable and ready to use.
@ UNSTABLE
The fitting is ready to use but it is considered as unstable (if the number of neighbors is low for e...