diff --git a/BGL/examples/BGL_polyhedron_3/polyhedron_2_OpenMesh.cpp b/BGL/examples/BGL_polyhedron_3/polyhedron_2_OpenMesh.cpp index fceb0523da3..6282060f28c 100644 --- a/BGL/examples/BGL_polyhedron_3/polyhedron_2_OpenMesh.cpp +++ b/BGL/examples/BGL_polyhedron_3/polyhedron_2_OpenMesh.cpp @@ -39,8 +39,24 @@ typedef boost::graph_traits::vertex_descriptor tm_vertex_descriptor; typedef boost::graph_traits::halfedge_descriptor sm_halfedge_descriptor; typedef boost::graph_traits::halfedge_descriptor tm_halfedge_descriptor; -boost::unordered_map v2v; -boost::unordered_map h2h; +namespace OpenMesh { + +inline std::size_t hash_value(const VertexHandle& i) + { + return i.idx(); + } + +inline std::size_t hash_value(const HalfedgeHandle& i) + { + return i.idx(); + } + +inline std::size_t hash_value(const FaceHandle& i) + { + return i.idx(); + } + +} int main(int, char* argv[]) { @@ -49,9 +65,23 @@ int main(int, char* argv[]) std::ifstream in(argv[1]); in >> S; - convert_surface_mesh(S,T,v2v,h2h); + { + boost::unordered_map v2v; + boost::unordered_map h2h; + + convert_surface_mesh(S,T,v2v,h2h); + OpenMesh::IO::write_mesh(T, "om.off"); + } - OpenMesh::IO::write_mesh(T, "om.off"); + { + boost::unordered_map v2v; + boost::unordered_map h2h; + + convert_surface_mesh(T,S,v2v,h2h); + std::ofstream out("reverse.off"); + out << S << std::endl; + } + return 0; } diff --git a/BGL/include/CGAL/boost/graph/convert_surface_mesh.h b/BGL/include/CGAL/boost/graph/convert_surface_mesh.h index 55cf23dd01c..b074cca9821 100644 --- a/BGL/include/CGAL/boost/graph/convert_surface_mesh.h +++ b/BGL/include/CGAL/boost/graph/convert_surface_mesh.h @@ -22,7 +22,7 @@ namespace CGAL { typedef boost::graph_traits::halfedge_descriptor tm_halfedge_descriptor; typedef typename boost::property_map::const_type sm_PMap; - typedef typename boost::property_map::const_type tm_PMap; + typedef typename boost::property_map::type tm_PMap; sm_PMap sm_pmap = get(vertex_point, sm); tm_PMap tm_pmap = get(vertex_point, tm); diff --git a/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h b/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h index 6899216356c..220001a37b1 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h @@ -355,6 +355,9 @@ typename boost::graph_traits >::halfedge_desc halfedge(typename boost::graph_traits >::vertex_descriptor v, const OpenMesh::PolyMesh_ArrayKernelT& sm) { + if(sm.halfedge_handle(v) == boost::graph_traits >::null_halfedge()){ + return boost::graph_traits >::null_halfedge(); + } // prev because OpenMesh stores out-going halfedges // return sm.prev_halfedge_handle(sm.halfedge_handle(v)); return sm.opposite_halfedge_handle(sm.halfedge_handle(v));