Merge branch 'hash_functions' into 'master'
Hash functions See merge request !75
This commit is contained in:
@@ -19,6 +19,12 @@
|
|||||||
<li>Fixed mingw compilataion error</li>
|
<li>Fixed mingw compilataion error</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<b>General</b>
|
||||||
|
<ul>
|
||||||
|
<li>Added size_t hash_value functions to support boost unordered_set and map</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr valign=top><td><b>6.1</b> (2016/05/31)</td><td>
|
<tr valign=top><td><b>6.1</b> (2016/05/31)</td><td>
|
||||||
|
|||||||
@@ -106,6 +106,8 @@ private:
|
|||||||
int idx_;
|
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
|
} // 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
|
#endif // OPENMESH_HANDLES_HH
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|||||||
@@ -608,7 +608,6 @@ const LHS mesh_cast(const PolyMeshT<KERNEL> *rhs) {
|
|||||||
return MeshCast<LHS, const PolyMeshT<KERNEL>*>::cast(rhs);
|
return MeshCast<LHS, const PolyMeshT<KERNEL>*>::cast(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
} // namespace OpenMesh
|
} // namespace OpenMesh
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|||||||
@@ -101,6 +101,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
|
||||||
|
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
|
||||||
|
#define OM_HAS_HASH
|
||||||
|
#endif
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
#endif // OPENMESH_CONFIG_H defined
|
#endif // OPENMESH_CONFIG_H defined
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user