mirror of https://github.com/CGAL/cgal
replace bind in Convex_hull_2
This commit is contained in:
parent
1e249afdb3
commit
c4ad713b9e
|
|
@ -2,7 +2,6 @@
|
||||||
#include <CGAL/ch_graham_andrew.h>
|
#include <CGAL/ch_graham_andrew.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/bind.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||||
|
|
@ -23,7 +22,7 @@ ch_graham_anderson( InputIterator first, InputIterator beyond,
|
||||||
std::vector< Point_2 > V (first, beyond);
|
std::vector< Point_2 > V (first, beyond);
|
||||||
typename std::vector< Point_2 >::iterator it =
|
typename std::vector< Point_2 >::iterator it =
|
||||||
std::min_element(V.begin(), V.end(), Less_xy_2());
|
std::min_element(V.begin(), V.end(), Less_xy_2());
|
||||||
std::sort( V.begin(), V.end(), boost::bind(Less_rotate_ccw_2(), *it, _1, _2) );
|
std::sort( V.begin(), V.end(), [it](const Point_2& p1, const Point_2& p2){return Less_rotate_ccw_2()(*it, p1, p2);} );
|
||||||
if ( *(V.begin()) != *(V.rbegin()) )
|
if ( *(V.begin()) != *(V.rbegin()) )
|
||||||
{
|
{
|
||||||
result = CGAL::ch_graham_andrew_scan( V.begin(), V.end(), result, ch_traits);
|
result = CGAL::ch_graham_andrew_scan( V.begin(), V.end(), result, ch_traits);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include <CGAL/ch_graham_andrew.h>
|
#include <CGAL/ch_graham_andrew.h>
|
||||||
#include <CGAL/algorithm.h>
|
#include <CGAL/algorithm.h>
|
||||||
#include <CGAL/IO/Tee_for_output_iterator.h>
|
#include <CGAL/IO/Tee_for_output_iterator.h>
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <CGAL/tuple.h>
|
#include <CGAL/tuple.h>
|
||||||
#include <CGAL/utility.h>
|
#include <CGAL/utility.h>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
@ -296,9 +295,11 @@ ch_akl_toussaint(ForwardIterator first, ForwardIterator last,
|
||||||
std::sort( std::next(region2.begin() ), region2.end(),
|
std::sort( std::next(region2.begin() ), region2.end(),
|
||||||
ch_traits.less_xy_2_object() );
|
ch_traits.less_xy_2_object() );
|
||||||
std::sort( std::next(region3.begin() ), region3.end(),
|
std::sort( std::next(region3.begin() ), region3.end(),
|
||||||
boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
|
[&ch_traits](const Point_2& p1, const Point_2& p2)
|
||||||
|
{ return ch_traits.less_xy_2_object()(p2, p1); });
|
||||||
std::sort( std::next(region4.begin() ), region4.end(),
|
std::sort( std::next(region4.begin() ), region4.end(),
|
||||||
boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
|
[&ch_traits](const Point_2& p1, const Point_2& p2)
|
||||||
|
{ return ch_traits.less_xy_2_object()(p2, p1); });
|
||||||
|
|
||||||
if (! equal_points(*w,*s) )
|
if (! equal_points(*w,*s) )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#include <CGAL/algorithm.h>
|
#include <CGAL/algorithm.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/bind.hpp>
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
template <class InputIterator, class OutputIterator, class Traits>
|
template <class InputIterator, class OutputIterator, class Traits>
|
||||||
|
|
@ -77,18 +76,21 @@ ch_bykat(InputIterator first, InputIterator last,
|
||||||
H.push_back( a );
|
H.push_back( a );
|
||||||
L.push_back( P.begin() );
|
L.push_back( P.begin() );
|
||||||
R.push_back( l = std::partition(P.begin(), P.end(),
|
R.push_back( l = std::partition(P.begin(), P.end(),
|
||||||
boost::bind(left_turn, boost::cref(a), boost::cref(b), _1)));
|
[&left_turn, &a, &b](const Point_2& p){ return left_turn(a,b,p); }) );
|
||||||
r = std::partition( l, P.end(), boost::bind(left_turn, boost::cref(b), boost::cref(a), _1));
|
r = std::partition( l, P.end(), [&left_turn, &a, &b](const Point_2& p){ return left_turn(b,a,p); });
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if ( l != r)
|
if ( l != r)
|
||||||
{
|
{
|
||||||
Point_2 c = *std::min_element( l, r, boost::bind(less_dist, boost::cref(a), boost::cref(b), _1, _2));
|
Point_2 c = *std::min_element( l, r, [&less_dist,&a,&b](const Point_2&p1, const Point_2& p2)
|
||||||
|
{ return less_dist(a, b, p1, p2); });
|
||||||
H.push_back( b );
|
H.push_back( b );
|
||||||
L.push_back( l );
|
L.push_back( l );
|
||||||
R.push_back( l = std::partition(l, r, boost::bind(left_turn, boost::cref(b), boost::cref(c), _1)));
|
R.push_back( l = std::partition(l, r, [&left_turn,&c,&b](const Point_2&p)
|
||||||
r = std::partition(l, r, boost::bind(left_turn, boost::cref(c), boost::cref(a), _1));
|
{ return left_turn(b, c, p); }));
|
||||||
|
r = std::partition(l, r, [&left_turn,&c,&a](const Point_2&p)
|
||||||
|
{ return left_turn(c, a, p); });
|
||||||
b = c;
|
b = c;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -173,8 +175,10 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last,
|
||||||
H.push_back( a );
|
H.push_back( a );
|
||||||
L.push_back( Pbegin );
|
L.push_back( Pbegin );
|
||||||
Left_turn_2 left_turn = ch_traits.left_turn_2_object();
|
Left_turn_2 left_turn = ch_traits.left_turn_2_object();
|
||||||
R.push_back( l = std::partition( Pbegin, Pend, boost::bind(left_turn, boost::cref(a), boost::cref(b), _1)));
|
R.push_back( l = std::partition( Pbegin, Pend, [&left_turn,&a,&b](const Point_2&p)
|
||||||
r = std::partition( l, Pend, boost::bind(left_turn, boost::cref(b), boost::cref(a), _1));
|
{ return left_turn(a, b, p); }));
|
||||||
|
r = std::partition( l, Pend, [&left_turn,&a,&b](const Point_2&p)
|
||||||
|
{ return left_turn(b, a, p); });
|
||||||
|
|
||||||
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
|
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
|
||||||
for (;;)
|
for (;;)
|
||||||
|
|
@ -183,11 +187,14 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last,
|
||||||
{
|
{
|
||||||
if ( r-l > CGAL_ch_THRESHOLD )
|
if ( r-l > CGAL_ch_THRESHOLD )
|
||||||
{
|
{
|
||||||
Point_2 c = *std::min_element( l, r, boost::bind(less_dist, boost::cref(a), boost::cref(b), _1, _2));
|
Point_2 c = *std::min_element( l, r, [&less_dist,&a,&b](const Point_2&p1, const Point_2& p2)
|
||||||
|
{ return less_dist(a, b, p1, p2); });
|
||||||
H.push_back( b );
|
H.push_back( b );
|
||||||
L.push_back( l );
|
L.push_back( l );
|
||||||
R.push_back( l = std::partition(l, r, boost::bind(left_turn, boost::cref(b), boost::cref(c), _1)));
|
R.push_back( l = std::partition(l, r, [&left_turn,&c,&b](const Point_2&p)
|
||||||
r = std::partition(l, r, boost::bind(left_turn, boost::cref(c), boost::cref(a), _1));
|
{ return left_turn(b, c, p); }));
|
||||||
|
r = std::partition(l, r, [&left_turn,&a,&c](const Point_2&p)
|
||||||
|
{ return left_turn(c, a, p); });
|
||||||
b = c;
|
b = c;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -201,8 +208,8 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::sort(std::next(l), r,
|
std::sort(std::next(l), r, [&ch_traits](const Point_2&p1, const Point_2& p2)
|
||||||
boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
|
{ return ch_traits.less_xy_2_object()(p2, p1); });
|
||||||
}
|
}
|
||||||
ch__ref_graham_andrew_scan(l, std::next(r), res, ch_traits);
|
ch__ref_graham_andrew_scan(l, std::next(r), res, ch_traits);
|
||||||
std::swap( a, *l);
|
std::swap( a, *l);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include <CGAL/algorithm.h>
|
#include <CGAL/algorithm.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/bind.hpp>
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
@ -45,7 +44,8 @@ ch__recursive_eddy(List& L,
|
||||||
|
|
||||||
CGAL_ch_precondition( \
|
CGAL_ch_precondition( \
|
||||||
std::find_if(a_it, b_it, \
|
std::find_if(a_it, b_it, \
|
||||||
boost::bind(left_turn, *b_it, *a_it, _1)) \
|
[&left_turn, a_it, b_it](const Point_2& p)
|
||||||
|
{ return left_turn(*b_it, *a_it, p); }) \
|
||||||
!= b_it );
|
!= b_it );
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,11 +53,14 @@ ch__recursive_eddy(List& L,
|
||||||
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
|
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
|
||||||
ListIterator
|
ListIterator
|
||||||
c_it = std::min_element( f_it, b_it, // max before
|
c_it = std::min_element( f_it, b_it, // max before
|
||||||
boost::bind(less_dist, *a_it, *b_it, _1, _2));
|
[&less_dist, a_it, b_it](const Point_2& p1, const Point_2& p2)
|
||||||
|
{ return less_dist(*a_it, *b_it, p1, p2); });
|
||||||
Point_2 c = *c_it;
|
Point_2 c = *c_it;
|
||||||
|
|
||||||
c_it = std::partition(f_it, b_it, boost::bind(left_turn, c, *a_it, _1));
|
c_it = std::partition(f_it, b_it, [&left_turn, &c, a_it](const Point_2& p)
|
||||||
f_it = std::partition(c_it, b_it, boost::bind(left_turn, *b_it, c, _1));
|
{return left_turn(c, *a_it, p);});
|
||||||
|
f_it = std::partition(c_it, b_it, [&left_turn, &c, b_it](const Point_2& p)
|
||||||
|
{return left_turn(*b_it, c, p);});
|
||||||
c_it = L.insert(c_it, c);
|
c_it = L.insert(c_it, c);
|
||||||
L.erase( f_it, b_it );
|
L.erase( f_it, b_it );
|
||||||
|
|
||||||
|
|
@ -104,7 +107,8 @@ ch_eddy(InputIterator first, InputIterator last,
|
||||||
L.erase(e);
|
L.erase(e);
|
||||||
|
|
||||||
e = std::partition(L.begin(), L.end(),
|
e = std::partition(L.begin(), L.end(),
|
||||||
boost::bind(left_turn, ep, wp, _1) );
|
[&left_turn, &wp, &ep](const Point_2& p)
|
||||||
|
{return left_turn(ep, wp, p);} );
|
||||||
L.push_front(wp);
|
L.push_front(wp);
|
||||||
e = L.insert(e, ep);
|
e = L.insert(e, ep);
|
||||||
|
|
||||||
|
|
@ -112,7 +116,8 @@ ch_eddy(InputIterator first, InputIterator last,
|
||||||
{
|
{
|
||||||
ch__recursive_eddy( L, L.begin(), e, ch_traits);
|
ch__recursive_eddy( L, L.begin(), e, ch_traits);
|
||||||
}
|
}
|
||||||
w = std::find_if( e, L.end(), boost::bind(left_turn, wp, ep, _1) );
|
w = std::find_if( e, L.end(), [&left_turn, &wp, &ep](const Point_2& p)
|
||||||
|
{ return left_turn(wp, ep, p); });
|
||||||
if ( w == L.end() )
|
if ( w == L.end() )
|
||||||
{
|
{
|
||||||
L.erase( ++e, L.end() );
|
L.erase( ++e, L.end() );
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
#include <CGAL/Convex_hull_2/ch_assertions.h>
|
#include <CGAL/Convex_hull_2/ch_assertions.h>
|
||||||
#include <CGAL/ch_selected_extreme_points_2.h>
|
#include <CGAL/ch_selected_extreme_points_2.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/bind.hpp>
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
@ -65,7 +64,8 @@ ch_jarvis_march(ForwardIterator first, ForwardIterator last,
|
||||||
Point previous_point = start_p; )
|
Point previous_point = start_p; )
|
||||||
|
|
||||||
ForwardIterator it = std::min_element( first, last,
|
ForwardIterator it = std::min_element( first, last,
|
||||||
boost::bind(rotation_predicate, boost::cref(start_p), _1, _2) );
|
[&start_p, &rotation_predicate](const Point& p1, const Point& p2)
|
||||||
|
{return rotation_predicate(start_p, p1, p2);} );
|
||||||
while (! equal_points(*it, stop_p) )
|
while (! equal_points(*it, stop_p) )
|
||||||
{
|
{
|
||||||
CGAL_ch_exactness_assertion( \
|
CGAL_ch_exactness_assertion( \
|
||||||
|
|
@ -80,7 +80,8 @@ ch_jarvis_march(ForwardIterator first, ForwardIterator last,
|
||||||
constructed_points <= count_points + 1 );
|
constructed_points <= count_points + 1 );
|
||||||
|
|
||||||
it = std::min_element( first, last,
|
it = std::min_element( first, last,
|
||||||
boost::bind(rotation_predicate, *it, _1, _2) );
|
[it, &rotation_predicate](const Point& p1, const Point& p2)
|
||||||
|
{return rotation_predicate(*it, p1, p2);} );
|
||||||
}
|
}
|
||||||
CGAL_ch_postcondition( \
|
CGAL_ch_postcondition( \
|
||||||
is_ccw_strongly_convex_2( res.output_so_far_begin(), \
|
is_ccw_strongly_convex_2( res.output_so_far_begin(), \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue