Skip to content

Commit

Permalink
Untwine update: fixed warnings and 32-bit build
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jan 6, 2021
1 parent cb6b306 commit 8e5b036
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 18 deletions.
3 changes: 3 additions & 0 deletions external/untwine/bu/Processor.cpp
Expand Up @@ -138,6 +138,9 @@ std::cerr << m_vi.key() << " Accepted/Rejected/num points = " <<


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

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


auto it = grid.find(key); auto it = grid.find(key);
Expand Down
1 change: 0 additions & 1 deletion external/untwine/epf/Epf.cpp
Expand Up @@ -73,7 +73,6 @@ void Epf::run(const Options& options, ProgressWriter& progress)
{ {
using namespace pdal; using namespace pdal;


double millionPoints = 0;
BOX3D totalBounds; BOX3D totalBounds;


if (pdal::FileUtils::fileExists(options.tempDir + "/" + MetadataFilename)) if (pdal::FileUtils::fileExists(options.tempDir + "/" + MetadataFilename))
Expand Down
1 change: 0 additions & 1 deletion external/untwine/epf/Grid.cpp
Expand Up @@ -42,7 +42,6 @@ int Grid::calcLevel()
{ {
int level = 0; int level = 0;
double mp = (double)m_millionPoints; double mp = (double)m_millionPoints;
double limit = (MaxPointsPerNode / 1000000.0);


double xside = m_bounds.maxx - m_bounds.minx; double xside = m_bounds.maxx - m_bounds.minx;
double yside = m_bounds.maxy - m_bounds.miny; double yside = m_bounds.maxy - m_bounds.miny;
Expand Down
3 changes: 3 additions & 0 deletions external/untwine/epf/Reprocessor.cpp
Expand Up @@ -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 <vector>
#include <pdal/util/FileUtils.hpp> #include <pdal/util/FileUtils.hpp>


Expand Down
4 changes: 3 additions & 1 deletion external/untwine/untwine/FileDimInfo.hpp
Expand Up @@ -40,7 +40,9 @@ inline std::ostream& operator<<(std::ostream& out, const FileDimInfo& fdi)


inline std::istream& operator>>(std::istream& in, 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; return in;
} }


Expand Down
20 changes: 13 additions & 7 deletions external/untwine/untwine/ProgressWriter.cpp
Expand Up @@ -18,7 +18,7 @@ ProgressWriter::ProgressWriter(int fd) : m_progressFd(fd), m_percent(0.0), m_inc


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


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


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


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


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


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


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


Expand All @@ -62,10 +62,16 @@ void ProgressWriter::write(double percent, const std::string& message)
void ProgressWriter::writeMessage(uint32_t percent, const std::string& message) void ProgressWriter::writeMessage(uint32_t percent, const std::string& message)
{ {
#ifndef _WIN32 #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(); uint32_t ssize = (uint32_t)message.size();
::write(m_progressFd, &ssize, sizeof(ssize)); err |= (::write(m_progressFd, &ssize, sizeof(ssize)) == -1);
::write(m_progressFd, message.data(), ssize); err |= (::write(m_progressFd, message.data(), ssize) == -1);
if (err)
{
::close(m_progressFd);
m_progressFd = -1;
}
#else #else
DWORD numWritten; DWORD numWritten;
HANDLE h = reinterpret_cast<HANDLE>((intptr_t)m_progressFd); HANDLE h = reinterpret_cast<HANDLE>((intptr_t)m_progressFd);
Expand Down
31 changes: 23 additions & 8 deletions external/untwine/untwine/VoxelKey.hpp
Expand Up @@ -102,15 +102,30 @@ namespace std
{ {
template<> struct hash<untwine::VoxelKey> 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"); size_t t;


// For this to work well we just assume that the values are no more than than 16 bits. static_assert(sizeof(size_t) == sizeof(uint64_t) ||
long long t = static_cast<long long>(k.x()) << 48; sizeof(size_t) == sizeof(uint32_t),
t |= static_cast<long long>(k.y()) << 32; "Only systems with 32 and 64 bit size_t are currently supported.");
t |= static_cast<long long>(k.z()) << 16;
t |= static_cast<long long>(k.level()); // 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; return t;
} }
}; };
Expand Down

0 comments on commit 8e5b036

Please sign in to comment.