21 #ifndef EMODNET_QMGC_POLYLINES_FROM_FEATURED_EDGES_H    22 #define EMODNET_QMGC_POLYLINES_FROM_FEATURED_EDGES_H    24 #include <CGAL/boost/graph/properties.h>    25 #include <CGAL/boost/graph/properties_Surface_mesh.h>    26 #include <boost/graph/filtered_graph.hpp>    27 #include <CGAL/boost/graph/split_graph_into_polylines.h>    35 template<
typename Surface_mesh, 
typename EdgeIsSharpMap>
    37     typedef typename boost::graph_traits<Surface_mesh>::edge_descriptor edge_descriptor;
    41     IsSharpEdge(EdgeIsSharpMap eisMap) : m_eisMap(eisMap) {}
    43     bool operator()(
typename boost::graph_traits<Surface_mesh>::edge_descriptor e)
 const {
    44         return get(m_eisMap, e);
    47     EdgeIsSharpMap m_eisMap;
    55 template<
typename Graph,
    59     std::vector<Polyline>& m_polylines;
    63             : m_polylines(polylines), m_graph(graph)
    66     void start_new_polyline()
    68         m_polylines.push_back(Polyline());
    71     void add_node(
typename boost::graph_traits<Graph>::vertex_descriptor vd)
    73         if(m_polylines.back().empty()) {
    74             m_polylines.back().push_back(m_graph[vd]);
    78     void add_edge(
typename boost::graph_traits<Graph>::edge_descriptor ed)
    80         typename boost::graph_traits<Graph>::vertex_descriptor
    81                 s = source(ed, m_graph),
    82                 t = target(ed, m_graph);
    83         Polyline& polyline = m_polylines.back();
    84         CGAL_assertion(!polyline.empty());
    85         if(polyline.back() != m_graph[s]) {
    86             polyline.push_back(m_graph[s]);
    87         } 
else if(polyline.back() != m_graph[t]) {
    89             polyline.push_back(m_graph[t]);
    96         if(m_polylines.back().size() < 2)
    97             m_polylines.resize(m_polylines.size() - 1);
   110 template <
typename Surface_mesh, 
typename EdgeIsSharpMap, 
typename Polyline>
   111 void extract_polylines_from_sharp_edges(
const Surface_mesh& sm,
   112                                         const EdgeIsSharpMap& eisMap,
   113                                         std::vector<Polyline>& polylines)
   115     typedef typename boost::property_traits<typename boost::property_map<Surface_mesh,CGAL::vertex_point_t>::type>::value_type Point_3;
   116     typedef boost::adjacency_list<
   120             Point_3 > Featured_edges_copy_graph;
   124     IsSharpEdge isSharpEdge(eisMap);
   125     typedef boost::filtered_graph<Surface_mesh, IsSharpEdge > FilteredGraph;
   126     FilteredGraph filteredGraph(sm, isSharpEdge);
   129     Featured_edges_copy_graph feGraph;
   130     typedef typename boost::property_map<Surface_mesh, CGAL::vertex_point_t>::const_type Vpm;
   131     Vpm vpm = 
get(CGAL::vertex_point, sm);
   133     typedef std::map<Point_3, typename boost::graph_traits<Featured_edges_copy_graph>::vertex_descriptor> P2vmap;
   137     BOOST_FOREACH(
typename FilteredGraph::vertex_descriptor v, vertices(filteredGraph)){
   138                     typename Featured_edges_copy_graph::vertex_descriptor vc;
   139                     typename P2vmap::iterator it = p2vmap.find(
get(vpm,v));
   140                     if(it == p2vmap.end()) {
   141                         vc = add_vertex(feGraph);
   142                         feGraph[vc] = 
get(vpm, v);
   143                         p2vmap[
get(vpm,v)] = vc;
   148     BOOST_FOREACH(
typename FilteredGraph::edge_descriptor e, edges(filteredGraph)) {
   149                     typename Featured_edges_copy_graph::vertex_descriptor vs = p2vmap[
get(vpm, source(e, filteredGraph))];
   150                     typename Featured_edges_copy_graph::vertex_descriptor vt = p2vmap[
get(vpm, target(e, filteredGraph))];
   151                     CGAL_warning_msg(vs != vt, 
"ignore self loop");
   153                         const std::pair<typename Featured_edges_copy_graph::edge_descriptor, bool> pair = add_edge(vs, vt, feGraph);
   159     CGAL::split_graph_into_polylines(feGraph, visitor);
   163 #endif //EMODNET_QMGC_POLYLINES_FROM_FEATURED_EDGES_H Struct/functor that returns true if the edge is sharp (given a previously computed edgeIsSharp map) ...
Definition: extract_polylines_from_sharp_edges.h:36