mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Integrate scaling and unscaling into Point.hpp
This commit is contained in:
parent
89d376dc35
commit
8c04536514
4 changed files with 104 additions and 228 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Technologies.hpp"
|
||||
#include "Semver.hpp"
|
||||
|
@ -247,6 +248,37 @@ static inline bool is_approx(Number value, Number test_value)
|
|||
return std::fabs(double(value) - double(test_value)) < double(EPSILON);
|
||||
}
|
||||
|
||||
// A meta-predicate which is true for integers wider than or equal to coord_t
|
||||
template<class I> struct is_scaled_coord
|
||||
{
|
||||
static const constexpr bool value =
|
||||
std::is_integral<I>::value &&
|
||||
std::numeric_limits<I>::digits >=
|
||||
std::numeric_limits<coord_t>::digits;
|
||||
};
|
||||
|
||||
// Meta predicates for floating, 'scaled coord' and generic arithmetic types
|
||||
// Can be used to restrict templates to work for only the specified set of types.
|
||||
// parameter T is the type we want to restrict
|
||||
// parameter O (Optional defaults to T) is the type that the whole expression
|
||||
// will be evaluated to.
|
||||
// e.g. template<class T> FloatingOnly<T, bool> is_nan(T val);
|
||||
// The whole template will be defined only for floating point types and the
|
||||
// return type will be bool.
|
||||
// For more info how to use, see docs for std::enable_if
|
||||
//
|
||||
template<class T, class O = T>
|
||||
using FloatingOnly = std::enable_if_t<std::is_floating_point<T>::value, O>;
|
||||
|
||||
template<class T, class O = T>
|
||||
using ScaledCoordOnly = std::enable_if_t<is_scaled_coord<T>::value, O>;
|
||||
|
||||
template<class T, class O = T>
|
||||
using IntegerOnly = std::enable_if_t<std::is_integral<T>::value, O>;
|
||||
|
||||
template<class T, class O = T>
|
||||
using ArithmeticOnly = std::enable_if_t<std::is_arithmetic<T>::value, O>;
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue