36#if defined(SegmentComputerEstimators_RECURSES)
37#error Recursive header files inclusion detected in SegmentComputerEstimators.h
40#define SegmentComputerEstimators_RECURSES
42#if !defined SegmentComputerEstimators_h
44#define SegmentComputerEstimators_h
49#include "DGtal/base/Common.h"
50#include "DGtal/helpers/StdDefs.h"
51#include "boost/utility.hpp"
83 template <
typename TSegmentComputer,
typename Functor,
84 typename ReturnType =
typename Functor::Value>
174 template <
typename OutputIterator>
176 OutputIterator result)
const
215 template <
typename TSegmentComputer,
typename Functor,
216 typename ReturnType =
typename Functor::Value>
348 template <
typename OutputIterator>
350 OutputIterator result)
const
387 template <
typename TSegmentComputer,
typename Functor,
388 typename ReturnType =
typename Functor::Value>
478 template <
typename OutputIterator>
480 OutputIterator result)
const
518 template <
typename TSegmentComputer,
typename Functor,
519 typename ReturnType =
typename Functor::Value>
652 template <
typename OutputIterator>
654 OutputIterator result)
const
700 template<
typename DSS>
704 ::castToDouble(aDSS.a());
706 ::castToDouble(aDSS.b());
708 return std::atan2(a,b);
733 template<
typename DSS>
750 template<
typename DSS>
767 return Value(aDSS.b(), aDSS.a());
782 template<
bool isCCW = true>
801 template<
typename DCA>
804 if ( aDCA.isStraight() )
807 return ( aDCA.getSeparatingCircle().getCurvature() / aH );
816 template<
typename DCA>
819 if ( aDCA.isStraight() )
822 return - ( aDCA.getSeparatingCircle().getCurvature() / aH );
848 template<
typename DCA>
850 const DCA& aDCA)
const
852 typedef typename DCA::Pair Pair;
853 typedef typename DCA::Point
Point;
854 typedef typename Point::Coordinate Coordinate;
856 if ( !aDCA.isStraight() )
860 aDCA.getSeparatingCircle().getParameters(c0, c1, r);
863 Point i = pair.first;
864 Point o = pair.second;
871 double n = std::sqrt(v0*v0 + v1*v1);
872 return Value( v0/n, v1/n );
878 aDCA.getStabbingLineComputerPtr()->getParameters(a, b, c);
880 double n = std::sqrt(a*a + b*b);
881 return Value( a/n, b/n );
910 template<
typename DCA>
912 const DCA& aDCA)
const
915 Value normal = f(it, aDCA);
916 return Value( normal[1], normal[0] );
928 typedef std::pair<double,double>
Value;
946 template<
typename DCA>
948 const DCA& aDCA,
const double& aH)
const
950 typedef typename DCA::Pair Pair;
951 typedef typename DCA::Point
Point;
952 typedef typename Point::Coordinate Coordinate;
954 if ( !aDCA.isStraight() )
958 aDCA.getSeparatingCircle().getParameters(c0, c1, r);
961 Point i = pair.first;
962 Point o = pair.second;
966 double distI = std::sqrt( distI0*distI0 + distI1*distI1 ) - r;
969 double distO = std::sqrt( distO0*distO0 + distO1*distO1 ) - r;
970 return Value( distI*aH, distO*aH );
976 aDCA.getStabbingLineComputerPtr()->getParameters(a, b, c);
978 double n = std::sqrt(a*a + b*b);
981 Point i = pair.first;
982 Point o = pair.second;
986 double distI = rI / n;
989 double distO = rO / n;
990 return Value( distI*aH, distO*aH );
1008 template <
typename DSSComputer>
1037 template <
typename DSSComputer>
1067 template <
typename DSSComputer>
1105 template <
typename DCAComputer,
bool isCCW = true>
1108 detail::CurvatureFromDCA<isCCW> >
1135 template <
typename DCAComputer>
1138 detail::NormalVectorFromDCA>
1165 template <
typename DCAComputer>
1168 detail::TangentVectorFromDCA>
1196 template <
typename DCAComputer>
1199 detail::DistanceFromDCA>
1238 template<
typename DSS>
1241 typedef typename DSS::Vector
Vector;
1243 Vector v = ( *aDSS.begin() - *boost::prior(aDSS.end()) );
1244 Value l = v.norm(Vector::L_2);
1246 return 1./( (l*l)/8. + 0.5 );
1266 template<
typename DSS>
1269 typedef typename DSS::Vector
Vector;
1271 Vector v = ( *aDSS.begin() - *boost::prior(aDSS.end()) );
1272 Value l = v.norm(Vector::L_2);
1274 Vector t( aDSS.b(), aDSS.a() );
1275 Value w = 1.0 / v.norm(Vector::L_2);
1277 return 1.0/( (l*l)/(8.*w) + w/2 );
1299 template <
typename DSSComputer,
typename Functor = detail::CurvatureFromDSSLength >
1411 typedef typename DSSComputer::Integer
Integer;
1412 typedef typename DSSComputer::Vector
Vector;
1429 if (isConnectedAtBack)
1433 if (isConnectedAtFront)
1435 if ((
mySCPtr->remainder(*back)<=mu-1)&&
1436 (
mySCPtr->remainder(*front)<=mu-1) )
1441 else if ( (
mySCPtr->remainder(*back)>=mu+omega)&&
1442 (
mySCPtr->remainder(*front)>=mu+omega) )
1450 if ( (
mySCPtr->remainder(*back)<=mu-1) )
1455 else if ( (
mySCPtr->remainder(*back)>=mu+omega) )
1462 else if (isConnectedAtFront)
1464 if ( (
mySCPtr->remainder(*front)<=mu-1) )
1469 else if ( (
mySCPtr->remainder(*front)>=mu+omega) )
1488 template <
typename OutputIterator>
1490 OutputIterator result)
1500 *result++ =
eval( it );
1502 }
while (it != ite);
1547 template <
typename DSSComputer>
1584 template <
typename DSSComputer>
1611#undef SegmentComputerEstimators_RECURSES
detail::PosIndepScaleDepSCEstimator< DCAComputer, detail::CurvatureFromDCA< isCCW > > Super
CurvatureFromDCAEstimator(const CurvatureFromDCAEstimator &other)
CurvatureFromDCAEstimator()
CurvatureFromDSSEstimator(const CurvatureFromDSSEstimator &other)
CurvatureFromDSSEstimator()
detail::CurvatureFromDSSBaseEstimator< DSSComputer, detail::CurvatureFromDSSLengthAndWidth > Super
detail::CurvatureFromDSSBaseEstimator< DSSComputer, detail::CurvatureFromDSSLength > Super
CurvatureFromDSSLengthEstimator()
CurvatureFromDSSLengthEstimator(const CurvatureFromDSSLengthEstimator &other)
DistanceFromDCAEstimator(const DistanceFromDCAEstimator &other)
DistanceFromDCAEstimator()
detail::PosDepScaleDepSCEstimator< DCAComputer, detail::DistanceFromDCA > Super
detail::PosDepScaleIndepSCEstimator< DCAComputer, detail::NormalVectorFromDCA > Super
NormalFromDCAEstimator(const NormalFromDCAEstimator &other)
Aim: Implements basic operations that will be used in Point and Vector classes.
TangentAngleFromDSSEstimator()
TangentAngleFromDSSEstimator(const TangentAngleFromDSSEstimator &other)
detail::PosIndepScaleIndepSCEstimator< DSSComputer, detail::TangentAngleFromDSS > Super
TangentFromDCAEstimator(const TangentFromDCAEstimator &other)
detail::PosDepScaleIndepSCEstimator< DCAComputer, detail::TangentVectorFromDCA > Super
TangentFromDCAEstimator()
detail::PosIndepScaleIndepSCEstimator< DSSComputer, detail::NormalizedTangentVectorFromDSS > Super
TangentFromDSSEstimator(const TangentFromDSSEstimator &other)
TangentFromDSSEstimator()
TangentVectorFromDSSEstimator(const TangentVectorFromDSSEstimator &other)
TangentVectorFromDSSEstimator()
detail::PosIndepScaleIndepSCEstimator< DSSComputer, detail::TangentVectorFromDSS< DSSComputer > > Super
DSSComputer::ConstIterator ConstIterator
BOOST_CONCEPT_ASSERT((concepts::CUnaryFunctor< Functor, SegmentComputer, Quantity >))
~CurvatureFromDSSBaseEstimator()
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
CurvatureFromDSSBaseEstimator(const CurvatureFromDSSBaseEstimator &other)
CurvatureFromDSSBaseEstimator & operator=(const CurvatureFromDSSBaseEstimator &other)
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result)
const SegmentComputer * mySCPtr
CurvatureFromDSSBaseEstimator()
void attach(const SegmentComputer &aSC)
Quantity eval(const ConstIterator &)
DSSComputer SegmentComputer
SegmentComputer::ConstIterator ConstIterator
~PosDepScaleDepSCEstimator()
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
PosDepScaleDepSCEstimator(const PosDepScaleDepSCEstimator &other)
PosDepScaleDepSCEstimator()
void attach(const SegmentComputer &aSC)
Quantity eval(const ConstIterator &it) const
PosDepScaleDepSCEstimator & operator=(const PosDepScaleDepSCEstimator &other)
const SegmentComputer * mySCPtr
TSegmentComputer SegmentComputer
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
SegmentComputer::ConstIterator ConstIterator
void init(const double, const ConstIterator &itb, const ConstIterator &ite)
void attach(const SegmentComputer &aSC)
const SegmentComputer * mySCPtr
Quantity eval(const ConstIterator &it) const
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
TSegmentComputer SegmentComputer
PosDepScaleIndepSCEstimator()
Quantity eval(const ConstIterator &) const
~PosIndepScaleDepSCEstimator()
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
PosIndepScaleDepSCEstimator()
void attach(const SegmentComputer &aSC)
TSegmentComputer SegmentComputer
SegmentComputer::ConstIterator ConstIterator
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
const SegmentComputer * mySCPtr
PosIndepScaleDepSCEstimator & operator=(const PosIndepScaleDepSCEstimator &other)
PosIndepScaleDepSCEstimator(const PosIndepScaleDepSCEstimator &other)
SegmentComputer::ConstIterator ConstIterator
PosIndepScaleIndepSCEstimator()
void attach(const SegmentComputer &aSC)
OutputIterator eval(const ConstIterator &itb, const ConstIterator &ite, OutputIterator result) const
const SegmentComputer * mySCPtr
void init(const double, const ConstIterator &itb, const ConstIterator &ite)
Quantity eval(const ConstIterator &) const
TSegmentComputer SegmentComputer
DigitalPlane::Point Vector
Point::Coordinate Integer
bool isNotEmpty(const IC &itb, const IC &ite, IteratorType)
DGtal is the top-level namespace which contains all DGtal functions and types.
static double castToDouble(const T &aT)
Aim: The traits class for all models of Cinteger.
Aim: Defines a unary functor, which associates arguments to results.
Value operator()(const DCA &aDCA, const double &aH=1.0) const
Value operator()(const DSS &aDSS) const
Value operator()(const DSS &aDSS) const
std::pair< double, double > Value
Value operator()(const typename DCA::ConstIterator &it, const DCA &aDCA, const double &aH) const
PointVector< 2, double > Value
Value operator()(const typename DCA::ConstIterator &it, const DCA &aDCA) const
Value operator()(const DSS &aDSS) const
DGtal::PointVector< 2, double > RealVector
Value operator()(const DSS &aDSS) const
PointVector< 2, double > Value
Value operator()(const typename DCA::ConstIterator &it, const DCA &aDCA) const
Value operator()(const DSS &aDSS) const
InHalfPlaneBySimple3x3Matrix< Point, double > Functor