27template <
class DataPo
int,
class _NFilter,
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 [[nodiscard]]
inline bool isReady()
const
88 PONCA_MULTIARCH [[nodiscard]]
inline int getNumNeighbors()
const {
return m_nbNeighbors; }
119 PONCA_FITTING_APIDOC_ADDNEIGHBOR
126 PONCA_FITTING_APIDOC_FINALIZE
129 if (m_sumW ==
Scalar(0.) || m_nbNeighbors < 1) {
161template <
class DataPo
int,
class _NFilter,
int Type,
typename T>
164 PONCA_FITTING_DECLARE_DEFAULT_TYPES
165 PONCA_FITTING_DECLARE_MATRIX_TYPE
168 Check = Base::PROVIDES_PRIMITIVE_BASE,
169 PROVIDES_PRIMITIVE_DERIVATIVE
173 static constexpr int NbDerivatives = ((Type &
FitScaleDer) ? 1 : 0 ) + ((Type &
FitSpaceDer) ? DataPoint::Dim : 0);
174 static constexpr int DerStorageOrder = (Type &
FitSpaceDer) ? Eigen::RowMajor : Eigen::ColMajor;
179 typedef Eigen::Matrix<Scalar, DataPoint::Dim, NbDerivatives, DerStorageOrder>
VectorArray;
194 PONCA_MULTIARCH
inline void init()
195 { Base::init();
m_dSumW.setZero(); }
204 const DataPoint &attributes,
207 if( Base::addLocalNeighbor(w, localQ, attributes) ) {
211 dw[0] = Base::getNeighborFilter().scaledw(attributes.pos(), attributes);
214 dw.template segment<int(DataPoint::Dim)>(spaceId) = -Base::getNeighborFilter().spacedw(attributes.pos(), attributes).transpose();
230 PONCA_MULTIARCH [[nodiscard]]
inline constexpr unsigned int derDimension()
const {
return NbDerivatives;}
bool isStable() const
Is the fitted primitive ready to use (finalize has been called and the result is stable)
typename DataPoint::Scalar Scalar
Inherited scalar type.
void startNewPass()
To be called when starting a new processing pass, ie.
bool addLocalNeighbor(Scalar w, const VectorType &, const DataPoint &)
Add a neighbor to perform the fit.
void setNeighborFilter(const NeighborFilter &_nFilter)
Init the WeightFunc, without changing the other internal states.
bool isReady() const
Is the primitive well fitted and ready to use (finalize has been called) ?
_NFilter NeighborFilter
Filter applied on each neighbor.
Scalar getWeightSum() const
Get the sum of the weights.
@ PROVIDES_PRIMITIVE_BASE
Provides base API for primitives.
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)
NeighborFilter & getNeighborFilter()
Write access to the NeighborFilter.
FIT_RESULT finalize()
Finalize the procedure.
const NeighborFilter & getNeighborFilter() const
Read access to the NeighborFilter.
typename DataPoint::VectorType VectorType
Inherited vector type.
FIT_RESULT m_eCurrentState
Represent the current state of the fit (finalize function update the state)
FIT_RESULT getCurrentState() const
bool needAnotherPass() const
Is another pass required for fitting (finalize has been called and the result is NEED_OTHER_PASS)
Generic class performing the Fit derivation.
constexpr bool isSpaceDer() const
State specified at compilation time to compute derivatives in space.
Eigen::Matrix< Scalar, 1, NbDerivatives > ScalarArray
Static array of scalars with a size adapted to the differentiation type.
ScalarArray m_dSumW
Sum of weight derivatives.
constexpr bool isScaleDer() const
State specified at compilation time to compute derivatives in scale.
bool addLocalNeighbor(Scalar w, const VectorType &localQ, const DataPoint &attributes, ScalarArray &dw)
typename DataPoint::Scalar Scalar
Alias to scalar type.
typename Base::VectorType VectorType
Alias to vector type.
@ Check
Provides base API for primitives.
Eigen::Matrix< Scalar, DataPoint::Dim, NbDerivatives, DerStorageOrder > VectorArray
Static array of scalars with a size adapted to the differentiation type.
constexpr unsigned int derDimension() const
Number of dimensions used for the differentiation.
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...