diff options
author | bubnikv <bubnikv@gmail.com> | 2017-07-27 11:39:43 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-07-27 11:39:43 +0300 |
commit | a6ea01a23f1f4013845fce4ec80c6511b6f40f37 (patch) | |
tree | 02bdb4d4146e0da9a8ecb3abfb2bf9c323a79bc2 /xs/src/libslic3r/ExtrusionSimulator.cpp | |
parent | 3b51f644110978f69edaf95b50a8796e992aab23 (diff) |
Moved some math macros (sqr, lerp, clamp) to libslic3r.h
Added UNUSED macro to libslic3r.h, used it to reduce some compile warnings.
Split the Int128 class from Clipper library to a separate file,
extended Int128 with intrinsic types wherever possible for performance,
added new geometric predicates.
Added a draft of new FillRectilinear3, which should reduce overfill near the perimeters in the future.
Diffstat (limited to 'xs/src/libslic3r/ExtrusionSimulator.cpp')
-rw-r--r-- | xs/src/libslic3r/ExtrusionSimulator.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/xs/src/libslic3r/ExtrusionSimulator.cpp b/xs/src/libslic3r/ExtrusionSimulator.cpp index 3752caed4..daecbc0d1 100644 --- a/xs/src/libslic3r/ExtrusionSimulator.cpp +++ b/xs/src/libslic3r/ExtrusionSimulator.cpp @@ -13,12 +13,15 @@ #include <boost/multi_array.hpp> +#include "libslic3r.h" #include "ExtrusionSimulator.hpp" #ifndef M_PI #define M_PI 3.1415926535897932384626433832795 #endif +namespace Slic3r { + // Replacement for a template alias. // Shorthand for the point_xy. template<typename T> @@ -173,24 +176,6 @@ inline T mag(const boost::geometry::model::d2::point_xy<T> &v) } template<typename T> -inline T lerp(T start, T end, T alpha) -{ - return start * (T(1.) - alpha) + end * alpha; -} - -template<typename T> -inline T clamp(T low, T high, T x) -{ - return std::max<T>(low, std::min<T>(high, x)); -} - -template<typename T> -inline T sqr(T x) -{ - return x * x; -} - -template<typename T> inline T dist2_to_line( const boost::geometry::model::d2::point_xy<T> &p0, const boost::geometry::model::d2::point_xy<T> &p1, @@ -657,7 +642,7 @@ void gcode_spread_points( A2f &acc, const A2f &mask, const ExtrusionPoints &points, - Slic3r::ExtrusionSimulationType simulationType) + ExtrusionSimulationType simulationType) { int nc = acc.shape()[1]; int nr = acc.shape()[0]; @@ -796,14 +781,14 @@ void gcode_spread_points( // if (true) { // printf("volume_total: %f, volume_full: %f, fill factor: %f\n", volume_total, volume_full, 100.f - 100.f * volume_total / volume_full); // printf("volume_full: %f, volume_excess+deficit: %f, volume_excess: %f, volume_deficit: %f\n", volume_full, volume_excess+volume_deficit, volume_excess, volume_deficit); - if (simulationType == Slic3r::ExtrusionSimulationSpreadFull || volume_total <= volume_full) { + if (simulationType == ExtrusionSimulationSpreadFull || volume_total <= volume_full) { // The volume under the circle is spreaded fully. float height_avg = volume_total / area_total; for (size_t i = 0; i < n_cells; ++ i) { const Cell &cell = cells[i]; acc[cell.idx.y()][cell.idx.x()] = (1.f - cell.fraction_covered) * cell.volume + cell.fraction_covered * cell.area * height_avg; } - } else if (simulationType == Slic3r::ExtrusionSimulationSpreadExcess) { + } else if (simulationType == ExtrusionSimulationSpreadExcess) { // The volume under the circle does not fit. // 1) Fill the underfilled cells and remove them from the list. float volume_borrowed_total = 0.; @@ -881,8 +866,6 @@ inline std::vector<V3uc> CreatePowerColorGradient24bit() return out; } -namespace Slic3r { - class ExtrusionSimulatorImpl { public: std::vector<unsigned char> image_data; |