From 629a5d9446b722d14b991c4bdb2f865f5bf269cd Mon Sep 17 00:00:00 2001 From: Joern Date: Sun, 3 Mar 2019 11:46:09 +0100 Subject: [PATCH 1/2] VC2017/Qt 5.12.1 - Fix 64Bit Build Problem ... with windows / VC2017 / 64Bit the code does not build / cannot resolve a overwritten function when using QT 5.12.1 ... adding the newly introduced function similar to the other function resolves the compile problem --- src/FileIO/LocationInterpolation.cpp | 5 +++++ src/FileIO/LocationInterpolation.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/FileIO/LocationInterpolation.cpp b/src/FileIO/LocationInterpolation.cpp index edfcd6ba7..71ef2e0a4 100644 --- a/src/FileIO/LocationInterpolation.cpp +++ b/src/FileIO/LocationInterpolation.cpp @@ -243,6 +243,11 @@ geolocation GeoPointInterpolator::Interpolate(double distance) return DistancePointInterpolator::Interpolate(distance).togeolocation(); } +bool GeoPointInterpolator::GetBracket(double &d0, double &d1) +{ + return DistancePointInterpolator::GetBracket(d0, d1); +} + void GeoPointInterpolator::Push(double distance, geolocation point) { DistancePointInterpolator::Push(distance, point.toxyz()); diff --git a/src/FileIO/LocationInterpolation.h b/src/FileIO/LocationInterpolation.h index 390d63867..7f358f759 100644 --- a/src/FileIO/LocationInterpolation.h +++ b/src/FileIO/LocationInterpolation.h @@ -492,6 +492,7 @@ public: GeoPointInterpolator() : DistancePointInterpolator() {} geolocation Interpolate(double distance); + bool GetBracket(double &d0, double &d1); void Push(double distance, geolocation point); }; From c9600248c6a1487a3f998dfe64e0d71864dcfb35 Mon Sep 17 00:00:00 2001 From: Joern Date: Wed, 6 Mar 2019 12:03:15 +0100 Subject: [PATCH 2/2] Proper Fix for the VS2017 / Qt 5.12.x Problem ... provided by Eric --- src/FileIO/LocationInterpolation.cpp | 9 ++----- src/FileIO/LocationInterpolation.h | 36 ++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/FileIO/LocationInterpolation.cpp b/src/FileIO/LocationInterpolation.cpp index 71ef2e0a4..caf56f3ed 100644 --- a/src/FileIO/LocationInterpolation.cpp +++ b/src/FileIO/LocationInterpolation.cpp @@ -240,15 +240,10 @@ xyz UnitCatmullRomInterpolator3D::Interpolate(double frac) geolocation GeoPointInterpolator::Interpolate(double distance) { - return DistancePointInterpolator::Interpolate(distance).togeolocation(); -} - -bool GeoPointInterpolator::GetBracket(double &d0, double &d1) -{ - return DistancePointInterpolator::GetBracket(d0, d1); + return DistancePointInterpolator::Interpolate(distance).togeolocation(); } void GeoPointInterpolator::Push(double distance, geolocation point) { - DistancePointInterpolator::Push(distance, point.toxyz()); + DistancePointInterpolator::Push(distance, point.toxyz()); } diff --git a/src/FileIO/LocationInterpolation.h b/src/FileIO/LocationInterpolation.h index 7f358f759..ef3714253 100644 --- a/src/FileIO/LocationInterpolation.h +++ b/src/FileIO/LocationInterpolation.h @@ -20,7 +20,7 @@ #define _LOCATION_INTERPOLATION_H #include -#include + #include "qwt_math.h" struct geolocation; @@ -173,11 +173,40 @@ public: xyz Interpolate(double frac); }; +// Visual studio has an error in how it compiles bitset that prevents +// us from mixing it with qt headers >= 5.12.0. The toolchain error will +// allegedly be fixed in vs2019 so roll our own for this very limited case. +template class MyBitset +{ + static_assert(T_bitsize <= 32, "T_bitsize must be <= 32."); + static_assert(T_bitsize >= 1, "T_bitsize must be >= 1."); + + unsigned m_mask; + + unsigned popcnt(unsigned x) const { + x = x - ((x >> 1) & 0x55555555); + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + return ((x + (x >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; + } + + void truncate() { m_mask &= (((unsigned)(-1 << (32 - T_bitsize))) >> (32 - T_bitsize)); } + +public: + + MyBitset(unsigned m) : m_mask(m) {} + void reset() { m_mask = 0; } + bool test(unsigned u) const { return ((m_mask >> u) & 1) != 0; } + void set(unsigned u) { m_mask |= (1 << u); truncate(); } + unsigned count() const { return popcnt(m_mask); } + MyBitset& operator <<=(unsigned u) { m_mask <<= u; truncate(); return (*this); } +}; + // 4 element sliding window to hold interpolation points template class SlidingWindow { std::tuple m_Window; - std::bitset<4> m_ElementExists; + MyBitset<4> m_ElementExists; + //std::bitset<4> m_ElementExists; // Visual studio error prevents bitset use alongside qtbase header. public: @@ -489,10 +518,9 @@ class GeoPointInterpolator : public DistancePointInterpolator() {} geolocation Interpolate(double distance); - bool GetBracket(double &d0, double &d1); void Push(double distance, geolocation point); };