diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 7718567dd26..d03695d6d0c 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -34,10 +34,10 @@ class Combinatorial_map_storage_1; template class Combinatorial_map_storage_2; -template +template class Generalized_map_storage_1; -template +template class Generalized_map_storage_2; template @@ -113,10 +113,10 @@ struct Init_id; template friend class Combinatorial_map_storage_2; - template + template friend class Generalized_map_storage_1; - template + template friend class Generalized_map_storage_2; template @@ -238,10 +238,10 @@ struct Init_id; template friend class Combinatorial_map_storage_2; - template + template friend class Generalized_map_storage_1; - template + template friend class Generalized_map_storage_2; template @@ -425,10 +425,10 @@ struct Init_id; template friend class Combinatorial_map_storage_2; - template + template friend class Generalized_map_storage_1; - template + template friend class Generalized_map_storage_2; template diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h index e20215fe0ea..ef52449df94 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h @@ -38,9 +38,11 @@ namespace CGAL { { public: using Self=Combinatorial_map_storage_2; + using Use_index=CGAL::Tag_true; + using Concurrent_tag=typename internal::Get_concurrent_tag::type; + typedef internal::Combinatorial_map_helper Helper; - using Use_index=CGAL::Tag_true; using Index_type=typename internal::Get_index_type::type; typedef typename Items_::template Dart_wrapper Dart_wrapper; diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index 4deb78f7dd0..dba2af5b116 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -35,10 +35,10 @@ namespace CGAL { template class Combinatorial_map_storage_2; - template + template class Generalized_map_storage_1; - template + template class Generalized_map_storage_2; template @@ -90,10 +90,10 @@ namespace CGAL { template friend class Combinatorial_map_storage_2; - template + template friend class Generalized_map_storage_1; - template + template friend class Generalized_map_storage_2; template @@ -253,10 +253,10 @@ namespace CGAL { template friend class Combinatorial_map_storage_2; - template + template friend class Generalized_map_storage_1; - template + template friend class Generalized_map_storage_2; template diff --git a/Generalized_map/include/CGAL/Generalized_map.h b/Generalized_map/include/CGAL/Generalized_map.h index f0b0f8a007e..4e148fea569 100644 --- a/Generalized_map/include/CGAL/Generalized_map.h +++ b/Generalized_map/include/CGAL/Generalized_map.h @@ -3607,7 +3607,7 @@ namespace CGAL { else { if (are_attributes_automatically_managed() && - update_attributes && ah!=nullptr) + update_attributes && ah!=null_handle) { internal::Set_i_attribute_of_dart_functor::run(*this, d2, ah); if (!isfree1) @@ -3833,7 +3833,7 @@ namespace CGAL { basic_link_alpha(dd, dddd, dim); basic_link_alpha(alpha<0>(dd), d0, dim); - if (oldb2!=nullptr) + if (oldb2!=null_handle) { basic_link_alpha<2>(alpha(oldb2, dim), dddd); basic_link_alpha<2>(alpha(oldb2, 0, dim), d0); @@ -3987,68 +3987,6 @@ namespace CGAL { {} }; - namespace Index - { - template - class Generalized_map : - public Generalized_map_base, - Items_, Alloc_, Storage_ > - { - public: - typedef Generalized_map Self; - typedef Generalized_map_base Base; - - 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; - - Generalized_map() : Base() - {} - - Generalized_map(const Self & amap) : Base(amap) - {} - - Generalized_map(Self && amap) : Base(amap) - {} - - template - Generalized_map(const Generalized_map_base& amap) : - Base(amap) - {} - - template - Generalized_map(const Generalized_map_base& amap, - const Converters& converters) : - Base(amap, converters) - {} - - template - Generalized_map(const Generalized_map_base& amap, - const Converters& converters, - const DartInfoConverter& dartinfoconverter) : - Base(amap, converters, dartinfoconverter) - {} - - template - Generalized_map(const Generalized_map_base& amap, - const Converters& converters, - const DartInfoConverter& dartinfoconverter, - const PointConverter& pointconverter) : - Base(amap, converters, dartinfoconverter, pointconverter) - {} - }; - } // namespace Index - } // namespace CGAL #if defined(BOOST_GCC) diff --git a/Generalized_map/include/CGAL/Generalized_map_fwd.h b/Generalized_map/include/CGAL/Generalized_map_fwd.h index 0ca8a8bd078..b73b1387d38 100644 --- a/Generalized_map/include/CGAL/Generalized_map_fwd.h +++ b/Generalized_map/include/CGAL/Generalized_map_fwd.h @@ -14,24 +14,60 @@ #include #include +#include namespace CGAL { -template +template class Generalized_map_storage_1; +template +class Generalized_map_storage_2; + struct Generic_map_min_items; -template < unsigned int d_, class Refs, - class Items_=Generic_map_min_items, - class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Generalized_map_storage_1 > +namespace internal +{ +template +struct Default_storage_for_gmap_when_tag +{ + template + using type=Generalized_map_storage_1; +}; +template<> +struct Default_storage_for_gmap_when_tag +{ + template + using type=Generalized_map_storage_2; +}; + +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag,Use_index,false) +template::value> +struct Default_storage_for_gmap +{ + template + using type=Generalized_map_storage_1; +}; +template +struct Default_storage_for_gmap +{ + template + using type=typename Default_storage_for_gmap_when_tag:: + type; +}; +} // namespace internal +template:: + type> class Generalized_map_base; -template < unsigned int d_, - class Items_=Generic_map_min_items, - class Alloc_=CGAL_ALLOCATOR(int), - class Storage_= Generalized_map_storage_1 > +template :: + type> class Generalized_map; } // CGAL diff --git a/Generalized_map/include/CGAL/Generalized_map_storages.h b/Generalized_map/include/CGAL/Generalized_map_storages.h index d28a050f42b..e8650e58fc8 100644 --- a/Generalized_map/include/CGAL/Generalized_map_storages.h +++ b/Generalized_map/include/CGAL/Generalized_map_storages.h @@ -35,12 +35,13 @@ namespace CGAL { } // Storage of darts with compact container, alpha with handles - template + template class Generalized_map_storage_1 { public: - using Self=Generalized_map_storage_1; + using Self=Generalized_map_storage_1; using Use_index=CGAL::Tag_false; + using Concurrent_tag=typename internal::Get_concurrent_tag::type; typedef internal::Combinatorial_map_helper Helper; @@ -65,6 +66,8 @@ namespace CGAL { typedef std::nullptr_t Null_handle_type; static const Null_handle_type null_handle; + using Type_for_compact_container=void*; + typedef Items_ Items; typedef Alloc_ Alloc; template @@ -433,9 +436,9 @@ namespace CGAL { }; /// null_handle - template < unsigned int d_, class Items_, class Alloc_, class Concurrent_tag > - const typename Generalized_map_storage_1::Null_handle_type - Generalized_map_storage_1::null_handle = nullptr; + template < unsigned int d_, class Items_, class Alloc_> + const typename Generalized_map_storage_1::Null_handle_type + Generalized_map_storage_1::null_handle = nullptr; } // namespace CGAL diff --git a/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h index e9ba38f36ed..7fc51f9f651 100644 --- a/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h +++ b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h @@ -33,21 +33,23 @@ namespace CGAL { } // Storage of darts with compact container, alpha with indices - template + template class Generalized_map_storage_2 { public: - using Self=Generalized_map_storage_2; + using Self=Generalized_map_storage_2; using Use_index=CGAL::Tag_true; - using Index_type=Index_type_; + using Concurrent_tag=typename internal::Get_concurrent_tag::type; typedef internal::Combinatorial_map_helper Helper; + using Index_type=typename internal::Get_index_type::type; + typedef typename Items_::template Dart_wrapper Dart_wrapper; typedef typename internal::template Get_dart_info::type Dart_info; - typedef CGAL::Index::Dart Dart; + typedef CGAL::Dart Dart; typedef std::allocator_traits Allocator_traits; typedef typename Allocator_traits::template rebind_alloc Dart_allocator; @@ -68,6 +70,8 @@ namespace CGAL { typedef Dart_index Null_handle_type; static Null_handle_type null_handle; + using Type_for_compact_container=Index_type; + typedef Items_ Items; typedef Alloc_ Alloc; template @@ -114,7 +118,7 @@ namespace CGAL { // Init void init_storage() - { null_dart_handle=nullptr; } + {} void clear_storage() {} @@ -388,13 +392,13 @@ namespace CGAL { void dart_link_alpha(Dart_handle adart, Dart_handle adart2) { CGAL_assertion(i <= dimension); - CGAL_assertion(adart!=nullptr && adart2!=nullptr); + CGAL_assertion(adart!=null_handle && adart2!=null_handle); mdarts[adart].mf[i] = adart2; } void dart_link_alpha(Dart_handle adart, Dart_handle adart2, unsigned int i) { CGAL_assertion(i <= dimension); - CGAL_assertion(adart!=nullptr && adart2!=nullptr); + CGAL_assertion(adart!=null_handle && adart2!=null_handle); mdarts[adart].mf[i] = adart2; } @@ -405,12 +409,12 @@ namespace CGAL { template void dart_unlink_alpha(Dart_handle adart) { - CGAL_assertion(adart!=nullptr && i <= dimension); + CGAL_assertion(adart!=null_handle && i <= dimension); mdarts[adart].mf[i] = adart; } void dart_unlink_alpha(Dart_handle adart, unsigned int i) { - CGAL_assertion(adart!=nullptr && i <= dimension); + CGAL_assertion(adart!=null_handle && i <= dimension); mdarts[adart].mf[i] = adart; } @@ -425,9 +429,9 @@ namespace CGAL { }; /// null_handle - template - typename Generalized_map_storage_2::Null_handle_type - Generalized_map_storage_2::null_handle((std::numeric_limits::max)()/2); + template + typename Generalized_map_storage_2::Null_handle_type + Generalized_map_storage_2::null_handle((std::numeric_limits::max)()/2); } // namespace CGAL diff --git a/Generalized_map/test/Generalized_map/CMakeLists.txt b/Generalized_map/test/Generalized_map/CMakeLists.txt index fec14337999..8d6c93723c4 100644 --- a/Generalized_map/test/Generalized_map/CMakeLists.txt +++ b/Generalized_map/test/Generalized_map/CMakeLists.txt @@ -19,11 +19,12 @@ if(NOT Boost_FOUND) endif() -# include for local directory +set(hfiles Generalized_map_2_test.h Generalized_map_3_test.h + Generalized_map_4_test.h GMap_test_insertions.h) -# include for local package +create_single_source_cgal_program("Generalized_map_test.cpp" ${hfiles}) -# Creating entries for all C++ files with "main" routine -# ########################################################## +add_executable(Generalized_map_test_index Generalized_map_test.cpp ${hfiles}) +target_compile_definitions(Generalized_map_test_index PUBLIC USE_COMPACT_CONTAINER_WITH_INDEX) +target_link_libraries(Generalized_map_test_index PUBLIC CGAL CGAL::Data) -create_single_source_cgal_program("Generalized_map_test.cpp") diff --git a/Generalized_map/test/Generalized_map/Generalized_map_test.cpp b/Generalized_map/test/Generalized_map/Generalized_map_test.cpp index ca12ca9b7e7..ae7f2149e68 100644 --- a/Generalized_map/test/Generalized_map/Generalized_map_test.cpp +++ b/Generalized_map/test/Generalized_map/Generalized_map_test.cpp @@ -21,8 +21,18 @@ struct Divide_by_two_functor } }; +struct Min_items: public CGAL::Generic_map_min_items +{ +#ifdef USE_COMPACT_CONTAINER_WITH_INDEX + typedef CGAL::Tag_true Use_index; +#endif +}; + struct Myitems_2 { +#ifdef USE_COMPACT_CONTAINER_WITH_INDEX + typedef CGAL::Tag_true Use_index; +#endif template struct Dart_wrapper { @@ -37,6 +47,9 @@ struct Myitems_2 struct Myitems_2c { +#ifdef USE_COMPACT_CONTAINER_WITH_INDEX + typedef CGAL::Tag_true Use_index; +#endif template struct Dart_wrapper { @@ -50,6 +63,9 @@ struct Myitems_2c }; struct Myitems_3 { +#ifdef USE_COMPACT_CONTAINER_WITH_INDEX + typedef CGAL::Tag_true Use_index; +#endif template struct Dart_wrapper { @@ -64,6 +80,9 @@ struct Myitems_3 struct Myitems_3c { +#ifdef USE_COMPACT_CONTAINER_WITH_INDEX + typedef CGAL::Tag_true Use_index; +#endif template struct Dart_wrapper { @@ -78,6 +97,9 @@ struct Myitems_3c struct Myitems_4 { +#ifdef USE_COMPACT_CONTAINER_WITH_INDEX + typedef CGAL::Tag_true Use_index; +#endif template struct Dart_wrapper { @@ -92,6 +114,9 @@ struct Myitems_4 struct Myitems_4c { +#ifdef USE_COMPACT_CONTAINER_WITH_INDEX + typedef CGAL::Tag_true Use_index; +#endif template struct Dart_wrapper { @@ -109,7 +134,7 @@ int main() std::cout<<"Generalized_map start test (v1)."<"); - typedef CGAL::Generalized_map<2> GMAP2; + typedef CGAL::Generalized_map<2, Min_items> GMAP2; if ( !test_GMAP_2() ) { std::cout<<" Error during Test_GMAP_2."<"); - typedef CGAL::Generalized_map<3> GMAP3; + typedef CGAL::Generalized_map<3, Min_items> GMAP3; if ( !test_GMAP_3() ) { std::cout<<" Error during Test_GMAP_3."<"); - typedef CGAL::Generalized_map<4> GMAP4; + typedef CGAL::Generalized_map<4, Min_items> GMAP4; if ( !test_GMAP_4() ) { std::cout<<" Error during Test_GMAP_4."<