mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 21:27:52 -06:00
Really fix build for msvc
This commit is contained in:
parent
c74e6513d9
commit
aff1863aed
2 changed files with 25 additions and 22 deletions
|
@ -260,18 +260,14 @@ template<class I> struct is_scaled_coord
|
|||
};
|
||||
|
||||
// Meta predicates for floating, 'scaled coord' and generic arithmetic types
|
||||
template<class T>
|
||||
using FloatingOnly = enable_if_t<std::is_floating_point<T>::value, T>;
|
||||
template<class T, class O = T>
|
||||
using FloatingOnly = enable_if_t<std::is_floating_point<T>::value, O>;
|
||||
|
||||
template<class T>
|
||||
using ScaledCoordOnly = enable_if_t<is_scaled_coord<T>::value, T>;
|
||||
template<class T, class O = T>
|
||||
using ScaledCoordOnly = enable_if_t<is_scaled_coord<T>::value, O>;
|
||||
|
||||
template<class T>
|
||||
using ArithmeticOnly = enable_if_t<std::is_arithmetic<T>::value, T>;
|
||||
|
||||
// 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>;
|
||||
template<class T, class O = T>
|
||||
using ArithmeticOnly = enable_if_t<std::is_arithmetic<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<T, N, 1, Eigen::DontAlign>;
|
|||
template<class Tout,
|
||||
class 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));
|
||||
}
|
||||
|
@ -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
|
||||
// std::round means loosing noexcept and constexpr modifiers
|
||||
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 Tout(v / Tin(SCALING_FACTOR));
|
||||
}
|
||||
|
||||
// Conversion for Eigen vectors (N dimensional points)
|
||||
template<class Tout = coord_t, class Tin, int N, class = FloatingOnly<Tin>>
|
||||
inline EigenVec<ArithmeticOnly<Tout>, N> scaled(const EigenVec<Tin, N> &v)
|
||||
template<class Tout = coord_t,
|
||||
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>();
|
||||
}
|
||||
|
@ -310,7 +311,7 @@ template<class Tout = double,
|
|||
class Tin,
|
||||
class = ArithmeticOnly<Tin>,
|
||||
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));
|
||||
}
|
||||
|
@ -321,9 +322,10 @@ template<class Tout = double,
|
|||
class Tin,
|
||||
int N,
|
||||
class = ArithmeticOnly<Tin>,
|
||||
class = FloatingOnly<Tout>>
|
||||
inline SLIC3R_CONSTEXPR EigenVec<Tout, N> unscaled(
|
||||
const EigenVec<Tin, N> &v) SLIC3R_NOEXCEPT
|
||||
class = FloatingOnly<Tout>,
|
||||
int...EigenArgs>
|
||||
inline constexpr Eigen::Matrix<Tout, N, EigenArgs...>
|
||||
unscaled(const Eigen::Matrix<Tin, N, EigenArgs...> &v) noexcept
|
||||
{
|
||||
return v.template cast<Tout>() * SCALING_FACTOR;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue