Add a Sparse infill only mode to Arc fitting (#16747)

This commit is contained in:
Ian Bassi authored and GitHub committed 2026-10-22 12:51:44 -03:00
1 parent 3f8ff53e65
commit 373ffaa13f
13 files changed
+114 -61

No files matched your search

+37
View File
@@ -16,9 +16,12 @@
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include <cstddef>
#include <fstream>
#include <ios>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <catch2/matchers/catch_matchers.hpp>
@@ -213,6 +216,40 @@ TEST_CASE("Object label comments number each object and copy with or without exc
}
}
TEST_CASE("Sparse infill only arc fitting emits arcs in the sparse infill alone", "[GCode]")
{
const auto arcs_per_type = [](const char *arc_fitting) {
// 360 facets keep the walls and the concentric infill within the resolution of a circle, so both fit arcs.
const std::string gcode = Test::slice({ make_cylinder(25.0, 10.0, 2.0 * PI / 360.0) }, {
{ "enable_arc_fitting", arc_fitting },
{ "sparse_infill_pattern", "concentric" },
{ "sparse_infill_density", "20%" },
{ "z_hop", "0" },
});
std::map<std::string, size_t> arcs;
std::istringstream input(gcode);
std::string line, type;
while (std::getline(input, line)) {
if (line.rfind(";TYPE:", 0) == 0)
type = line.substr(6);
else if (line.rfind("G2 ", 0) == 0 || line.rfind("G3 ", 0) == 0)
++arcs[type];
}
return arcs;
};
CHECK(arcs_per_type("enabled").count("Outer wall") == 1);
const std::map<std::string, size_t> sparse_only = arcs_per_type("sparse_infill");
CHECK(sparse_only.count("Sparse infill") == 1);
for (const auto &[type, count] : sparse_only) {
INFO(type << ": " << count << " arcs");
CHECK(type == "Sparse infill");
}
CHECK(arcs_per_type("disabled").empty());
}
TEST_CASE("An exported G-code's settings load back as the settings it was sliced with", "[GCode]")
{
// Two filaments, so the config block carries the flush matrix already multiplied by flush_multiplier.