mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-04 01:20:40 +08:00
constexpr party
This commit is contained in:
parent
ecc171eca6
commit
8250839fd5
@ -76,7 +76,7 @@ enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
|
||||
#else
|
||||
typedef signed long long cInt;
|
||||
static cInt const loRange = 0x3FFFFFFF;
|
||||
static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
|
||||
constexpr cInt hiRange = 0x3FFFFFFFFFFFFFFFLL;
|
||||
typedef signed long long long64; //used by Int128 class
|
||||
typedef unsigned long long ulong64;
|
||||
|
||||
|
@ -19,8 +19,8 @@ namespace Slic3r {
|
||||
// How about 2^17=131072?
|
||||
// By the way, is the scalling needed at all? Cura runs all the computation with a fixed point precision of 1um, while Slic3r scales to 1nm,
|
||||
// further scaling by 10e5 brings us to
|
||||
static const float CLIPPER_OFFSET_SCALE = 100000.0;
|
||||
static const coord_t MAX_COORD = ClipperLib::hiRange / CLIPPER_OFFSET_SCALE;
|
||||
constexpr float CLIPPER_OFFSET_SCALE = 100000.0;
|
||||
constexpr auto MAX_COORD = ClipperLib::hiRange / CLIPPER_OFFSET_SCALE;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// legacy code from Clipper documentation
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
#define BRIDGE_EXTRA_SPACING 0.05
|
||||
#define OVERLAP_FACTOR 1.0
|
||||
constexpr auto BRIDGE_EXTRA_SPACING = 0.05;
|
||||
constexpr auto OVERLAP_FACTOR = 1.0;
|
||||
|
||||
enum FlowRole {
|
||||
frExternalPerimeter,
|
||||
|
@ -453,8 +453,8 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
|
||||
paths.front().polyline.points[0],
|
||||
paths.front().polyline.points[1]
|
||||
);
|
||||
double distance = std::min(
|
||||
scale_(EXTRUDER_CONFIG(nozzle_diameter)),
|
||||
const double distance = std::min(
|
||||
(double)scale_(EXTRUDER_CONFIG(nozzle_diameter)),
|
||||
first_segment.length()
|
||||
);
|
||||
Point point = first_segment.point_at(distance);
|
||||
|
@ -26,10 +26,10 @@
|
||||
std::fstream fs;
|
||||
#endif
|
||||
|
||||
#define KEEP_SENT 20
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
constexpr auto KEEP_SENT = 20;
|
||||
|
||||
namespace asio = boost::asio;
|
||||
|
||||
GCodeSender::GCodeSender()
|
||||
|
@ -9,11 +9,11 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#define MP_INNER_MARGIN scale_(1.0)
|
||||
#define MP_OUTER_MARGIN scale_(2.0)
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
constexpr coord_t MP_INNER_MARGIN = scale_(1.0);
|
||||
constexpr coord_t MP_OUTER_MARGIN = scale_(2.0);
|
||||
|
||||
class MotionPlanner;
|
||||
|
||||
class MotionPlannerEnv
|
||||
|
@ -4,7 +4,7 @@
|
||||
namespace Slic3r {
|
||||
|
||||
// how much we extend support around the actual contact area
|
||||
#define SUPPORT_MATERIAL_MARGIN 1.5
|
||||
constexpr coordf_t SUPPORT_MATERIAL_MARGIN = 1.5;
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,33 +10,6 @@
|
||||
#include <vector>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#define SLIC3R_VERSION "1.3.0-dev"
|
||||
|
||||
//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
|
||||
// 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
|
||||
#define 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
|
||||
// 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
|
||||
// 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 EXTERNAL_INFILL_MARGIN 3
|
||||
#define scale_(val) ((val) / SCALING_FACTOR)
|
||||
#define unscale(val) ((val) * SCALING_FACTOR)
|
||||
#define SCALED_EPSILON scale_(EPSILON)
|
||||
typedef long coord_t;
|
||||
typedef double coordf_t;
|
||||
|
||||
/* Implementation of CONFESS("foo"): */
|
||||
#ifdef _MSC_VER
|
||||
#define CONFESS(...) confess_at(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
|
||||
@ -61,6 +34,35 @@ void confess_at(const char *file, int line, const char *func, const char *pat, .
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
constexpr auto SLIC3R_VERSION = "1.3.0-dev";
|
||||
|
||||
typedef long coord_t;
|
||||
typedef double coordf_t;
|
||||
|
||||
// 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
|
||||
constexpr auto SCALING_FACTOR = 0.000001;
|
||||
inline constexpr coord_t scale_(const coordf_t &val) { return val / SCALING_FACTOR; }
|
||||
inline constexpr coordf_t unscale(const coord_t &val) { return val * SCALING_FACTOR; }
|
||||
|
||||
//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.
|
||||
constexpr auto EPSILON = 1e-4;
|
||||
constexpr auto SCALED_EPSILON = scale_(EPSILON);
|
||||
// RESOLUTION, SCALED_RESOLUTION: Used as an error threshold for a Douglas-Peucker polyline simplification algorithm.
|
||||
constexpr auto RESOLUTION = 0.0125;
|
||||
constexpr auto SCALED_RESOLUTION = scale_(RESOLUTION);
|
||||
constexpr auto PI = 3.141592653589793238;
|
||||
// When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam.
|
||||
constexpr auto LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER = 0.15;
|
||||
// Maximum perimeter length for the loop to apply the small perimeter speed.
|
||||
constexpr coord_t SMALL_PERIMETER_LENGTH = scale_(6.5) * 2 * PI;
|
||||
constexpr coordf_t INSET_OVERLAP_TOLERANCE = 0.4;
|
||||
constexpr coordf_t EXTERNAL_INFILL_MARGIN = 3;
|
||||
|
||||
enum Axis { X=0, Y, Z };
|
||||
|
||||
template <class T>
|
||||
|
Loading…
x
Reference in New Issue
Block a user