12 #include <boost/bimap.hpp>
13 #include <boost/bimap/unordered_set_of.hpp>
15 #include "TOL/Graph.h"
18 #include "utils/graph_typedefs.hpp"
23 struct TOL_Vertex_Hash
25 size_t operator()(
const TOL::Graph::Vertex& v)
const {
32 using VTranslateBoostTOL = boost::bimap< boost::bimaps::unordered_set_of<Vertex<Graph> >, boost::bimaps::unordered_set_of<TOL::Graph::Vertex, TOL_Vertex_Hash> >;
36 void convert(
const Graph& g, TOL::Graph& tg, VTranslateBoostTOL<Graph>* vtranslate = NULL)
38 typedef typename VTranslateBoostTOL<Graph>::value_type translate_pair;
40 VTranslateBoostTOL<Graph>* vtrans = vtranslate ? vtranslate :
new VTranslateBoostTOL<Graph>();
46 for(VertexIterRange<Graph> r = vertices(g); r.first != r.second; ++r.first)
47 vtrans->insert(translate_pair((Vertex<Graph>)*r.first, (TOL::Graph::Vertex)tg.new_vertex(index++)));
50 for(EdgeIterRange<Graph> e = edges(g); e.first != e.second; ++e.first)
51 tg.new_edge(vtrans->left.at(source(*e.first, g)), vtrans->left.at(target(*e.first, g)));
54 if(!vtranslate)
delete vtrans;