Fix compilation errors

This commit is contained in:
Laurent Rineau 2017-10-30 16:16:25 +01:00
parent a2fc6e1830
commit 2b7bd7c4b8
4 changed files with 76 additions and 20 deletions

View File

@ -53,7 +53,19 @@ public:
typedef typename internal::vector<Node>::iterator Self_iterator; typedef typename internal::vector<Node>::iterator Self_iterator;
typedef typename Traits::Point_2 Point_2; typedef typename Traits::Point_2 Point_2;
using internal::vector< Rotation_tree_node_2<Traits_> >::push_back; using internal::vector< Rotation_tree_node_2<Traits_> >::push_back;
class Less {
typename Traits::Less_xy_2 less;
typedef typename Traits::Point_2 Point;
public:
Less(typename Traits::Less_xy_2 less) : less(less) {}
template <typename Point_like>
bool operator()(const Point_like& p1, const Point_like& p2) {
return less(Point(p1), Point(p2));
}
};
// constructor // constructor
template<class ForwardIterator> template<class ForwardIterator>
@ -62,8 +74,8 @@ public:
for (ForwardIterator it = first; it != beyond; it++) for (ForwardIterator it = first; it != beyond; it++)
push_back(*it); push_back(*it);
std::sort(this->begin(), this->end(), Less less (Traits().less_xy_2_object());
boost::bind(Traits().less_xy_2_object(), _2, _1)); std::sort(this->begin(), this->end(), less);
std::unique(this->begin(), this->end()); std::unique(this->begin(), this->end());
// front() is the point with the largest x coordinate // front() is the point with the largest x coordinate
@ -166,3 +178,8 @@ private:
#include <CGAL/Partition_2/Rotation_tree_2_impl.h> #include <CGAL/Partition_2/Rotation_tree_2_impl.h>
#endif // CGAL_ROTATION_TREE_H #endif // CGAL_ROTATION_TREE_H
// For the Emacs editor:
// Local Variables:
// c-basic-offset: 3
// End:

View File

@ -57,9 +57,11 @@ private:
Circulator _p0, _p1, _p2; Circulator _p0, _p1, _p2;
}; };
template <class Compare_x_2> template <class Traits>
class Indirect_compare_x_2 class Indirect_compare_x_2
{ {
typedef typename Traits::Compare_x_2 Compare_x_2;
typedef typename Traits::Point_2 Point;
public: public:
Indirect_compare_x_2(const Compare_x_2& compare_x_2) Indirect_compare_x_2(const Compare_x_2& compare_x_2)
: _compare_x_2(compare_x_2) : _compare_x_2(compare_x_2)
@ -68,16 +70,18 @@ public:
template <class Point_2_ptr> template <class Point_2_ptr>
Comparison_result operator()(Point_2_ptr p1, Point_2_ptr p2) Comparison_result operator()(Point_2_ptr p1, Point_2_ptr p2)
{ {
return _compare_x_2(*p1, *p2); return _compare_x_2(Point(*p1), Point(*p2));
} }
private: private:
Compare_x_2 _compare_x_2; Compare_x_2 _compare_x_2;
}; };
template <class Compare_y_2> template <class Traits>
class Indirect_compare_y_2 class Indirect_compare_y_2
{ {
typedef typename Traits::Compare_y_2 Compare_y_2;
typedef typename Traits::Point_2 Point;
public: public:
Indirect_compare_y_2(const Compare_y_2& compare_y_2) Indirect_compare_y_2(const Compare_y_2& compare_y_2)
: _compare_y_2(compare_y_2) : _compare_y_2(compare_y_2)
@ -86,16 +90,18 @@ public:
template <class Point_2_ptr> template <class Point_2_ptr>
Comparison_result operator()(Point_2_ptr p1, Point_2_ptr p2) Comparison_result operator()(Point_2_ptr p1, Point_2_ptr p2)
{ {
return _compare_y_2(*p1, *p2); return _compare_y_2(Point(*p1), Point(*p2));
} }
private: private:
Compare_y_2 _compare_y_2; Compare_y_2 _compare_y_2;
}; };
template <class Orientation_2> template <class Traits>
class Indirect_orientation_2 class Indirect_orientation_2
{ {
typedef typename Traits::Orientation_2 Orientation_2;
typedef typename Traits::Point_2 Point;
public: public:
Indirect_orientation_2(const Orientation_2& orientation_2) Indirect_orientation_2(const Orientation_2& orientation_2)
: _orientation_2(orientation_2) : _orientation_2(orientation_2)
@ -104,7 +110,7 @@ public:
template <class Point_2_ptr> template <class Point_2_ptr>
Orientation operator()(Point_2_ptr p1, Point_2_ptr p2, Point_2_ptr p3) Orientation operator()(Point_2_ptr p1, Point_2_ptr p2, Point_2_ptr p3)
{ {
return _orientation_2(*p1, *p2, *p3); return _orientation_2(Point(*p1), Point(*p2), Point(*p3));
} }
private: private:
@ -139,9 +145,9 @@ public:
typedef Indirect_segment<Circulator> Segment_2; typedef Indirect_segment<Circulator> Segment_2;
typedef Indirect_triangle<Circulator> Triangle_2; typedef Indirect_triangle<Circulator> Triangle_2;
typedef Indirect_orientation_2<typename Traits::Orientation_2> Orientation_2; typedef Indirect_orientation_2<Traits> Orientation_2;
typedef Indirect_compare_x_2<typename Traits::Compare_x_2> Compare_x_2; typedef Indirect_compare_x_2<Traits> Compare_x_2;
typedef Indirect_compare_y_2<typename Traits::Compare_y_2> Compare_y_2; typedef Indirect_compare_y_2<Traits> Compare_y_2;
typedef Construct_indirect_segment_2<Circulator> Construct_segment_2; typedef Construct_indirect_segment_2<Circulator> Construct_segment_2;
typedef Construct_circulator_2<Circulator> Construct_point_2; typedef Construct_circulator_2<Circulator> Construct_point_2;
@ -181,3 +187,8 @@ private:
} }
#endif // CGAL_TRIANGULATION_INDIRECT_TRAITS_2_H #endif // CGAL_TRIANGULATION_INDIRECT_TRAITS_2_H
// For the Emacs editor
// Local Variables:
// c-basic-offset: 3
// End:

View File

@ -227,20 +227,21 @@ Vertex_visibility_graph_2<Traits>::left_turn_to_parent(
Tree_iterator q, Tree_iterator q,
Tree& tree) Tree& tree)
{ {
typedef typename Traits::Point_2 Point;
if (tree.parent_is_p_infinity(q)) if (tree.parent_is_p_infinity(q))
{ {
return (less_xy_2(*p, *q)); return (less_xy_2(Point(*p), Point(*q)));
} }
else if (orientation_2(*p, *q, *(*q).parent()) == COLLINEAR && else if (orientation_2(Point(*p), Point(*q), Point(*q->parent())) == COLLINEAR &&
(collinear_ordered_2(*p, *q, *(*q).parent()) || (collinear_ordered_2(Point(*p), Point(*q), Point(*q->parent())) ||
collinear_ordered_2(*p, *q, *(*q).parent()))) collinear_ordered_2(Point(*p), Point(*q), Point(*q->parent()))))
{ {
return true; return true;
} }
else else
{ {
return left_turn_2(*p, *q, *(*q).parent()); return left_turn_2(Point(*p), Point(*q), Point(*q->parent()));
} }
} }

View File

@ -52,6 +52,25 @@ bool is_simple_2(ForwardIterator first,
return is_simple_polygon(first, last, traits); return is_simple_polygon(first, last, traits);
} }
namespace internal { namespace Polygon_2 {
template <typename Traits>
class Compare_vertices {
typedef typename Traits::Less_xy_2 Less_xy_2;
typedef typename Traits::Point_2 Point_2;
Less_xy_2 less;
public:
Compare_vertices(Less_xy_2 less) : less(less) {}
// `Point_like` derives from `Point_2`
template <typename Point_like>
bool operator()(const Point_like& p1, const Point_like& p2) {
return less(Point_2(p1), Point_2(p2));
}
}; // end Compare_vertices
} // end namespace Polygon_2
} // end namespace internal
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
// left_vertex_2 // left_vertex_2
@ -64,7 +83,9 @@ ForwardIterator left_vertex_2(ForwardIterator first,
const PolygonTraits&traits) const PolygonTraits&traits)
{ {
CGAL_polygon_precondition(first != last); CGAL_polygon_precondition(first != last);
return std::min_element(first, last, traits.less_xy_2_object()); internal::Polygon_2::Compare_vertices<PolygonTraits>
less(traits.less_xy_2_object());
return std::min_element(first, last, less);
} }
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
@ -78,7 +99,9 @@ ForwardIterator right_vertex_2(ForwardIterator first,
const PolygonTraits &traits) const PolygonTraits &traits)
{ {
CGAL_polygon_precondition(first != last); CGAL_polygon_precondition(first != last);
return std::max_element(first, last, traits.less_xy_2_object()); internal::Polygon_2::Compare_vertices<PolygonTraits>
less(traits.less_xy_2_object());
return std::max_element(first, last, less);
} }
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
@ -423,3 +446,7 @@ Orientation orientation_2(ForwardIterator first,
} //namespace CGAL } //namespace CGAL
/// \endcond /// \endcond
// Local Variables:
// c-basic-offset: 4
// End: