Add hash_value and specialization of hash for OpenMesh

This commit is contained in:
Andreas Fabri 2016-06-06 19:10:58 +02:00
parent 2a47ae5ef4
commit d84be563f8
5 changed files with 71 additions and 10 deletions

View File

@ -12,13 +12,6 @@
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
namespace OpenMesh { // auxiliary functions so OpenMesh Handles can be hashed
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(); }
}
#endif
#include <CGAL/boost/graph/copy_face_graph.h>

View File

@ -37,6 +37,8 @@
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <CGAL/hash_openmesh.h>
// http://openmesh.org/Documentation/OpenMesh-Doc-Latest/classOpenMesh_1_1Concepts_1_1KernelT.html
#if defined(BOOST_MSVC)
@ -672,8 +674,6 @@ void clear(OpenMesh::PolyMesh_ArrayKernelT<K>& sm)
}
}
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/boost/graph/backward_compatibility_functions.h>

View File

@ -35,6 +35,8 @@
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <CGAL/hash_openmesh.h>
// http://openmesh.org/Documentation/OpenMesh-Doc-Latest/classOpenMesh_1_1Concepts_1_1KernelT.html
#if defined(BOOST_MSVC)

View File

@ -7,7 +7,9 @@ A type `Key` is a model of the concept `Hashable` if the
specializations `boost::hash<Key>` and `std::hash<Key>` exist.
\cgalHasModel All handles and indices of \cgal data structures.
\cgalHasModel All handles of OpenMesh, by including the specializations
of the `graph_traits` header files provided by \cgal.
They can be disables by defining the macro `CGAL_DISABLE_HASH_OPENMESH`.
\sa `CGAL::Unique_hash_map<Key,Mapped,Hash>`
\sa <A HREF="http://www.cplusplus.com/reference/unordered_set/unordered_set/">`std::unordered_set`</a>

View File

@ -0,0 +1,64 @@
// Copyright (c) 2016 GeometryFactory (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri
#ifndef CGAL_HASH_OPENMESH_H
#define CGAL_HASH_OPENMESH_H
#ifndef CGAL_DISABLE_HASH_OPENMESH
#include <functional>
#include <OpenMesh/Core/Mesh/Handles.hh>
namespace OpenMesh {
inline std::size_t hash_value(const BaseHandle& h) { return h.idx(); }
} // namespace OpenMesh
namespace std {
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable:4099) // For VC10 it is class hash
#endif
#ifndef CGAL_CFG_NO_STD_HASH
template <>
struct hash<OpenMesh::BaseHandle >
: public std::unary_function<OpenMesh::BaseHandle, std::size_t>
{
std::size_t operator()(const OpenMesh::BaseHandle& h) const
{
return h.idx();
}
};
#endif // CGAL_CFG_NO_STD_HASH
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
} // namespace std
#endif // CGAL_DISABLE_HASH_OPENMESH
#endif // CGAL_HASH_OPENMESH_H