diff --git a/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h b/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h index 1c8e90bb683..b6e764277ef 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h @@ -137,7 +137,9 @@ struct HDS_edge { friend std::size_t hash_value(const HDS_edge& i) { - return hash_value(i.halfedge()); + if (i.halfedge()==Halfedge_handle()) return 0; + return hash_value(i.halfedge()opposite()? + i.halfedge():i.halfedge()->opposite()); } private: @@ -153,6 +155,7 @@ namespace handle{ operator()(const HDS_edge& edge) { Halfedge_handle he = edge.halfedge(); + if (he==Halfedge_handle()) return 0; if ( he < he->opposite() ) return Hash_functor()(he); return Hash_functor()(he->opposite()); @@ -240,7 +243,9 @@ namespace std { std::size_t operator()(const CGAL::internal::HDS_edge& e) const { std::hash fct; - return fct(e.halfedge()); + if (e.halfedge()==H()) return 0; + return fct(e.halfedge()opposite()? + e.halfedge():e.halfedge()->opposite()); } }; diff --git a/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h b/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h index 6d5d426bbf0..8cea712b933 100644 --- a/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h +++ b/BGL/include/CGAL/boost/graph/graph_traits_Triangulation_2.h @@ -74,7 +74,9 @@ public: friend std::size_t hash_value(const Edge& e) { - return hash_value(e.first); + if (e.first==Face_handle()) return 0; + return hash_value(e.firstneighbor(e.second)? + e.first:e.first->neighbor(e.second)); } bool operator==(const Edge& other) const @@ -846,7 +848,6 @@ namespace std { struct hash > { std::size_t operator()(const CGAL::detail::Edge& e) const { - std::cerr << "Triangulation_2::Edge HashFct" << std::endl; return hash_value(e); } }; @@ -855,7 +856,6 @@ namespace std { struct hash > { std::size_t operator()(const CGAL::detail::T2_halfedge_descriptor& e) const { - std::cerr << "Triangulation_2::halfedge_descriptor HashFct" << std::endl; return hash_value(e); } }; diff --git a/Hash_map/test/Hash_map/Hash.cpp b/Hash_map/test/Hash_map/Hash.cpp index 36e99a99eeb..3d6b15e91db 100644 --- a/Hash_map/test/Hash_map/Hash.cpp +++ b/Hash_map/test/Hash_map/Hash.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include typedef CGAL::Simple_cartesian Kernel; @@ -21,10 +23,10 @@ typedef CGAL::Arrangement_2 Arrangement_2; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::Surface_mesh Surface_mesh; typedef CGAL::Triangulation_2 Triangulation_2; -#ifdef CGAL_LINKED_WITH_TBB -typedef CGAL::Triangulation_data_structure_3< - CGAL::Triangulation_vertex_base_3, - CGAL::Triangulation_cell_base_3, +#ifdef CGAL_LINKED_WITH_TBB +typedef CGAL::Triangulation_data_structure_3< + CGAL::Triangulation_vertex_base_3, + CGAL::Triangulation_cell_base_3, CGAL::Parallel_tag> Tds; typedef CGAL::Delaunay_triangulation_3 Triangulation_3; #endif @@ -80,6 +82,29 @@ fct3(const P& ) U[vd] = 12; } +template +void test_edge_hash_and_null(const P& p) +{ + typedef boost::graph_traits

GT; + typedef typename GT::halfedge_descriptor halfedge_descriptor; + typedef typename GT::vertex_descriptor vertex_descriptor; + typedef typename GT::face_descriptor face_descriptor; + + BOOST_FOREACH(halfedge_descriptor h, halfedges(p)) + { + assert( + hash_value( edge(h,p) ) == + hash_value( edge(opposite(h,p),p) ) ); + } + face_descriptor f1=GT::null_face(), f2=GT::null_face(); + vertex_descriptor v1=GT::null_vertex(), v2=GT::null_vertex(); + halfedge_descriptor h1=GT::null_halfedge(), h2=GT::null_halfedge(); + + assert(hash_value(f1)==hash_value(f2)); + assert(hash_value(v1)==hash_value(v2)); + assert(hash_value(h1)==hash_value(h2)); +} + template void fct4(const P& p) @@ -88,6 +113,7 @@ fct4(const P& p) fct::halfedge_descriptor>(p); fct::edge_descriptor>(p); fct::face_descriptor>(p); + test_edge_hash_and_null(p); } int main() @@ -96,17 +122,24 @@ int main() fct::vertex_descriptor>(A); fct::edge_descriptor>(A); + Kernel::Point_3 p3; Polyhedron P; + CGAL::make_triangle(p3,p3,p3,P); fct4(P); Surface_mesh S; + CGAL::make_triangle(p3,p3,p3,S); fct4(S); Triangulation_2 T; + T.insert(Kernel::Point_2(0,0)); + T.insert(Kernel::Point_2(0,1)); + T.insert(Kernel::Point_2(1,0)); + T.insert(Kernel::Point_2(1,1)); fct4(T); fct2(); - + #ifdef CGAL_LINKED_WITH_TBB Triangulation_3 T3; fct3(T3);