Now attributes and darts in CMap/GMap/LCC can have id or not depending on a template argument.

This commit is contained in:
Guillaume Damiand 2017-03-27 17:16:40 -04:00
parent 1d765e91c9
commit bfbee1701e
12 changed files with 224 additions and 109 deletions

View File

@ -12,9 +12,9 @@ struct Myitem
template<class Refs>
struct Dart_wrapper
{
typedef CGAL::Dart<2, Refs > Dart;
typedef CGAL::Cell_attribute_with_point< Refs > Vertex_attribute;
typedef CGAL::Cell_attribute< Refs > Face_attribute;
typedef CGAL::Tag_true Darts_with_id;
typedef CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute;
typedef CGAL::Cell_attribute_with_id< Refs > Face_attribute;
typedef CGAL::cpp11::tuple<Vertex_attribute, void, Face_attribute> Attributes;
};
};

View File

@ -46,9 +46,9 @@ struct Myitem
template<class Refs>
struct Dart_wrapper
{
typedef CGAL::Dart<2, Refs > Dart;
typedef CGAL::Cell_attribute_with_point< Refs > Vertex_attribute;
typedef CGAL::Cell_attribute< Refs > Face_attribute;
typedef CGAL::Tag_true Darts_with_id;
typedef CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute;
typedef CGAL::Cell_attribute_with_id< Refs > Face_attribute;
typedef CGAL::cpp11::tuple<Vertex_attribute, void, Face_attribute> Attributes;
};
};

View File

@ -42,7 +42,7 @@ namespace CGAL {
namespace internal {
template<class>
template<class, class>
struct Init_id;
} // end namespace internal
@ -77,15 +77,41 @@ namespace CGAL {
Info minfo;
};
/// Id associated with a cell attribute
template <class WithId>
class Add_id
{
public:
// Required to have "internal" property maps.
std::size_t& id()
{ return m_id; }
const std::size_t& id() const
{ return m_id; }
protected:
void set_id(std::size_t id)
{ m_id=id; }
protected:
/// id of the cell
std::size_t m_id;
};
/// If the tag WithId is false, we do not add id to cells.
template <>
class Add_id<Tag_false>
{};
/// Cell_attribute_without_info
template <class Refs, class Tag=Tag_true, class OnMerge=Null_functor,
class OnSplit=Null_functor>
class OnSplit=Null_functor, class WithID=Tag_false>
class Cell_attribute_without_info;
// Cell_attribute_without_info without dart support.
template <class Refs, class OnMerge, class OnSplit>
template <class Refs, class OnMerge, class OnSplit, class WithID>
class Cell_attribute_without_info<Refs, Tag_false,
OnMerge, OnSplit>
OnMerge, OnSplit, WithID>:
public Add_id<WithID>
{
template<unsigned int, class, class>
friend class Combinatorial_map_storage_1;
@ -105,7 +131,7 @@ namespace CGAL {
template <class, class>
friend class Concurrent_compact_container;
template<class>
template<class, class>
friend struct internal::Init_id;
public:
@ -117,6 +143,7 @@ namespace CGAL {
typedef OnMerge On_merge;
typedef OnSplit On_split;
typedef WithID Has_id;
/// operator =
Cell_attribute_without_info&
@ -146,14 +173,6 @@ namespace CGAL {
bool operator!=(const Cell_attribute_without_info& other) const
{ return !operator==(other); }
// Required to have "internal" property maps.
// TODO better (use id only when we want to use bgl ?)
// (or have an id directly in compact container ?)
std::size_t& id()
{ return m_id; }
const std::size_t& id() const
{ return m_id; }
protected:
/// Contructor without parameter.
Cell_attribute_without_info(): mrefcounting(0)
@ -176,9 +195,6 @@ namespace CGAL {
mrefcounting-=4; // 4 because the two lowest bits are reserved for cc
}
void set_id(std::size_t id)
{ m_id=id; }
public:
/// Get the reference counting.
std::size_t get_nb_refs() const
@ -196,9 +212,6 @@ namespace CGAL {
std::size_t mrefcounting;
void *vp;
};
/// id of the dart // TODO better
std::size_t m_id;
};
/** Definition of cell attribute.
@ -206,9 +219,9 @@ namespace CGAL {
* link to a dart of the cell (when T is true).
* The refs class must provide the type of Combinatorial_map used.
*/
template <class Refs, class OnMerge, class OnSplit>
template <class Refs, class OnMerge, class OnSplit, class WithID>
class Cell_attribute_without_info<Refs, Tag_true,
OnMerge, OnSplit>
OnMerge, OnSplit, WithID>: public Add_id<WithID>
{
template<unsigned int, class, class>
friend class Combinatorial_map_storage_1;
@ -240,6 +253,7 @@ namespace CGAL {
typedef OnMerge On_merge;
typedef OnSplit On_split;
typedef WithID Has_id;
/// operator =
Cell_attribute_without_info&
@ -270,14 +284,6 @@ namespace CGAL {
bool operator!=(const Cell_attribute_without_info& other) const
{ return !operator==(other); }
// Required to have "internal" property maps.
// TODO better (use id only when we want to use bgl ?)
// (or have an id directly in compact container ?)
std::size_t& id()
{ return m_id; }
const std::size_t& id() const
{ return m_id; }
protected:
/// Contructor without parameter.
Cell_attribute_without_info() : mdart(Refs::null_handle),
@ -302,9 +308,6 @@ namespace CGAL {
--mrefcounting;
}
void set_id(std::size_t id)
{ m_id=id; }
public:
/// Get the reference counting.
std::size_t get_nb_refs() const
@ -321,23 +324,20 @@ namespace CGAL {
/// Reference counting: the number of darts linked to this cell.
std::size_t mrefcounting;
/// id of the dart // TODO better
std::size_t m_id;
};
/// Cell associated with an attribute, with or without info depending
/// if Info==void.
template <class Refs, class Info_=void, class Tag_=Tag_true,
class OnMerge=Null_functor,
class OnSplit=Null_functor>
class OnSplit=Null_functor,
class WithID=Tag_false>
class Cell_attribute;
/// Specialization when Info==void.
template <class Refs, class Tag_,
class OnMerge, class OnSplit>
class Cell_attribute<Refs, void, Tag_, OnMerge, OnSplit> :
public Cell_attribute_without_info<Refs, Tag_, OnMerge, OnSplit>
template <class Refs, class Tag_, class OnMerge, class OnSplit, class WithID>
class Cell_attribute<Refs, void, Tag_, OnMerge, OnSplit, WithID> :
public Cell_attribute_without_info<Refs, Tag_, OnMerge, OnSplit, WithID>
{
template<unsigned int, class, class>
friend class Combinatorial_map_storage_1;
@ -374,9 +374,9 @@ namespace CGAL {
/// Specialization when Info!=void.
template <class Refs, class Info_, class Tag_,
class OnMerge, class OnSplit>
class OnMerge, class OnSplit, class WithID>
class Cell_attribute :
public Cell_attribute_without_info<Refs, Tag_, OnMerge, OnSplit>,
public Cell_attribute_without_info<Refs, Tag_, OnMerge, OnSplit, WithID>,
public Info_for_cell_attribute<Info_>
{
template<unsigned int, class, class>
@ -398,7 +398,7 @@ namespace CGAL {
friend class Concurrent_compact_container;
public:
typedef Cell_attribute<Refs, Info_, Tag_, OnMerge, OnSplit> Self;
typedef Cell_attribute<Refs, Info_, Tag_, OnMerge, OnSplit, WithID> Self;
typedef Tag_ Supports_cell_dart;
typedef typename Refs::Dart_handle Dart_handle;
@ -425,6 +425,47 @@ namespace CGAL {
{}
};
// A cell attribute with an id, when Info_!=void
template <class Refs, class Info_=void, class Tag_=Tag_true,
class OnMerge=Null_functor,
class OnSplit=Null_functor>
class Cell_attribute_with_id: public Cell_attribute
<Refs, Info_, Tag_, OnMerge, OnSplit, Tag_true>
{
template <class, class, class, class>
friend class Compact_container;
template <class, class>
friend class Concurrent_compact_container;
protected:
/// Default contructor.
Cell_attribute_with_id()
{}
/// Contructor with an info in parameter.
Cell_attribute_with_id(const Info_& ainfo) :
Cell_attribute<Refs, Info_, Tag_, OnMerge, OnSplit, Tag_true>(ainfo)
{}
};
/// Specialization when Info==void.
template <class Refs, class Tag_, class OnMerge, class OnSplit>
class Cell_attribute_with_id<Refs, void, Tag_, OnMerge, OnSplit>:
public Cell_attribute<Refs, void, Tag_, OnMerge, OnSplit, Tag_true>
{
template <class, class, class, class>
friend class Compact_container;
template <class, class>
friend class Concurrent_compact_container;
protected:
/// Default contructor.
Cell_attribute_with_id()
{}
};
} // namespace CGAL
#endif // CGAL_CELL_ATTRIBUTE_H //

View File

@ -57,16 +57,18 @@ namespace CGAL {
typedef typename Dart_wrapper::Dart Dart;
#else
typedef typename internal::template Get_dart_info<Dart_wrapper>::type
Dart_info;
typedef CGAL::Dart<d_, Self, Dart_info> Dart;
Dart_info;
typedef typename internal::template Get_darts_with_id<Dart_wrapper>::type
Darts_with_id;
typedef CGAL::Dart<d_, Self, Dart_info, Darts_with_id> Dart;
#endif
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef Compact_container<Dart, Dart_allocator> Dart_container;
typedef Compact_container<Dart, Dart_allocator> Dart_container;
typedef typename Dart_container::iterator Dart_handle;
typedef typename Dart_container::const_iterator Dart_const_handle;
typedef typename Dart_container::size_type size_type;
typedef typename Dart_container::iterator Dart_handle;
typedef typename Dart_container::const_iterator Dart_const_handle;
typedef typename Dart_container::size_type size_type;
typedef CGAL::Void* Null_handle_type;
static const Null_handle_type null_handle;

View File

@ -46,7 +46,7 @@ namespace CGAL {
namespace internal {
template<class>
template<class, class>
struct Init_id;
} // end namespace internal
@ -62,8 +62,8 @@ namespace CGAL {
* n is the dimension of the space (2 for 2D, 3 for 3D...)
* Refs the ref class
*/
template <unsigned int d, typename Refs>
struct Dart_without_info
template <unsigned int d, typename Refs, class WithId>
struct Dart_without_info: public Add_id<WithId>
{
public:
template<unsigned int, class, class>
@ -87,11 +87,12 @@ namespace CGAL {
template<class>
friend struct internal::Init_id;
typedef Dart_without_info<d,Refs> Self;
typedef typename Refs::Dart_handle Dart_handle;
typedef typename Refs::size_type size_type;
typedef typename Refs::Dart_const_handle Dart_const_handle;
typedef typename Refs::Helper Helper;
typedef Dart_without_info<d,Refs, WithId> Self;
typedef typename Refs::Dart_handle Dart_handle;
typedef typename Refs::size_type size_type;
typedef typename Refs::Dart_const_handle Dart_const_handle;
typedef typename Refs::Helper Helper;
typedef WithId Has_id;
/// Typedef for attributes
template<int i>
@ -119,14 +120,6 @@ namespace CGAL {
return mf[i];
}
// Required to have "internal" property maps.
// TODO better (use id only when we want to use bgl ?)
// (or have an id directly in compact container ?)
std::size_t& id()
{ return m_id; }
const std::size_t& id() const
{ return m_id; }
protected:
/** Default constructor: no real initialisation,
* because this is done in the combinatorial map class.
@ -202,9 +195,6 @@ namespace CGAL {
(mattribute_handles);
}
void set_id(std::size_t id)
{ m_id=id; }
protected:
/// Neighboors for each dimension +1 (from 0 to dimension).
Dart_handle mf[dimension+1];
@ -214,9 +204,6 @@ namespace CGAL {
/// Attributes enabled
typename Helper::Attribute_handles mattribute_handles;
/// id of the dart // TODO better
std::size_t m_id;
};
#if defined(CGAL_CMAP_DART_DEPRECATED) && !defined(CGAL_NO_DEPRECATED_CODE)
@ -324,8 +311,9 @@ namespace CGAL {
#else // CGAL_CMAP_DART_DEPRECATED
// Dart definition with an info;
// (there is a specialization below when Info_==void)
template <unsigned int d, typename Refs, typename Info_=void>
struct Dart : public Dart_without_info<d, Refs>
template <unsigned int d, typename Refs, typename Info_=void,
class WithID=Tag_false>
struct Dart : public Dart_without_info<d, Refs, WithID>
{
public:
template<unsigned int, class, class>
@ -346,8 +334,8 @@ namespace CGAL {
template <class, class>
friend class Concurrent_compact_container;
typedef Dart<d, Refs, Info_> Self;
typedef Info_ Info;
typedef Dart<d, Refs, Info_, WithID> Self;
typedef Info_ Info;
protected:
/** Default constructor: no real initialisation,
@ -369,8 +357,8 @@ namespace CGAL {
};
// Specialization of Dart class when info==void
template <unsigned int d, typename Refs>
struct Dart<d, Refs, void> : public Dart_without_info<d, Refs>
template <unsigned int d, typename Refs, class WithID>
struct Dart<d, Refs, void, WithID> : public Dart_without_info<d, Refs, WithID>
{
public:
typedef CGAL::Void Info;

View File

@ -1037,7 +1037,8 @@ struct Beta_functor_static<CMap, Dart_handle, B, Betas...>
};
#endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
// ****************************************************************************
template<typename Container>
template<typename Container, class WitdId=
typename Container::value_type::Has_id>
struct Init_id
{
static void run(Container& c, typename Container::iterator e)
@ -1045,6 +1046,12 @@ struct Init_id
e->set_id(c.index(e));
}
};
template<typename Container>
struct Init_id<Container, Tag_false>
{
static void run(Container&, typename Container::iterator)
{}
};
// ****************************************************************************
} // namespace internal
} // namespace CGAL

View File

@ -60,6 +60,16 @@ namespace CGAL
struct Get_dart_info<T, true>
{ typedef typename Convert_void<typename T::Dart_info>::type type; };
// Get the type Darts_with_id as inner type of T.
// If T::Darts_with_id is not defined or if T::Darts_widh_id is Tag_false
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_darts_with_id,Darts_with_id,false)
template<typename T, bool typedefined=Has_darts_with_id<T>::value >
struct Get_darts_with_id
{ typedef CGAL::Tag_false type; };
template<typename T>
struct Get_darts_with_id<T, true>
{ typedef CGAL::Tag_true type; };
// Get the type Attributes defined as inner type of T.
// If T::Attributes is not defined, defined CGAL::cpp11::tuple<> as type.
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(Has_attributes_tuple,Attributes,false)

View File

@ -56,7 +56,9 @@ namespace CGAL {
typedef typename internal::template Get_dart_info<Dart_wrapper>::type
Dart_info;
typedef CGAL::Dart<d_, Self, Dart_info> Dart;
typedef typename internal::template Get_darts_with_id<Dart_wrapper>::type
Darts_with_id;
typedef CGAL::Dart<d_, Self, Dart_info, Darts_with_id> Dart;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;

View File

@ -68,16 +68,18 @@ namespace CGAL {
typedef typename Dart_wrapper::Dart Dart;
#else
typedef typename internal::template Get_dart_info<Dart_wrapper>::type
Dart_info;
typedef CGAL::Dart<d_, Self, Dart_info> Dart;
Dart_info;
typedef typename internal::template Get_darts_with_id<Dart_wrapper>::type
Darts_with_id;
typedef CGAL::Dart<d_, Self, Dart_info, Darts_with_id> Dart;
#endif
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef Compact_container<Dart, Dart_allocator> Dart_container;
typedef Compact_container<Dart, Dart_allocator> Dart_container;
typedef typename Dart_container::iterator Dart_handle;
typedef typename Dart_container::const_iterator Dart_const_handle;
typedef typename Dart_container::size_type size_type;
typedef typename Dart_container::iterator Dart_handle;
typedef typename Dart_container::const_iterator Dart_const_handle;
typedef typename Dart_container::size_type size_type;
typedef CGAL::Void* Null_handle_type;
static const Null_handle_type null_handle;

View File

@ -57,10 +57,11 @@ namespace CGAL {
/// Attribute associated with a point and an info.
template < class LCC, class Info_=void, class Tag=Tag_true,
class Functor_on_merge_=Null_functor,
class Functor_on_split_=Null_functor >
class Functor_on_split_=Null_functor,
class WithID=Tag_false >
class Cell_attribute_with_point :
public Cell_attribute<LCC, Info_, Tag,
Functor_on_merge_, Functor_on_split_>,
Functor_on_merge_, Functor_on_split_, WithID>,
public Point_for_cell<typename LCC::Point>
{
template <class, class, class, class>
@ -112,10 +113,13 @@ namespace CGAL {
/// Attribute associated with a point and without info.
template < class LCC, class Tag,
class Functor_on_merge_,
class Functor_on_split_ >
class Functor_on_split_,
class WithID>
class Cell_attribute_with_point<LCC, void, Tag,
Functor_on_merge_, Functor_on_split_> :
public Cell_attribute<LCC, void, Tag, Functor_on_merge_, Functor_on_split_>,
Functor_on_merge_, Functor_on_split_,
WithID>:
public Cell_attribute<LCC, void,
Tag, Functor_on_merge_, Functor_on_split_, WithID>,
public Point_for_cell<typename LCC::Point>
{
template <class, class, class, class>
@ -126,7 +130,7 @@ namespace CGAL {
public:
typedef Cell_attribute<LCC, void, Tag,
Functor_on_merge_, Functor_on_split_> Base1;
Functor_on_merge_, Functor_on_split_, WithID> Base1;
typedef Point_for_cell<typename LCC::Point> Base2;
typedef void Info;
@ -156,6 +160,63 @@ namespace CGAL {
Cell_attribute_with_point(const Point& apoint) : Base2(apoint)
{}
};
// A cell attribute with point and id, when Info_!=void
template <class Refs, class Info_=void, class Tag_=Tag_true,
class OnMerge=Null_functor,
class OnSplit=Null_functor>
class Cell_attribute_with_point_and_id: public
Cell_attribute_with_point<Refs, Info_, Tag_, OnMerge, OnSplit, Tag_true>
{
typedef Cell_attribute_with_point
<Refs, Info_, Tag_, OnMerge, OnSplit, Tag_true> Base;
typedef typename Refs::Point Point;
template <class, class, class, class>
friend class Compact_container;
template <class, class>
friend class Concurrent_compact_container;
protected:
/// Default contructor.
Cell_attribute_with_point_and_id()
{}
/// Contructor with an info in parameter.
Cell_attribute_with_point_and_id(const Point& apoint) : Base(apoint)
{}
/// Contructor with a point and an attribute in parameters.
Cell_attribute_with_point_and_id(const Point& apoint, const Info_& ainfo) :
Base(apoint, ainfo)
{}
};
/// Specialization when Info==void.
template <class Refs, class Tag_, class OnMerge, class OnSplit>
class Cell_attribute_with_point_and_id<Refs, void, Tag_, OnMerge, OnSplit>:
public Cell_attribute_with_point<Refs, void, Tag_, OnMerge, OnSplit, Tag_true>
{
typedef Cell_attribute_with_point
<Refs, void, Tag_, OnMerge, OnSplit, Tag_true> Base;
typedef typename Refs::Point Point;
template <class, class, class, class>
friend class Compact_container;
template <class, class>
friend class Concurrent_compact_container;
protected:
/// Default contructor.
Cell_attribute_with_point_and_id()
{}
/// Contructor with a point in parameter.
Cell_attribute_with_point_and_id(const Point& apoint) : Base(apoint)
{}
};
} // namespace CGAL
#endif // CGAL_CELL_ATTRIBUTE_WITH_POINT_H //

View File

@ -65,16 +65,18 @@ namespace CGAL {
typedef typename Items_::template Dart_wrapper<Self> Dart_wrapper;
typedef typename internal::template Get_dart_info<Dart_wrapper>::type
Dart_info;
typedef CGAL::Dart<d_, Self, Dart_info> Dart;
Dart_info;
typedef typename internal::template Get_darts_with_id<Dart_wrapper>::type
Darts_with_id;
typedef CGAL::Dart<d_, Self, Dart_info, Darts_with_id> Dart;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef typename Alloc_::template rebind<Dart>::other Dart_allocator;
typedef Compact_container<Dart, Dart_allocator> Dart_container;
typedef Compact_container<Dart, Dart_allocator> Dart_container;
typedef typename Dart_container::iterator Dart_handle;
typedef typename Dart_container::const_iterator Dart_const_handle;
typedef typename Dart_container::size_type size_type;
typedef typename Dart_container::iterator Dart_handle;
typedef typename Dart_container::const_iterator Dart_const_handle;
typedef typename Dart_container::size_type size_type;
typedef CGAL::Void* Null_handle_type;
static const Null_handle_type null_handle;

View File

@ -19,9 +19,9 @@ struct Myitem
template<class Refs>
struct Dart_wrapper
{
typedef CGAL::Dart<2, Refs > Dart;
typedef CGAL::Cell_attribute_with_point< Refs > Vertex_attribute;
typedef CGAL::Cell_attribute< Refs > Face_attribute;
typedef CGAL::Tag_true Darts_with_id;
typedef CGAL::Cell_attribute_with_point_and_id< Refs > Vertex_attribute;
typedef CGAL::Cell_attribute_with_id< Refs > Face_attribute;
typedef CGAL::cpp11::tuple<Vertex_attribute, void, Face_attribute> Attributes;
};
};