From 6b2b2798890e34eff7ff148c7c38b6b90988472b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 12 Sep 2017 18:20:06 +0200 Subject: [PATCH] Fix of "exponentional values generated as G1 F-1.95058e+006 causing problems" https://github.com/prusa3d/Slic3r/issues/463 --- xs/src/libslic3r/Flow.cpp | 8 ++++++-- xs/src/libslic3r/GCodeWriter.cpp | 3 +++ xs/src/slic3r/GUI/3DScene.hpp | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/xs/src/libslic3r/Flow.cpp b/xs/src/libslic3r/Flow.cpp index 1f787f50e..25a44ea8f 100644 --- a/xs/src/libslic3r/Flow.cpp +++ b/xs/src/libslic3r/Flow.cpp @@ -131,9 +131,13 @@ float Flow::spacing(const Flow &other) const // This method returns extrusion volume per head move unit. double Flow::mm3_per_mm() const { - return this->bridge ? + double res = this->bridge ? + // Area of a circle with dmr of this->width. (this->width * this->width) * 0.25 * PI : - this->width * this->height + 0.25 * (this->height * this->height) / (PI - 4.0); + // Rectangle with semicircles at the ends. ~ h (w - 0.215 h) + this->height * (this->width - this->height * (1. - 0.25 * PI)); + assert(res > 0.); + return res; } Flow support_material_flow(const PrintObject *object, float layer_height) diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp index 40500d084..abf55114b 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #define FLAVOR_IS(val) this->config.gcode_flavor == val #define FLAVOR_IS_NOT(val) this->config.gcode_flavor != val @@ -259,6 +260,8 @@ std::string GCodeWriter::toolchange(unsigned int extruder_id) std::string GCodeWriter::set_speed(double F, const std::string &comment, const std::string &cooling_marker) const { + assert(F > 0.); + assert(F < 100000.); std::ostringstream gcode; gcode << "G1 F" << F; COMMENT(comment); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 850b72000..27eeb7ca8 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -158,6 +158,7 @@ public: BoundingBoxf3 bounding_box() const { BoundingBoxf3 bbox; if (! this->vertices_and_normals_interleaved.empty()) { + bbox.defined = true; bbox.min.x = bbox.max.x = this->vertices_and_normals_interleaved[3]; bbox.min.y = bbox.max.y = this->vertices_and_normals_interleaved[4]; bbox.min.z = bbox.max.z = this->vertices_and_normals_interleaved[5];