From d7420df963943842a6deb251e8d3901d882b600b Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Tue, 5 Jan 2021 11:53:29 -0500 Subject: [PATCH 1/2] Create a dumb VoxelKey hash function for 32-bit systems. --- untwine/VoxelKey.hpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/untwine/VoxelKey.hpp b/untwine/VoxelKey.hpp index 4f53ad0..bd66752 100644 --- a/untwine/VoxelKey.hpp +++ b/untwine/VoxelKey.hpp @@ -102,15 +102,30 @@ namespace std { template<> struct hash { - std::size_t operator()(const untwine::VoxelKey& k) const noexcept + size_t operator()(const untwine::VoxelKey& k) const noexcept { - static_assert(sizeof(size_t) > sizeof(int), "wrong assumption that size_t is 64 bits"); - - // For this to work well we just assume that the values are no more than than 16 bits. - size_t t = size_t(k.x()) << 48; - t |= size_t(k.y()) << 32; - t |= size_t(k.z()) << 16; - t |= size_t(k.level()); + size_t t; + + static_assert(sizeof(size_t) == sizeof(uint64_t) || + sizeof(size_t) == sizeof(uint32_t), + "Only systems with 32 and 64 bit size_t are currently supported."); + + // Counting on the compiler to optimize away the wrong branch. + if (sizeof(size_t) == sizeof(uint64_t)) + { + // For this to work well we just assume that the values are no more than 16 bits. + t = size_t(k.x()) << 48; + t |= size_t(k.y()) << 32; + t |= size_t(k.z()) << 16; + t |= size_t(k.level()); + } + else if (sizeof(size_t) == sizeof(uint32_t)) + { + t = size_t((k.x() << 24) | 0xFF000000); + t |= size_t((k.y() << 16) | 0xFF0000); + t |= size_t((k.z() << 8) | 0xFF00); + t |= size_t(k.level() | 0xFF); + } return t; } }; From 20a0d99f7d50cfa079341bcc3418b8afffd683e6 Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Tue, 5 Jan 2021 12:02:34 -0500 Subject: [PATCH 2/2] Add include for old PDAL. --- epf/Reprocessor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/epf/Reprocessor.cpp b/epf/Reprocessor.cpp index 9f0a1a2..99c6798 100644 --- a/epf/Reprocessor.cpp +++ b/epf/Reprocessor.cpp @@ -11,6 +11,9 @@ ****************************************************************************/ +// This include is necessary for released PDAL 2.0 and earlier, as it wasn't included in +// FileUtils.hpp. +#include #include #include "Reprocessor.hpp"