Ponca  aa50bfdf187919869239c5b44b748842569114c1
Point Cloud Analysis library
Loading...
Searching...
No Matches
Fitting module: Concepts
[Go back to Fitting user manual]
[Go back to concept manual]
[Go back to user manual]

Ponca Fitting Module is structured around the following concepts:

  • WeightKernelConcept: defines how neighbor samples should be weighted
  • ComputationalObjectConcept and ComputationalDerivativesConcept: define API of the computational objects used in Basket and BasketDiff respectively.

API of Computational Objects

Computations will always follow the same pattern:

// Definition
typedef Basket<MyPointStructure,MyWeightingFunction,MyFittingProcedure...> Fit;
// Initialization
MyWeightingFunction w ( some_parameters ); //< Init weight function
Fit fit; //< Create a fit object
fit.init( referencePosition ); //< Init the internal state with respect to the reference position
fit.setWeightFunc( w ); //< Set the weighting function (w can be shared accross multiple fits)
// Computations
foreach neighbors of referencePosition //< Traverse neighborhood
fit.addNeighbor(neighbor); //< Intermediate computation for each neighbor
fit.finalize(); //< Final computations
// Usage
if(fit.isStable())
{
// use the fit ...
}

Note that in the above example, the type Fit can be either a Basket or a BasketDiff, without affecting the rest of the code.

Objects used in Basket

Objects used in Basket should respect the following API:

template < class DataPoint, class _WFunctor, typename T = void >
class ComputationalObjectConcept
{
protected:
enum {
Check = PROVIDES_CAPABILITY_1 && PROVIDES_CAPABILITY_2 //< List of required capabilities
PROVIDES_CAPABILITY, //< List of provided capabilities
};
public:
using Scalar = typename DataPoint::Scalar; //< Inherited scalar type
using VectorType = typename DataPoint::VectorType; //< Inherited vector type
using WFunctor = _WFunctor; //< Weight Function
public:
/**************************************************************************/
/* Initialization */
/**************************************************************************/
// Init the WeightFunc, without changing the other internal states.
// \warning Must be called be for any computation
PONCA_MULTIARCH inline void setWeightFunc (const WFunctor& _w);
// Set the evaluation position and reset the internal states.
// \warning Must be called be for any computation
PONCA_MULTIARCH inline void init(const VectorType& _basisCenter = VectorType::Zero());
/**************************************************************************/
/* Computations */
/**************************************************************************/
// Add a neighbor to perform the fit
// \return false if param nei is not a valid neighbour (weight = 0)
PONCA_MULTIARCH inline bool addLocalNeighbor(Scalar, const VectorType &, const DataPoint &);
// Finalize the fitting procedure.
// \return State of fitting
// \warning Must be called be for any use of the fitting output
PONCA_MULTIARCH inline FIT_RESULT finalize();
}; //class ComputationalObjectConcept

Objects used in BasketDiff

Objects used in BasketDiff should respect the following API:

template < class DataPoint, class _WFunctor, int Type, typename T>
class ComputationalDerivativesConcept
{
protected:
enum {
Check = PROVIDES_CAPABILITY_1 && PROVIDES_CAPABILITY_2 //< List of required capabilities
PROVIDES_CAPABILITY, //< List of provided capabilities
};
public:
using Scalar = typename DataPoint::Scalar; //< Inherited scalar type
using VectorType = typename DataPoint::VectorType; //< Inherited vector type
using WFunctor = _WFunctor; //< Weight Function
// Static array of scalars with a size adapted to the differentiation type
using VectorArray = typename Base::VectorArray;
// Static array of scalars with a size adapted to the differentiation type
using ScalarArray = typename Base::ScalarArray;
public:
/**************************************************************************/
/* Initialization */
/**************************************************************************/
// Init the WeightFunc, without changing the other internal states.
// \warning Must be called be for any computation
PONCA_MULTIARCH inline void setWeightFunc (const WFunctor& _w);
// Set the evaluation position and reset the internal states.
// \warning Must be called be for any computation
PONCA_MULTIARCH inline void init(const VectorType& _basisCenter = VectorType::Zero());
/**************************************************************************/
/* Computations */
/**************************************************************************/
// Add a neighbor to perform the fit
// \return false if param nei is not a valid neighbour (weight = 0)
PONCA_MULTIARCH inline bool addLocalNeighbor(Scalar w,
const VectorType &localQ,
const DataPoint &attributes,
ScalarArray &dw);
// Finalize the fitting procedure.
// \return State of fitting
// \warning Must be called be for any use of the fitting output
PONCA_MULTIARCH inline FIT_RESULT finalize();
}; //class ComputationalDerivativesConcept
Note
PrimitiveDer defines the default entry point to most classes used in BasketDiff.

Concepts related to weighting functions

Weighting functions are critical components of the library. They are represented by DistWeightFunc, which is defined from the euclidean distance field centered at the evaluation position (see DistWeightFunc::init()). Given a distance to this evaluation position, the weight is computed (see DistWeightFunc::w()) by applying a 1d weighting function defined as follows:

// \brief Concept of a 1D weighting function and its derivatives.
template <typename _Scalar>
class WeightKernelConcept{
public:
typedef _Scalar Scalar;
// \brief Apply the weighting kernel to the scalar value f(x)
PONCA_MULTIARCH inline Scalar f (const Scalar& x) const {}
// \brief Apply the first derivative of the weighting kernel to the scalar value f'(x)
PONCA_MULTIARCH inline Scalar df (const Scalar& x) const {}
// \brief Apply the second derivative of the weighting kernel to the scalar value f''(x)
PONCA_MULTIARCH inline Scalar ddf(const Scalar& x) const {}
};// class WeightKernelConcept

DistWeightFunc also provides computation of the first and second order derivatives of the weight, both in scale (DistWeightFunc::scaledw(), DistWeightFunc::scaled2w()) and space (DistWeightFunc::spacedw(), DistWeightFunc::spaced2w()), and their cross derivatives (DistWeightFunc::scaleSpaced2w()). Theses methods check if the weight kernels provides the appropriate derivatives


[Go back to Fitting user manual]
[Go back to concept manual]
[Go back to user manual]