mirror of https://github.com/CGAL/cgal
Add property map for Dual<>
This commit is contained in:
parent
b538707892
commit
a41f54cc54
|
|
@ -40,6 +40,10 @@ int main(int, char* argv[])
|
||||||
ccmap = sm.add_property_map<face_descriptor,int>("f:CC").first;
|
ccmap = sm.add_property_map<face_descriptor,int>("f:CC").first;
|
||||||
int num = connected_components(dsm, ccmap);
|
int num = connected_components(dsm, ccmap);
|
||||||
|
|
||||||
|
BOOST_FOREACH(face_descriptor f , faces(sm)){
|
||||||
|
std::cout << f << "in connected component " << ccmap[f] << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
Mesh::Property_map<vertex_descriptor,vertex_descriptor> predecessor;
|
Mesh::Property_map<vertex_descriptor,vertex_descriptor> predecessor;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef CGAL_BGL_DUAL_H
|
#ifndef CGAL_BGL_DUAL_H
|
||||||
#define CGAL_BGL_DUAL_H
|
#define CGAL_BGL_DUAL_H
|
||||||
|
|
||||||
|
#include <CGAL/boost/graph/properties.h>
|
||||||
|
#include <boost/range/distance.hpp>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
template <typename Primal_>
|
template <typename Primal_>
|
||||||
|
|
@ -30,7 +33,7 @@ template <typename Primal>
|
||||||
class graph_traits<CGAL::Dual<Primal> >
|
class graph_traits<CGAL::Dual<Primal> >
|
||||||
{
|
{
|
||||||
typedef boost::graph_traits<Primal> GTP;
|
typedef boost::graph_traits<Primal> GTP;
|
||||||
struct SM_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
|
struct Dual_traversal_category : public virtual boost::bidirectional_graph_tag,
|
||||||
public virtual boost::vertex_list_graph_tag,
|
public virtual boost::vertex_list_graph_tag,
|
||||||
public virtual boost::edge_list_graph_tag
|
public virtual boost::edge_list_graph_tag
|
||||||
{};
|
{};
|
||||||
|
|
@ -42,7 +45,7 @@ public:
|
||||||
typedef typename GTP::edge_descriptor edge_descriptor;
|
typedef typename GTP::edge_descriptor edge_descriptor;
|
||||||
typedef typename GTP::directed_category directed_category;
|
typedef typename GTP::directed_category directed_category;
|
||||||
typedef boost::allow_parallel_edge_tag edge_parallel_category;
|
typedef boost::allow_parallel_edge_tag edge_parallel_category;
|
||||||
typedef SM_graph_traversal_category traversal_category;
|
typedef Dual_traversal_category traversal_category;
|
||||||
|
|
||||||
typedef typename GTP::faces_size_type vertices_size_type;
|
typedef typename GTP::faces_size_type vertices_size_type;
|
||||||
typedef typename GTP::vertices_size_type faces_size_type;
|
typedef typename GTP::vertices_size_type faces_size_type;
|
||||||
|
|
@ -55,8 +58,8 @@ public:
|
||||||
typedef typename GTP::halfedge_iterator halfedge_iterator;
|
typedef typename GTP::halfedge_iterator halfedge_iterator;
|
||||||
typedef typename GTP::edge_iterator edge_iterator;
|
typedef typename GTP::edge_iterator edge_iterator;
|
||||||
|
|
||||||
typedef CGAL::In_edge_iterator<CGAL::Dual<Primal> > in_edge_iterator;
|
typedef CGAL::Halfedge_around_face_iterator<Primal> in_edge_iterator;
|
||||||
typedef CGAL::Out_edge_iterator<CGAL::Dual<Primal> > out_edge_iterator;
|
typedef CGAL::Opposite_halfedge_around_face_iterator<Primal> out_edge_iterator;
|
||||||
|
|
||||||
static vertex_descriptor null_vertex() { return vertex_descriptor(); }
|
static vertex_descriptor null_vertex() { return vertex_descriptor(); }
|
||||||
static face_descriptor null_face() { return face_descriptor(); }
|
static face_descriptor null_face() { return face_descriptor(); }
|
||||||
|
|
@ -66,12 +69,28 @@ public:
|
||||||
template<typename P>
|
template<typename P>
|
||||||
struct graph_traits< const CGAL::Dual<P> >
|
struct graph_traits< const CGAL::Dual<P> >
|
||||||
: public graph_traits< CGAL::Dual<P> >
|
: public graph_traits< CGAL::Dual<P> >
|
||||||
{ };
|
{};
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
struct property_map<CGAL::Dual<P>, boost::vertex_index_t>
|
||||||
|
{
|
||||||
|
typedef typename property_map<P, CGAL::face_index_t>::type type;
|
||||||
|
typedef typename property_map<P, CGAL::face_index_t>::const_type const_type;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
typename boost::property_map<P, boost::face_index_t>::type
|
||||||
|
get(boost::vertex_index_t, const Dual<P>& dual)
|
||||||
|
{
|
||||||
|
return get(CGAL::face_index, dual.primal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
typename boost::graph_traits<CGAL::Dual<P> >::vertices_size_type
|
typename boost::graph_traits<CGAL::Dual<P> >::vertices_size_type
|
||||||
num_vertices(const CGAL::Dual<P>& dual)
|
num_vertices(const CGAL::Dual<P>& dual)
|
||||||
|
|
@ -188,6 +207,41 @@ prev(typename boost::graph_traits<Dual<P> >::halfedge_descriptor h,
|
||||||
return next(opposite(h,primal),primal);
|
return next(opposite(h,primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
Iterator_range<typename boost::graph_traits<Dual<P> >::out_edge_iterator>
|
||||||
|
out_edges(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
||||||
|
const Dual<P>& dual)
|
||||||
|
{
|
||||||
|
typename const Dual<P>::Primal& primal = dual.primal();
|
||||||
|
return opposite_halfedges_around_face(halfedge(v,primal),primal);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
Iterator_range<typename boost::graph_traits<Dual<P> >::out_edge_iterator>
|
||||||
|
in_edges(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
||||||
|
const Dual<P>& dual)
|
||||||
|
{
|
||||||
|
typename const Dual<P>::Primal& primal = dual.primal();
|
||||||
|
return halfedges_around_face(halfedge(v,primal),primal);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
typename boost::graph_traits<Dual<P> >::degree_size_type
|
||||||
|
out_degree(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
||||||
|
const Dual<P>& dual)
|
||||||
|
{
|
||||||
|
typename const Dual<P>::Primal& primal = dual.primal();
|
||||||
|
return boost::distance(halfedges_around_face(halfedge(v,primal),primal));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename P>
|
||||||
|
typename boost::graph_traits<Dual<P> >::degree_size_type
|
||||||
|
in_degree(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
||||||
|
const Dual<P>& dual)
|
||||||
|
{
|
||||||
|
return out_degree(v,dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1050,6 +1050,44 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename Graph>
|
||||||
|
class Opposite_halfedge_around_face_iterator
|
||||||
|
#ifndef DOXYGEN_RUNNING
|
||||||
|
: public boost::iterator_adaptor<
|
||||||
|
Opposite_halfedge_around_face_iterator<Graph> // Derived
|
||||||
|
, Halfedge_around_face_iterator<Graph> // Base
|
||||||
|
, typename boost::graph_traits<Graph>::halfedge_descriptor // Value
|
||||||
|
, std::bidirectional_iterator_tag // CategoryOrTraversal
|
||||||
|
, typename boost::graph_traits<Graph>::halfedge_descriptor // Reference
|
||||||
|
>
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
|
||||||
|
internal::OppositeHalfedge<Graph> fct;
|
||||||
|
public:
|
||||||
|
|
||||||
|
Opposite_halfedge_around_face_iterator()
|
||||||
|
{}
|
||||||
|
|
||||||
|
Opposite_halfedge_around_face_iterator(halfedge_descriptor h, const Graph& g, int n = 0)
|
||||||
|
: Opposite_halfedge_around_face_iterator::iterator_adaptor_(Halfedge_around_face_iterator<Graph>(h,g,(h==halfedge_descriptor())?1:n)), fct(g)
|
||||||
|
{}
|
||||||
|
private:
|
||||||
|
friend class boost::iterator_core_access;
|
||||||
|
typename boost::graph_traits<Graph>::halfedge_descriptor dereference() const { return fct(*this->base_reference()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Graph>
|
||||||
|
Iterator_range<Opposite_halfedge_around_face_iterator<Graph> >
|
||||||
|
opposite_halfedges_around_face(typename boost::graph_traits<Graph>::halfedge_descriptor h, const Graph& g)
|
||||||
|
{
|
||||||
|
typedef Opposite_halfedge_around_face_iterator<Graph> I;
|
||||||
|
return make_range(I(h,g), I(h,g,1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup PkgBGLIterators
|
* \ingroup PkgBGLIterators
|
||||||
* A bidirectional circulator with value type `boost::graph_traits<Graph>::%vertex_descriptor` over all vertices adjacent to the same vertex.
|
* A bidirectional circulator with value type `boost::graph_traits<Graph>::%vertex_descriptor` over all vertices adjacent to the same vertex.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue