From cf030e89580e815f4ba622db1f8449213f124c62 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 8 Oct 2019 14:04:50 +0200 Subject: [PATCH] Simplified inclusion of the wipe tower into skirt calculation --- src/libslic3r/GCode/PrintExtents.cpp | 37 ---------------------------- src/libslic3r/GCode/PrintExtents.hpp | 4 --- src/libslic3r/Print.cpp | 13 +++++++--- 3 files changed, 9 insertions(+), 45 deletions(-) diff --git a/src/libslic3r/GCode/PrintExtents.cpp b/src/libslic3r/GCode/PrintExtents.cpp index ed1d097e1..d44ef1aad 100644 --- a/src/libslic3r/GCode/PrintExtents.cpp +++ b/src/libslic3r/GCode/PrintExtents.cpp @@ -160,43 +160,6 @@ BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_ return bbox; } -// Returns a vector of points of a projection of the wipe tower for the layers <= max_print_z. -// The projection does not contain the priming regions. -std::vector get_wipe_tower_extrusions_points(const Print &print, const coordf_t max_print_z) -{ - // Wipe tower extrusions are saved as if the tower was at the origin with no rotation - // We need to get position and angle of the wipe tower to transform them to actual position. - Transform2d trafo = - Eigen::Translation2d(print.config().wipe_tower_x.value, print.config().wipe_tower_y.value) * - Eigen::Rotation2Dd(Geometry::deg2rad(print.config().wipe_tower_rotation_angle.value)); - - BoundingBoxf bbox; - for (const std::vector &tool_changes : print.wipe_tower_data().tool_changes) { - if (!tool_changes.empty() && tool_changes.front().print_z > max_print_z) - break; - for (const WipeTower::ToolChangeResult &tcr : tool_changes) { - for (size_t i = 1; i < tcr.extrusions.size(); ++i) { - const WipeTower::Extrusion &e = tcr.extrusions[i]; - if (e.width > 0) { - Vec2d delta = 0.5 * Vec2d(e.width, e.width); - Vec2d p1 = Vec2d((&e - 1)->pos.x(), (&e - 1)->pos.y()); - Vec2d p2 = Vec2d(e.pos.x(), e.pos.y()); - bbox.merge(p1.cwiseMin(p2) - delta); - bbox.merge(p1.cwiseMax(p2) + delta); - } - } - } - } - - std::vector points; - points.push_back(trafo * Vec2d(bbox.min.x(), bbox.max.y())); - points.push_back(trafo * Vec2d(bbox.max.x(), bbox.max.y())); - points.push_back(trafo * Vec2d(bbox.max.x(), bbox.min.y())); - points.push_back(trafo * Vec2d(bbox.min.x(), bbox.min.y())); - - return points; -} - // Returns a bounding box of the wipe tower priming extrusions. BoundingBoxf get_wipe_tower_priming_extrusions_extents(const Print &print) { diff --git a/src/libslic3r/GCode/PrintExtents.hpp b/src/libslic3r/GCode/PrintExtents.hpp index cb60c939b..db507689d 100644 --- a/src/libslic3r/GCode/PrintExtents.hpp +++ b/src/libslic3r/GCode/PrintExtents.hpp @@ -22,10 +22,6 @@ BoundingBoxf get_print_object_extrusions_extents(const PrintObject &print_object // The projection does not contain the priming regions. BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_t max_print_z); -// Returns a vector of points of a projection of the wipe tower for the layers <= max_print_z. -// The projection does not contain the priming regions. -std::vector get_wipe_tower_extrusions_points(const Print &print, const coordf_t max_print_z); - // Returns a bounding box of the wipe tower priming extrusions. BoundingBoxf get_wipe_tower_priming_extrusions_extents(const Print &print); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index e7e813164..88645df15 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -11,7 +11,6 @@ #include "SupportMaterial.hpp" #include "GCode.hpp" #include "GCode/WipeTower.hpp" -#include "GCode/PrintExtents.hpp" #include "Utils.hpp" //#include "PrintExport.hpp" @@ -1607,9 +1606,15 @@ void Print::_make_skirt() } // Include the wipe tower. - if (has_wipe_tower()) - for (const Vec2d& point : get_wipe_tower_extrusions_points(*this, skirt_height_z)) - points.push_back(Point(scale_(point.x()), scale_(point.y()))); + if (has_wipe_tower() && ! m_wipe_tower_data.tool_changes.empty()) { + double width = m_config.wipe_tower_width + 2*m_wipe_tower_data.brim_width; + double depth = m_wipe_tower_data.depth + 2*m_wipe_tower_data.brim_width; + Vec2d pt = Vec2d(m_config.wipe_tower_x-m_wipe_tower_data.brim_width, m_config.wipe_tower_y-m_wipe_tower_data.brim_width); + points.push_back(Point(scale_(pt.x()), scale_(pt.y()))); + points.push_back(Point(scale_(pt.x()+width), scale_(pt.y()))); + points.push_back(Point(scale_(pt.x()+width), scale_(pt.y()+depth))); + points.push_back(Point(scale_(pt.x()), scale_(pt.y()+depth))); + } if (points.size() < 3) // At least three points required for a convex hull.