Commit 6f862cad authored by Jan Möbius's avatar Jan Möbius

Merge branch 'hash_functions' into 'master'

Hash functions



See merge request !75
parents c2d7bf98 58b9e408
Pipeline #2296 passed with stage
in 69 minutes and 10 seconds
......@@ -19,6 +19,12 @@
<li>Fixed mingw compilataion error</li>
</ul>
<b>General</b>
<ul>
<li>Added size_t hash_value functions to support boost unordered_set and map</li>
</ul>
</tr>
<tr valign=top><td><b>6.1</b> (2016/05/31)</td><td>
......
......@@ -106,6 +106,8 @@ private:
int idx_;
};
// this is used by boost::unordered_set/map
inline size_t hash_value(const BaseHandle& h) { return h.idx(); }
//-----------------------------------------------------------------------------
......@@ -150,5 +152,79 @@ struct FaceHandle : public BaseHandle
//=============================================================================
} // namespace OpenMesh
//=============================================================================
#ifdef OM_HAS_HASH
#include <functional>
namespace std {
#if defined(_MSVC_VER)
# pragma warning(push)
# pragma warning(disable:4099) // For VC++ it is class hash
#endif
template <>
class hash<OpenMesh::BaseHandle >
: public std::unary_function<OpenMesh::BaseHandle, std::size_t>
{
std::size_t operator()(const OpenMesh::BaseHandle& h) const
{
return h.idx();
}
};
template <>
struct hash<OpenMesh::VertexHandle >
: public std::unary_function<OpenMesh::VertexHandle, std::size_t>
{
std::size_t operator()(const OpenMesh::VertexHandle& h) const
{
return h.idx();
}
};
template <>
struct hash<OpenMesh::HalfedgeHandle >
: public std::unary_function<OpenMesh::HalfedgeHandle, std::size_t>
{
std::size_t operator()(const OpenMesh::HalfedgeHandle& h) const
{
return h.idx();
}
};
template <>
struct hash<OpenMesh::EdgeHandle >
: public std::unary_function<OpenMesh::EdgeHandle, std::size_t>
{
std::size_t operator()(const OpenMesh::EdgeHandle& h) const
{
return h.idx();
}
};
template <>
struct hash<OpenMesh::FaceHandle >
: public std::unary_function<OpenMesh::FaceHandle, std::size_t>
{
std::size_t operator()(const OpenMesh::FaceHandle& h) const
{
return h.idx();
}
};
#if defined(_MSVC_VER)
# pragma warning(pop)
#endif
}
#endif // OM_HAS_HASH
#endif // OPENMESH_HANDLES_HH
//=============================================================================
......@@ -608,7 +608,6 @@ const LHS mesh_cast(const PolyMeshT<KERNEL> *rhs) {
return MeshCast<LHS, const PolyMeshT<KERNEL>*>::cast(rhs);
}
//=============================================================================
} // namespace OpenMesh
//=============================================================================
......
......@@ -101,6 +101,11 @@
#endif
typedef unsigned int uint;
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#define OM_HAS_HASH
#endif
//=============================================================================
#endif // OPENMESH_CONFIG_H defined
//=============================================================================
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment