30#include "DGtal/kernel/CPointFunctor.h"
31#include "DGtal/kernel/PointVector.h"
32#include "DGtal/kernel/PointFunctorHolder.h"
34#include "DGtalCatch.h"
36template <
typename T,
typename Po
int>
37T kernel(
Point const& pt,
Point const& center, T radius)
39 return (pt - center).norm() - radius;
42template <
typename T,
typename Po
int>
52 T operator() (
Point const& pt)
const
54 return kernel<T>(pt, center, radius);
58TEST_CASE(
"2D PointFunctorHolder from functor by rvalue",
"[2D][functor][rvalue]" )
60 using namespace DGtal;
64 auto fn = functors::holdPointFunctor<Point, Value>( Functor<Value, Point>(
Point(1, 0), 1 ) );
70 std::cout << fn << std::endl;
74 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
77TEST_CASE(
"2D PointFunctorHolder from functor by lvalue",
"[2D][functor][lvalue]" )
79 using namespace DGtal;
83 const auto functor = Functor<Value, Point>(
Point(1, 0), 1 );
84 auto fn = functors::holdPointFunctor<Point>( functor );
90 std::cout << fn << std::endl;
94 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
97TEST_CASE(
"2D PointFunctorHolder from lambda by rvalue",
"[2D][lambda][rvalue]" )
99 using namespace DGtal;
101 using Value = double;
104 const Value radius = 1;
106 auto fn = functors::holdPointFunctor<Point, Value>(
107 [¢er, &radius] (
Point const& pt) {
return kernel<Value>(pt, center, radius); }
114 std::cout << fn << std::endl;
118 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
121TEST_CASE(
"2D PointFunctorHolder from lambda by lvalue",
"[2D][lambda][lvalue]" )
123 using namespace DGtal;
125 using Value = double;
128 const Value radius = 1;
130 const auto lambda = [&
center, &radius] (
Point const& pt) {
return kernel<Value>(pt, center, radius); };
131 auto fn = functors::holdPointFunctor<Point, Value>( lambda );
137 std::cout << fn << std::endl;
141 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
Aim: Implements basic operations that will be used in Point and Vector classes.
Point center(const std::vector< Point > &points)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines a functor on points.
TEST_CASE("int container traits", "[int][traits]")
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
REQUIRE(domain.isInside(aPoint))