From f21ab5a1a112a0692c3ee3b26ddccca13512bf98 Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Thu, 14 Oct 2021 17:48:43 +0200 Subject: [PATCH] When cells have id, store the max id. --- .../include/CGAL/Cell_attribute.h | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 4409b2ebfe3..99b502ec202 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -14,6 +14,7 @@ #include #include +#include namespace CGAL { @@ -83,15 +84,27 @@ namespace CGAL { const std::size_t& id() const { return m_id; } - protected: - void set_id(std::size_t id) - { m_id=id; } + static const std::size_t& max_id() + { return m_max_id; } protected: - /// id of the cell - std::size_t m_id; + void set_id(std::size_t id) + { + m_id=id; + if (m_id+1>m_max_id) { m_max_id=m_id+1; } + } + + static void reset_max_id() + { m_max_id=0; } + + protected: + std::size_t m_id; ///< id of the cell + static std::size_t m_max_id; ///< max id used (warning: never decreases) }; + template + std::size_t Add_id::m_max_id=0; + /// If the tag WithId is false, we do not add id to cells. template <> class Add_id