mirror of https://github.com/CGAL/cgal
Merge remote-tracking branch 'cgal/releases/CGAL-4.9-branch' into HEAD
This commit is contained in:
commit
6d3d570239
|
|
@ -104,8 +104,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::Halfedge_around_face_iterator<Primal> in_edge_iterator;
|
typedef CGAL::Edge_around_face_iterator<Primal> out_edge_iterator;
|
||||||
typedef CGAL::Opposite_edge_around_face_iterator<Primal> out_edge_iterator;
|
typedef CGAL::Opposite_edge_around_face_iterator<Primal> in_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(); }
|
||||||
|
|
@ -335,7 +335,7 @@ source(typename boost::graph_traits<Dual<P> >::halfedge_descriptor h,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return face(opposite(h,primal),primal);
|
return face(h,primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
|
|
@ -344,7 +344,7 @@ target(typename boost::graph_traits<Dual<P> >::halfedge_descriptor h,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return face(h,primal);
|
return face(opposite(h,primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -354,7 +354,7 @@ source(typename boost::graph_traits<Dual<P> >::edge_descriptor h,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return face(opposite(halfedge(h,primal),primal),primal);
|
return face(halfedge(h,primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
|
|
@ -363,7 +363,7 @@ target(typename boost::graph_traits<Dual<P> >::edge_descriptor h,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return face(halfedge(h,primal),primal);
|
return face(opposite(halfedge(h,primal),primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
|
|
@ -371,7 +371,8 @@ typename boost::graph_traits<Dual<P> >::halfedge_descriptor
|
||||||
halfedge(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
halfedge(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
return halfedge(v, dual.primal());
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
|
return opposite(halfedge(v, primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
|
|
@ -428,7 +429,7 @@ next(typename boost::graph_traits<Dual<P> >::halfedge_descriptor h,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return opposite(prev(h,primal),primal);
|
return prev(opposite(h,primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
|
|
@ -437,7 +438,7 @@ prev(typename boost::graph_traits<Dual<P> >::halfedge_descriptor h,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return next(opposite(h,primal),primal);
|
return opposite(next(h,primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
|
|
@ -446,16 +447,16 @@ out_edges(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return opposite_edges_around_face(halfedge(v,primal),primal);
|
return edges_around_face(halfedge(v,primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
Iterator_range<typename boost::graph_traits<Dual<P> >::out_edge_iterator>
|
Iterator_range<typename boost::graph_traits<Dual<P> >::in_edge_iterator>
|
||||||
in_edges(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
in_edges(typename boost::graph_traits<Dual<P> >::vertex_descriptor v,
|
||||||
const Dual<P>& dual)
|
const Dual<P>& dual)
|
||||||
{
|
{
|
||||||
const typename Dual<P>::Primal& primal = dual.primal();
|
const typename Dual<P>::Primal& primal = dual.primal();
|
||||||
return halfedges_around_face(halfedge(v,primal),primal);
|
return opposite_edges_around_face(halfedge(v,primal),primal);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename P>
|
template <typename P>
|
||||||
|
|
|
||||||
|
|
@ -1128,6 +1128,40 @@ opposite_edges_around_face(typename boost::graph_traits<Graph>::halfedge_descrip
|
||||||
return make_range(I(h,g), I(h,g,1));
|
return make_range(I(h,g), I(h,g,1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Graph>
|
||||||
|
class Edge_around_face_iterator
|
||||||
|
#ifndef DOXYGEN_RUNNING
|
||||||
|
: public boost::iterator_adaptor<
|
||||||
|
Edge_around_face_iterator<Graph> // Derived
|
||||||
|
, Halfedge_around_face_iterator<Graph> // Base
|
||||||
|
, typename boost::graph_traits<Graph>::edge_descriptor // Value
|
||||||
|
, std::bidirectional_iterator_tag // CategoryOrTraversal
|
||||||
|
, typename boost::graph_traits<Graph>::edge_descriptor // Reference
|
||||||
|
>
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
|
||||||
|
internal::Edge<Graph> fct;
|
||||||
|
public:
|
||||||
|
|
||||||
|
Edge_around_face_iterator()
|
||||||
|
{}
|
||||||
|
|
||||||
|
Edge_around_face_iterator(halfedge_descriptor h, const Graph& g, int n = 0)
|
||||||
|
: Edge_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>::edge_descriptor dereference() const { return fct(*this->base_reference()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Graph>
|
||||||
|
Iterator_range<Edge_around_face_iterator<Graph> >
|
||||||
|
edges_around_face(typename boost::graph_traits<Graph>::halfedge_descriptor h, const Graph& g)
|
||||||
|
{
|
||||||
|
typedef Edge_around_face_iterator<Graph> I;
|
||||||
|
return make_range(I(h,g), I(h,g,1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ create_single_source_cgal_program( "test_circulator.cpp" )
|
||||||
|
|
||||||
create_single_source_cgal_program( "test_Gwdwg.cpp" )
|
create_single_source_cgal_program( "test_Gwdwg.cpp" )
|
||||||
|
|
||||||
|
create_single_source_cgal_program( "test_bgl_dual.cpp" )
|
||||||
|
|
||||||
create_single_source_cgal_program( "graph_concept_Polyhedron_3.cpp" )
|
create_single_source_cgal_program( "graph_concept_Polyhedron_3.cpp" )
|
||||||
|
|
||||||
create_single_source_cgal_program( "graph_concept_Dual.cpp" )
|
create_single_source_cgal_program( "graph_concept_Dual.cpp" )
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
OFF
|
||||||
|
4 4 0
|
||||||
|
|
||||||
|
0 0 0
|
||||||
|
1 0 0
|
||||||
|
0 1 0
|
||||||
|
0 0 1
|
||||||
|
|
||||||
|
3 0 1 2
|
||||||
|
3 2 1 3
|
||||||
|
3 1 0 3
|
||||||
|
3 0 2 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
#include <CGAL/Surface_mesh.h>
|
||||||
|
#include <CGAL/boost/graph/Dual.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||||
|
typedef Kernel::Point_3 Point;
|
||||||
|
typedef CGAL::Surface_mesh<Point> Mesh;
|
||||||
|
typedef CGAL::Dual<Mesh> Dual;
|
||||||
|
typedef boost::graph_traits<Dual>::face_descriptor face_descriptor;
|
||||||
|
typedef boost::graph_traits<Dual>::vertex_descriptor vertex_descriptor;
|
||||||
|
typedef boost::graph_traits<Dual>::halfedge_descriptor halfedge_descriptor;
|
||||||
|
typedef boost::graph_traits<Dual>::out_edge_iterator out_edge_iterator;
|
||||||
|
typedef boost::graph_traits<Dual>::in_edge_iterator in_edge_iterator;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::ifstream in("data/primal.off");
|
||||||
|
Mesh primal;
|
||||||
|
in >> primal;
|
||||||
|
|
||||||
|
Dual dual(primal);
|
||||||
|
face_descriptor fd = *faces(dual).first;
|
||||||
|
halfedge_descriptor hd = halfedge(fd,dual);
|
||||||
|
assert(face(hd,dual) == fd);
|
||||||
|
halfedge_descriptor nhd = next(hd,dual);
|
||||||
|
assert(hd != nhd);
|
||||||
|
assert(hd == prev(nhd,dual));
|
||||||
|
assert(face(nhd,dual) == fd);
|
||||||
|
BOOST_FOREACH(halfedge_descriptor lhd, halfedges_around_face(hd,dual)){
|
||||||
|
assert(face(lhd,dual) == fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex_descriptor vd = *vertices(dual).first;
|
||||||
|
|
||||||
|
assert(target(halfedge(vd,dual),dual) == vd);
|
||||||
|
BOOST_FOREACH(halfedge_descriptor lhd, halfedges_around_target(halfedge(vd,dual),dual)){
|
||||||
|
assert(target(lhd,dual) == vd);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
out_edge_iterator b,e;
|
||||||
|
boost::tie(b,e) = out_edges(vd,dual);
|
||||||
|
std::cerr << vd << " " << source(*b,dual) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
in_edge_iterator b,e;
|
||||||
|
boost::tie(b,e) = in_edges(vd,dual);
|
||||||
|
std::cerr << vd << " " << source(*b,dual) << std::endl;
|
||||||
|
}
|
||||||
|
std::cerr << "done"<< std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue