Start GMap with index

This commit is contained in:
Guillaume Damiand 2022-04-13 19:26:15 +02:00
parent 382db4acbd
commit b56e89ca2c
9 changed files with 122 additions and 113 deletions

View File

@ -34,10 +34,10 @@ class Combinatorial_map_storage_1;
template<unsigned int, class, class>
class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
class Generalized_map_storage_1;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
@ -113,10 +113,10 @@ struct Init_id;
template<unsigned int, class, class>
friend class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_1;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
@ -238,10 +238,10 @@ struct Init_id;
template<unsigned int, class, class>
friend class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_1;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
@ -425,10 +425,10 @@ struct Init_id;
template<unsigned int, class, class>
friend class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_1;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>

View File

@ -38,9 +38,11 @@ namespace CGAL {
{
public:
using Self=Combinatorial_map_storage_2<d_, Items_, Alloc_>;
using Use_index=CGAL::Tag_true;
using Concurrent_tag=typename internal::Get_concurrent_tag<Items_>::type;
typedef internal::Combinatorial_map_helper<Self> Helper;
using Use_index=CGAL::Tag_true;
using Index_type=typename internal::Get_index_type<Items_>::type;
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;

View File

@ -35,10 +35,10 @@ namespace CGAL {
template<unsigned int, class, class>
class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
class Generalized_map_storage_1;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
@ -90,10 +90,10 @@ namespace CGAL {
template<unsigned int, class, class>
friend class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_1;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>
@ -253,10 +253,10 @@ namespace CGAL {
template<unsigned int, class, class>
friend class Combinatorial_map_storage_2;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_1;
template<unsigned int, class, class, class>
template<unsigned int, class, class>
friend class Generalized_map_storage_2;
template<unsigned int, unsigned int, class, class, class, class>

View File

@ -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<Self, 0>::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<unsigned int d_, class Items_, class Alloc_,class Storage_>
class Generalized_map :
public Generalized_map_base<d_,
Generalized_map<d_,Items_,Alloc_, Storage_>,
Items_, Alloc_, Storage_ >
{
public:
typedef Generalized_map<d_, Items_,Alloc_, Storage_> Self;
typedef Generalized_map_base<d_, Self, Items_, Alloc_, Storage_> 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 <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2>
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap) :
Base(amap)
{}
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2, typename Converters>
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap,
const Converters& converters) :
Base(amap, converters)
{}
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2,
typename Converters, typename DartInfoConverter>
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap,
const Converters& converters,
const DartInfoConverter& dartinfoconverter) :
Base(amap, converters, dartinfoconverter)
{}
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2,
typename Converters, typename DartInfoConverter,
typename PointConverter >
Generalized_map(const Generalized_map_base<d2, Refs2, Items2, Alloc2, Storage2>& amap,
const Converters& converters,
const DartInfoConverter& dartinfoconverter,
const PointConverter& pointconverter) :
Base(amap, converters, dartinfoconverter, pointconverter)
{}
};
} // namespace Index
} // namespace CGAL
#if defined(BOOST_GCC)

View File

@ -14,24 +14,60 @@
#include <CGAL/memory.h>
#include <CGAL/tags.h>
#include <boost/mpl/has_xxx.hpp>
namespace CGAL {
template<unsigned int d_, class Items_, class Alloc_, class Concurrent_tag=CGAL::Tag_false >
template<unsigned int d_, class Items_, class Alloc_>
class Generalized_map_storage_1;
template<unsigned int d_, class Items_, class Alloc_>
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<d_, Items_, Alloc_, CGAL::Tag_false> >
namespace internal
{
template<typename Tag>
struct Default_storage_for_gmap_when_tag
{
template<unsigned int d_, class Items_, class Alloc_>
using type=Generalized_map_storage_1<d_, Items_, Alloc_>;
};
template<>
struct Default_storage_for_gmap_when_tag<CGAL::Tag_true>
{
template<unsigned int d_, class Items_, class Alloc_>
using type=Generalized_map_storage_2<d_, Items_, Alloc_>;
};
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_use_index_tag,Use_index,false)
template<typename T, bool typedefined=Has_use_index_tag<T>::value>
struct Default_storage_for_gmap
{
template<unsigned int d_, class Items_, class Alloc_>
using type=Generalized_map_storage_1<d_, Items_, Alloc_>;
};
template<typename T>
struct Default_storage_for_gmap<T, true>
{
template<unsigned int d_, class Items_, class Alloc_>
using type=typename Default_storage_for_gmap_when_tag<typename T::Use_index>::
type<d_, Items_, Alloc_>;
};
} // namespace internal
template<unsigned int d_, class Refs_,
class Items_=Generic_map_min_items,
class Alloc_=CGAL_ALLOCATOR(int),
class Storage_=typename internal::Default_storage_for_gmap<Items_>::
type<d_, Items_, Alloc_>>
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<d_, Items_, Alloc_, CGAL::Tag_false> >
template <unsigned int d_,
class Items_=Generic_map_min_items,
class Alloc_=CGAL_ALLOCATOR(int),
class Storage_=typename internal::Default_storage_for_gmap<Items_>::
type<d_, Items_, Alloc_>>
class Generalized_map;
} // CGAL

View File

@ -35,12 +35,13 @@ namespace CGAL {
}
// Storage of darts with compact container, alpha with handles
template<unsigned int d_, class Items_, class Alloc_, class Concurrent_tag >
template<unsigned int d_, class Items_, class Alloc_>
class Generalized_map_storage_1
{
public:
using Self=Generalized_map_storage_1<d_, Items_, Alloc_, Concurrent_tag>;
using Self=Generalized_map_storage_1<d_, Items_, Alloc_>;
using Use_index=CGAL::Tag_false;
using Concurrent_tag=typename internal::Get_concurrent_tag<Items_>::type;
typedef internal::Combinatorial_map_helper<Self> 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 <typename T>
@ -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<d_, Items_, Alloc_, Concurrent_tag>::Null_handle_type
Generalized_map_storage_1<d_, Items_, Alloc_, Concurrent_tag>::null_handle = nullptr;
template < unsigned int d_, class Items_, class Alloc_>
const typename Generalized_map_storage_1<d_, Items_, Alloc_>::Null_handle_type
Generalized_map_storage_1<d_, Items_, Alloc_>::null_handle = nullptr;
} // namespace CGAL

View File

@ -33,21 +33,23 @@ namespace CGAL {
}
// Storage of darts with compact container, alpha with indices
template<unsigned int d_, class Items_, class Alloc_, class Index_type_ >
template<unsigned int d_, class Items_, class Alloc_>
class Generalized_map_storage_2
{
public:
using Self=Generalized_map_storage_2<d_, Items_, Alloc_, Index_type_>;
using Self=Generalized_map_storage_2<d_, Items_, Alloc_>;
using Use_index=CGAL::Tag_true;
using Index_type=Index_type_;
using Concurrent_tag=typename internal::Get_concurrent_tag<Items_>::type;
typedef internal::Combinatorial_map_helper<Self> Helper;
using Index_type=typename internal::Get_index_type<Items_>::type;
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
typedef typename internal::template Get_dart_info<Dart_wrapper>::type
Dart_info;
typedef CGAL::Index::Dart<d_, Self, Dart_info> Dart;
typedef CGAL::Dart<d_, Self, Dart_info> Dart;
typedef std::allocator_traits<Alloc_> Allocator_traits;
typedef typename Allocator_traits::template rebind_alloc<Dart> 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 <typename T>
@ -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<unsigned int i>
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<unsigned int d_, class Items_, class Alloc_, class Size_type>
typename Generalized_map_storage_2<d_, Items_, Alloc_, Size_type>::Null_handle_type
Generalized_map_storage_2<d_, Items_, Alloc_, Size_type>::null_handle((std::numeric_limits<size_type>::max)()/2);
template<unsigned int d_, class Items_, class Alloc_>
typename Generalized_map_storage_2<d_, Items_, Alloc_>::Null_handle_type
Generalized_map_storage_2<d_, Items_, Alloc_>::null_handle((std::numeric_limits<size_type>::max)()/2);
} // namespace CGAL

View File

@ -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")

View File

@ -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 <class GMAP>
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 <class GMAP>
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 <class GMAP>
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 <class GMAP>
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 <class GMAP>
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 <class GMAP>
struct Dart_wrapper
{
@ -109,7 +134,7 @@ int main()
std::cout<<"Generalized_map start test (v1)."<<std::flush;
trace_display_msg("\ntest_GMAP_2<GMAP2>");
typedef CGAL::Generalized_map<2> GMAP2;
typedef CGAL::Generalized_map<2, Min_items> GMAP2;
if ( !test_GMAP_2<GMAP2>() )
{
std::cout<<" Error during Test_GMAP_2<GMAP2>."<<std::endl;
@ -117,7 +142,7 @@ int main()
}
trace_display_msg("test_GMAP_3<GMAP3>");
typedef CGAL::Generalized_map<3> GMAP3;
typedef CGAL::Generalized_map<3, Min_items> GMAP3;
if ( !test_GMAP_3<GMAP3>() )
{
std::cout<<" Error during Test_GMAP_3<GMAP3>."<<std::endl;
@ -125,7 +150,7 @@ int main()
}
trace_display_msg("test_GMAP_4<GMAP4>");
typedef CGAL::Generalized_map<4> GMAP4;
typedef CGAL::Generalized_map<4, Min_items> GMAP4;
if ( !test_GMAP_4<GMAP4>() )
{
std::cout<<" Error during Test_GMAP_4<GMAP4>."<<std::endl;