From acb0950398836b3ab75dab263315de5af16bc6bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 17 Jun 2011 13:04:58 +0000 Subject: [PATCH] BUGFIX (together with 64192,64193,64194): Modifiable_priority_queue no longer depends on non-documented boost code. This code has been copied into CGAL. Modify boost's mutable_queue to have a constructor initializing indices of elements not in the queue to the maximum number of elements. Update pop to maintain this property --- .../include/CGAL/Modifiable_priority_queue.h | 11 +++++---- .../CGAL/internal/boost/array_binary_tree.hpp | 5 ++++ .../CGAL/internal/boost/mutable_heap.hpp | 5 ++++ .../CGAL/internal/boost/mutable_queue.hpp | 24 +++++++++++++++---- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/STL_Extension/include/CGAL/Modifiable_priority_queue.h b/STL_Extension/include/CGAL/Modifiable_priority_queue.h index 45d25779cf9..be21614a98a 100644 --- a/STL_Extension/include/CGAL/Modifiable_priority_queue.h +++ b/STL_Extension/include/CGAL/Modifiable_priority_queue.h @@ -24,7 +24,7 @@ #ifdef CGAL_SURFACE_MESH_SIMPLIFICATION_USE_RELAXED_HEAP #include #else -#include +#include namespace CGAL { @@ -32,15 +32,16 @@ namespace CGAL { template , class Comp = std::less, - class ID = boost::identity_property_map > -class mutable_queue_with_remove : public boost::mutable_queue + class ID = ::boost::identity_property_map > +class mutable_queue_with_remove : public internal::boost::mutable_queue { - typedef boost::mutable_queue Base; + typedef internal::boost::mutable_queue Base; public: typedef typename Base::size_type size_type; typedef typename Base::Node Node; - mutable_queue_with_remove(size_type n, const Comp& x=Comp(), const ID& _id=ID()) : Base(n,x,_id) {} + mutable_queue_with_remove(size_type n, const Comp& x=Comp(), const ID& _id=ID()) : Base(n,x,_id,true) + {} void remove(const IndexedType& x){ //first place element at the top diff --git a/STL_Extension/include/CGAL/internal/boost/array_binary_tree.hpp b/STL_Extension/include/CGAL/internal/boost/array_binary_tree.hpp index 990ac8594b2..2741376707e 100644 --- a/STL_Extension/include/CGAL/internal/boost/array_binary_tree.hpp +++ b/STL_Extension/include/CGAL/internal/boost/array_binary_tree.hpp @@ -11,6 +11,11 @@ // $URL$ // $Id$ // +// NOTE: this file have been taken from boost 1.46.1 for using +// with Modificable_priority_queue (to enhance the +// non-documented mutable_queue). +// original file is +// #ifndef CGAL_INTERNAL_ARRAY_BINARY_TREE_HPP #define CGAL_INTERNAL_ARRAY_BINARY_TREE_HPP diff --git a/STL_Extension/include/CGAL/internal/boost/mutable_heap.hpp b/STL_Extension/include/CGAL/internal/boost/mutable_heap.hpp index fc536fae98a..b6be2d8290d 100644 --- a/STL_Extension/include/CGAL/internal/boost/mutable_heap.hpp +++ b/STL_Extension/include/CGAL/internal/boost/mutable_heap.hpp @@ -11,6 +11,11 @@ // $URL$ // $Id$ // +// NOTE: this file have been taken from boost 1.46.1 for using +// with Modificable_priority_queue (to enhance the +// non-documented mutable_queue). +// original file is +// #ifndef CGAL_INTERNAL_BOOST_MUTABLE_HEAP_H #define CGAL_INTERNAL_BOOST_MUTABLE_HEAP_H diff --git a/STL_Extension/include/CGAL/internal/boost/mutable_queue.hpp b/STL_Extension/include/CGAL/internal/boost/mutable_queue.hpp index 0745adf50a4..7b897b20f1c 100644 --- a/STL_Extension/include/CGAL/internal/boost/mutable_queue.hpp +++ b/STL_Extension/include/CGAL/internal/boost/mutable_queue.hpp @@ -11,6 +11,11 @@ // $URL$ // $Id$ // +// NOTE: this file have been taken from boost 1.46.1 for using +// with Modificable_priority_queue (to enhance the +// non-documented mutable_queue). +// original file is +// #ifndef CGAL_INTERNAL_BOOST_MUTABLE_QUEUE_HPP #define CGAL_INTERNAL_BOOST_MUTABLE_QUEUE_HPP @@ -63,6 +68,14 @@ namespace boost { : index_array(n), comp(x), id(_id) { c.reserve(n); } +//SL: added this constructor so that index_array is filled with +// indices equals to n. Maintaining this property in pop allows +// to have a method to detect if an element is in the queue + mutable_queue(size_type n, const Comp& x, const ID& _id,bool) + : index_array(n,n), comp(x), id(_id) { + c.reserve(n); + } + template mutable_queue(ForwardIterator first, ForwardIterator last, const Comp& x, const ID& _id) @@ -75,7 +88,10 @@ namespace boost { } bool empty() const { return c.empty(); } - +//SL: modified this function so that the element popped from the queue +// has its index set to the max number of element. That way we know +// that an element is not in the tree if its index is the max number +// of elements. void pop() { value_type tmp = c.back(); c.back() = c.front(); @@ -83,10 +99,10 @@ namespace boost { size_type id_f = get(id, c.back()); size_type id_b = get(id, tmp); - size_type i = index_array[ id_b ]; + //SL was: size_type i = index_array[ id_b ]; index_array[ id_b ] = index_array[ id_f ]; - index_array[ id_f ] = i; - + //SL was: index_array[ id_f ] = i; + index_array[ id_f ] = index_array.size(); /*SL added*/ c.pop_back(); Node node(c.begin(), c.end(), c.begin(), id); down_heap(node, comp, index_array);