diff --git a/src/FileIO/LocationInterpolation.cpp b/src/FileIO/LocationInterpolation.cpp index edfcd6ba7..caf56f3ed 100644 --- a/src/FileIO/LocationInterpolation.cpp +++ b/src/FileIO/LocationInterpolation.cpp @@ -240,10 +240,10 @@ xyz UnitCatmullRomInterpolator3D::Interpolate(double frac) geolocation GeoPointInterpolator::Interpolate(double distance) { - return DistancePointInterpolator::Interpolate(distance).togeolocation(); + 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 390d63867..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,7 +518,7 @@ class GeoPointInterpolator : public DistancePointInterpolator() {} geolocation Interpolate(double distance);