diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index 5b048b0ffb..3f535db86e 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -51,8 +51,8 @@ template struct NfpImpl namespace Slic3r { template, int...EigenArgs> -inline SLIC3R_CONSTEXPR Eigen::Matrix unscaled( - const ClipperLib::IntPoint &v) SLIC3R_NOEXCEPT +inline constexpr Eigen::Matrix unscaled( + const ClipperLib::IntPoint &v) noexcept { return Eigen::Matrix{unscaled(v.X), unscaled(v.Y)}; diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index 814ee08071..45ee5acc10 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -24,37 +24,37 @@ #if 1 // 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 //FIXME At least FillRectilinear2 requires coord_t to be 32bit. typedef int64_t coord_t; #endif -typedef double coordf_t; +using coordf_t = double; //FIXME This epsilon value is used for many non-related purposes: // For a threshold of a squared Euclidean distance, // for a trheshold in a difference of radians, // 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 // This scaling generates a following fixed point representation with for a 32bit integer: // 0..4294mm with 1nm resolution // 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. -#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. -#define RESOLUTION 0.0125 -#define SCALED_RESOLUTION (RESOLUTION / SCALING_FACTOR) -#define PI 3.141592653589793238 +static constexpr double RESOLUTION = 0.0125; +#define SCALED_RESOLUTION (RESOLUTION / SCALING_FACTOR) +static constexpr double PI = 3.141592653589793238; // 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. -#define SMALL_PERIMETER_LENGTH (6.5 / SCALING_FACTOR) * 2 * PI -#define INSET_OVERLAP_TOLERANCE 0.4 +#define SMALL_PERIMETER_LENGTH ((6.5 / SCALING_FACTOR) * 2 * PI); +static constexpr double INSET_OVERLAP_TOLERANCE = 0.4; // 3mm ring around the top / bottom / bridging areas. //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. //inline coord_t scale_(coordf_t v) { return coord_t(floor(v / SCALING_FACTOR + 0.5f)); } #define scale_(val) ((val) / SCALING_FACTOR) @@ -63,14 +63,6 @@ typedef double coordf_t; #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, ...) { char buffer[2048]; @@ -92,11 +84,6 @@ inline std::string debug_out_path(const char *name, ...) #define UNUSED(x) (void)(x) #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. // #define SLIC3R_DEBUG_SLICE_PROCESSING