Skip to content
Permalink
Browse files

Untwine update: fixed warnings and 32-bit build

  • Loading branch information
wonder-sk committed Jan 6, 2021
1 parent cb6b306 commit 8e5b036fec982e4b001f8df3449a44295ff7a567
@@ -138,6 +138,9 @@ std::cerr << m_vi.key() << " Accepted/Rejected/num points = " <<

bool Processor::acceptable(int pointId, GridKey key)
{
//ABELL - Currently unused - see commented-out code.
(void)pointId;

VoxelInfo::Grid& grid = m_vi.grid();

auto it = grid.find(key);
@@ -73,7 +73,6 @@ void Epf::run(const Options& options, ProgressWriter& progress)
{
using namespace pdal;

double millionPoints = 0;
BOX3D totalBounds;

if (pdal::FileUtils::fileExists(options.tempDir + "/" + MetadataFilename))
@@ -42,7 +42,6 @@ int Grid::calcLevel()
{
int level = 0;
double mp = (double)m_millionPoints;
double limit = (MaxPointsPerNode / 1000000.0);

double xside = m_bounds.maxx - m_bounds.minx;
double yside = m_bounds.maxy - m_bounds.miny;
@@ -10,6 +10,9 @@
* *
****************************************************************************/


// This include is necessary for released PDAL 2.0 and earlier, as it wasn't included in
// FileUtils.hpp.
#include <vector>
#include <pdal/util/FileUtils.hpp>

@@ -40,7 +40,9 @@ inline std::ostream& operator<<(std::ostream& out, const FileDimInfo& fdi)

inline std::istream& operator>>(std::istream& in, FileDimInfo& fdi)
{
in >> fdi.name >> (int&)fdi.type >> fdi.offset;
int type;
in >> fdi.name >> type >> fdi.offset;
fdi.type = (pdal::Dimension::Type)type;
return in;
}

@@ -18,7 +18,7 @@ ProgressWriter::ProgressWriter(int fd) : m_progressFd(fd), m_percent(0.0), m_inc

void ProgressWriter::setIncrement(double increment)
{
if (!m_progressFd)
if (m_progressFd < 0)
return;
std::unique_lock<std::mutex> lock(m_mutex);

@@ -27,7 +27,7 @@ void ProgressWriter::setIncrement(double increment)

void ProgressWriter::setPercent(double percent)
{
if (!m_progressFd)
if (m_progressFd < 0)
return;
std::unique_lock<std::mutex> lock(m_mutex);

@@ -36,7 +36,7 @@ void ProgressWriter::setPercent(double percent)

void ProgressWriter::writeIncrement(const std::string& message)
{
if (!m_progressFd)
if (m_progressFd < 0)
return;
std::unique_lock<std::mutex> lock(m_mutex);

@@ -49,7 +49,7 @@ void ProgressWriter::writeIncrement(const std::string& message)

void ProgressWriter::write(double percent, const std::string& message)
{
if (!m_progressFd)
if (m_progressFd < 0)
return;
std::unique_lock<std::mutex> lock(m_mutex);

@@ -62,10 +62,16 @@ void ProgressWriter::write(double percent, const std::string& message)
void ProgressWriter::writeMessage(uint32_t percent, const std::string& message)
{
#ifndef _WIN32
::write(m_progressFd, &percent, sizeof(percent));
bool err = false;
err = (::write(m_progressFd, &percent, sizeof(percent)) == -1);
uint32_t ssize = (uint32_t)message.size();
::write(m_progressFd, &ssize, sizeof(ssize));
::write(m_progressFd, message.data(), ssize);
err |= (::write(m_progressFd, &ssize, sizeof(ssize)) == -1);
err |= (::write(m_progressFd, message.data(), ssize) == -1);
if (err)
{
::close(m_progressFd);
m_progressFd = -1;
}
#else
DWORD numWritten;
HANDLE h = reinterpret_cast<HANDLE>((intptr_t)m_progressFd);
@@ -102,15 +102,30 @@ namespace std
{
template<> struct hash<untwine::VoxelKey>
{
long long operator()(const untwine::VoxelKey& k) const noexcept
size_t operator()(const untwine::VoxelKey& k) const noexcept
{
static_assert(sizeof(long long) >= 8, "wrong assumption that long long is 64 bits");

// For this to work well we just assume that the values are no more than than 16 bits.
long long t = static_cast<long long>(k.x()) << 48;
t |= static_cast<long long>(k.y()) << 32;
t |= static_cast<long long>(k.z()) << 16;
t |= static_cast<long long>(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;
}
};

0 comments on commit 8e5b036

Please sign in to comment.
You can’t perform that action at this time.