Commit 56f27201 authored by Nicolas Mellado's avatar Nicolas Mellado

Clean Primitives

 - methods primitiveGradient and potential are now defined in primitives (CompactPlane, AlgebraicSphere, MongePatch)
 - primitives can now expose cast function to give explicit access to methods potentially hidden by the CRTP inheritence
parent dea7a86a
......@@ -86,6 +86,11 @@ public:
resetPrimitive();
}
/*! \brief Explicit conversion to AlgebraicSphere, to access methods potentially hidden by inheritage */
MULTIARCH inline
AlgebraicSphere<DataPoint, WFunctor, T>& algebraicSphere()
{ return * static_cast<AlgebraicSphere<DataPoint, WFunctor, T>*>(this); }
/*! \brief Set the scalar field values to 0 and reset the isNormalized() status
\warning Set m_ul to Zero(), which leads to nans in OrientedSphere::normal()
......@@ -206,12 +211,18 @@ public:
//! \brief Value of the scalar field at the location \f$ \mathbf{q} \f$
MULTIARCH inline Scalar potential (const VectorType& _q) const;
/*! \brief Value of the scalar field at the evaluation point */
MULTIARCH inline Scalar potential() const { return m_uc; }
//! \brief Project a point on the sphere
MULTIARCH inline VectorType project (const VectorType& _q) const;
//! \brief Approximation of the scalar field gradient at \f$ \mathbf{q} (not normalized) \f$
MULTIARCH inline VectorType primitiveGradient (const VectorType& _q) const;
/*! \brief Approximation of the scalar field gradient at the evaluation point */
MULTIARCH inline VectorType primitiveGradient () const { return m_ul.normalized(); }
/*!
\brief Used to know if the fitting result to a plane
\return true if finalize() have been called and the fitting result to a plane
......
......@@ -77,6 +77,11 @@ public:
/*! \brief Default constructor */
MULTIARCH inline CovariancePlaneFit() : Base() {}
/*! \brief Explicit conversion to CovariancePlaneFit, to access methods potentially hidden by inheritage */
MULTIARCH inline
CovariancePlaneFit<DataPoint, WFunctor, T>& covariancePlaneFit()
{ return * static_cast<CovariancePlaneFit<DataPoint, WFunctor, T>*>(this); }
/**************************************************************************/
/* Initialization */
/**************************************************************************/
......@@ -101,12 +106,6 @@ public:
using Base::potential;
/*! \brief Value of the scalar field at the evaluation point */
MULTIARCH inline Scalar potential() const { return Base::potential(m_evalPos); }
/*! \brief Value of the normal of the primitive at the evaluation point */
MULTIARCH inline VectorType normal() const { return Base::m_p.template head<DataPoint::Dim>(); }
/*! \brief Reading access to the Solver used to analyse the covariance
matrix */
MULTIARCH inline const Solver& solver() const { return m_solver; }
......
......@@ -189,7 +189,7 @@ CovariancePlaneDer<DataPoint, _WFunctor, T, Type>::finalize()
// apply normalization by sumW:
m_dCog.col(k) = (m_dCog.col(k) - m_dSumW(k) * Base::m_cog) / Base::m_sumW;
VectorType normal = Base::normal();
VectorType normal = Base::primitiveGradient();
// The derivative of 'normal' is the derivative of the smallest eigenvector.
// Since the covariance matrix is real and symmetric, it is equal to:
// n' = - (C - lambda_0 I)^+ C' n
......
......@@ -91,7 +91,7 @@ CurvatureEstimator<DataPoint, _WFunctor, T>::tangentPlane(bool useNormal) const
if(useNormal)
{
VectorType n = Base::normal();
VectorType n = Base::primitiveGradient();
n.minCoeff(&i0);
i1 = (i0+1)%3;
i2 = (i0+2)%3;
......
......@@ -98,7 +98,7 @@ public:
}
/*! \brief Compute and return \f$ \eta \f$ */
MULTIARCH inline VectorType eta() const { return Base::normal(); }
MULTIARCH inline VectorType eta() const { return Base::primitiveGradient(); }
/*! \brief Compute and return \f$ \kappa \f$ */
MULTIARCH inline Scalar kappa() const
......
......@@ -76,19 +76,6 @@ public:
/*! \copydoc Concept::FittingProcedureConcept::finalize() */
MULTIARCH inline FIT_RESULT finalize();
/**************************************************************************/
/* Results */
/**************************************************************************/
using Base::potential;
/*! \brief Value of the scalar field at the evaluation point */
MULTIARCH inline Scalar potential() const { return Base::m_uc; }
/*! \brief Value of the normal of the primitive at the evaluation point */
MULTIARCH inline VectorType normal() const { return Base::m_ul.normalized(); }
}; //class OrientedSphereFit
......
......@@ -74,6 +74,11 @@ public:
resetPrimitive();
}
/*! \brief Explicit conversion to CompactPlane, to access methods potentially hidden by inheritage */
MULTIARCH inline
CompactPlane<DataPoint, WFunctor, T>& compactPlane()
{ return * static_cast<CompactPlane<DataPoint, WFunctor, T>*>(this); }
/*! \brief Set the scalar field values to 0 and reset the isNormalized()
status */
MULTIARCH inline void resetPrimitive()
......@@ -103,6 +108,12 @@ public:
*cc = EigenBase(_dir.normalized(), _pos);
}
/*! \brief Value of the scalar field at the evaluation point */
MULTIARCH inline Scalar potential ( ) const
{
return EigenBase::signedDistance(VectorType::Zero());
}
//! \brief Value of the scalar field at the location \f$ \mathbf{q} \f$
MULTIARCH inline Scalar potential (const VectorType& _q) const
{
......@@ -115,6 +126,11 @@ public:
{
// Project on the normal vector and add the offset value
return EigenBase::projection(_q);
//! \brief Scalar field gradient direction at the evaluation point
MULTIARCH inline VectorType primitiveGradient () const
{
// Uniform gradient defined only by the orientation of the plane
return EigenBase::normal();
}
//! \brief Scalar field gradient direction at \f$ \mathbf{q}\f$
......
......@@ -72,19 +72,6 @@ public:
/*! \copydoc Concept::FittingProcedureConcept::finalize() */
MULTIARCH inline FIT_RESULT finalize();
/**************************************************************************/
/* Results */
/**************************************************************************/
using Base::potential;
/*! \brief Value of the scalar field at the evaluation point */
MULTIARCH inline Scalar potential() const { return Base::m_uc; }
/*! \brief Value of the normal of the primitive at the evaluation point */
MULTIARCH inline VectorType normal() const { return Base::m_ul.normalized(); }
}; //class SphereFit
......
......@@ -80,14 +80,6 @@ public:
/*! \copydoc Concept::FittingProcedureConcept::finalize() */
MULTIARCH inline FIT_RESULT finalize();
using Base::potential;
/*! \brief Value of the scalar field at the evaluation point */
MULTIARCH inline Scalar potential() const { return Base::m_uc; }
/*! \brief Value of the normal of the primitive at the evaluation point */
MULTIARCH inline VectorType normal() const { return Base::m_ul.normalized(); }
}; // class UnorientedSphereFit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment