From d95ed10d76e67b26151ee25292f3b7c24b1a192a Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Thu, 7 Apr 2022 12:41:42 +0200 Subject: [PATCH] update --- .../include/CGAL/Cell_attribute.h | 2 +- .../include/CGAL/Combinatorial_map.h | 118 ++++- .../include/CGAL/Combinatorial_map_fwd.h | 22 +- .../CGAL/Combinatorial_map_iterators_base.h | 1 + .../include/CGAL/Combinatorial_map_storages.h | 411 ---------------- .../Combinatorial_map_storages_with_index.h | 459 ++++++++++++++++++ .../include/CGAL/Generic_map_min_items.h | 2 +- 7 files changed, 581 insertions(+), 434 deletions(-) create mode 100644 Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 02f2169e081..46a852ad0fd 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -670,7 +670,7 @@ namespace CGAL { friend class Concurrent_compact_container; public: - typedef Cell_attribute Self; + typedef Cell_attribute Self; typedef Tag_ Supports_cell_dart; typedef typename Refs::Dart_handle Dart_handle; diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index 895992e6c03..f0bbc880cad 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -153,7 +153,8 @@ namespace CGAL { using Base::dart; using Base::darts; using Base::number_of_darts; - + using Base::is_empty; + /// Typedef for attributes template struct Attribute_type: public Base::template Attribute_type @@ -657,6 +658,64 @@ namespace CGAL { return is; } + /** Create a new dart and add it to the map. + * The marks of the darts are initialised with mmask_marks, i.e. the dart + * is unmarked for all the marks. + * @return a Dart_handle on the new dart. + */ + template < typename... Args > + Dart_handle create_dart(const Args&... args) + { + Dart_handle res=mdarts.emplace(args...); + init_dart(res); + return res; + } + + /** Erase a dart from the list of darts. + * @param adart the dart to erase. + */ + void erase_dart(Dart_handle adart) + { + // 1) We update the number of marked darts. + for ( size_type i = 0; i < mnb_used_marks; ++i) + { + if (is_marked(adart, mused_marks_stack[i])) + --mnb_marked_darts[mused_marks_stack[i]]; + } + + // 2) We update the attribute_ref_counting. + Helper::template Foreach_enabled_attributes + >::run(*this,adart); + + // 3) We erase the dart. + mdarts.erase(adart); + } + + /** Erase a dart from the list of darts. Restricted version + * which do not delete attribute having no more dart associated. + * @param adart the dart to erase. + */ + void restricted_erase_dart(Dart_handle adart) + { + // 1) We update the number of marked darts. + for ( size_type i = 0; i < mnb_used_marks; ++i) + { + if (is_marked(adart, mused_marks_stack[i])) + --mnb_marked_darts[mused_marks_stack[i]]; + } + + // 2) We update the attribute_ref_counting. + Helper::template Foreach_enabled_attributes + >::run(*this,adart); + + // 3) We erase the dart. + mdarts.erase(adart); + } + + /// @return true if dh points to a used dart (i.e. valid). + bool is_dart_used(Dart_const_handle dh) const + { return mdarts.is_used(dh); } + /** Get the first dart of this map. * @return the first dart. */ @@ -4766,12 +4825,13 @@ namespace CGAL { Base(amap, converters, dartinfoconverter, pointconverter) {} }; + namespace Index { template < unsigned int d_, - class Items_=Combinatorial_map_min_items, - class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Combinatorial_map_storage_2 > + class Items_, + class Alloc_, + class Storage_> class Combinatorial_map : public Combinatorial_map_base, @@ -4784,27 +4844,49 @@ namespace CGAL { typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Dart_const_handle Dart_const_handle; typedef typename Base::Alloc Alloc; + typedef typename Base::Exception_no_more_available_mark + Exception_no_more_available_mark; Combinatorial_map() : Base() {} - Combinatorial_map(const Self & amap) - { Base::template copy(amap); } + Combinatorial_map(const Self & amap) : Base(amap) + {} - template < class CMap > - Combinatorial_map(const CMap & amap) - { Base::template copy(amap); } + Combinatorial_map(Self && amap) : Base(amap) + {} - template < class CMap, typename Converters > - Combinatorial_map(const CMap & amap, const Converters& converters) - { Base::template copy - (amap, converters); } + template + Combinatorial_map(const Combinatorial_map_base& + amap) : Base(amap) + {} - template < class CMap, typename Converters, typename Pointconverter > - Combinatorial_map(const CMap & amap, const Converters& converters, - const Pointconverter& pointconverter) - { Base::template copy - (amap, converters, pointconverter); } + template + Combinatorial_map(const Combinatorial_map_base& + amap, const Converters& converters) : + Base(amap, converters) + {} + + template + Combinatorial_map(const Combinatorial_map_base& + amap, const Converters& converters, + const DartInfoConverter& dartinfoconverter) : + Base(amap, converters, dartinfoconverter) + {} + + template + Combinatorial_map(const Combinatorial_map_base& + amap, const Converters& converters, + const DartInfoConverter& dartinfoconverter, + const PointConverter& pointconverter) : + Base(amap, converters, dartinfoconverter, pointconverter) + {} }; } // namespace Index diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h index 8a1805d2fa4..6d11cd14700 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_fwd.h @@ -19,21 +19,37 @@ namespace CGAL { struct Generic_map_min_items; -template +template class Combinatorial_map_storage_1; +template +class Combinatorial_map_storage_2; + template < unsigned int d_, class Refs_, class Items_=Generic_map_min_items, class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Combinatorial_map_storage_1 > + class Storage_= Combinatorial_map_storage_1 + > class Combinatorial_map_base; template < unsigned int d_, class Items_=Generic_map_min_items, class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Combinatorial_map_storage_1 > + class Storage_= Combinatorial_map_storage_1 + > class Combinatorial_map; +namespace Index +{ +template < unsigned int d_, + class Items_=Generic_map_min_items, + class Alloc_=CGAL_ALLOCATOR(int), + class Storage_= Combinatorial_map_storage_2 + > +class Combinatorial_map; +} // namespace Index + } // CGAL #endif // COMBINATORIAL_MAP_FWD_H diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h index 6e06b617fbf..972242857d5 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h @@ -176,6 +176,7 @@ namespace CGAL { /// The last operation used for the ++ operator. OperationState mprev_op; }; + template < typename Map_,bool Const > class CMap_dart_iterator: /*public boost::mpl::if_c< Const, diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h index 7b55ec36d97..73055a7fe0c 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -453,416 +452,6 @@ namespace CGAL { const typename Combinatorial_map_storage_1::Null_handle_type Combinatorial_map_storage_1::null_handle = nullptr; - // Storage with combinatorial maps using index - template - class Combinatorial_map_storage_2 - { - public: - typedef Combinatorial_map_storage_2 Self; - - typedef internal::Combinatorial_map_helper Helper; - - typedef typename Items_::template Dart_wrapper Dart_wrapper; - typedef typename Dart_wrapper::Dart Dart; - typedef typename Alloc_::template rebind::other Dart_allocator; - - typedef Size_type size_type; // Type used as index. - - typedef Compact_container_with_index_2, size_type > - Dart_container; - - typedef CGAL::Tag_true Use_index; - - typedef Items_ Items; - typedef Alloc_ Alloc; - - template - struct Container_for_attributes : public - Compact_container_with_index_2::other, - Constant_size_policy_for_cc_with_size<1024>, size_type > - {}; - - /// Typedef for attributes - typedef typename Dart_wrapper::Attributes Attributes; - - template - struct Attribute_type: public Helper::template Attribute_type - {}; - template - struct Attribute_handle: public Helper::template Attribute_handle - {}; - template - struct Attribute_const_handle: - public Helper::template Attribute_const_handle - {}; - template - struct Attribute_range: public Helper::template Attribute_range - {}; - template - struct Attribute_const_range: - public Helper::template Attribute_const_range - {}; - - /// Number of marks - static const unsigned int NB_MARKS = 32; - - /// The dimension of the combinatorial map. - static const unsigned int dimension = d_; - - // typedef unsigned int Dart_index; - // typedef MyIndex Dart_index; - typedef typename Dart_container::Index Dart_index; - - // Definition of old types, for backward compatibility. - typedef Dart_index Dart_handle; - typedef Dart_index Dart_const_handle; - - /// Value of null handle (!= null_dart_handle !!) - typedef size_type Null_handle_type; - static const size_type null_handle; - - typedef Index_hash_function Hash_function; - - //************************************************************************** - // Dart_range - struct Dart_range - { - typedef typename Dart_container::iterator iterator; - typedef typename Dart_container::const_iterator const_iterator; - Dart_range(Self &amap) : mmap(amap) - {} - iterator begin() - { iterator res=mmap.mdarts.begin(); ++res; return res; } - iterator end() { return mmap.mdarts.end(); } - const_iterator begin() const - { const_iterator res=mmap.mdarts.begin(); ++res; return res; } - const_iterator end() const { return mmap.mdarts.end(); } - size_type size() - { return mmap.mdarts.size()-1; } - bool empty() const - { return mmap.is_empty(); } - private: - Self & mmap; - }; - typedef const Dart_range Dart_const_range; - - /// @return a Dart_range (range through all the darts of the map). - Dart_range& darts() { return mdarts_range;} - Dart_const_range& darts() const { return mdarts_range; } - //************************************************************************** - - Combinatorial_map_storage_2() : mdarts_range(*this) - {} - - void init_storage() - { - // Allocate a dart for null_dart_handle - null_dart_handle = mdarts.emplace(); - } - - void clear_storage() - {} - - /** Test if the map is empty. - * @return true iff the map is empty. - */ - bool is_empty() const - { return this->mdarts.size()==1; } - - /// @return the number of darts. - size_type number_of_darts() const - { return mdarts.size()-1; } - - /** Return if this dart is free for adimension. - * @param dh a dart handle - * @param i the dimension. - * @return true iff dh is linked with NULL for \em adimension. - */ - template - bool is_free(Dart_const_handle dh) const - { - CGAL_assertion(i <= dimension); - return mdarts[dh].mbeta[i]==null_dart_handle; - } - bool is_free(Dart_const_handle dh, unsigned int i) const - { - CGAL_assertion(i <= dimension); - return mdarts[dh].mbeta[i]==null_dart_handle; - } - - /// Set simultaneously all the marks of this dart to a given value. - void set_dart_marks(Dart_const_handle ADart, - const std::bitset& amarks) const - { - mdarts[ADart].set_marks(amarks); - } - /// Return all the marks of a dart. - std::bitset get_dart_marks(Dart_const_handle ADart) const - { - return mdarts[ADart].get_marks(); - } - /// Return the mark value of dart a given mark number. - bool get_dart_mark(Dart_const_handle ADart, int amark) const - { - return mdarts[ADart].get_mark(amark); - } - - /// Set the mark of a given mark number to a given value. - void set_dart_mark(Dart_const_handle ADart, int amark, bool avalue) const - { - mdarts[ADart].set_mark(amark, avalue); - } - - /// Flip the mark of a given mark number to a given value. - void flip_dart_mark(Dart_const_handle ADart, int amark) const - { - mdarts[ADart].flip_mark(amark); - } - - // Access to beta maps - Dart_handle get_beta(Dart_handle ADart, int B1) - { - CGAL_assertion(B1>=0 && B1<=dimension); - return mdarts[ADart].mbeta[B1]; - } - Dart_const_handle get_beta(Dart_const_handle ADart, int B1) const - { - CGAL_assertion(B1>=0 && B1<=dimension); - return mdarts[ADart].mbeta[B1]; - } - template - Dart_handle get_beta(Dart_handle ADart) - { - CGAL_assertion(B1>=0 && B1<=dimension); - return mdarts[ADart].mbeta[B1]; - } - template - Dart_const_handle get_beta(Dart_const_handle ADart) const - { - CGAL_assertion(B1>=0 && B1<=dimension); - return mdarts[ADart].mbeta[B1]; - } - - // return a handle on the i-attribute - template - typename Attribute_handle::type attribute(Dart_handle ADart) - { - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "attribute called but i-attributes are disabled."); - return CGAL::cpp11::get::value> - (mdarts[ADart].mattribute_handles); - } - template - typename Attribute_const_handle::type - attribute(Dart_const_handle ADart) const - { - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "attribute called but i-attributes are disabled."); - return CGAL::cpp11::get::value> - (mdarts[ADart].mattribute_handles); - } - - template - typename Attribute_type::type& - get_attribute(typename Attribute_handle::type ah) - { - CGAL_assertion( ah!=null_handle ); - return CGAL::cpp11::get::value> - (mattribute_containers)[ah]; - } - - template - const typename Attribute_type::type& - get_attribute(typename Attribute_const_handle::type ah) const - { - CGAL_assertion( ah!=null_handle ); - return CGAL::cpp11::get::value> - (mattribute_containers)[ah]; - } - - Dart & get_dart(Dart_handle ah) - { - CGAL_assertion( ah!=null_handle ); - return mdarts[ah]; - } - const Dart & get_dart(Dart_const_handle ah) const - { - CGAL_assertion( ah!=null_handle ); - return mdarts[ah]; - } - - // Get the attribute of a dart - template - typename Attribute_type::type& get_attribute_of_dart(Dart_handle adart) - { - CGAL_assertion( adart!=null_handle ); - CGAL_assertion( attribute(adart)!=null_handle ); - return get_attribute(attribute(adart)); - } - template - const typename Attribute_type::type& - get_attribute_of_dart(Dart_const_handle adart) const - { - CGAL_assertion( adart!=null_handle ); - CGAL_assertion( attribute(adart)!=null_handle ); - return get_attribute(attribute(adart)); - } - - // Get the dart of the given attribute - template - Dart_handle dart_of_attribute(typename Attribute_handle::type ah) - { - CGAL_assertion( ah!=null_handle ); - return CGAL::cpp11::get::value> - (mattribute_containers)[ah].dart(); - } - template - Dart_const_handle - dart_of_attribute(typename Attribute_const_handle::type ah) const - { - CGAL_assertion( ah!=null_handle ); - return CGAL::cpp11::get::value> - (mattribute_containers)[ah].dart(); - } - - // Set the dart of the given attribute - template - void set_dart_of_attribute(typename Attribute_handle::type ah, - Dart_handle adart) - { - CGAL_assertion( ah!=null_handle ); - CGAL::cpp11::get::value> - (mattribute_containers)[ah].set_dart(adart); - } - - // Get the info of the given attribute - template - typename Attribute_type::type::Info & - info_of_attribute(typename Attribute_handle::type ah) - { - CGAL_assertion( ah!=null_handle ); - return CGAL::cpp11::get::value> - (mattribute_containers)[ah].info(); - } - template - const typename Attribute_type::type::Info & - info_of_attribute(typename Attribute_const_handle::type ah) const - { - CGAL_assertion( ah!=null_handle ); - return CGAL::cpp11::get::value> - (mattribute_containers)[ah].info(); - } - - // Get the info of the i-cell attribute associated with the given dart - template - typename Attribute_type::type::Info & info(Dart_handle adart) - { - CGAL_assertion( adart!=null_handle ); - CGAL_assertion( this->template attribute(adart)!=null_handle ); - return info_of_attribute(attribute(adart)); - } - template - const typename Attribute_type::type::Info & - info(Dart_const_handle adart) const - { - CGAL_assertion( adart!=null_handle ); - CGAL_assertion( attribute(adart)!=null_handle ); - return info_of_attribute(attribute(adart)); - } - - // Get the dart of the i-cell attribute associated with the given dart - template - Dart_handle & dart(Dart_handle adart) - { - CGAL_assertion( adart!=null_handle ); - CGAL_assertion( attribute(adart)!=null_handle ); - return dart_of_attribute(attribute(adart)); - } - template - Dart_const_handle dart(Dart_const_handle adart) const - { - CGAL_assertion( adart!=null_handle ); - CGAL_assertion( attribute(adart)!=null_handle ); - return dart_of_attribute(attribute(adart)); - } - - void display_dart(Dart_const_handle ADart) const - { std::cout< - void display_attribute(typename Attribute_const_handle::type ah) const - { std::cout< - void basic_set_dart_attribute(Dart_handle ADart, - typename Attribute_handle::type ah) - { - CGAL::cpp11::get::value> - (mdarts[ADart].mattribute_handles) = ah; - } - - /** Link a dart with a given dart for a given dimension. - * @param adart the dart to link. - * @param adart2 the dart to link with. - * @param i the dimension. - */ - template - void dart_link_beta(Dart_handle adart, Dart_handle adart2) - { - CGAL_assertion(i <= dimension); - CGAL_assertion(adart!=null_dart_handle); - mdarts[adart].mbeta[i] = adart2; - } - void dart_link_beta(Dart_handle adart, Dart_handle adart2, unsigned int i) - { - CGAL_assertion(i <= dimension); - CGAL_assertion(adart!=null_dart_handle); - mdarts[adart].mbeta[i] = adart2; - } - - /** Unlink a dart for a given dimension. - * @param adart a dart. - * @param i the dimension. - */ - template - void dart_unlink_beta(Dart_handle adart) - { - CGAL_assertion(i <= dimension); - mdarts[adart].mbeta[i] = null_dart_handle; - } - void dart_unlink_beta(Dart_handle adart, unsigned int i) - { - CGAL_assertion(i <= dimension); - mdarts[adart].mbeta[i] = null_dart_handle; - } - - public: - /// Void dart. A dart d is i-free if beta_i(d)=null_dart_handle. - static const Dart_index null_dart_handle; //=0; - - protected: - /// Dart container. - Dart_container mdarts; - Dart_range mdarts_range; - - /// Tuple of attributes containers - typename Helper::Attribute_containers mattribute_containers; - }; - - /// null_dart_handle - template - const typename Combinatorial_map_storage_2::Dart_index - Combinatorial_map_storage_2::null_dart_handle(0); - - /// null_handle - template - const Size_type Combinatorial_map_storage_2::null_handle((std::numeric_limits::max)()/2); - - } // namespace CGAL #if defined(BOOST_GCC) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h new file mode 100644 index 00000000000..3e5a198f5ea --- /dev/null +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h @@ -0,0 +1,459 @@ +// Copyright (c) 2013 CNRS and LIRIS' Establishments (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Guillaume Damiand +// +#ifndef CGAL_COMBINATORIAL_MAP_STORAGES_WITH_INDEX_H +#define CGAL_COMBINATORIAL_MAP_STORAGES_WITH_INDEX_HH 1 + +#include +#include +#include +#include + +#include +#if defined(BOOST_GCC) +_Pragma("GCC diagnostic push") +_Pragma("GCC diagnostic ignored \"-Warray-bounds\"") +#endif + +namespace CGAL { + + namespace internal { + template + struct Combinatorial_map_helper; + + template + struct Container_type; + } + + // Storage with combinatorial maps using index + template + class Combinatorial_map_storage_2 + { + public: + typedef Combinatorial_map_storage_2 Self; + typedef CGAL::Tag_true Use_index; + using Index_type=Index_type_; + + typedef internal::Combinatorial_map_helper Helper; + + typedef typename Items_::template Dart_wrapper Dart_wrapper; + typedef typename Dart_wrapper::Dart Dart; + typedef typename Alloc_::template rebind::other Dart_allocator; + + typedef Size_type size_type; // Type used as index. + + typedef Compact_container_with_index_2, size_type > + Dart_container; + + typedef Items_ Items; + typedef Alloc_ Alloc; + + template + struct Container_for_attributes : public + Compact_container_with_index_2::other, + Constant_size_policy_for_cc_with_size<1024>, size_type > + {}; + + /// Typedef for attributes + typedef typename Dart_wrapper::Attributes Attributes; + + template + struct Attribute_type: public Helper::template Attribute_type + {}; + template + struct Attribute_handle: public Helper::template Attribute_handle + {}; + template + struct Attribute_const_handle: + public Helper::template Attribute_const_handle + {}; + template + struct Attribute_range: public Helper::template Attribute_range + {}; + template + struct Attribute_const_range: + public Helper::template Attribute_const_range + {}; + + /// Number of marks + static const size_type NB_MARKS = 32; + + /// The dimension of the combinatorial map. + static const unsigned int dimension = d_; + + // typedef unsigned int Dart_index; + // typedef MyIndex Dart_index; + typedef typename Dart_container::Index Dart_index; + + // Definition of old types, for backward compatibility. + typedef Dart_index Dart_handle; + typedef Dart_index Dart_const_handle; + + /// Value of null handle (!= null_dart_handle !!) + typedef size_type Null_handle_type; + static const size_type null_handle; + + typedef Index_hash_function Hash_function; + + //************************************************************************** + // Dart_range + struct Dart_range + { + typedef typename Dart_container::iterator iterator; + typedef typename Dart_container::const_iterator const_iterator; + Dart_range(Self &amap) : mmap(amap) + {} + iterator begin() + { iterator res=mmap.mdarts.begin(); ++res; return res; } + iterator end() { return mmap.mdarts.end(); } + const_iterator begin() const + { const_iterator res=mmap.mdarts.begin(); ++res; return res; } + const_iterator end() const { return mmap.mdarts.end(); } + size_type size() + { return mmap.mdarts.size()-1; } + bool empty() const + { return mmap.is_empty(); } + private: + Self & mmap; + }; + typedef const Dart_range Dart_const_range; + + /// @return a Dart_range (range through all the darts of the map). + Dart_range& darts() { return mdarts_range;} + Dart_const_range& darts() const { return mdarts_range; } + //************************************************************************** + + Combinatorial_map_storage_2() : mdarts_range(*this) + {} + + void init_storage() + { + // Allocate a dart for null_dart_handle + null_dart_handle = mdarts.emplace(); + } + + void clear_storage() + {} + + /** Test if the map is empty. + * @return true iff the map is empty. + */ + bool is_empty() const + { return this->mdarts.size()==1; } + + /// @return the number of darts. + size_type number_of_darts() const + { return mdarts.size()-1; } + + /** Return if this dart is free for adimension. + * @param dh a dart handle + * @param i the dimension. + * @return true iff dh is linked with NULL for \em adimension. + */ + template + bool is_free(Dart_const_handle dh) const + { + CGAL_assertion(i <= dimension); + return mdarts[dh].mbeta[i]==null_dart_handle; + } + bool is_free(Dart_const_handle dh, unsigned int i) const + { + CGAL_assertion(i <= dimension); + return mdarts[dh].mbeta[i]==null_dart_handle; + } + + /// Set simultaneously all the marks of this dart to a given value. + void set_dart_marks(Dart_const_handle ADart, + const std::bitset& amarks) const + { + mdarts[ADart].set_marks(amarks); + } + /// Return all the marks of a dart. + std::bitset get_dart_marks(Dart_const_handle ADart) const + { + return mdarts[ADart].get_marks(); + } + /// Return the mark value of dart a given mark number. + bool get_dart_mark(Dart_const_handle ADart, int amark) const + { + return mdarts[ADart].get_mark(amark); + } + + /// Set the mark of a given mark number to a given value. + void set_dart_mark(Dart_const_handle ADart, int amark, bool avalue) const + { + mdarts[ADart].set_mark(amark, avalue); + } + + /// Flip the mark of a given mark number to a given value. + void flip_dart_mark(Dart_const_handle ADart, int amark) const + { + mdarts[ADart].flip_mark(amark); + } + + // Access to beta maps + Dart_handle get_beta(Dart_handle ADart, int B1) + { + CGAL_assertion(B1>=0 && B1<=dimension); + return mdarts[ADart].mbeta[B1]; + } + Dart_const_handle get_beta(Dart_const_handle ADart, int B1) const + { + CGAL_assertion(B1>=0 && B1<=dimension); + return mdarts[ADart].mbeta[B1]; + } + template + Dart_handle get_beta(Dart_handle ADart) + { + CGAL_assertion(B1>=0 && B1<=dimension); + return mdarts[ADart].mbeta[B1]; + } + template + Dart_const_handle get_beta(Dart_const_handle ADart) const + { + CGAL_assertion(B1>=0 && B1<=dimension); + return mdarts[ADart].mbeta[B1]; + } + + // return a handle on the i-attribute + template + typename Attribute_handle::type attribute(Dart_handle ADart) + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "attribute called but i-attributes are disabled."); + return CGAL::cpp11::get::value> + (mdarts[ADart].mattribute_handles); + } + template + typename Attribute_const_handle::type + attribute(Dart_const_handle ADart) const + { + CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, + "attribute called but i-attributes are disabled."); + return CGAL::cpp11::get::value> + (mdarts[ADart].mattribute_handles); + } + + template + typename Attribute_type::type& + get_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return CGAL::cpp11::get::value> + (mattribute_containers)[ah]; + } + + template + const typename Attribute_type::type& + get_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return CGAL::cpp11::get::value> + (mattribute_containers)[ah]; + } + + Dart & get_dart(Dart_handle ah) + { + CGAL_assertion( ah!=null_handle ); + return mdarts[ah]; + } + const Dart & get_dart(Dart_const_handle ah) const + { + CGAL_assertion( ah!=null_handle ); + return mdarts[ah]; + } + + // Get the attribute of a dart + template + typename Attribute_type::type& get_attribute_of_dart(Dart_handle adart) + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return get_attribute(attribute(adart)); + } + template + const typename Attribute_type::type& + get_attribute_of_dart(Dart_const_handle adart) const + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return get_attribute(attribute(adart)); + } + + // Get the dart of the given attribute + template + Dart_handle dart_of_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return CGAL::cpp11::get::value> + (mattribute_containers)[ah].dart(); + } + template + Dart_const_handle + dart_of_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return CGAL::cpp11::get::value> + (mattribute_containers)[ah].dart(); + } + + // Set the dart of the given attribute + template + void set_dart_of_attribute(typename Attribute_handle::type ah, + Dart_handle adart) + { + CGAL_assertion( ah!=null_handle ); + CGAL::cpp11::get::value> + (mattribute_containers)[ah].set_dart(adart); + } + + // Get the information associated with a given dart + Dart_info& info(Dart_handle adart) + { return mdarts[adart].info(); } + const Dart_info& info(Dart_const_handle adart) const + { return mdarts[adart].info(); } + + // Get the info of the given attribute + template + typename Attribute_type::type::Info & + info_of_attribute(typename Attribute_handle::type ah) + { + CGAL_assertion( ah!=null_handle ); + return CGAL::cpp11::get::value> + (mattribute_containers)[ah].info(); + } + template + const typename Attribute_type::type::Info & + info_of_attribute(typename Attribute_const_handle::type ah) const + { + CGAL_assertion( ah!=null_handle ); + return CGAL::cpp11::get::value> + (mattribute_containers)[ah].info(); + } + + // Get the info of the i-cell attribute associated with the given dart + template + typename Attribute_type::type::Info & info(Dart_handle adart) + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( this->template attribute(adart)!=null_handle ); + return info_of_attribute(attribute(adart)); + } + template + const typename Attribute_type::type::Info & + info(Dart_const_handle adart) const + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return info_of_attribute(attribute(adart)); + } + + // Get the dart of the i-cell attribute associated with the given dart + template + Dart_handle dart(Dart_handle adart) + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return dart_of_attribute(attribute(adart)); + } + template + Dart_const_handle dart(Dart_const_handle adart) const + { + CGAL_assertion( adart!=null_handle ); + CGAL_assertion( attribute(adart)!=null_handle ); + return dart_of_attribute(attribute(adart)); + } + + // Debug function + void display_dart(Dart_const_handle ADart) const + { std::cout< + void display_attribute(typename Attribute_const_handle::type ah) const + { std::cout< + void basic_set_dart_attribute(Dart_handle ADart, + typename Attribute_handle::type ah) + { + CGAL::cpp11::get::value> + (mdarts[ADart].mattribute_handles) = ah; + } + + /** Link a dart with a given dart for a given dimension. + * @param adart the dart to link. + * @param adart2 the dart to link with. + * @param i the dimension. + */ + template + void dart_link_beta(Dart_handle adart, Dart_handle adart2) + { + CGAL_assertion(i <= dimension); + CGAL_assertion(adart!=null_dart_handle); + mdarts[adart].mf[i] = adart2; + } + void dart_link_beta(Dart_handle adart, Dart_handle adart2, unsigned int i) + { + CGAL_assertion(i <= dimension); + CGAL_assertion(adart!=null_dart_handle); + mdarts[adart].mf[i] = adart2; + } + + /** Unlink a dart for a given dimension. + * @param adart a dart. + * @param i the dimension. + */ + template + void dart_unlink_beta(Dart_handle adart) + { + CGAL_assertion(i <= dimension); + mdarts[adart].mf[i] = null_dart_handle; + } + void dart_unlink_beta(Dart_handle adart, unsigned int i) + { + CGAL_assertion(i <= dimension); + mdarts[adart].mf[i] = null_dart_handle; + } + + public: + /// Void dart. A dart d is i-free if beta_i(d)=null_dart_handle. + static const Dart_index null_dart_handle; //=0; + + protected: + /// Dart container. + Dart_container mdarts; + Dart_range mdarts_range; + + /// Tuple of attributes containers + typename Helper::Attribute_containers mattribute_containers; + }; + + /// null_dart_handle + template + const typename Combinatorial_map_storage_2::Dart_index + Combinatorial_map_storage_2::null_dart_handle(0); + + /// null_handle + template + const Size_type Combinatorial_map_storage_2::null_handle((std::numeric_limits::max)()/2); + +} // namespace CGAL + +#if defined(BOOST_GCC) + _Pragma("GCC diagnostic pop") +#endif + +#endif // CGAL_COMBINATORIAL_MAP_STORAGES_WITH_INDEX_H // +// EOF // diff --git a/Combinatorial_map/include/CGAL/Generic_map_min_items.h b/Combinatorial_map/include/CGAL/Generic_map_min_items.h index 32542bd2032..6cfbdc940fc 100644 --- a/Combinatorial_map/include/CGAL/Generic_map_min_items.h +++ b/Combinatorial_map/include/CGAL/Generic_map_min_items.h @@ -38,7 +38,7 @@ namespace CGAL { struct Dart_wrapper {}; }; - + } // namespace Index } // namespace CGAL #endif // CGAL_GENERIC_MAP_MIN_ITEMS_H