Update cmap to use index in attributes/darts for property maps.

This commit is contained in:
Guillaume Damiand 2017-03-27 11:58:30 -04:00
parent 93713122a4
commit f95a9558b2
7 changed files with 307 additions and 148 deletions

View File

@ -67,6 +67,8 @@ template<typename CMap>
typename CMap::Dart_handle next(typename CMap::Dart_handle dh, const CMap& cmap)
{ return const_cast<CMap&>(cmap).template beta<1>(dh); }
namespace internal {
template <typename Dart_handle>
struct EdgeHandle : Dart_handle
{
@ -86,7 +88,8 @@ struct EdgeHandle : Dart_handle
bool operator==(const EdgeHandle& h) const
{
return first_halfedge()==h.first_halfedge() ||
first_halfedge()==h.second_halfedge();
(h.first_halfedge()!=NULL &&
first_halfedge()==h.second_halfedge());
}
bool operator!=(const EdgeHandle& other) const
@ -95,12 +98,51 @@ struct EdgeHandle : Dart_handle
friend bool operator<(const EdgeHandle& a, const EdgeHandle& b)
{ return a.first_halfedge()<b.first_halfedge(); }
// this is hacky, we don't know the actual type of the id and if we
// start adding decltype special cases we have to do it consistently
// up to the property map and maybe back down to Polyhedron.
std::size_t id() const { return first_halfedge()->id() / 2; }
friend bool operator>(const EdgeHandle& a, const EdgeHandle& b)
{ return b<a; }
friend bool operator<=(const EdgeHandle& a, const EdgeHandle& b)
{ return !(a>b); }
friend bool operator>=(const EdgeHandle& a, const EdgeHandle& b)
{ return !(a<b); }
const std::size_t id() const
{ return first_halfedge()->id()/2; }
friend std::size_t hash_value(const EdgeHandle& i)
{
if (i.first_halfedge()==NULL) return 0;
return hash_value(i.first_halfedge()<i.second_halfedge()?
i.first_halfedge():i.second_halfedge());
}
};
// make edge_descriptor hashable by default in Unique_hash_map
namespace handle{
template<typename Dart_handle>
struct Hash_functor< EdgeHandle<Dart_handle> >
{
std::size_t
operator()(const EdgeHandle<Dart_handle>& edge)
{ return hash_value(edge); }
};
} //end of namespace handle
/*template<typename Dart_handle>
struct Construct_edge {
typedef EdgeHandle<Dart_handle> result_type;
result_type operator()(const EdgeHandle& he) const
{ return HDS_edge<Halfedge_handle>(he); }
};
template<typename Dart_handle>
struct Construct_edge_opposite {
typedef EdgeHandle<Dart_handle> result_type;
result_type operator()(const EdgeHandle& he) const
{ return HDS_edge<Dart_handle>(he->opposite()); }
};*/
template <class CMap, typename Dart_Iterator>
class CMap_dart_handle_edge_iterator
{
@ -150,6 +192,8 @@ private:
Iterator nt;
};
} // internal
template <class CMap>
struct CMap_Base_graph_traits
{
@ -162,7 +206,7 @@ public :
// Expose types required by the boost::Graph concept.
typedef typename CMap::template Attribute_handle<0>::type vertex_descriptor;
typedef EdgeHandle<typename CMap::Dart_handle> edge_descriptor;
typedef internal::EdgeHandle<typename CMap::Dart_handle> edge_descriptor;
typedef typename CMap::template Attribute_handle<2>::type face_descriptor;
typedef typename CMap::Dart_handle halfedge_descriptor;
@ -174,7 +218,7 @@ public :
typedef Prevent_deref<typename CMap::template Attribute_range<2>::type::iterator> face_iterator;
typedef Prevent_deref<typename CMap::Dart_range::iterator> halfedge_iterator;
typedef CMap_dart_handle_edge_iterator<CMap, typename CMap::Dart_range::iterator> edge_iterator;
typedef internal::CMap_dart_handle_edge_iterator<CMap, typename CMap::Dart_range::iterator> edge_iterator;
typedef typename CMap::size_type degree_size_type;
typedef typename CMap::size_type halfedges_size_type;
@ -344,7 +388,7 @@ edge(typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor u,
{
std::pair<typename boost::graph_traits<CGAL_LCC_TYPE>::halfedge_descriptor,
bool> res=halfedge(u,v,cm);
return std::make_pair(EdgeHandle<typename CGAL_LCC_TYPE::Dart_handle>(res.first),
return std::make_pair(internal::EdgeHandle<typename CGAL_LCC_TYPE::Dart_handle>(res.first),
res.second);
}
@ -484,7 +528,7 @@ CGAL_LCC_TEMPLATE_ARGS
typename boost::graph_traits<CGAL_LCC_TYPE>::edge_descriptor
edge(typename boost::graph_traits<CGAL_LCC_TYPE>::halfedge_descriptor h,
const CGAL_LCC_TYPE&/* cm*/)
{ return EdgeHandle
{ return internal::EdgeHandle
<typename boost::graph_traits<CGAL_LCC_TYPE>::halfedge_descriptor>(h); }
CGAL_LCC_TEMPLATE_ARGS

View File

@ -217,6 +217,30 @@ protected:
const LCC & m_lcc;
}; */
template<typename LCC, typename FT>
struct Wrap_squared_lcc
: boost::put_get_helper< double, Wrap_squared_lcc<LCC, FT> >
{
typedef typename boost::graph_traits<LCC>::edge_descriptor Handle;
typedef FT value_type;
typedef FT reference;
typedef Handle key_type;
typedef boost::readable_property_map_tag category;
Wrap_squared_lcc(const LCC& alcc): m_lcc(alcc)
{}
template<typename E>
FT operator[](const E& e) const
{
return approximate_sqrt(CGAL::squared_distance
(m_lcc.point(e.first_halfedge()),
m_lcc.point(e.second_halfedge())));
}
private:
const LCC& m_lcc;
};
// the tag we dispatch on from property_map<G, Property>
template <class Tag>
@ -268,7 +292,7 @@ void put(PropertyTag p, CGAL_LCC_TYPE& g, const Key& key, const Value& value)
typedef internal::ACCESSOR##_accessor< \
CGAL_LCC_TYPE, \
typename boost::graph_traits<CGAL_LCC_TYPE> \
::ENTITY##_descriptor> type; \
::ENTITY##_descriptor > type; \
typedef type const_type; \
}; \
}; \
@ -304,7 +328,7 @@ struct LCC_property_map<boost::edge_weight_t>
typedef typename Traits_::FT FT;
typedef typename boost::graph_traits<CGAL_LCC_TYPE>::edge_descriptor
edge_descriptor;
typedef internal::Wrap_squared<edge_descriptor,FT> type;
typedef Wrap_squared_lcc<CGAL_LCC_TYPE, FT> type;
typedef type const_type;
};
};
@ -334,7 +358,9 @@ struct LCC_property_map<edge_external_index_t>
template<CGAL_LCC_ARGS>
struct bind_
{
typedef internal::Polyhedron_edge_index_map_external<CGAL_LCC_TYPE> type;
// typedef internal::Polyhedron_edge_index_map_external<CGAL_LCC_TYPE> type;
typedef internal::Edge_index_accessor<
typename boost::graph_traits<CGAL_LCC_TYPE>::edge_descriptor> type;
typedef type const_type;
};
};
@ -345,7 +371,9 @@ struct LCC_property_map<halfedge_external_index_t>
template<CGAL_LCC_ARGS>
struct bind_
{
typedef internal::Polyhedron_index_map_external<CGAL_LCC_TYPE> type;
//typedef internal::Polyhedron_index_map_external<
typedef internal::Index_accessor<CGAL_LCC_TYPE,
typename boost::graph_traits<CGAL_LCC_TYPE >::halfedge_descriptor> type;
typedef type const_type;
};
};
@ -357,7 +385,9 @@ struct LCC_property_map<vertex_external_index_t>
template<CGAL_LCC_ARGS>
struct bind_
{
typedef internal::Polyhedron_index_map_external<CGAL_LCC_TYPE> type;
//typedef internal::Polyhedron_index_map_external<
typedef internal::Index_accessor<CGAL_LCC_TYPE,
typename boost::graph_traits<CGAL_LCC_TYPE >::vertex_descriptor> type;
typedef type const_type;
};
};
@ -368,7 +398,9 @@ struct LCC_property_map<face_external_index_t>
template<CGAL_LCC_ARGS>
struct bind_
{
typedef internal::Polyhedron_index_map_external<CGAL_LCC_TYPE> type;
//typedef internal::Polyhedron_index_map_external<
typedef internal::Index_accessor<CGAL_LCC_TYPE,
typename boost::graph_traits<CGAL_LCC_TYPE >::face_descriptor> type;
typedef type const_type;
};
};
@ -378,38 +410,42 @@ struct LCC_property_map<face_external_index_t>
namespace CGAL{
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t >::const_type
get(boost::edge_external_index_t, CGAL_LCC_TYPE const& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t >::const_type
typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_index_t/*boost::halfedge_external_index_t*/ >::const_type
get(boost::halfedge_external_index_t, CGAL_LCC_TYPE const& cmap)
{
CGAL_LCC_TYPE& ncmap=const_cast<CGAL_LCC_TYPE&>(cmap);
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_index_t >::const_type();
/* CGAL_LCC_TYPE& ncmap=const_cast<CGAL_LCC_TYPE&>(cmap);
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t>::
const_type(halfedges(ncmap).begin(), halfedges(ncmap).end(), num_halfedges(ncmap));
const_type(halfedges(ncmap).begin(), halfedges(ncmap).end(), num_halfedges(ncmap)); */
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t >::const_type
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_index_t /*boost::vertex_external_index_t*/ >::const_type
get(boost::vertex_external_index_t, CGAL_LCC_TYPE const& cmap)
{
CGAL_LCC_TYPE& ncmap=const_cast<CGAL_LCC_TYPE&>(cmap);
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_index_t >::const_type();
/* CGAL_LCC_TYPE& ncmap=const_cast<CGAL_LCC_TYPE&>(cmap);
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t>::
const_type(vertices(ncmap).begin(), vertices(ncmap).end(), num_vertices(ncmap));
const_type(vertices(ncmap).begin(), vertices(ncmap).end(), num_vertices(ncmap)); */
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t >::const_type
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_index_t/*boost::edge_external_index_t*/ >::const_type
get(boost::edge_external_index_t, CGAL_LCC_TYPE const& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_index_t >::const_type();
/*return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));*/
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::face_index_t /* boost::face_external_index_t*/ >::const_type
get(boost::face_external_index_t, CGAL_LCC_TYPE const& cmap)
{
CGAL_LCC_TYPE& ncmap=const_cast<CGAL_LCC_TYPE&>(cmap);
return typename boost::property_map<CGAL_LCC_TYPE, boost::face_index_t >::const_type();
/*CGAL_LCC_TYPE& ncmap=const_cast<CGAL_LCC_TYPE&>(cmap);
return typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t>::
const_type(faces(ncmap).begin(), faces(ncmap).end(), num_faces(ncmap));
const_type(faces(ncmap).begin(), faces(ncmap).end(), num_faces(ncmap));*/
}
/*
@ -454,47 +490,60 @@ get(boost::vertex_point_t, CGAL_LCC_TYPE const& cmap)
return typename boost::property_map<CGAL_LCC_TYPE,boost::vertex_point_t>::
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
}
*/
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_weight_t >::const_type
get(boost::edge_weight_t, CGAL_LCC_TYPE const& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE,boost::edge_weight_t>::
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_weight_t>::
const_type(const_cast<CGAL_LCC_TYPE&>(cmap));
}
*/
// the same blurb for non-const
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t >::type
typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_index_t/*boost::halfedge_external_index_t*/ >::type
get(boost::halfedge_external_index_t, CGAL_LCC_TYPE& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_index_t >::type();
/* return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t>::
type(halfedges(cmap).begin(), halfedges(cmap).end(), num_halfedges(cmap));*/
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_index_t/*boost::vertex_external_index_t*/ >::type
get(boost::vertex_external_index_t, CGAL_LCC_TYPE& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_index_t >::type();
/* return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t>::
type(vertices(cmap).begin(), vertices(cmap).end(), num_vertices(cmap));*/
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_index_t/*boost::edge_external_index_t*/ >::type
get(boost::edge_external_index_t, CGAL_LCC_TYPE& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
type(const_cast<CGAL_LCC_TYPE&>(cmap));
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_index_t>::type(cmap);
/*return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_external_index_t>::
type(const_cast<CGAL_LCC_TYPE&>(cmap));*/
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t >::type
get(boost::halfedge_external_index_t, CGAL_LCC_TYPE& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::halfedge_external_index_t>::
type(halfedges(cmap).begin(), halfedges(cmap).end(), num_halfedges(cmap));
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t >::type
get(boost::vertex_external_index_t, CGAL_LCC_TYPE& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::vertex_external_index_t>::
type(vertices(cmap).begin(), vertices(cmap).end(), num_vertices(cmap));
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t >::type
typename boost::property_map<CGAL_LCC_TYPE, boost::face_index_t/*boost::face_external_index_t*/ >::type
get(boost::face_external_index_t, CGAL_LCC_TYPE& cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t>::
type(faces(cmap).begin(), faces(cmap).end(), num_faces(cmap));
return typename boost::property_map<CGAL_LCC_TYPE, boost::face_index_t >::type();
/*return typename boost::property_map<CGAL_LCC_TYPE, boost::face_external_index_t>::
type(faces(cmap).begin(), faces(cmap).end(), num_faces(cmap));*/
}
template<CGAL_LCC_ARGS>
typename boost::property_map<CGAL_LCC_TYPE, boost::edge_weight_t >::type
get(boost::edge_weight_t, CGAL_LCC_TYPE & cmap)
{
return typename boost::property_map<CGAL_LCC_TYPE, boost::edge_weight_t>::
type(cmap);
}
} // namespace CGAL

View File

@ -33,40 +33,40 @@ void concept_check_polyhedron() {
boost::function_requires< boost::GraphConcept<LCC> >();
boost::function_requires< boost::VertexListGraphConcept<LCC> >();
boost::function_requires< boost::EdgeListGraphConcept<LCC> >();
boost::function_requires< boost::AdjacencyMatrixConcept<LCC> >();
boost::function_requires< boost::MutableGraphConcept<LCC> >();
boost::function_requires< CGAL::FaceListGraphConcept<LCC> >();
boost::function_requires< CGAL::HalfedgeGraphConcept<LCC> >();
boost::function_requires< boost::IncidenceGraphConcept<LCC> >();
boost::function_requires< CGAL::HalfedgeListGraphConcept<LCC> >();
boost::function_requires< boost::AdjacencyMatrixConcept<LCC> >();
boost::function_requires< boost::BidirectionalGraphConcept<LCC> >();
boost::function_requires< CGAL::MutableHalfedgeGraphConcept<LCC> >();
// TODO Perhaps to remove ?
boost::function_requires< CGAL::HalfedgeGraphConcept<LCC> >();
boost::function_requires< CGAL::HalfedgeListGraphConcept<LCC> >();
boost::function_requires< CGAL::FaceGraphConcept<LCC> >();
boost::function_requires< CGAL::FaceListGraphConcept<LCC> >();
boost::function_requires< CGAL::MutableHalfedgeGraphConcept<LCC> >();
boost::function_requires< CGAL::MutableFaceGraphConcept<LCC> >();
boost::function_requires< boost::MutableGraphConcept<LCC> >();
boost::function_requires< boost::concepts::PropertyGraph<
LCC, halfedge_descriptor, boost::halfedge_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, halfedge_descriptor, boost::halfedge_external_index_t> >();
boost::function_requires< boost::PropertyGraphConcept<
LCC, vertex_descriptor, boost::vertex_point_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, edge_descriptor, boost::edge_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, edge_descriptor, boost::edge_external_index_t> >();
boost::function_requires< boost::concepts::PropertyGraph<
LCC, face_descriptor, boost::face_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, face_descriptor, boost::face_external_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, edge_descriptor, boost::edge_weight_t> >();
boost::function_requires< boost::PropertyGraphConcept<
LCC, vertex_descriptor, boost::vertex_point_t> >();
boost::function_requires< boost::concepts::PropertyGraph<
LCC, vertex_descriptor, boost::vertex_index_t> >();
boost::function_requires< boost::concepts::PropertyGraph<
LCC, face_descriptor, boost::face_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, halfedge_descriptor, boost::halfedge_external_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, vertex_descriptor, boost::vertex_external_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, edge_descriptor, boost::edge_external_index_t> >();
boost::function_requires< boost::concepts::ReadablePropertyGraph<
LCC, face_descriptor, boost::face_external_index_t> >();
// null
boost::graph_traits<LCC>::null_vertex();
boost::graph_traits<LCC>::null_face();
@ -122,63 +122,8 @@ void runtime_check_halfedgegraph()
assert(num_faces(p) == 4);
}
int
main()
int main()
{
LCC lcc;
typedef typename boost::graph_traits<LCC>::halfedge_iterator iter;
iter it;
/* CGAL::Halfedge_around_target_iterator<LCC> it;
vd myvd;
typedef typename boost::graph_traits<LCC>::in_edge_iterator iter;
iter myiter;
*/
// std::pair<iter, iter> p; // = in_edges(myvd, lcc);*/
/*
const LCC& lcc2 = lcc;
iter_type a1(lcc);
const iter_type a2(a1);
iter_type a3(a2);
// a1=a2;
CGAL::CMap_one_dart_per_cell_iterator<LCC, 1> toto1(lcc);
const CGAL::CMap_one_dart_per_cell_iterator<LCC, 1> toto2(lcc);
toto1=toto2;
//iter_type it(lcc);
std::pair<typename boost::graph_traits<LCC>::edge_iterator, typename boost::graph_traits<LCC>::edge_iterator> it=std::make_pair<iter_type, iter_type>
(iter_type(lcc),
iter_type(lcc)), it2=std::make_pair<iter_type, iter_type>
(iter_type(lcc),
iter_type(lcc));
it=it2;
iter_type t1(lcc);
std::pair<iter_type, iter_type> p=edges(lcc);
std::pair<iter_type, iter_type> p2=std::make_pair<iter_type, iter_type>(t1, t1);*/
//p=std::make_pair(t1, t1); //p2;
//iter_type(lcc), iter_type(lcc));
//toto(lcc);
// std::pair<int, int> p;
// p = std::make_pair<int, int>(0,0);
concept_check_polyhedron<LCC>();
runtime_check_halfedgegraph<LCC>();
std::cerr << "done\n";

View File

@ -40,6 +40,13 @@ namespace CGAL {
template<unsigned int, unsigned int, class, class, class>
class GMap_linear_cell_complex_storage_1;
namespace internal {
template<class>
struct Init_id;
} // end namespace internal
/** @file Cell_attribute.h
* Definition of cell attribute, with or without info.
*/
@ -98,6 +105,9 @@ namespace CGAL {
template <class, class>
friend class Concurrent_compact_container;
template<class>
friend struct internal::Init_id;
public:
typedef Tag_false Supports_cell_dart;
@ -136,6 +146,14 @@ 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)
@ -158,6 +176,9 @@ 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
@ -175,6 +196,9 @@ namespace CGAL {
std::size_t mrefcounting;
void *vp;
};
/// id of the dart // TODO better
std::size_t m_id;
};
/** Definition of cell attribute.
@ -204,6 +228,9 @@ namespace CGAL {
template <class, class>
friend class Concurrent_compact_container;
template<class>
friend class internal::Init_id;
public:
typedef Tag_true Supports_cell_dart;
@ -243,6 +270,14 @@ 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),
@ -267,6 +302,9 @@ 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
@ -283,6 +321,9 @@ 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

View File

@ -698,6 +698,8 @@ namespace CGAL {
Helper::template Foreach_enabled_attributes
<internal::Init_attribute_functor<Self> >::run(*this, adart);
internal::Init_id<Dart_container>::run(mdarts, adart);
}
// Initialize a given dart: all beta to null_dart_handle and all
// attributes to null, marks are given.
@ -1494,6 +1496,8 @@ namespace CGAL {
// Reinitialize the ref counting of the new attribute. This is normally
// not required except if create_attribute is used as "copy contructor".
this->template init_attribute_ref_counting<i>(res);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
#else
@ -1503,8 +1507,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace();
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace();
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1>
typename Attribute_handle<i>::type
@ -1515,7 +1523,11 @@ namespace CGAL {
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1);
// Reinitialize the ref counting of the new attribute. This is normally
// not required except if create_attribute is used as "copy contructor".
this->template init_attribute_ref_counting<i>(res);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2>
@ -1524,8 +1536,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2, typename T3>
typename Attribute_handle<i>::type
@ -1533,8 +1549,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2, typename T3, typename T4>
typename Attribute_handle<i>::type
@ -1542,8 +1562,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2, typename T3, typename T4,
typename T5>
@ -1553,8 +1577,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
@ -1564,8 +1592,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
@ -1575,8 +1607,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6, t7);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6, t7);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
@ -1586,8 +1622,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6, t7, t8);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6, t7, t8);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
template<unsigned int i, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8, typename T9>
@ -1598,8 +1638,12 @@ namespace CGAL {
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"create_attribute<i> but i-attributes are disabled");
return CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6, t7, t8, t9);
typename Attribute_handle<i>::type res=
CGAL::cpp11::get<Helper::template Dimension_index<i>::value>
(mattribute_containers).emplace(t1, t2, t3, t4, t5, t6, t7, t8, t9);
internal::Init_id<typename Attribute_range<i>::type>::run
(this->template attributes<i>(), res);
return res;
}
#endif

View File

@ -44,6 +44,13 @@ namespace CGAL {
template<unsigned int, unsigned int, class, class, class>
class GMap_linear_cell_complex_storage_1;
namespace internal {
template<class>
struct Init_id;
} // end namespace internal
/** @file Dart.h
* Definition of nD dart.
*/
@ -77,6 +84,9 @@ namespace CGAL {
template <class, class>
friend class Concurrent_compact_container;
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;
@ -109,6 +119,14 @@ 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.
@ -184,6 +202,9 @@ 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];
@ -193,6 +214,9 @@ 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)

View File

@ -90,6 +90,9 @@
*
* internal::Cleanup_useless_attributes to erase all attributes having
* no more associated dart
*
* internal::Init_id initialize the id of an new element created in a compact
* container, when the underlying type defines id (TODO Move in Compact container ?)
*/
namespace CGAL
@ -1034,6 +1037,15 @@ struct Beta_functor_static<CMap, Dart_handle, B, Betas...>
};
#endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
// ****************************************************************************
template<typename Container>
struct Init_id
{
static void run(Container& c, typename Container::iterator e)
{
e->set_id(c.index(e));
}
};
// ****************************************************************************
} // namespace internal
} // namespace CGAL