Volume Cartographer 2.27.0
HashFunctions.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6
7#include <opencv2/core.hpp>
8
9namespace volcart
10{
11
20template <class Vector>
21struct Vec3Hash {
22 std::size_t operator()(const Vector& v) const
23 {
24 auto max = std::max({v[0], v[1], v[2]});
25 std::size_t hash = (max * max * max) + (2 * max * v[2]) + v[2];
26 if (max == v[2]) {
27 auto val = std::max({v[0], v[1]});
28 hash +=
29 static_cast<std::size_t>(val) * static_cast<std::size_t>(val);
30 }
31 if (v[1] >= v[0]) {
32 hash += v[0] + v[1];
33 } else {
34 hash += v[1];
35 }
36 return hash;
37 }
38};
39
42
43} // namespace volcart
Volume Cartographer library