mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Replaced many defines in libslic3r.h with constexpr,
removed some macros to support old visual studio compiler.
This commit is contained in:
parent
99514ba42b
commit
4c365ad583
2 changed files with 13 additions and 26 deletions
|
@ -51,8 +51,8 @@ template<class S> struct NfpImpl<S, NfpLevel::CONVEX_ONLY>
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
template<class Tout = double, class = FloatingOnly<Tout>, int...EigenArgs>
|
template<class Tout = double, class = FloatingOnly<Tout>, int...EigenArgs>
|
||||||
inline SLIC3R_CONSTEXPR Eigen::Matrix<Tout, 2, EigenArgs...> unscaled(
|
inline constexpr Eigen::Matrix<Tout, 2, EigenArgs...> unscaled(
|
||||||
const ClipperLib::IntPoint &v) SLIC3R_NOEXCEPT
|
const ClipperLib::IntPoint &v) noexcept
|
||||||
{
|
{
|
||||||
return Eigen::Matrix<Tout, 2, EigenArgs...>{unscaled<Tout>(v.X),
|
return Eigen::Matrix<Tout, 2, EigenArgs...>{unscaled<Tout>(v.X),
|
||||||
unscaled<Tout>(v.Y)};
|
unscaled<Tout>(v.Y)};
|
||||||
|
|
|
@ -24,37 +24,37 @@
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// Saves around 32% RAM after slicing step, 6.7% after G-code export (tested on PrusaSlicer 2.2.0 final).
|
// Saves around 32% RAM after slicing step, 6.7% after G-code export (tested on PrusaSlicer 2.2.0 final).
|
||||||
typedef int32_t coord_t;
|
using coord_t = int32_t;
|
||||||
#else
|
#else
|
||||||
//FIXME At least FillRectilinear2 requires coord_t to be 32bit.
|
//FIXME At least FillRectilinear2 requires coord_t to be 32bit.
|
||||||
typedef int64_t coord_t;
|
typedef int64_t coord_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef double coordf_t;
|
using coordf_t = double;
|
||||||
|
|
||||||
//FIXME This epsilon value is used for many non-related purposes:
|
//FIXME This epsilon value is used for many non-related purposes:
|
||||||
// For a threshold of a squared Euclidean distance,
|
// For a threshold of a squared Euclidean distance,
|
||||||
// for a trheshold in a difference of radians,
|
// for a trheshold in a difference of radians,
|
||||||
// for a threshold of a cross product of two non-normalized vectors etc.
|
// for a threshold of a cross product of two non-normalized vectors etc.
|
||||||
#define EPSILON 1e-4
|
static constexpr double EPSILON = 1e-4;
|
||||||
// Scaling factor for a conversion from coord_t to coordf_t: 10e-6
|
// Scaling factor for a conversion from coord_t to coordf_t: 10e-6
|
||||||
// This scaling generates a following fixed point representation with for a 32bit integer:
|
// This scaling generates a following fixed point representation with for a 32bit integer:
|
||||||
// 0..4294mm with 1nm resolution
|
// 0..4294mm with 1nm resolution
|
||||||
// int32_t fits an interval of (-2147.48mm, +2147.48mm)
|
// int32_t fits an interval of (-2147.48mm, +2147.48mm)
|
||||||
// with int64_t we don't have to worry anymore about the size of the int.
|
// with int64_t we don't have to worry anymore about the size of the int.
|
||||||
#define SCALING_FACTOR 0.000001
|
static constexpr double SCALING_FACTOR = 0.000001;
|
||||||
// RESOLUTION, SCALED_RESOLUTION: Used as an error threshold for a Douglas-Peucker polyline simplification algorithm.
|
// RESOLUTION, SCALED_RESOLUTION: Used as an error threshold for a Douglas-Peucker polyline simplification algorithm.
|
||||||
#define RESOLUTION 0.0125
|
static constexpr double RESOLUTION = 0.0125;
|
||||||
#define SCALED_RESOLUTION (RESOLUTION / SCALING_FACTOR)
|
#define SCALED_RESOLUTION (RESOLUTION / SCALING_FACTOR)
|
||||||
#define PI 3.141592653589793238
|
static constexpr double PI = 3.141592653589793238;
|
||||||
// When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam.
|
// When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam.
|
||||||
#define LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER 0.15
|
static constexpr double LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER = 0.15;
|
||||||
// Maximum perimeter length for the loop to apply the small perimeter speed.
|
// Maximum perimeter length for the loop to apply the small perimeter speed.
|
||||||
#define SMALL_PERIMETER_LENGTH (6.5 / SCALING_FACTOR) * 2 * PI
|
#define SMALL_PERIMETER_LENGTH ((6.5 / SCALING_FACTOR) * 2 * PI);
|
||||||
#define INSET_OVERLAP_TOLERANCE 0.4
|
static constexpr double INSET_OVERLAP_TOLERANCE = 0.4;
|
||||||
// 3mm ring around the top / bottom / bridging areas.
|
// 3mm ring around the top / bottom / bridging areas.
|
||||||
//FIXME This is quite a lot.
|
//FIXME This is quite a lot.
|
||||||
#define EXTERNAL_INFILL_MARGIN 3.
|
static constexpr double EXTERNAL_INFILL_MARGIN = 3.;
|
||||||
//FIXME Better to use an inline function with an explicit return type.
|
//FIXME Better to use an inline function with an explicit return type.
|
||||||
//inline coord_t scale_(coordf_t v) { return coord_t(floor(v / SCALING_FACTOR + 0.5f)); }
|
//inline coord_t scale_(coordf_t v) { return coord_t(floor(v / SCALING_FACTOR + 0.5f)); }
|
||||||
#define scale_(val) ((val) / SCALING_FACTOR)
|
#define scale_(val) ((val) / SCALING_FACTOR)
|
||||||
|
@ -63,14 +63,6 @@ typedef double coordf_t;
|
||||||
|
|
||||||
#define SLIC3R_DEBUG_OUT_PATH_PREFIX "out/"
|
#define SLIC3R_DEBUG_OUT_PATH_PREFIX "out/"
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
|
||||||
# define SLIC3R_CONSTEXPR
|
|
||||||
# define SLIC3R_NOEXCEPT
|
|
||||||
#else
|
|
||||||
#define SLIC3R_CONSTEXPR constexpr
|
|
||||||
#define SLIC3R_NOEXCEPT noexcept
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline std::string debug_out_path(const char *name, ...)
|
inline std::string debug_out_path(const char *name, ...)
|
||||||
{
|
{
|
||||||
char buffer[2048];
|
char buffer[2048];
|
||||||
|
@ -92,11 +84,6 @@ inline std::string debug_out_path(const char *name, ...)
|
||||||
#define UNUSED(x) (void)(x)
|
#define UNUSED(x) (void)(x)
|
||||||
#endif /* UNUSED */
|
#endif /* UNUSED */
|
||||||
|
|
||||||
// Detect whether the compiler supports C++11 noexcept exception specifications.
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
|
||||||
#define noexcept throw()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Write slices as SVG images into out directory during the 2D processing of the slices.
|
// Write slices as SVG images into out directory during the 2D processing of the slices.
|
||||||
// #define SLIC3R_DEBUG_SLICE_PROCESSING
|
// #define SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue