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()
75 PONCA_MULTIARCH
inline bool isReady()
const
112 PONCA_FITTING_APIDOC_ADDNEIGHBOR
119 PONCA_FITTING_APIDOC_FINALIZE
122 if (m_sumW ==
Scalar(0.) || m_nbNeighbors < 1) {
150template <
class DataPo
int,
class _WFunctor,
int Type,
typename T>
158 Check = Base::PROVIDES_PRIMITIVE_BASE,
159 PROVIDES_PRIMITIVE_DERIVATIVE
163 static constexpr int NbDerivatives = ((Type &
FitScaleDer) ? 1 : 0 ) + ((Type &
FitSpaceDer) ? DataPoint::Dim : 0);
164 static constexpr int DerStorageOrder = (Type &
FitSpaceDer) ? Eigen::RowMajor : Eigen::ColMajor;
173 typedef Eigen::Matrix<Scalar, DataPoint::Dim, NbDerivatives, DerStorageOrder>
VectorArray;
188 PONCA_MULTIARCH
inline void init()
189 { Base::init();
m_dSumW.setZero(); }
198 const DataPoint &attributes,
201 if( Base::addLocalNeighbor(w, localQ, attributes) ) {
205 dw[0] = Base::m_w.scaledw(attributes.pos(), attributes);
208 dw.template segment<int(DataPoint::Dim)>(spaceId) = -Base::m_w.spacedw(attributes.pos(), attributes).transpose();
224 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 and ready to use (finalize has been called) ?
typename DataPoint::VectorType VectorType
Inherited vector type.
void init()
Set the evaluation position and reset the internal states.
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)
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.
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...