Wildmeshing Toolkit
Loading...
Searching...
No Matches
hash.cpp
Go to the documentation of this file.
1
#include "
hash.hpp
"
2
#include <
wmtk/Mesh.hpp
>
3
#include <
wmtk/attribute/MeshAttributeHandle.hpp
>
4
std::size_t
wmtk::hash<wmtk::attribute::AttributeHandle>::operator()
(
5
const
wmtk::attribute::AttributeHandle
& handle)
const
noexcept
6
{
7
return
handle.index;
8
// return std::hash<int64_t>{}(handle.index);
9
}
10
11
size_t
wmtk::hash<wmtk::attribute::MeshAttributeHandle>::operator()
(
12
const
wmtk::attribute::MeshAttributeHandle
& handle)
const
noexcept
13
{
14
std::vector<size_t> data;
15
data.emplace_back(handle_hash(handle));
16
data.emplace_back(mesh_hash(handle));
17
data.emplace_back(
size_t
(handle.held_type()));
18
const
size_t
r =
wmtk::utils::vector_hash
(data);
19
return
r;
20
}
21
size_t
wmtk::hash<wmtk::attribute::MeshAttributeHandle>::handle_hash
(
22
const
wmtk::attribute::MeshAttributeHandle
& handle)
const
noexcept
23
{
24
return
std::visit(
25
[&](
const
auto
& h)
noexcept
->
size_t
{
26
using
T = std::decay_t<
decltype
(h)>;
27
return
hash<T>
{}(h);
28
},
29
handle.m_handle);
30
}
31
size_t
wmtk::hash<wmtk::attribute::MeshAttributeHandle>::mesh_hash
(
32
const
wmtk::attribute::MeshAttributeHandle
& handle)
const
noexcept
33
{
34
if
(!handle.is_valid()) {
35
return
-1;
// TODO: this assumes the vector hash never returns a value of -1
36
}
37
// here we hash off of the absolute mesh id rather than the mesh itself to prevent cyclic
38
// hashing
39
return
wmtk::utils::vector_hash
(handle.mesh().absolute_multi_mesh_id());
40
}
Mesh.hpp
MeshAttributeHandle.hpp
wmtk::attribute::AttributeHandle
Internal handle representation used by MeshAttributes.
Definition
AttributeHandle.hpp:24
wmtk::attribute::MeshAttributeHandle
Definition
MeshAttributeHandle.hpp:28
wmtk::hash
Definition
hash.hpp:14
hash.hpp
wmtk::utils::vector_hash
std::size_t vector_hash(const std::vector< size_t > &data)
Definition
vector_hash.cpp:28
src
wmtk
attribute
internal
hash.cpp
Generated by
1.9.8