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

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukáš Hejl <hejl.lukas@gmail.com>2022-08-11 23:44:05 +0300
committersupermerill <merill@free.fr>2022-09-13 17:22:27 +0300
commit2ca5f1b274d2fb1271b92d4fb6c6627c79b17b39 (patch)
tree16e04db4be87fa4ba0f979ade89300b51ab28400
parent19988c1a160754c83a2faf074dabe01c0e18dcf5 (diff)
Reconnected endpoints of closed polyline when PolylineStitcher produced an open polyline mark as closed.
-rw-r--r--src/libslic3r/Arachne/WallToolPaths.cpp8
-rw-r--r--tests/libslic3r/test_arachne.cpp31
2 files changed, 18 insertions, 21 deletions
diff --git a/src/libslic3r/Arachne/WallToolPaths.cpp b/src/libslic3r/Arachne/WallToolPaths.cpp
index 27fe9159f..556747b14 100644
--- a/src/libslic3r/Arachne/WallToolPaths.cpp
+++ b/src/libslic3r/Arachne/WallToolPaths.cpp
@@ -615,6 +615,14 @@ void WallToolPaths::stitchToolPaths(std::vector<VariableWidthLines> &toolpaths,
{
continue;
}
+
+ // PolylineStitcher, in some cases, produced closed extrusion (polygons),
+ // but the endpoints differ by a small distance. So we reconnect them.
+ // FIXME Lukas H.: Investigate more deeply why it is happening.
+ if (wall_polygon.junctions.front().p != wall_polygon.junctions.back().p &&
+ (wall_polygon.junctions.back().p - wall_polygon.junctions.front().p).cast<double>().norm() < stitch_distance) {
+ wall_polygon.junctions.emplace_back(wall_polygon.junctions.front());
+ }
wall_polygon.is_closed = true;
wall_lines.push_back(std::move(wall_polygon)); // add stitched polygons to result
}
diff --git a/tests/libslic3r/test_arachne.cpp b/tests/libslic3r/test_arachne.cpp
index c8ea262fe..7ef5eda14 100644
--- a/tests/libslic3r/test_arachne.cpp
+++ b/tests/libslic3r/test_arachne.cpp
@@ -33,30 +33,19 @@ static void draw_extrusion(const std::string &path, const Polygons &polygons, co
TEST_CASE("Arachne - Closed ExtrusionLine", "[ArachneClosedExtrusionLine]") {
Polygon poly = {
- Point(62478540, -7411873), Point(62478540, 9978540), Point(-62478540, 9978540), Point(-62478540, -7411873), Point(-58818049, -7411874),
- Point(-58639424, -7393054), Point(-58430204, -7325743), Point(-58317958, -7261069), Point(-58187096, -7150294), Point(-58032997, -6934055),
- Point(-57956770, -6723830), Point(-57927922, -6536131), Point(-57948215, -6249353), Point(-58038066, -5971432), Point(-58400146, -5419566),
- Point(-58720844, -4711417), Point(-58812247, -4429032), Point(-58945877, -3868129), Point(-58999054, -3458536), Point(-59021495, -3000104),
- Point(-58978088, -2345755), Point(-58945641, -2130557), Point(-58719408, -1284462), Point(-58350699, -492550), Point(-57854519, 218384),
- Point(-57690839, 403070), Point(-57242241, 834472), Point(-56937894, 1068372), Point(-56522699, 1341801), Point(-56245930, 1488656),
- Point(-55633586, 1748152), Point(-54872819, 1945077), Point(-54279560, 2011550), Point(-53999789, 2021482), Point(-53550613, 1995780),
- Point(-53127364, 1945077), Point(-52852060, 1886312), Point(-52262142, 1711199), Point(-51479386, 1343079), Point(-50763215, 839141),
- Point(-50302640, 384003), Point(-50150730, 224721), Point(-49616021, -551391), Point(-49279548, -1287513), Point(-49210805, -1492871),
- Point(-49054178, -2131559), Point(-49004097, -2510916), Point(-48978506, -2999863), Point(-49012690, -3563440), Point(-49054263, -3868963),
- Point(-49280289, -4714703), Point(-49649307, -5507428), Point(-49921685, -5909300), Point(-49982145, -6037568), Point(-50058406, -6311890),
- Point(-50071436, -6450122), Point(-50045218, -6724784), Point(-50006267, -6852153), Point(-49876677, -7082551), Point(-49687434, -7260679),
- Point(-49451449, -7373245), Point(-49184639, -7411873), Point(-13258854, -7411871), Point(-13258853, -7021460), Point(-44501672, -7021460),
- Point(-44816622, -6971390), Point(-45100558, -6826592), Point(-45326629, -6600516), Point(-45471725, -6315721), Point(-45521460, -6001689),
- Point(-45521460, 3000836), Point(-45509082, 3159381), Point(-45412385, 3459576), Point(-45326445, 3600421), Point(-45221777, 3722975),
- Point(-44964550, 3909861), Point(-44815338, 3971666), Point(-44598502, 4016264), Point(58501687, 4021460), Point(58814884, 3971856),
- Point(58964551, 3909863), Point(59221777, 3722976), Point(59326668, 3600164), Point(59436707, 3406438), Point(59508907, 3160338),
- Point(59521460, 3000842), Point(59521460, -6001688), Point(59471724, -6315713), Point(59326597, -6600557), Point(59100555, -6826595),
- Point(58814822, -6971976), Point(58501662, -7021460), Point(27258850, -7021460), Point(27258851, -7411871), Point(59755385, -7411874),
+ Point(-40000000, 10000000),
+ Point(-62480000, 10000000),
+ Point(-62480000, -7410000),
+ Point(-58430000, -7330000),
+ Point(-58400000, -5420000),
+ Point(-58720000, -4710000),
+ Point(-58940000, -3870000),
+ Point(-59020000, -3000000),
};
Polygons polygons = {poly};
coord_t spacing = 407079;
- coord_t inset_count = 8;
+ coord_t inset_count = 5;
Arachne::WallToolPaths wallToolPaths(polygons, spacing, spacing, inset_count, 0, 0.2, PrintObjectConfig::defaults(), PrintConfig::defaults());
wallToolPaths.generate();
@@ -69,7 +58,7 @@ TEST_CASE("Arachne - Closed ExtrusionLine", "[ArachneClosedExtrusionLine]") {
for (VariableWidthLines &perimeter : perimeters)
for (ExtrusionLine &el : perimeter)
if (el.is_closed) {
-// REQUIRE(el.junctions.front().p == el.junctions.back().p);
+ REQUIRE(el.junctions.front().p == el.junctions.back().p);
}
}