Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Matena <lukasmatena@seznam.cz>2021-12-14 14:23:31 +0300
committerLukas Matena <lukasmatena@seznam.cz>2021-12-14 14:23:31 +0300
commit02755b64e35b079ce551ad0b2f3451aeb71d6219 (patch)
tree48329269309a0196814783b8be22c9e791676c48
parentdc3da0b626261c3023515034fe4342350d5a9651 (diff)
Fixed inward move after external perimeterslm_seam_hook
-rw-r--r--src/libslic3r/GCode.cpp15
-rw-r--r--src/libslic3r/Point.cpp4
2 files changed, 9 insertions, 10 deletions
diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp
index bd14e0a0b..92d269418 100644
--- a/src/libslic3r/GCode.cpp
+++ b/src/libslic3r/GCode.cpp
@@ -2598,22 +2598,21 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
m_wipe.path = paths.front().polyline; // TODO: don't limit wipe to last path
// make a little move inwards before leaving loop
- if (paths.back().role() == erExternalPerimeter && m_layer != NULL && m_config.perimeters.value > 1 && paths.front().size() >= 2 && paths.back().polyline.points.size() >= 3) {
+ if (paths.back().role() == erExternalPerimeter && m_layer != NULL && m_config.perimeters.value > 1 && paths.front().size() >= 2 && paths.back().polyline.points.size() >= 2) {
// detect angle between last and first segment
// the side depends on the original winding order of the polygon (left for contours, right for holes)
//FIXME improve the algorithm in case the loop is tiny.
//FIXME improve the algorithm in case the loop is split into segments with a low number of points (see the Point b query).
- Point a = paths.front().polyline.points[1]; // second point
- Point b = *(paths.back().polyline.points.end()-3); // second to last point
- if (was_clockwise) {
- // swap points
- Point c = a; a = b; b = c;
- }
+ Point a = paths.front().polyline.points[1]; // second point
+ Point b = *(paths.back().polyline.points.end() - 2); // last but one point
+ if (was_clockwise)
+ std::swap(a, b);
double angle = paths.front().first_point().ccw_angle(a, b) / 3;
// turn left if contour, turn right if hole
- if (was_clockwise) angle *= -1;
+ if (was_clockwise)
+ angle *= -1;
// create the destination point along the first segment and rotate it
// we make sure we don't exceed the segment length because we don't know
diff --git a/src/libslic3r/Point.cpp b/src/libslic3r/Point.cpp
index b2427d46d..9b829468d 100644
--- a/src/libslic3r/Point.cpp
+++ b/src/libslic3r/Point.cpp
@@ -132,8 +132,8 @@ double Point::ccw(const Line &line) const
double Point::ccw_angle(const Point &p1, const Point &p2) const
{
//FIXME this calculates an atan2 twice! Project one vector into the other!
- double angle = atan2(p1.x() - (*this).x(), p1.y() - (*this).y())
- - atan2(p2.x() - (*this).x(), p2.y() - (*this).y());
+ double angle = atan2(p2.y() - (*this).y(), p2.x() - (*this).x())
+ - atan2(p1.y() - (*this).y(), p1.x() - (*this).x());
// we only want to return only positive angles
return angle <= 0 ? angle + 2*PI : angle;
}