Wildmeshing Toolkit
Loading...
Searching...
No Matches
hash.cpp
Go to the documentation of this file.
1#include "hash.hpp"
2#include <wmtk/Mesh.hpp>
5 const wmtk::attribute::AttributeHandle& handle) const noexcept
6{
7 return handle.index;
8 // return std::hash<int64_t>{}(handle.index);
9}
10
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}
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}
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}
Internal handle representation used by MeshAttributes.
std::size_t vector_hash(const std::vector< size_t > &data)