From aa03fdc65e5605d1c0b448d227d4def8c88c3bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 27 Apr 2017 13:52:20 +0200 Subject: [PATCH] Adapted sorting algorithms based on compare_xyz to handle weighted point vectors --- .../include/CGAL/Regular_triangulation_3.h | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 439f7438514..2190484f9c5 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef CGAL_LINKED_WITH_TBB @@ -1627,13 +1628,22 @@ dual(Cell_handle c) const return os; // We are now in a degenerate case => we do a symbolic perturbation. + typename Geom_traits::Construct_point_3 cp = + geom_traits().construct_point_3_object(); // We sort the points lexicographically. const Weighted_point * points[5] = {&p0, &p1, &p2, &p3, &p}; + + // It is important to tell boost::bind that we want references in return + // by writing `boost::bind(...)` otherwise we get temporaries + // and we call Compare_xyz_3 on objects that might have been cleaned std::sort(points, points + 5, boost::bind(geom_traits().compare_xyz_3_object(), - boost::bind(Dereference(), _1), - boost::bind(Dereference(), _2)) == SMALLER); + boost::bind( + cp, boost::bind(Dereference(), _1)), + boost::bind( + cp, boost::bind(Dereference(), _2))) + == SMALLER); // We successively look whether the leading monomial, then 2nd monomial // of the determinant has non null coefficient. @@ -1737,13 +1747,22 @@ dual(Cell_handle c) const return os; // We are now in a degenerate case => we do a symbolic perturbation. + typename Geom_traits::Construct_point_3 cp = + geom_traits().construct_point_3_object(); // We sort the points lexicographically. const Weighted_point * points[4] = {&p0, &p1, &p2, &p}; + + // It is important to tell boost::bind that we want references in return + // by writing `boost::bind(...)` otherwise we get temporaries + // and we call Compare_xyz_3 on objects that might have been cleaned std::sort(points, points + 4, boost::bind(geom_traits().compare_xyz_3_object(), - boost::bind(Dereference(), _1), - boost::bind(Dereference(), _2)) == SMALLER); + boost::bind( + cp, boost::bind(Dereference(), _1)), + boost::bind( + cp, boost::bind(Dereference(), _2))) + == SMALLER); // We successively look whether the leading monomial, then 2nd monomial // of the determinant has non null coefficient.