10#include "../../defines.h"
11#include "../concepts.h"
13#include <Eigen/Geometry>
15#define LINE_REQUIREMENTS ProvidesBasketUnitBase<T>
33 template <
class DataPo
int,
class _NFilter,
typename T>
34 requires LINE_REQUIREMENTS
35 class Line :
public T,
public Eigen::ParametrizedLine<typename DataPoint::Scalar, DataPoint::Dim>
37 PONCA_FITTING_DECLARE_DEFAULT_TYPES
41 using EigenBase = Eigen::ParametrizedLine<typename DataPoint::Scalar, DataPoint::Dim>;
44 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(
Line,
line)
51 PONCA_MULTIARCH inline
void init()
54 EigenBase::origin().setZero();
55 EigenBase::direction().setZero();
61 PONCA_MULTIARCH [[nodiscard]]
inline bool isValid()
const
63 const typename EigenBase::VectorType zeros = EigenBase::VectorType::Zero();
64 return !(EigenBase::origin().isApprox(zeros) && EigenBase::direction().isApprox(zeros));
70 return Base::operator==(other) && internal::isApprox(EigenBase::origin(), other.origin()) &&
71 internal::isApprox(EigenBase::direction(), other.direction());
77 return !((*this) == other);
95 VectorType diff = Base::getNeighborFrame().center() - newbasis;
96 Base::m_nFilter.changeNeighborhoodFrame(newbasis);
98 EigenBase::origin() += diff;
106 return EigenBase::squaredDistance(VectorType::Zero());
116 const VectorType lq = Base::getNeighborFrame().convertToLocalBasis(_q);
125 return Base::getNeighborFrame().convertToGlobalBasis(
126 EigenBase::projection(Base::getNeighborFrame().convertToLocalBasis(_q)));
134 const VectorType lq = Base::getNeighborFrame().convertToLocalBasis(_q);
135 return primitiveGradientLocal(lq);
146 return EigenBase::squaredDistance(_lq);
149 PONCA_MULTIARCH [[nodiscard]]
inline VectorType primitiveGradientLocal(
const VectorType& _lq)
const
A parametrized line is defined by an origin point and a unit direction vector such that the line co...
Line< DataPoint, _NFilter, T > & line()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Line< DataPoint, _NFilter, T > & projectionOperator()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Scalar potentialLocal(const VectorType &_lq) const
Value of the scalar field at the evaluation point.
Scalar potential() const
Value of the scalar field at the evaluation point.
void changeBasis(const VectorType &newbasis)
Express the line relatively to a new basis.
void init()
Set the scalar field values to 0 and reset the distance() and origin() status.
bool operator==(const Line< DataPoint, NeighborFilter, T > &other) const
Comparison operator.
VectorType primitiveGradient(const VectorType &_q) const
Approximation of the scalar field gradient at .
Line< DataPoint, _NFilter, T > & implicitPrimitive()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
VectorType project(const VectorType &_q) const
Project a point on the line.
Scalar potential(const VectorType &_q) const
Value of the scalar field at the location , defined as the squared distance between and the line.
void setLine(const VectorType &origin, const VectorType &direction)
Init the line from a direction and a position.
Eigen::ParametrizedLine< typename DataPoint::Scalar, DataPoint::Dim > EigenBase
Specialization of Eigen::ParametrizedLine inherited by Ponca::Line.
typename DataPoint::Scalar Scalar
Alias to scalar type.
bool operator!=(const Line< DataPoint, NeighborFilter, T > &other) const
Comparison operator, convenience function.
typename Base::VectorType VectorType
Alias to vector type.
VectorType primitiveGradient() const
Gradient of the scalar field at the line location.
bool isValid() const
Tell if the line as been correctly set. Used to set CONFLICT_ERROR_FOUND during fitting.
This Source Code Form is subject to the terms of the Mozilla Public License, v.