diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index 63398fd0f1..bc3eedb63c 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -46,11 +46,12 @@ template struct NfpImpl namespace Slic3r { -template> -inline SLIC3R_CONSTEXPR EigenVec unscaled( +template, int...EigenArgs> +inline SLIC3R_CONSTEXPR Eigen::Matrix unscaled( const ClipperLib::IntPoint &v) SLIC3R_NOEXCEPT { - return EigenVec{unscaled(v.X), unscaled(v.Y)}; + return Eigen::Matrix{unscaled(v.X), + unscaled(v.Y)}; } namespace arrangement { @@ -139,7 +140,7 @@ protected: ItemGroup m_remaining; // Remaining items (m_items at the beginning) ItemGroup m_items; // The items to be packed - template> double norm(T val) + template ArithmeticOnly norm(T val) { return double(val) / m_norm; } diff --git a/src/libslic3r/MTUtils.hpp b/src/libslic3r/MTUtils.hpp index 24542558ce..a9f2c0274c 100644 --- a/src/libslic3r/MTUtils.hpp +++ b/src/libslic3r/MTUtils.hpp @@ -260,18 +260,14 @@ template struct is_scaled_coord }; // Meta predicates for floating, 'scaled coord' and generic arithmetic types -template -using FloatingOnly = enable_if_t::value, T>; +template +using FloatingOnly = enable_if_t::value, O>; -template -using ScaledCoordOnly = enable_if_t::value, T>; +template +using ScaledCoordOnly = enable_if_t::value, O>; -template -using ArithmeticOnly = enable_if_t::value, T>; - -// A shorter form for a generic Eigen vector which is widely used in PrusaSlicer -template -using EigenVec = Eigen::Matrix; +template +using ArithmeticOnly = enable_if_t::value, O>; // Semantics are the following: // Upscaling (scaled()): only from floating point types (or Vec) to either @@ -282,7 +278,7 @@ using EigenVec = Eigen::Matrix; template> -inline SLIC3R_CONSTEXPR FloatingOnly scaled(const Tin &v) SLIC3R_NOEXCEPT +inline constexpr FloatingOnly scaled(const Tin &v) noexcept { return Tout(v / Tin(SCALING_FACTOR)); } @@ -292,15 +288,20 @@ inline SLIC3R_CONSTEXPR FloatingOnly scaled(const Tin &v) SLIC3R_NOEXCEPT // it can be different for integers but it does not have to be. Using // std::round means loosing noexcept and constexpr modifiers template> -inline SLIC3R_CONSTEXPR ScaledCoordOnly scaled(const Tin &v) SLIC3R_NOEXCEPT +inline constexpr ScaledCoordOnly scaled(const Tin &v) noexcept { //return static_cast(std::round(v / SCALING_FACTOR)); return Tout(v / Tin(SCALING_FACTOR)); } // Conversion for Eigen vectors (N dimensional points) -template> -inline EigenVec, N> scaled(const EigenVec &v) +template, + int...EigenArgs> +inline Eigen::Matrix, N, EigenArgs...> +scaled(const Eigen::Matrix &v) { return (v / SCALING_FACTOR).template cast(); } @@ -310,7 +311,7 @@ template, class = FloatingOnly> -inline SLIC3R_CONSTEXPR Tout unscaled(const Tin &v) SLIC3R_NOEXCEPT +inline constexpr Tout unscaled(const Tin &v) noexcept { return Tout(v * Tout(SCALING_FACTOR)); } @@ -321,9 +322,10 @@ template, - class = FloatingOnly> -inline SLIC3R_CONSTEXPR EigenVec unscaled( - const EigenVec &v) SLIC3R_NOEXCEPT + class = FloatingOnly, + int...EigenArgs> +inline constexpr Eigen::Matrix +unscaled(const Eigen::Matrix &v) noexcept { return v.template cast() * SCALING_FACTOR; }