This commit is contained in:
Guillaume Damiand 2022-04-07 12:41:42 +02:00
parent eb39602066
commit d95ed10d76
7 changed files with 581 additions and 434 deletions

View File

@ -670,7 +670,7 @@ namespace CGAL {
friend class Concurrent_compact_container;
public:
typedef Cell_attribute<Refs, Info_, Tag_, OnMerge, OnSplit, WithID> Self;
typedef Cell_attribute<Refs, Info_, Tag_, OnMerge, OnSplit> Self;
typedef Tag_ Supports_cell_dart;
typedef typename Refs::Dart_handle Dart_handle;

View File

@ -153,6 +153,7 @@ namespace CGAL {
using Base::dart;
using Base::darts;
using Base::number_of_darts;
using Base::is_empty;
/// Typedef for attributes
template<int i>
@ -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
<internal::Decrease_attribute_functor<Self> >::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
<internal::Restricted_decrease_attribute_functor<Self> >::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<d_>,
class Alloc_=CGAL_ALLOCATOR(int),
class Storage_= Combinatorial_map_storage_2<d_, Items_, Alloc_, unsigned int> >
class Items_,
class Alloc_,
class Storage_>
class Combinatorial_map :
public Combinatorial_map_base<d_,
Combinatorial_map<d_,Items_,Alloc_, Storage_>,
@ -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<Self>(amap); }
Combinatorial_map(const Self & amap) : Base(amap)
{}
template < class CMap >
Combinatorial_map(const CMap & amap)
{ Base::template copy<CMap>(amap); }
Combinatorial_map(Self && amap) : Base(amap)
{}
template < class CMap, typename Converters >
Combinatorial_map(const CMap & amap, const Converters& converters)
{ Base::template copy<CMap, Converters>
(amap, converters); }
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2>
Combinatorial_map(const Combinatorial_map_base<d2, Refs2, Items2, Alloc2, Storage2>&
amap) : Base(amap)
{}
template < class CMap, typename Converters, typename Pointconverter >
Combinatorial_map(const CMap & amap, const Converters& converters,
const Pointconverter& pointconverter)
{ Base::template copy<CMap, Converters, Pointconverter>
(amap, converters, pointconverter); }
template <unsigned int d2, typename Refs2, typename Items2, typename Alloc2,
typename Storage2, typename Converters>
Combinatorial_map(const Combinatorial_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>
Combinatorial_map(const Combinatorial_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 >
Combinatorial_map(const Combinatorial_map_base<d2, Refs2, Items2, Alloc2, Storage2>&
amap, const Converters& converters,
const DartInfoConverter& dartinfoconverter,
const PointConverter& pointconverter) :
Base(amap, converters, dartinfoconverter, pointconverter)
{}
};
} // namespace Index

View File

@ -19,21 +19,37 @@ namespace CGAL {
struct Generic_map_min_items;
template<unsigned int d_, class Items_, class Alloc_, class Concurrent_tag=CGAL::Tag_false >
template<unsigned int d_, class Items_, class Alloc_,
class Concurrent_tag=CGAL::Tag_false >
class Combinatorial_map_storage_1;
template<unsigned int d_, class Items_, class Alloc_, class Index_type_ >
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<d_, Items_, Alloc_, CGAL::Tag_false> >
class Storage_= Combinatorial_map_storage_1
<d_, Items_, Alloc_, CGAL::Tag_false> >
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<d_, Items_, Alloc_, CGAL::Tag_false> >
class Storage_= Combinatorial_map_storage_1
<d_, Items_, Alloc_, CGAL::Tag_false> >
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
<d_, Items_, Alloc_, unsigned int> >
class Combinatorial_map;
} // namespace Index
} // CGAL
#endif // COMBINATORIAL_MAP_FWD_H

View File

@ -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<Map_, Const, Tag_true>:
/*public boost::mpl::if_c< Const,

View File

@ -14,7 +14,6 @@
#include <CGAL/Compact_container.h>
#include <CGAL/Concurrent_compact_container.h>
#include <CGAL/Compact_container_with_index_2.h>
#include <CGAL/Dart.h>
#include <CGAL/Handle_hash_function.h>
#include <bitset>
@ -453,416 +452,6 @@ namespace CGAL {
const typename Combinatorial_map_storage_1<d_, Items_, Alloc_, Concurrent_tag>::Null_handle_type
Combinatorial_map_storage_1<d_, Items_, Alloc_, Concurrent_tag>::null_handle = nullptr;
// Storage with combinatorial maps using index
template<unsigned int d_, class Items_, class Alloc_, class Size_type >
class Combinatorial_map_storage_2
{
public:
typedef Combinatorial_map_storage_2<d_, Items_, Alloc_, Size_type> Self;
typedef internal::Combinatorial_map_helper<Self> Helper;
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
typedef typename Dart_wrapper::Dart Dart;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef Size_type size_type; // Type used as index.
typedef Compact_container_with_index_2<Dart,Dart_allocator,
Constant_size_policy_for_cc_with_size<1024>, size_type >
Dart_container;
typedef CGAL::Tag_true Use_index;
typedef Items_ Items;
typedef Alloc_ Alloc;
template <typename T>
struct Container_for_attributes : public
Compact_container_with_index_2<T,
typename Alloc_::template rebind<T>::other,
Constant_size_policy_for_cc_with_size<1024>, size_type >
{};
/// Typedef for attributes
typedef typename Dart_wrapper::Attributes Attributes;
template<int i>
struct Attribute_type: public Helper::template Attribute_type<i>
{};
template<int i>
struct Attribute_handle: public Helper::template Attribute_handle<i>
{};
template<int i>
struct Attribute_const_handle:
public Helper::template Attribute_const_handle<i>
{};
template<int i>
struct Attribute_range: public Helper::template Attribute_range<i>
{};
template<int i>
struct Attribute_const_range:
public Helper::template Attribute_const_range<i>
{};
/// 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<unsigned int> 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<unsigned int i>
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<NB_MARKS>& amarks) const
{
mdarts[ADart].set_marks(amarks);
}
/// Return all the marks of a dart.
std::bitset<NB_MARKS> 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<int B1>
Dart_handle get_beta(Dart_handle ADart)
{
CGAL_assertion(B1>=0 && B1<=dimension);
return mdarts[ADart].mbeta[B1];
}
template<int B1>
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<unsigned int i>
typename Attribute_handle<i>::type attribute(Dart_handle ADart)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
template<unsigned int i>
typename Attribute_const_handle<i>::type
attribute(Dart_const_handle ADart) const
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
template<unsigned int i>
typename Attribute_type<i>::type&
get_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah];
}
template<unsigned int i>
const typename Attribute_type<i>::type&
get_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::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<unsigned int i>
typename Attribute_type<i>::type& get_attribute_of_dart(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return get_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
const typename Attribute_type<i>::type&
get_attribute_of_dart(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return get_attribute<i>(attribute<i>(adart));
}
// Get the dart of the given attribute
template<unsigned int i>
Dart_handle dart_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].dart();
}
template<unsigned int i>
Dart_const_handle
dart_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].dart();
}
// Set the dart of the given attribute
template<unsigned int i>
void set_dart_of_attribute(typename Attribute_handle<i>::type ah,
Dart_handle adart)
{
CGAL_assertion( ah!=null_handle );
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].set_dart(adart);
}
// Get the info of the given attribute
template<unsigned int i>
typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].info();
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].info();
}
// Get the info of the i-cell attribute associated with the given dart
template<unsigned int i>
typename Attribute_type<i>::type::Info & info(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( this->template attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle & dart(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
Dart_const_handle dart(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(adart));
}
void display_dart(Dart_const_handle ADart) const
{ std::cout<<ADart; }
template<unsigned int i>
void display_attribute(typename Attribute_const_handle<i>::type ah) const
{ std::cout<<ah; }
protected:
// Set the handle on the i th attribute
template<unsigned int i>
void basic_set_dart_attribute(Dart_handle ADart,
typename Attribute_handle<i>::type ah)
{
CGAL::cpp11::get<Helper::template Dimension_index<i>::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<unsigned int i>
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<unsigned int i>
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<unsigned int d_, class Items_, class Alloc_, class Size_type>
const typename Combinatorial_map_storage_2<d_, Items_, Alloc_, Size_type>::Dart_index
Combinatorial_map_storage_2<d_, Items_, Alloc_, Size_type>::null_dart_handle(0);
/// null_handle
template<unsigned int d_, class Items_, class Alloc_, class Size_type>
const Size_type Combinatorial_map_storage_2<d_, Items_, Alloc_, Size_type>::null_handle((std::numeric_limits<size_type>::max)()/2);
} // namespace CGAL
#if defined(BOOST_GCC)

View File

@ -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 <guillaume.damiand@liris.cnrs.fr>
//
#ifndef CGAL_COMBINATORIAL_MAP_STORAGES_WITH_INDEX_H
#define CGAL_COMBINATORIAL_MAP_STORAGES_WITH_INDEX_HH 1
#include <CGAL/Compact_container_with_index_2.h>
#include <CGAL/Dart.h>
#include <CGAL/Handle_hash_function.h>
#include <bitset>
#include <boost/config.hpp>
#if defined(BOOST_GCC)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
#endif
namespace CGAL {
namespace internal {
template <typename M>
struct Combinatorial_map_helper;
template<typename Concurrent_tag, class T, class Alloc_>
struct Container_type;
}
// Storage with combinatorial maps using index
template<unsigned int d_, class Items_, class Alloc_, class Index_type_ >
class Combinatorial_map_storage_2
{
public:
typedef Combinatorial_map_storage_2<d_, Items_, Alloc_, Index_type_> Self;
typedef CGAL::Tag_true Use_index;
using Index_type=Index_type_;
typedef internal::Combinatorial_map_helper<Self> Helper;
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
typedef typename Dart_wrapper::Dart Dart;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef Size_type size_type; // Type used as index.
typedef Compact_container_with_index_2<Dart,Dart_allocator,
Constant_size_policy_for_cc_with_size<1024>, size_type >
Dart_container;
typedef Items_ Items;
typedef Alloc_ Alloc;
template <typename T>
struct Container_for_attributes : public
Compact_container_with_index_2<T,
typename Alloc_::template rebind<T>::other,
Constant_size_policy_for_cc_with_size<1024>, size_type >
{};
/// Typedef for attributes
typedef typename Dart_wrapper::Attributes Attributes;
template<int i>
struct Attribute_type: public Helper::template Attribute_type<i>
{};
template<int i>
struct Attribute_handle: public Helper::template Attribute_handle<i>
{};
template<int i>
struct Attribute_const_handle:
public Helper::template Attribute_const_handle<i>
{};
template<int i>
struct Attribute_range: public Helper::template Attribute_range<i>
{};
template<int i>
struct Attribute_const_range:
public Helper::template Attribute_const_range<i>
{};
/// 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<unsigned int> 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<unsigned int i>
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<NB_MARKS>& amarks) const
{
mdarts[ADart].set_marks(amarks);
}
/// Return all the marks of a dart.
std::bitset<NB_MARKS> 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<int B1>
Dart_handle get_beta(Dart_handle ADart)
{
CGAL_assertion(B1>=0 && B1<=dimension);
return mdarts[ADart].mbeta[B1];
}
template<int B1>
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<unsigned int i>
typename Attribute_handle<i>::type attribute(Dart_handle ADart)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
template<unsigned int i>
typename Attribute_const_handle<i>::type
attribute(Dart_const_handle ADart) const
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"attribute<i> called but i-attributes are disabled.");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mdarts[ADart].mattribute_handles);
}
template<unsigned int i>
typename Attribute_type<i>::type&
get_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah];
}
template<unsigned int i>
const typename Attribute_type<i>::type&
get_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::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<unsigned int i>
typename Attribute_type<i>::type& get_attribute_of_dart(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return get_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
const typename Attribute_type<i>::type&
get_attribute_of_dart(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return get_attribute<i>(attribute<i>(adart));
}
// Get the dart of the given attribute
template<unsigned int i>
Dart_handle dart_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].dart();
}
template<unsigned int i>
Dart_const_handle
dart_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].dart();
}
// Set the dart of the given attribute
template<unsigned int i>
void set_dart_of_attribute(typename Attribute_handle<i>::type ah,
Dart_handle adart)
{
CGAL_assertion( ah!=null_handle );
CGAL::cpp11::get<Helper::template Dimension_index<i>::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<unsigned int i>
typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_handle<i>::type ah)
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].info();
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info_of_attribute(typename Attribute_const_handle<i>::type ah) const
{
CGAL_assertion( ah!=null_handle );
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers)[ah].info();
}
// Get the info of the i-cell attribute associated with the given dart
template<unsigned int i>
typename Attribute_type<i>::type::Info & info(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( this->template attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
const typename Attribute_type<i>::type::Info &
info(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return info_of_attribute<i>(attribute<i>(adart));
}
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle dart(Dart_handle adart)
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(adart));
}
template<unsigned int i>
Dart_const_handle dart(Dart_const_handle adart) const
{
CGAL_assertion( adart!=null_handle );
CGAL_assertion( attribute<i>(adart)!=null_handle );
return dart_of_attribute<i>(attribute<i>(adart));
}
// Debug function
void display_dart(Dart_const_handle ADart) const
{ std::cout<<ADart; }
template<unsigned int i>
void display_attribute(typename Attribute_const_handle<i>::type ah) const
{ std::cout<<ah; }
protected:
// Set the handle on the i th attribute
template<unsigned int i>
void basic_set_dart_attribute(Dart_handle ADart,
typename Attribute_handle<i>::type ah)
{
CGAL::cpp11::get<Helper::template Dimension_index<i>::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<unsigned int i>
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<unsigned int i>
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<unsigned int d_, class Items_, class Alloc_, class Size_type>
const typename Combinatorial_map_storage_2<d_, Items_, Alloc_, Size_type>::Dart_index
Combinatorial_map_storage_2<d_, Items_, Alloc_, Size_type>::null_dart_handle(0);
/// null_handle
template<unsigned int d_, class Items_, class Alloc_, class Size_type>
const Size_type Combinatorial_map_storage_2<d_, Items_, Alloc_, Size_type>::null_handle((std::numeric_limits<size_type>::max)()/2);
} // namespace CGAL
#if defined(BOOST_GCC)
_Pragma("GCC diagnostic pop")
#endif
#endif // CGAL_COMBINATORIAL_MAP_STORAGES_WITH_INDEX_H //
// EOF //

View File

@ -38,7 +38,7 @@ namespace CGAL {
struct Dart_wrapper
{};
};
} // namespace Index
} // namespace CGAL
#endif // CGAL_GENERIC_MAP_MIN_ITEMS_H