mirror of https://github.com/CGAL/cgal
Fix hack for non-const correct BGL
This commit is contained in:
parent
509f5904a3
commit
7af5138e14
|
|
@ -233,7 +233,6 @@ struct HDS_graph_traits
|
|||
public :
|
||||
|
||||
struct HDS_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
|
||||
// public virtual boost::adjacency_graph_tag,
|
||||
public virtual boost::vertex_list_graph_tag,
|
||||
public virtual boost::edge_list_graph_tag
|
||||
{};
|
||||
|
|
|
|||
|
|
@ -31,45 +31,21 @@
|
|||
#endif
|
||||
|
||||
|
||||
//
|
||||
// NOTE: The BGL algorithms are NOT const-correct: i.e., they take a "G const&"
|
||||
// but instantiate "graph_traits<G>" instead of "graph_traits<G const>"
|
||||
// This is known Boost bug which will eventually be fixed, but in the meantime we need
|
||||
// to coerce both const and non-const specializations.
|
||||
// That is, HDS_graph_traits<G const> is really the same as HDS_graph_traits<G>
|
||||
// so graph_traits<G> is also the same as graph_traits<G const>.
|
||||
// Therefore, while, for instance, "graph_traits<G const>::vertex_descriptor"
|
||||
// is conceptually const-correct, it actually corresponds to the non-const handle,
|
||||
// hence the const_cast<> used below in the functions implementation.
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertices_size_type
|
||||
num_vertices(const CGAL::Polyhedron_3<Gt,I,HDS,A>& p)
|
||||
{
|
||||
return p.size_of_vertices();
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edges_size_type
|
||||
num_edges(const CGAL::Polyhedron_3<Gt,I,HDS,A>& p)
|
||||
{
|
||||
return p.size_of_halfedges() ;
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::degree_size_type
|
||||
degree(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor v, const CGAL::Polyhedron_3<Gt,I,HDS,A>&)
|
||||
{
|
||||
return v->vertex_degree() * 2 ;
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::degree_size_type
|
||||
out_degree(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor v, const CGAL::Polyhedron_3<Gt,I,HDS,A>&)
|
||||
{
|
||||
return v->vertex_degree();
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::degree_size_type
|
||||
in_degree(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor v, const CGAL::Polyhedron_3<Gt,I,HDS,A>&)
|
||||
{
|
||||
return v->vertex_degree();
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
struct graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >
|
||||
: CGAL::HDS_graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >
|
||||
|
|
@ -77,67 +53,109 @@ struct graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >
|
|||
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor
|
||||
source(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor e, const CGAL::Polyhedron_3<Gt,I,HDS,A> & )
|
||||
struct graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const >
|
||||
: CGAL::HDS_graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> > // See NOTE above!
|
||||
{};
|
||||
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertices_size_type
|
||||
num_vertices(const CGAL::Polyhedron_3<Gt,I,HDS,A>& p)
|
||||
{
|
||||
return p.size_of_vertices();
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edges_size_type
|
||||
num_edges(const CGAL::Polyhedron_3<Gt,I,HDS,A>& p)
|
||||
{
|
||||
return p.size_of_halfedges() ;
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::degree_size_type
|
||||
degree(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_descriptor v, const CGAL::Polyhedron_3<Gt,I,HDS,A>&)
|
||||
{
|
||||
return v->vertex_degree() * 2 ;
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::degree_size_type
|
||||
out_degree(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_descriptor v, const CGAL::Polyhedron_3<Gt,I,HDS,A>&)
|
||||
{
|
||||
return v->vertex_degree();
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::degree_size_type
|
||||
in_degree(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_descriptor v, const CGAL::Polyhedron_3<Gt,I,HDS,A>&)
|
||||
{
|
||||
return v->vertex_degree();
|
||||
}
|
||||
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_descriptor
|
||||
source(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor e, const CGAL::Polyhedron_3<Gt,I,HDS,A> & )
|
||||
{
|
||||
return e->opposite()->vertex();
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor
|
||||
target(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edge_descriptor e, const CGAL::Polyhedron_3<Gt,I,HDS,A> & )
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_descriptor
|
||||
target(typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edge_descriptor e, const CGAL::Polyhedron_3<Gt,I,HDS,A> & )
|
||||
{
|
||||
return e->vertex();
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_iterator
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_iterator
|
||||
>
|
||||
vertices( const CGAL::Polyhedron_3<Gt,I,HDS,A>& p)
|
||||
{
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_iterator Iter;
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_iterator Iter;
|
||||
CGAL::Polyhedron_3<Gt,I,HDS,A>& ncp = const_cast<CGAL::Polyhedron_3<Gt,I,HDS,A>&>(p);
|
||||
return std::make_pair( Iter(ncp.vertices_begin()), Iter(ncp.vertices_end()) );
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edge_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edge_iterator
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edge_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edge_iterator
|
||||
>
|
||||
edges( const CGAL::Polyhedron_3<Gt,I,HDS,A>& p)
|
||||
{
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edge_iterator Iter;
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edge_iterator Iter;
|
||||
CGAL::Polyhedron_3<Gt,I,HDS,A>& ncp = const_cast<CGAL::Polyhedron_3<Gt,I,HDS,A>&>(p);
|
||||
return std::make_pair( Iter(ncp.halfedges_begin()), Iter(ncp.halfedges_end()) );
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::in_edge_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::in_edge_iterator
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::in_edge_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::in_edge_iterator
|
||||
>
|
||||
in_edges( typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor u, const CGAL::Polyhedron_3<Gt,I,HDS,A>& g)
|
||||
in_edges( typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_descriptor u, const CGAL::Polyhedron_3<Gt,I,HDS,A>& g)
|
||||
{
|
||||
typename CGAL::Polyhedron_3<Gt,I,HDS,A>::Halfedge_around_vertex_circulator ec = u->vertex_begin();
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edges_size_type in_deg = in_degree(u,g);
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::in_edge_iterator Iter;
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edges_size_type in_deg = in_degree(u,g);
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::in_edge_iterator Iter;
|
||||
return std::make_pair( Iter(ec), Iter(ec,in_deg) );
|
||||
}
|
||||
|
||||
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::out_edge_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::out_edge_iterator
|
||||
inline std::pair<typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::out_edge_iterator
|
||||
,typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::out_edge_iterator
|
||||
>
|
||||
out_edges( typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::vertex_descriptor u, const CGAL::Polyhedron_3<Gt,I,HDS,A>& g)
|
||||
out_edges( typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::vertex_descriptor u, const CGAL::Polyhedron_3<Gt,I,HDS,A>& g)
|
||||
{
|
||||
typename CGAL::Polyhedron_3<Gt,I,HDS,A>::Halfedge_around_vertex_circulator ec = u->vertex_begin();
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::edges_size_type out_deg = out_degree(u,g);
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> >::out_edge_iterator Iter;
|
||||
typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::edges_size_type out_deg = out_degree(u,g);
|
||||
typedef typename graph_traits< CGAL::Polyhedron_3<Gt,I,HDS,A> const>::out_edge_iterator Iter;
|
||||
return std::make_pair( Iter(ec), Iter(ec,out_deg) );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#undef CGAL_HDS_
|
||||
#undef CGAL_HDS_PARAM_
|
||||
|
||||
#endif // CGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYHEDRON_3_H
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public:
|
|||
typedef boost::readable_property_map_tag category;
|
||||
typedef double value_type;
|
||||
typedef double reference;
|
||||
typedef typename boost::graph_traits<Polyhedron>::edge_descriptor key_type;
|
||||
typedef typename boost::graph_traits<Polyhedron const>::edge_descriptor key_type;
|
||||
|
||||
Polyhedron_edge_weight_map( Polyhedron const& ) {}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ public:
|
|||
typedef boost::readable_property_map_tag category;
|
||||
typedef bool value_type;
|
||||
typedef bool reference;
|
||||
typedef typename boost::graph_traits<Polyhedron>::edge_descriptor key_type;
|
||||
typedef typename boost::graph_traits<Polyhedron const>::edge_descriptor key_type;
|
||||
|
||||
Polyhedron_edge_is_border_map( Polyhedron const& ) {}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ public:
|
|||
typedef boost::readable_property_map_tag category;
|
||||
typedef std::size_t value_type;
|
||||
typedef std::size_t reference;
|
||||
typedef typename boost::graph_traits<Polyhedron>::edge_descriptor key_type;
|
||||
typedef typename boost::graph_traits<Polyhedron const>::edge_descriptor key_type;
|
||||
|
||||
Polyhedron_edge_index_map_stored( Polyhedron const& ) {}
|
||||
|
||||
|
|
@ -104,16 +104,23 @@ public:
|
|||
typedef boost::readable_property_map_tag category;
|
||||
typedef std::size_t value_type;
|
||||
typedef std::size_t reference;
|
||||
typedef typename boost::graph_traits<Polyhedron>::edge_descriptor key_type;
|
||||
typedef typename boost::graph_traits<Polyhedron const>::edge_descriptor key_type;
|
||||
|
||||
Polyhedron_edge_index_map_external( Polyhedron const& p)
|
||||
: map( p.halfedges_begin(),p.halfedges_end(),0,std::size_t(-1),p.size_of_halfedges() )
|
||||
: map( remove_const(p).halfedges_begin()
|
||||
, remove_const(p).halfedges_end()
|
||||
, 0
|
||||
, std::size_t(-1)
|
||||
, p.size_of_halfedges()
|
||||
)
|
||||
{}
|
||||
|
||||
reference operator[](key_type const& e) const { return map[e]; }
|
||||
|
||||
private:
|
||||
|
||||
static Polyhedron& remove_const ( Polyhedron const& p ) { return const_cast<Polyhedron&>(p) ; }
|
||||
|
||||
CGAL::Unique_hash_map<key_type,std::size_t> map ;
|
||||
};
|
||||
|
||||
|
|
@ -155,7 +162,7 @@ public:
|
|||
typedef boost::readable_property_map_tag category;
|
||||
typedef Point_3 value_type;
|
||||
typedef Point_3 const& reference;
|
||||
typedef typename boost::graph_traits<Polyhedron>::vertex_descriptor key_type;
|
||||
typedef typename boost::graph_traits<Polyhedron const>::vertex_descriptor key_type;
|
||||
|
||||
Polyhedron_vertex_point_const_map( Polyhedron const& ) {}
|
||||
|
||||
|
|
@ -174,7 +181,7 @@ public:
|
|||
typedef boost::readable_property_map_tag category;
|
||||
typedef std::size_t value_type;
|
||||
typedef std::size_t reference;
|
||||
typedef typename boost::graph_traits<Polyhedron>::vertex_descriptor key_type;
|
||||
typedef typename boost::graph_traits<Polyhedron const>::vertex_descriptor key_type;
|
||||
|
||||
Polyhedron_vertex_index_map_stored( Polyhedron const& ) {}
|
||||
|
||||
|
|
@ -193,16 +200,23 @@ public:
|
|||
typedef boost::readable_property_map_tag category;
|
||||
typedef std::size_t value_type;
|
||||
typedef std::size_t reference;
|
||||
typedef typename boost::graph_traits<Polyhedron>::vertex_descriptor key_type;
|
||||
typedef typename boost::graph_traits<Polyhedron const>::vertex_descriptor key_type;
|
||||
|
||||
Polyhedron_vertex_index_map_external( Polyhedron const& p)
|
||||
: map( p.vertices_begin(),p.vertices_end(),0,std::size_t(-1),p.size_of_vertices() )
|
||||
: map( remove_const(p).vertices_begin()
|
||||
, remove_const(p).vertices_end()
|
||||
, 0
|
||||
, std::size_t(-1)
|
||||
, p.size_of_vertices()
|
||||
)
|
||||
{}
|
||||
|
||||
reference operator[](key_type const& v) const { return map[v]; }
|
||||
|
||||
private:
|
||||
|
||||
static Polyhedron& remove_const ( Polyhedron const& p ) { return const_cast<Polyhedron&>(p) ; }
|
||||
|
||||
CGAL::Unique_hash_map<key_type,std::size_t> map ;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue