mirror of https://github.com/CGAL/cgal
commit
fc44ee3051
|
|
@ -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()<i.halfedge()->opposite()?
|
||||
i.halfedge():i.halfedge()->opposite());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -153,6 +155,7 @@ namespace handle{
|
|||
operator()(const HDS_edge<Halfedge_handle>& edge)
|
||||
{
|
||||
Halfedge_handle he = edge.halfedge();
|
||||
if (he==Halfedge_handle()) return 0;
|
||||
if ( he < he->opposite() )
|
||||
return Hash_functor<Halfedge_handle>()(he);
|
||||
return Hash_functor<Halfedge_handle>()(he->opposite());
|
||||
|
|
@ -240,7 +243,9 @@ namespace std {
|
|||
std::size_t operator()(const CGAL::internal::HDS_edge<H>& e) const
|
||||
{
|
||||
std::hash<H> fct;
|
||||
return fct(e.halfedge());
|
||||
if (e.halfedge()==H()) return 0;
|
||||
return fct(e.halfedge()<e.halfedge()->opposite()?
|
||||
e.halfedge():e.halfedge()->opposite());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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.first<e.first->neighbor(e.second)?
|
||||
e.first:e.first->neighbor(e.second));
|
||||
}
|
||||
|
||||
bool operator==(const Edge& other) const
|
||||
|
|
@ -846,7 +848,6 @@ namespace std {
|
|||
struct hash<CGAL::detail::Edge<T,EdgeBase> > {
|
||||
std::size_t operator()(const CGAL::detail::Edge<T,EdgeBase>& e) const
|
||||
{
|
||||
std::cerr << "Triangulation_2::Edge HashFct" << std::endl;
|
||||
return hash_value(e);
|
||||
}
|
||||
};
|
||||
|
|
@ -855,7 +856,6 @@ namespace std {
|
|||
struct hash<CGAL::detail::T2_halfedge_descriptor<Tr> > {
|
||||
std::size_t operator()(const CGAL::detail::T2_halfedge_descriptor<Tr>& e) const
|
||||
{
|
||||
std::cerr << "Triangulation_2::halfedge_descriptor HashFct" << std::endl;
|
||||
return hash_value(e);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#include <CGAL/boost/graph/graph_traits_Triangulation_2.h>
|
||||
#include <map>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
|
|
@ -80,6 +82,29 @@ fct3(const P& )
|
|||
U[vd] = 12;
|
||||
}
|
||||
|
||||
template <class P>
|
||||
void test_edge_hash_and_null(const P& p)
|
||||
{
|
||||
typedef boost::graph_traits<P> 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 <typename P>
|
||||
void
|
||||
fct4(const P& p)
|
||||
|
|
@ -88,6 +113,7 @@ fct4(const P& p)
|
|||
fct<P, typename boost::graph_traits<P>::halfedge_descriptor>(p);
|
||||
fct<P, typename boost::graph_traits<P>::edge_descriptor>(p);
|
||||
fct<P, typename boost::graph_traits<P>::face_descriptor>(p);
|
||||
test_edge_hash_and_null(p);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
|
@ -96,13 +122,20 @@ int main()
|
|||
fct<Arrangement_2, boost::graph_traits<Arrangement_2>::vertex_descriptor>(A);
|
||||
fct<Arrangement_2, boost::graph_traits<Arrangement_2>::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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue