14#include PONCA_MULTIARCH_INCLUDE_STD(iterator)
19#define BSKW typename BasketType::WeightFunction
20#define BSKP typename BasketType::DataPoint
22#ifndef PARSED_WITH_DOXYGEN
35 template <
class P,
class W,
37 template <
class,
class,
typename>
class Ext,
38 template <
class,
class,
typename>
class... Exts>
39 struct BasketAggregateImpl
41 using type =
typename BasketAggregateImpl<P, W, Ext<P, W, Aggregate>, Exts...>::type;
52 template <
class P,
class W,
54 template <
class,
class,
typename>
class Ext>
55 struct BasketAggregateImpl<P, W, Aggregate, Ext>
57 using type = Ext<P, W, Aggregate>;
68 template <
class P,
class W,
69 template <
class,
class,
typename>
class... Exts>
70 struct BasketAggregate : BasketAggregateImpl<P, W, PrimitiveBase<P, W>, Exts...>
85 template <
class,
class,
int,
typename>
class Ext,
86 template <
class,
class,
int,
typename>
class... Exts>
87 struct BasketDiffAggregateImpl
89 using type =
typename BasketDiffAggregateImpl<Type, Ext<BSKP, BSKW, Type, BasketType>, Exts...>::type;
101 template <
class,
class,
int,
typename>
class Ext>
102 struct BasketDiffAggregateImpl<Type, BasketType, Ext>
104 using type = Ext<BSKP, BSKW, Type, BasketType>;
115 template <
typename BasketType,
int Type,
116 template <
class,
class,
int,
typename>
class... Exts>
117 struct BasketDiffAggregate : BasketDiffAggregateImpl<Type, BasketType, PrimitiveDer, Exts...>
144 template<
typename _Derived,
typename _Base>
160 template <
typename IteratorBegin,
typename IteratorEnd>
167 for (
auto it = begin; it != end; ++it){
170 res = Base::finalize();
183 template <
typename IndexRange,
typename Po
intContainer>
190 for (
const auto& i : ids){
191 derived().addNeighbor(points[i]);
193 res = Base::finalize();
207 template<
typename Func>
210 const auto t = Base::m_w.evalScale();
211 auto lastPos = Base::m_w.evalPos();
213 for (
int mm = 0; mm < mlsIter; ++mm) {
214 Base::setWeightFunc({lastPos, t});
217 if (Base::isStable()) {
218 auto newPos = Base::project(lastPos);
219 if (newPos.isApprox(lastPos, epsilon))
234 template<
typename Po
intContainer>
236 const PointContainer& points,
237 const int mlsIter = 5,
238 const Scalar epsilon = Eigen::NumTraits<Scalar>::dummy_precision()
241 [&]() {
return compute(points); },
251 template<
typename IndexRange,
typename Po
intContainer>
253 const IndexRange& ids,
254 const PointContainer& points,
255 const int mlsIter = 5,
256 const Scalar epsilon = Eigen::NumTraits<Scalar>::dummy_precision()
265#define WRITE_COMPUTE_FUNCTIONS \
266 using BasketComputeObject<Self, Base>::compute; \
267 using BasketComputeObject<Self, Base>::computeWithIds; \
268 using BasketComputeObject<Self, Base>::computeMLS; \
269 using BasketComputeObject<Self, Base>::computeWithIdsMLS;
279 template <
typename BasketType,
int Type,
280 template <
class,
class,
int,
typename>
class Ext0,
281 template <
class,
class,
int,
typename>
class... Exts>
283 typename internal::BasketDiffAggregate<BasketType, Type, Ext0, Exts...>::type>
288 using Base =
typename internal::BasketDiffAggregate<BasketType,Type,Ext0,Exts...>::type;
294 using Scalar =
typename BasketType::Scalar;
295 WRITE_COMPUTE_FUNCTIONS
300 auto wres = Base::m_w.w(_nei.pos(), _nei);
301 typename Base::ScalarArray dw;
303 if (wres.first >
Scalar(0.)) {
304 Base::addLocalNeighbor(wres.first, wres.second, _nei, dw);
319 template <
class P,
class W,
320 template <
class,
class,
typename>
class Ext0,
321 template <
class,
class,
typename>
class... Exts>
323 typename internal::BasketAggregate<P, W, Ext0, Exts...>::type>
329 using Base =
typename internal::BasketAggregate<P, W, Ext0, Exts...>::type;
332 using VectorType =
typename P::VectorType;
338 WRITE_COMPUTE_FUNCTIONS
348 auto wres = Base::m_w.w(_nei.pos(), _nei);
350 if (wres.first >
Scalar(0.)) {
351 Base::addLocalNeighbor(wres.first, wres.second, _nei);
358#undef WRITE_COMPUTE_FUNCTIONS
Aggregator class used to declare specialized structures with derivatives computations,...
typename BasketType::DataPoint DataPoint
Point type used for computation.
bool addNeighbor(const DataPoint &_nei)
Add a neighbor to perform the fit.
typename BasketType::WeightFunction WeightFunction
Weight function.
typename BasketType::Scalar Scalar
Scalar type used for computation, as defined from Basket.
Aggregator class used to declare specialized structures using CRTP.
W WeightFunction
Weighting function.
P DataPoint
Point type used for computation.
typename P::Scalar Scalar
Scalar type used for computation, as defined from template parameter P
bool addNeighbor(const DataPoint &_nei)
Add a neighbor to perform the fit.
typename internal::BasketAggregate< P, W, Ext0, Exts... >::type Base
Base type, which aggregates all the computational objects using the CRTP.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
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.
Base ComputeObject for the Basket classes.
FIT_RESULT computeWithIds(IndexRange ids, const PointContainer &points)
Convenience function to iterate over a subset of samples in a PointContainer Add neighbors stored in ...
FIT_RESULT computeMLS(const PointContainer &points, const int mlsIter=5, const Scalar epsilon=Eigen::NumTraits< Scalar >::dummy_precision())
Computes the fit using the MLS iteration process.
FIT_RESULT computeMLSImpl(Func &&computeFunc, int mlsIter, Scalar epsilon)
Computes the fit using the MLS iteration process.
FIT_RESULT compute(const IteratorBegin &begin, const IteratorEnd &end)
Convenience function for STL-like iterators Add neighbors stored in a container using STL-like iterat...
FIT_RESULT computeWithIdsMLS(const IndexRange &ids, const PointContainer &points, const int mlsIter=5, const Scalar epsilon=Eigen::NumTraits< Scalar >::dummy_precision())
Computes the fit using the MLS iteration process.
typename Base::Scalar Scalar
Alias to the Derived type.
ComputeObject is a virtual object that represents an algorithm which can be used with the compute fun...
_Derived & derived()
Retrieve the top layer object Returns a reference to the derived class so that we can use its overwri...