BGL: Add adjacency_iterator for several classes

This commit is contained in:
Andreas Fabri 2022-05-03 14:02:21 +01:00
parent 8a88edc676
commit abb54bf0b8
7 changed files with 51 additions and 4 deletions

View File

@ -21,6 +21,7 @@ typedef LCC::Traits::Point Point_3;
template<typename Graph>
void concept_check_polyhedron() {
boost::function_requires< boost::GraphConcept<LCC> >();
boost::function_requires< boost::AdjacencyGraphConcept<LCC> >();
boost::function_requires< boost::VertexListGraphConcept<LCC> >();
boost::function_requires< boost::EdgeListGraphConcept<LCC> >();
boost::function_requires< boost::IncidenceGraphConcept<LCC> >();

View File

@ -15,6 +15,7 @@ typedef Kernel::Point_3 Point_3;
template<typename Graph>
void concept_check_polyhedron() {
boost::function_requires< boost::GraphConcept<Polyhedron> >();
boost::function_requires< boost::AdjacencyGraphConcept<Polyhedron> >();
boost::function_requires< boost::VertexListGraphConcept<Polyhedron> >();
boost::function_requires< boost::EdgeListGraphConcept<Polyhedron> >();
boost::function_requires< boost::IncidenceGraphConcept<Polyhedron> >();

View File

@ -15,6 +15,7 @@ typedef Traits::face_descriptor face_descriptor;
void concept_check_surface_mesh()
{
boost::function_requires< boost::GraphConcept<Surface_mesh> >();
boost::function_requires< boost::AdjacencyGraphConcept<Surface_mesh> >();
boost::function_requires< boost::VertexListGraphConcept<Surface_mesh> >();
boost::function_requires< boost::EdgeListGraphConcept<Surface_mesh> >();
boost::function_requires< boost::IncidenceGraphConcept<Surface_mesh> >();

View File

@ -20,6 +20,7 @@
#include <boost/config.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <CGAL/boost/iterator/transform_iterator.hpp>
#include <boost/graph/adjacency_iterator.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/graph/graph_traits.hpp>
@ -155,7 +156,8 @@ struct HDS_graph_traits
private:
struct HDS_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
public virtual boost::vertex_list_graph_tag,
public virtual boost::edge_list_graph_tag
public virtual boost::edge_list_graph_tag,
public virtual boost::adjacency_graph_tag
{};
public:
@ -179,6 +181,8 @@ public:
typedef In_edge_iterator<HDS> in_edge_iterator;
typedef typename boost::adjacency_iterator_generator<HDS, vertex_descriptor, out_edge_iterator>::type adjacency_iterator;
typedef boost::undirected_tag directed_category;
typedef boost::disallow_parallel_edge_tag edge_parallel_category;
typedef HDS_graph_traversal_category traversal_category;

View File

@ -172,6 +172,16 @@ out_edges( typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::verte
return make_range(Iter(halfedge(u,p),p), Iter(halfedge(u,p),p,1));
}
template<class T, class I, class A>
inline Iterator_range<typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::adjacency_iterator>
adjacent_vertices( typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::vertex_descriptor u
, const HalfedgeDS_default<T,I,A>& p)
{
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::out_edge_iterator OutEdgeIter;
typedef typename boost::graph_traits< HalfedgeDS_default<T,I,A> const>::adjacency_iterator Iter;
return make_range(Iter(OutEdgeIter(halfedge(u,p),p),&p), Iter(OutEdgeIter(halfedge(u,p),p,1), &p));
}
//
// MutableHalfedgeGraph
//

View File

@ -18,6 +18,7 @@
#include <boost/config.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/properties.hpp>
#include <boost/graph/adjacency_iterator.hpp>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/properties_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/graph_traits_HalfedgeDS.h>
@ -178,7 +179,8 @@ struct CMap_Base_graph_traits
public :
struct CMap_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
public virtual boost::vertex_list_graph_tag,
public virtual boost::edge_list_graph_tag
public virtual boost::edge_list_graph_tag,
public virtual boost::adjacency_graph_tag
{};
// Expose types required by the boost::Graph concept.
@ -206,6 +208,8 @@ public :
typedef CGAL::In_edge_iterator<CMap> in_edge_iterator;
typedef CGAL::Out_edge_iterator<CMap> out_edge_iterator;
typedef typename boost::adjacency_iterator_generator<CMap, vertex_descriptor, out_edge_iterator>::type adjacency_iterator;
// nulls
static vertex_descriptor null_vertex() { return nullptr; }
static face_descriptor null_face() { return nullptr; }
@ -391,6 +395,16 @@ out_edges(typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor v,
return make_range(Iter(halfedge(v, lcc), lcc), Iter(halfedge(v, lcc), lcc, 1));
}
CGAL_LCC_TEMPLATE_ARGS
CGAL::Iterator_range<typename boost::graph_traits<CGAL_LCC_TYPE>::adjacency_iterator>
adjacent_vertices(typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor v,
const CGAL_LCC_TYPE& lcc)
{
typedef typename boost::graph_traits<CGAL_LCC_TYPE>::out_edge_iterator OutEdgeIter;
typedef typename boost::graph_traits<CGAL_LCC_TYPE>::adjacency_iterator Iter;
return make_range(Iter(OutEdgeIter(halfedge(v, lcc), lcc), &lcc), Iter(OutEdgeIter(halfedge(v, lcc), lcc, 1), &lcc));
}
//
// 2) HalfedgeGraph
//

View File

@ -30,6 +30,7 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/assertions.h>
#include <boost/graph/adjacency_iterator.hpp>
namespace boost {
@ -41,7 +42,8 @@ private:
struct SM_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
public virtual boost::vertex_list_graph_tag,
public virtual boost::edge_list_graph_tag
public virtual boost::edge_list_graph_tag,
public virtual boost::adjacency_graph_tag
{};
public:
@ -77,14 +79,18 @@ public:
typedef typename SM::size_type degree_size_type;
typedef CGAL::In_edge_iterator<SM> in_edge_iterator;
typedef CGAL::Out_edge_iterator<SM> out_edge_iterator;
typedef typename boost::adjacency_iterator_generator<SM, vertex_descriptor, out_edge_iterator>::type adjacency_iterator;
// nulls
static vertex_descriptor null_vertex() { return vertex_descriptor(); }
static face_descriptor null_face() { return face_descriptor(); }
static halfedge_descriptor null_halfedge() { return halfedge_descriptor(); }
static halfedge_descriptor null_halfedge() { return halfedge_descriptor(); }
};
template<typename P>
@ -217,6 +223,16 @@ out_edges(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descripto
return make_range(Iter(halfedge(v,sm),sm), Iter(halfedge(v,sm),sm,1));
}
template <typename P>
Iterator_range<typename boost::graph_traits<CGAL::Surface_mesh<P> >::adjacency_iterator>
adjacent_vertices(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
const CGAL::Surface_mesh<P>& sm)
{
typedef typename boost::graph_traits<CGAL::Surface_mesh<P> >::out_edge_iterator OutEdgeIter;
typedef typename boost::graph_traits<CGAL::Surface_mesh<P> >::adjacency_iterator Iter;
return make_range(Iter(OutEdgeIter(halfedge(v,sm),sm), &sm),
Iter(OutEdgeIter(halfedge(v,sm),sm,1), &sm));
}
template<typename P>
std::pair<typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor,