Really fix build for msvc

This commit is contained in:
tamasmeszaros 2019-07-17 16:47:09 +02:00
parent c74e6513d9
commit aff1863aed
2 changed files with 25 additions and 22 deletions

View file

@ -46,11 +46,12 @@ template<class S> struct NfpImpl<S, NfpLevel::CONVEX_ONLY>
namespace Slic3r { namespace Slic3r {
template<class Tout = double, class = FloatingOnly<Tout>> template<class Tout = double, class = FloatingOnly<Tout>, int...EigenArgs>
inline SLIC3R_CONSTEXPR EigenVec<Tout, 2> unscaled( inline SLIC3R_CONSTEXPR Eigen::Matrix<Tout, 2, EigenArgs...> unscaled(
const ClipperLib::IntPoint &v) SLIC3R_NOEXCEPT const ClipperLib::IntPoint &v) SLIC3R_NOEXCEPT
{ {
return EigenVec<Tout, 2>{unscaled<Tout>(v.X), unscaled<Tout>(v.Y)}; return Eigen::Matrix<Tout, 2, EigenArgs...>{unscaled<Tout>(v.X),
unscaled<Tout>(v.Y)};
} }
namespace arrangement { namespace arrangement {
@ -139,7 +140,7 @@ protected:
ItemGroup m_remaining; // Remaining items (m_items at the beginning) ItemGroup m_remaining; // Remaining items (m_items at the beginning)
ItemGroup m_items; // The items to be packed ItemGroup m_items; // The items to be packed
template<class T, class = ArithmeticOnly<T>> double norm(T val) template<class T> ArithmeticOnly<T, double> norm(T val)
{ {
return double(val) / m_norm; return double(val) / m_norm;
} }

View file

@ -260,18 +260,14 @@ template<class I> struct is_scaled_coord
}; };
// Meta predicates for floating, 'scaled coord' and generic arithmetic types // Meta predicates for floating, 'scaled coord' and generic arithmetic types
template<class T> template<class T, class O = T>
using FloatingOnly = enable_if_t<std::is_floating_point<T>::value, T>; using FloatingOnly = enable_if_t<std::is_floating_point<T>::value, O>;
template<class T> template<class T, class O = T>
using ScaledCoordOnly = enable_if_t<is_scaled_coord<T>::value, T>; using ScaledCoordOnly = enable_if_t<is_scaled_coord<T>::value, O>;
template<class T> template<class T, class O = T>
using ArithmeticOnly = enable_if_t<std::is_arithmetic<T>::value, T>; using ArithmeticOnly = enable_if_t<std::is_arithmetic<T>::value, O>;
// A shorter form for a generic Eigen vector which is widely used in PrusaSlicer
template<class T, int N>
using EigenVec = Eigen::Matrix<T, N, 1, Eigen::DontAlign>;
// Semantics are the following: // Semantics are the following:
// Upscaling (scaled()): only from floating point types (or Vec) to either // Upscaling (scaled()): only from floating point types (or Vec) to either
@ -282,7 +278,7 @@ using EigenVec = Eigen::Matrix<T, N, 1, Eigen::DontAlign>;
template<class Tout, template<class Tout,
class Tin, class Tin,
class = FloatingOnly<Tin>> class = FloatingOnly<Tin>>
inline SLIC3R_CONSTEXPR FloatingOnly<Tout> scaled(const Tin &v) SLIC3R_NOEXCEPT inline constexpr FloatingOnly<Tout> scaled(const Tin &v) noexcept
{ {
return Tout(v / Tin(SCALING_FACTOR)); return Tout(v / Tin(SCALING_FACTOR));
} }
@ -292,15 +288,20 @@ inline SLIC3R_CONSTEXPR FloatingOnly<Tout> scaled(const Tin &v) SLIC3R_NOEXCEPT
// it can be different for integers but it does not have to be. Using // it can be different for integers but it does not have to be. Using
// std::round means loosing noexcept and constexpr modifiers // std::round means loosing noexcept and constexpr modifiers
template<class Tout = coord_t, class Tin, class = FloatingOnly<Tin>> template<class Tout = coord_t, class Tin, class = FloatingOnly<Tin>>
inline SLIC3R_CONSTEXPR ScaledCoordOnly<Tout> scaled(const Tin &v) SLIC3R_NOEXCEPT inline constexpr ScaledCoordOnly<Tout> scaled(const Tin &v) noexcept
{ {
//return static_cast<Tout>(std::round(v / SCALING_FACTOR)); //return static_cast<Tout>(std::round(v / SCALING_FACTOR));
return Tout(v / Tin(SCALING_FACTOR)); return Tout(v / Tin(SCALING_FACTOR));
} }
// Conversion for Eigen vectors (N dimensional points) // Conversion for Eigen vectors (N dimensional points)
template<class Tout = coord_t, class Tin, int N, class = FloatingOnly<Tin>> template<class Tout = coord_t,
inline EigenVec<ArithmeticOnly<Tout>, N> scaled(const EigenVec<Tin, N> &v) class Tin,
int N,
class = FloatingOnly<Tin>,
int...EigenArgs>
inline Eigen::Matrix<ArithmeticOnly<Tout>, N, EigenArgs...>
scaled(const Eigen::Matrix<Tin, N, EigenArgs...> &v)
{ {
return (v / SCALING_FACTOR).template cast<Tout>(); return (v / SCALING_FACTOR).template cast<Tout>();
} }
@ -310,7 +311,7 @@ template<class Tout = double,
class Tin, class Tin,
class = ArithmeticOnly<Tin>, class = ArithmeticOnly<Tin>,
class = FloatingOnly<Tout>> class = FloatingOnly<Tout>>
inline SLIC3R_CONSTEXPR Tout unscaled(const Tin &v) SLIC3R_NOEXCEPT inline constexpr Tout unscaled(const Tin &v) noexcept
{ {
return Tout(v * Tout(SCALING_FACTOR)); return Tout(v * Tout(SCALING_FACTOR));
} }
@ -321,9 +322,10 @@ template<class Tout = double,
class Tin, class Tin,
int N, int N,
class = ArithmeticOnly<Tin>, class = ArithmeticOnly<Tin>,
class = FloatingOnly<Tout>> class = FloatingOnly<Tout>,
inline SLIC3R_CONSTEXPR EigenVec<Tout, N> unscaled( int...EigenArgs>
const EigenVec<Tin, N> &v) SLIC3R_NOEXCEPT inline constexpr Eigen::Matrix<Tout, N, EigenArgs...>
unscaled(const Eigen::Matrix<Tin, N, EigenArgs...> &v) noexcept
{ {
return v.template cast<Tout>() * SCALING_FACTOR; return v.template cast<Tout>() * SCALING_FACTOR;
} }