Merge branch 'main' into main

This commit is contained in:
Rodrigo Faselli
2026-10-03 14:41:20 -03:00
committed by GitHub
892 changed files with 7766 additions and 368 deletions
+29 -10
View File
@@ -1,11 +1,13 @@
#!/usr/bin/env bash
# End-to-end check that the CLI loads a project's printer and process settings as the GUI does.
# End-to-end check that the CLI loads a project's printer, process and filament settings as the GUI does.
#
# The GUI takes every key a project does not list as changed from the project's current system preset:
# keys saved before an option existed, and keys holding an older system value. Keys the project lists
# in different_settings_to_system keep the project's value. A project is exported from the shipped
# Bambu Lab P1S presets; one printer key and one process key are removed, one printer key and one
# process key are changed without being listed, one key is changed and listed, and it is sliced again.
# Bambu Lab P1S presets with two filaments; one printer key and one process key are removed, one printer
# key, one process key and two filament keys (one per filament, one per extruder variant) are changed
# without being listed, one process key and the first filament's density are changed and listed, and it
# is sliced again: as is, with --uptodate, and with --load-filaments replacing only the second filament.
#
# usage: test_cli_project_missing_keys.sh <orca-slicer binary> <python3> <resources/profiles/BBL>
set -u
@@ -45,7 +47,7 @@ slice() {
slice base "$WORK/cube.stl" \
--load-settings "$PROFILES/machine/Bambu Lab P1S 0.4 nozzle.json;$PROFILES/process/0.20mm Standard @BBL X1C.json" \
--load-filaments "$PROFILES/filament/Bambu PLA Basic @BBL P1S 0.4 nozzle.json"
--load-filaments "$PROFILES/filament/Bambu PLA Basic @BBL P1S 0.4 nozzle.json;$PROFILES/filament/Bambu PLA Basic @BBL P1S 0.4 nozzle.json"
# The removed keys, with their option defaults from PrintConfig.cpp; stale keys changed without being
# listed as different, which must come back with the system value; and a listed key the project keeps.
@@ -67,30 +69,47 @@ with zipfile.ZipFile(src) as zin, zipfile.ZipFile(dst, "w", zipfile.ZIP_DEFLATED
for key in ("top_shell_layers", "extruder_clearance_height_to_rod"):
expected[key] = config[key]
config[key] = str(int(float(config[key])) + 1)
for key in ("filament_cost", "filament_max_volumetric_speed"):
expected[key] = config[key]
config[key] = [str(float(v) + 1) for v in config[key]]
expected["wall_loops"] = str(int(config["wall_loops"]) + 1)
config["wall_loops"] = expected["wall_loops"]
expected["filament_density"] = [str(float(config["filament_density"][0]) + 1)] + config["filament_density"][1:]
config["filament_density"] = [expected["filament_density"][0]] + [str(float(v) + 1) for v in config["filament_density"][1:]]
# One entry for the process, one per filament, one for the printer.
different = config["different_settings_to_system"]
different[0] = ";".join([k for k in different[0].split(";") if k] + ["wall_loops"])
different[1] = ";".join([k for k in different[1].split(";") if k] + ["filament_density"])
data = json.dumps(config, indent=4)
zout.writestr(item, data)
with open(dst + ".expected.json", "w") as f:
json.dump(expected, f)
EOF
slice project "$WORK/old.3mf"
"$PY" - "$WORK/project/out.3mf" "$WORK/old.3mf.expected.json" <<'EOF'
check() {
if ! "$PY" - "$WORK/$1/out.3mf" "$WORK/old.3mf.expected.json" "$1" <<'EOF'
import json, sys, zipfile
with zipfile.ZipFile(sys.argv[1]) as z:
config = json.loads(z.read("Metadata/project_settings.config"))
with open(sys.argv[2]) as f:
expected = json.load(f)
errors = ["%s is %r, want %r" % (key, config.get(key), want) for key, want in expected.items() if config.get(key) != want]
errors = ["%s: %s is %r, want %r" % (sys.argv[3], key, config.get(key), want) for key, want in expected.items() if config.get(key) != want]
for e in errors:
print("FAIL: " + e)
sys.exit(1 if errors else 0)
EOF
status=$?
[ "$status" -eq 0 ] || { tail -n 40 "$WORK/project/log"; exit 1; }
then
tail -n 40 "$WORK/$1/log"
exit 1
fi
}
slice project "$WORK/old.3mf"
check project
slice uptodate "$WORK/old.3mf" --uptodate
check uptodate
# The replaced second filament takes the system values the refresh would have given it.
slice partial "$WORK/old.3mf" --load-filaments ";$PROFILES/filament/Bambu PLA Basic @BBL P1S 0.4 nozzle.json"
check partial
echo "PASS"
+6
View File
@@ -1,10 +1,16 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "test_helpers.hpp"
#include <algorithm>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/libslic3r.h"
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace Slic3r;
@@ -1,7 +1,12 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <cstdlib>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include "libslic3r/ExtrusionEntityCollection.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Point.hpp"
@@ -1,6 +1,13 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>
#include "libslic3r/AABBTreeLines.hpp"
#include "libslic3r/GCode.hpp"
#include "libslic3r/GCode/ExtrusionProcessor.hpp"
#include "libslic3r/GCodeReader.hpp"
#include "libslic3r/TriangleMesh.hpp"
@@ -9,7 +16,17 @@
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include "libslic3r/Line.hpp"
#include "libslic3r/Point.hpp"
#include <cstddef>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Print.hpp"
#include "libslic3r/Model.hpp"
#include <string>
#include <string_view>
#include <vector>
using namespace Slic3r;
@@ -524,6 +541,187 @@ TEST_CASE("A wall is left whole where neither its speed nor its cooling changes"
REQUIRE(points.size() == 3);
}
namespace {
// The caged overhang box, sliced, and a layer on its slope.
struct SlicedCage
{
Print print;
Model model;
const PrintObject *object{nullptr};
const Layer *layer{nullptr};
explicit SlicedCage(const DynamicPrintConfig &config = caged_overhang_config("classic"))
{
init_print(std::vector<TriangleMesh>{caged_overhang_mesh()}, print, model, config, nullptr, false);
print.process();
object = print.objects().front();
layer = object->get_layer(int(std::lround((caged_slope_z_min + caged_slope_z_max) / 2. / caged_layer_height)));
}
};
using Walls = std::vector<std::vector<ProcessedPoint>>;
// Estimates every wall of `layer` against whatever layer `estimator` was last prepared with before it.
Walls estimate_walls(ExtrusionQualityEstimator &estimator, const PrintObject *object, const Layer &layer)
{
const ConfigOptionPercents overlaps({90, 75, 50, 25, 13, 0});
const ConfigOptionFloatsOrPercents speeds({FloatOrPercent{100, true}, FloatOrPercent{50, true}, FloatOrPercent{30, true},
FloatOrPercent{20, true}, FloatOrPercent{10, true}, FloatOrPercent{5, true}});
Walls walls;
estimator.set_current_object(object);
for (const LayerRegion *region : layer.regions())
for_each_extrusion_path(region->perimeters, [&](const ExtrusionPath &path) {
if (is_perimeter(path.role()))
walls.push_back(estimator.estimate_extrusion_quality(path, overlaps, speeds, caged_outer_wall_speed, caged_outer_wall_speed,
true, 0.5f));
});
return walls;
}
uint32_t float_bits(float value)
{
uint32_t bits;
std::memcpy(&bits, &value, sizeof(bits));
return bits;
}
bool same_point(const ProcessedPoint &a, const ProcessedPoint &b)
{
return a.p == b.p && float_bits(a.speed) == float_bits(b.speed) && float_bits(a.overlap) == float_bits(b.overlap);
}
// Requires the walls to match point for point, bit for bit.
void check_identical(const Walls &actual, const Walls &expected)
{
REQUIRE(actual.size() == expected.size());
for (size_t wall = 0; wall < actual.size(); ++wall) {
INFO("wall " << wall);
REQUIRE(actual[wall].size() == expected[wall].size());
for (size_t i = 0; i < actual[wall].size(); ++i) {
const ProcessedPoint &a = actual[wall][i];
const ProcessedPoint &e = expected[wall][i];
INFO("point " << i << ": speed " << a.speed << " vs " << e.speed << ", overlap " << a.overlap << " vs " << e.overlap);
CHECK(a.p == e.p);
CHECK(float_bits(a.speed) == float_bits(e.speed));
CHECK(float_bits(a.overlap) == float_bits(e.overlap));
}
}
}
bool any_difference(const Walls &a, const Walls &b)
{
return !std::equal(a.begin(), a.end(), b.begin(), b.end(), [](const std::vector<ProcessedPoint> &wa, const std::vector<ProcessedPoint> &wb) {
return std::equal(wa.begin(), wa.end(), wb.begin(), wb.end(), same_point);
});
}
bool any_slowed(const Walls &walls)
{
return std::any_of(walls.begin(), walls.end(), [](const std::vector<ProcessedPoint> &wall) {
return std::any_of(wall.begin(), wall.end(), [](const ProcessedPoint &point) { return point.speed < caged_outer_wall_speed; });
});
}
} // namespace
TEST_CASE("Overhang data computed ahead of the generator gives the same wall speeds", "[ExtrusionProcessor]")
{
const SlicedCage cage;
REQUIRE(cage.layer->lower_layer != nullptr);
ExtrusionQualityEstimator queried;
queried.prepare_for_new_layer(cage.object, cage.layer->lower_layer);
queried.prepare_for_new_layer(cage.object, cage.layer);
const Walls expected = estimate_walls(queried, cage.object, *cage.layer);
REQUIRE(any_slowed(expected));
ExtrusionQualityEstimator precomputed;
precomputed.prepare_for_new_layer(cage.object, cage.layer->lower_layer);
precomputed.set_precomputed_layers({precompute_overhang_layer(cage.object, *cage.layer)});
precomputed.prepare_for_new_layer(cage.object, cage.layer);
check_identical(estimate_walls(precomputed, cage.object, *cage.layer), expected);
}
TEST_CASE("Overhang distances measured against another layer than the previous one are not used", "[ExtrusionProcessor]")
{
const SlicedCage cage;
const Layer *two_below = cage.layer->lower_layer->lower_layer;
REQUIRE(two_below != nullptr);
ExtrusionQualityEstimator queried;
queried.prepare_for_new_layer(cage.object, two_below);
queried.prepare_for_new_layer(cage.object, cage.layer);
const Walls expected = estimate_walls(queried, cage.object, *cage.layer);
ExtrusionQualityEstimator one_below;
one_below.prepare_for_new_layer(cage.object, cage.layer->lower_layer);
one_below.prepare_for_new_layer(cage.object, cage.layer);
REQUIRE(any_difference(estimate_walls(one_below, cage.object, *cage.layer), expected));
ExtrusionQualityEstimator precomputed;
precomputed.prepare_for_new_layer(cage.object, two_below);
precomputed.set_precomputed_layers({precompute_overhang_layer(cage.object, *cage.layer)});
precomputed.prepare_for_new_layer(cage.object, cage.layer);
check_identical(estimate_walls(precomputed, cage.object, *cage.layer), expected);
}
TEST_CASE("Overhang data computed for another layer is not used", "[ExtrusionProcessor]")
{
const SlicedCage cage;
const Layer *one_below = cage.layer->lower_layer;
REQUIRE(one_below != nullptr);
REQUIRE(one_below->lower_layer != nullptr);
ExtrusionQualityEstimator queried;
queried.prepare_for_new_layer(cage.object, one_below);
queried.prepare_for_new_layer(cage.object, cage.layer);
const Walls expected = estimate_walls(queried, cage.object, *cage.layer);
ExtrusionQualityEstimator two_below;
two_below.prepare_for_new_layer(cage.object, one_below->lower_layer);
two_below.prepare_for_new_layer(cage.object, cage.layer);
REQUIRE(any_difference(estimate_walls(two_below, cage.object, *cage.layer), expected));
ExtrusionQualityEstimator precomputed;
precomputed.set_precomputed_layers({precompute_overhang_layer(cage.object, *one_below)});
precomputed.prepare_for_new_layer(cage.object, one_below);
precomputed.prepare_for_new_layer(cage.object, cage.layer);
check_identical(estimate_walls(precomputed, cage.object, *cage.layer), expected);
}
TEST_CASE("Precomputed overhang data has the curled-line tree exactly when a region slows down for curled perimeters", "[ExtrusionProcessor]")
{
const bool slowdown = GENERATE(false, true);
DynamicPrintConfig config = caged_overhang_config("classic");
config.set_deserialize_strict("slowdown_for_curled_perimeters", slowdown ? "1" : "0");
const SlicedCage cage(config);
GCode::LayerToPrint layer;
layer.object_layer = cage.layer;
layer.original_object = cage.object;
const std::vector<PrecomputedOverhangLayer> precomputed = precompute_overhang_layers({layer}, false);
REQUIRE(precomputed.size() == 1);
CHECK((precomputed.front().lower_curled_lines != nullptr) == slowdown);
}
TEST_CASE("Caged external overhangs are slowed when printed by object or through the pressure equalizer", "[ExtrusionProcessor]")
{
const auto [key, value] = GENERATE(table<const char *, const char *>({
{"print_sequence", "by object"},
{"max_volumetric_extrusion_rate_slope", "10"},
}));
INFO(key << " = " << value);
DynamicPrintConfig config = caged_overhang_config("classic");
config.set_deserialize_strict(key, value);
Print print;
Model model;
init_print(std::vector<TriangleMesh>{caged_overhang_mesh()}, print, model, config, nullptr, false);
const std::vector<double> feed_rates = caged_slope_feed_rates(gcode(print));
info_feed_rates("caged slope", feed_rates);
REQUIRE_FALSE(feed_rates.empty());
REQUIRE(*std::max_element(feed_rates.begin(), feed_rates.end()) < caged_slow_speed * MM_PER_MIN);
}
TEST_CASE("Benchmark caged overhang interior sampling", "[ExtrusionProcessor][!benchmark]"){
const char* wall_generator = GENERATE("classic", "arachne");
+22
View File
@@ -2,13 +2,35 @@
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <functional>
#include "libslic3r/Fill/FillBase.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/Surface.hpp"
#include "libslic3r/Point.hpp"
#include <iterator>
#include "libslic3r/Polygon.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Line.hpp"
#include "libslic3r/ExPolygon.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <limits>
#include "libslic3r/Model.hpp"
#include <map>
#include <memory>
#include <math.h>
#include <numeric>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/AABBTreeLines.hpp"
#include "libslic3r/Fill/Fill.hpp"
+3
View File
@@ -1,8 +1,11 @@
#include <catch2/catch_all.hpp>
#include <cmath>
#include <numeric>
#include <sstream>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "test_helpers.hpp" // get access to init_print, etc
#include "libslic3r/Config.hpp"
+8
View File
@@ -1,5 +1,9 @@
#include <catch2/catch_all.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/libslic3r.h"
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "libslic3r/MultiNozzleUtils.hpp"
@@ -8,9 +12,13 @@
#include "test_utils.hpp"
#include <cmath>
#include <cstddef>
#include <fstream>
#include <iomanip>
#include "libslic3r/ExtrusionEntity.hpp"
#include <ios>
#include <map>
#include <math.h>
#include <memory>
#include <sstream>
#include <string>
+94
View File
@@ -1,8 +1,15 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/libslic3r.h"
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "libslic3r/Utils.hpp"
#include "test_utils.hpp"
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
@@ -77,3 +84,90 @@ TEST_CASE("Reserved keyword detection reports every offending line", "[GCodeProc
CHECK(tags.empty());
}
}
namespace {
// Closed outer-wall squares, each after a fast travel and before an inner-wall move, so the processor
// records seams and inserts actual speed moves. virtual_moves adds a VG1 move after each square.
void process_squares(int squares, GCodeProcessorResult &result, bool virtual_moves = false)
{
std::ostringstream gcode;
gcode << "M83\nG90\n";
for (int i = 0; i < squares; ++i) {
gcode << "G1 X10 Y10 Z" << 0.2 * (i + 1) << " F12000\n"
<< "; FEATURE: Outer wall\n"
<< "G1 X50 Y10 E2 F3000\nG1 X50 Y50 E2\nG1 X10 Y50 E2\nG1 X10 Y10 E2\n"
<< "; FEATURE: Inner wall\n"
<< "G1 X12 Y12 E0.1\nG1 X30 Y12 E1\n";
if (virtual_moves)
gcode << "VG1 X20 Y30 F12000\n";
}
FullPrintConfig config;
config.gcode_flavor.value = gcfMarlinFirmware;
// s_IsBBLPrinter selects the "; FEATURE: " role tags this G-code uses.
const bool was_bbl_printer = GCodeProcessor::s_IsBBLPrinter;
const ScopeGuard restore_bbl_printer([was_bbl_printer] { GCodeProcessor::s_IsBBLPrinter = was_bbl_printer; });
GCodeProcessor::s_IsBBLPrinter = true;
ScopedTemporaryFile temp(".gcode");
std::ofstream(temp.string()) << gcode.str();
GCodeProcessor processor;
processor.apply_config(config);
processor.process_file(temp.string());
result = std::move(processor.extract_result());
}
bool is_block_move(const GCodeProcessorResult::MoveVertex &move)
{
return !move.internal_only && (move.type == EMoveType::Extrude || move.type == EMoveType::Travel);
}
} // namespace
TEST_CASE("Actual speed moves are inserted on their block's segment just before its move", "[GCodeProcessor]")
{
// 60 squares take several planner passes, which remap the blocks kept between passes.
const int squares = GENERATE(10, 60);
const bool virtual_moves = GENERATE(false, true);
GCodeProcessorResult result;
process_squares(squares, result, virtual_moves);
const auto &moves = result.moves;
constexpr size_t normal = size_t(PrintEstimatedStatistics::ETimeMode::Normal);
size_t inserted = 0;
for (size_t i = 1; i < moves.size(); ++i) {
if (!moves[i].internal_only)
continue;
++inserted;
// Inserted moves have zero time, but a VG1 block's time is written to whatever move its move_id names.
if (!virtual_moves)
CHECK(moves[i].time[normal] == 0.f);
size_t block = i + 1;
while (block < moves.size() && moves[block].internal_only)
++block;
size_t previous = i - 1;
while (previous > 0 && moves[previous].internal_only)
--previous;
REQUIRE(block < moves.size());
CHECK(moves[block].gcode_id == moves[i].gcode_id);
const Vec3f segment = moves[block].position - moves[previous].position;
const Vec3f offset = moves[i].position - moves[previous].position;
CHECK(segment.cross(offset).norm() / segment.norm() < 1e-3f);
}
REQUIRE(inserted > 0);
}
TEST_CASE("A seam takes the actual speed of the move it follows", "[GCodeProcessor]")
{
GCodeProcessorResult result;
// 10 squares fit in one planner pass, so the seam's move and the block after it are timed together.
process_squares(10, result);
const auto &moves = result.moves;
size_t seams = 0;
for (size_t i = 1; i < moves.size(); ++i)
if (moves[i].type == EMoveType::Seam && is_block_move(moves[i - 1])) {
++seams;
CHECK_THAT(moves[i].actual_feedrate, Catch::Matchers::WithinAbs(moves[i - 1].actual_feedrate, 1e-4));
}
REQUIRE(seams > 0);
}
+14
View File
@@ -1,14 +1,28 @@
#include <boost/filesystem/operations.hpp>
#include <catch2/catch_all.hpp>
#include <algorithm>
#include <cstdlib>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Extruder.hpp"
#include "libslic3r/libslic3r.h"
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "nlohmann/json.hpp"
#include "libslic3r/GCodeReader.hpp"
+13
View File
@@ -1,5 +1,6 @@
#include "test_helpers.hpp"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/GCodeReader.hpp"
#include "libslic3r/Config.hpp"
@@ -7,11 +8,23 @@
#include "libslic3r/Format/OBJ.hpp"
#include "libslic3r/Format/STL.hpp"
#include <algorithm>
#include <cstdlib>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Exception.hpp"
#include "libslic3r/PrintConfig.hpp"
#include <initializer_list>
#include "libslic3r/Point.hpp"
#include <fstream>
#include <iterator>
#include <set>
#include <string>
#include <boost/filesystem.hpp>
#include <libslic3r/ModelArrange.hpp>
#include <unordered_map>
#include <utility>
#include <vector>
#include "test_utils.hpp"
+4
View File
@@ -8,6 +8,10 @@
#include "libslic3r/Print.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/libslic3r.h"
#include <cstddef>
#include "libslic3r/PrintConfig.hpp"
#include <initializer_list>
#include <set>
#include <string>
#include <unordered_map>
+11
View File
@@ -1,5 +1,16 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include "libslic3r/PrintConfig.hpp"
#include <string>
#include <cstddef>
#include "libslic3r/Model.hpp"
#include <vector>
#include "libslic3r/Config.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/PrintBase.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/GCode/ToolOrdering.hpp"
#include "libslic3r/MultiNozzleUtils.hpp"
#include "libslic3r/Print.hpp"
+7
View File
@@ -1,10 +1,17 @@
#include <boost/filesystem/operations.hpp>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Model.hpp"
#include "libslic3r/ModelArrange.hpp"
#include <boost/filesystem.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/PrintConfig.hpp"
#include <vector>
#include "libslic3r/Point.hpp"
#include <cstddef>
#include "test_helpers.hpp"
#include "test_utils.hpp"
+128 -36
View File
@@ -1,5 +1,8 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "libslic3r/GCodeReader.hpp"
@@ -12,9 +15,15 @@
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Print.hpp"
#include <limits>
#include <map>
#include <optional>
#include <regex>
#include <set>
#include <sstream>
#include <string>
@@ -1416,6 +1425,47 @@ TEST_CASE("Each filament sets the pressure advance of its extruder variant", "[M
}
}
// A two-extruder printer, Standard nozzle on extruder 1 and High Flow on extruder 2, whose per-variant arrays
// hold filament 1 Standard, filament 1 High Flow, filament 2 Standard and filament 2 High Flow.
static DynamicPrintConfig two_extruder_pressure_advance_config(const std::string &filament_map, const std::string &adaptive_pressure_advance,
int wall_filament, int infill_filament)
{
DynamicPrintConfig config = multifilament_config(2, {
{ "gcode_flavor", "klipper" },
{ "single_extruder_multi_material", 0 },
{ "nozzle_diameter", "0.4,0.4" },
{ "extruder_printable_height", "0,0" },
{ "printer_extruder_id", "1,2" },
{ "printer_extruder_variant", "Direct Drive Standard;Direct Drive High Flow" },
{ "extruder_variant_list", "Direct Drive Standard;Direct Drive High Flow" },
{ "filament_map", filament_map },
{ "filament_extruder_variant", "Direct Drive Standard;Direct Drive High Flow;Direct Drive Standard;Direct Drive High Flow" },
{ "filament_self_index", "1,1,2,2" },
{ "enable_pressure_advance", "1,1,1,1" },
{ "pressure_advance", "0.021,0.037,0.043,0.049" },
{ "adaptive_pressure_advance", adaptive_pressure_advance },
{ "sparse_infill_filament_id", infill_filament },
{ "internal_solid_filament_id", infill_filament },
{ "top_surface_filament_id", infill_filament },
{ "bottom_surface_filament_id", infill_filament },
{ "outer_wall_filament_id", wall_filament },
{ "inner_wall_filament_id", wall_filament },
{ "enable_prime_tower", 0 },
{ "skirt_loops", 0 },
{ "brim_type", "no_brim" },
// custom G-code indexes the per-filament arrays by filament
{ "machine_start_gcode", "; start pressure advance {pressure_advance[initial_extruder]}" },
});
config.option<ConfigOptionStrings>("adaptive_pressure_advance_model")->values = {
constant_pressure_advance_model("0.012"), constant_pressure_advance_model("0.034"),
constant_pressure_advance_model("0.056"), constant_pressure_advance_model("0.078") };
config.option<ConfigOptionEnumsGeneric>("extruder_type", true)->values = { etDirectDrive, etDirectDrive };
config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type", true)->values = { nvtStandard, nvtHighFlow };
// print each filament on the extruder filament_map gives it
config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = fmmManual;
return config;
}
// On a printer with two extruders, a filament takes the pressure advance of the variant of the extruder
// it is mapped to, whichever filament and extruder that is.
TEST_CASE("Each filament sets the pressure advance of its extruder variant on a two-extruder printer", "[MultiFilament]")
@@ -1431,42 +1481,8 @@ TEST_CASE("Each filament sets the pressure advance of its extruder variant on a
// the other filament goes on the other extruder
const std::string filament_map = filament == 1 ? std::to_string(extruder) + "," + std::to_string(3 - extruder) :
std::to_string(3 - extruder) + "," + std::to_string(extruder);
DynamicPrintConfig config = multifilament_config(2, {
{ "gcode_flavor", "klipper" },
{ "single_extruder_multi_material", 0 },
{ "nozzle_diameter", "0.4,0.4" },
{ "extruder_printable_height", "0,0" },
// extruder 1 has a Standard nozzle, extruder 2 a High Flow one
{ "printer_extruder_id", "1,2" },
{ "printer_extruder_variant", "Direct Drive Standard;Direct Drive High Flow" },
{ "extruder_variant_list", "Direct Drive Standard;Direct Drive High Flow" },
{ "filament_map", filament_map },
// both filaments define Standard and High Flow
{ "filament_extruder_variant", "Direct Drive Standard;Direct Drive High Flow;Direct Drive Standard;Direct Drive High Flow" },
{ "filament_self_index", "1,1,2,2" },
{ "enable_pressure_advance", "1,1,1,1" },
{ "pressure_advance", "0.021,0.037,0.043,0.049" },
{ "adaptive_pressure_advance", adaptive ? "1,1,1,1" : "0,0,0,0" },
{ "sparse_infill_filament_id", filament },
{ "internal_solid_filament_id", filament },
{ "top_surface_filament_id", filament },
{ "bottom_surface_filament_id", filament },
{ "outer_wall_filament_id", filament },
{ "inner_wall_filament_id", filament },
{ "enable_prime_tower", 0 },
{ "skirt_loops", 0 },
{ "brim_type", "no_brim" },
// custom G-code indexes the per-filament arrays by filament
{ "machine_start_gcode", "; start pressure advance {pressure_advance[initial_extruder]}" },
});
config.option<ConfigOptionStrings>("adaptive_pressure_advance_model")->values = {
constant_pressure_advance_model("0.012"), constant_pressure_advance_model("0.034"),
constant_pressure_advance_model("0.056"), constant_pressure_advance_model("0.078") };
config.option<ConfigOptionEnumsGeneric>("extruder_type", true)->values = { etDirectDrive, etDirectDrive };
config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type", true)->values = { nvtStandard, nvtHighFlow };
// keep the mapping above rather than grouping the filaments automatically
config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = fmmManual;
const std::string gcode = slice({ cube(20) }, config);
const std::string gcode = slice({ cube(20) },
two_extruder_pressure_advance_config(filament_map, adaptive ? "1,1,1,1" : "0,0,0,0", filament, filament));
std::set<std::string> expected{ pressure_advance };
if (adaptive)
@@ -1476,6 +1492,82 @@ TEST_CASE("Each filament sets the pressure advance of its extruder variant on a
}
}
// Filament 1 prints the walls on extruder 1 (variant index 0), filament 2 the infill on extruder 2 (variant index 3).
TEST_CASE("Adaptive pressure advance on one extruder leaves the other extruder's pressure advance alone", "[MultiFilament]")
{
auto [adaptive, expected] = GENERATE(table<std::string, std::set<std::string>>({
{ "1,0,0,0", { "0.021", "0.049", "0.012" } },
{ "0,0,0,1", { "0.021", "0.049", "0.078" } },
}));
DYNAMIC_SECTION("adaptive " << adaptive) {
const std::string gcode = slice({ cube(20) }, two_extruder_pressure_advance_config("1,2", adaptive, 1, 2));
CHECK(pressure_advance_values(gcode) == expected);
}
}
// The pressure advance values a Klipper G-code sets while `tool` is active, in order, without repeating the value already set.
static std::vector<std::string> pressure_advance_sequence(const std::string &gcode, int tool)
{
const std::string token = "SET_PRESSURE_ADVANCE ADVANCE=";
std::vector<std::string> values;
int current_tool = 0;
std::istringstream stream(gcode);
for (std::string line; std::getline(stream, line);) {
if (line.size() > 1 && line[0] == 'T' && std::isdigit((unsigned char) line[1]))
current_tool = std::stoi(line.substr(1));
else if (current_tool == tool && line.rfind(token, 0) == 0) {
std::string value = line.substr(token.size(), line.find(';') - token.size());
if (values.empty() || values.back() != value)
values.push_back(std::move(value));
}
}
return values;
}
TEST_CASE("Adaptive pressure advance predicts the same values after layers only a non-adaptive extruder prints", "[MultiFilament]")
{
auto slice_with = [](const std::string &adaptive) {
DynamicPrintConfig config = two_extruder_pressure_advance_config("1,2", adaptive, 1, 1);
config.set_deserialize_strict({
{ "print_sequence", "by object" },
// extruder 2 moves at one speed on its first layer, so no G1 F follows its first PA_CHANGE tag
{ "filament_max_volumetric_speed", "100" },
{ "slow_down_for_layer_cooling", "0" },
{ "travel_speed", "120,40" },
{ "retraction_speed", "30,40" },
{ "deretraction_speed", "30,40" },
{ "initial_layer_speed", "30,40" },
{ "initial_layer_infill_speed", "60,40" },
});
auto &models = config.option<ConfigOptionStrings>("adaptive_pressure_advance_model")->values;
// with adaptive pressure advance on, filament 1 gets PA_CHANGE tags on every layer but keeps its pressure advance
models[0] = constant_pressure_advance_model("0.021");
// a prediction that rises with flow, so it depends on the print speed
models[3] = "0.01,1,1000\n0.09,40,1000\n0.01,1,100000\n0.09,40,100000";
return slice_with_object_overrides({ cube(20), cube(20) }, config,
{ {}, { { "outer_wall_filament_id", 2 }, { "inner_wall_filament_id", 2 }, { "sparse_infill_filament_id", 2 },
{ "internal_solid_filament_id", 2 }, { "top_surface_filament_id", 2 }, { "bottom_surface_filament_id", 2 } } });
};
const std::vector<std::string> expected = pressure_advance_sequence(slice_with("1,0,0,1"), 1);
REQUIRE(expected.size() > 2);
CHECK(pressure_advance_sequence(slice_with("0,0,0,1"), 1) == expected);
}
TEST_CASE("Adaptive pressure advance on an unused extruder variant leaves the G-code unchanged", "[MultiFilament]")
{
const std::string adaptive = GENERATE("0,1,0,0", "0,0,1,0");
DYNAMIC_SECTION("adaptive " << adaptive) {
// the time and object ids differ between any two slices, and the config block lists the setting itself
auto masked = [](const std::string &gcode) {
return std::regex_replace(gcode.substr(0, gcode.find("; CONFIG_BLOCK_START")), std::regex("; generated by .*| id:\\d+"), "");
};
const std::string reference = masked(slice({ cube(20) }, two_extruder_pressure_advance_config("1,2", "0,0,0,0", 1, 2)));
const std::string gcode = masked(slice({ cube(20) }, two_extruder_pressure_advance_config("1,2", adaptive, 1, 2)));
REQUIRE(reference.find("SET_PRESSURE_ADVANCE") != std::string::npos);
CHECK(gcode == reference);
}
}
// The speeds, in percent, a G-code turns a fan on at: the part cooling fan for `M106 S`, the auxiliary
// fan for `M106 P2 S`.
static std::set<int> fan_speeds(const std::string &gcode, const std::string &command)
+12
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
#include "libslic3r/Layer.hpp"
@@ -10,8 +15,15 @@
#include <algorithm>
#include <cmath>
#include "libslic3r/PrintConfig.hpp"
#include <cstddef>
#include "libslic3r/libslic3r.h"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/ExPolygon.hpp"
#include "libslic3r/Point.hpp"
#include <limits>
#include <string>
#include <utility>
#include <vector>
#include "test_helpers.hpp"
+15
View File
@@ -1,9 +1,24 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "test_helpers.hpp"
#include "libslic3r/GCode/PreciseSeam.hpp"
#include <algorithm>
#include "libslic3r/Point.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Print.hpp"
#include "libslic3r/Layer.hpp"
#include <vector>
#include <utility>
#include "libslic3r/libslic3r.h"
#include "libslic3r/GCode/SeamPlacer.hpp"
#include <cstddef>
using namespace Slic3r;
+14
View File
@@ -8,6 +8,20 @@
#include <Windows.h>
#endif
#include <catch2/catch_test_macros.hpp>
#include <string>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/generators/catch_generators_range.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/PrintConfig.hpp"
#include <cstddef>
#include "libslic3r/Surface.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/PrintBase.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_all.hpp>
#include "libslic3r/libslic3r.h"
+19
View File
@@ -1,5 +1,11 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Print.hpp"
#include "libslic3r/Layer.hpp"
@@ -10,7 +16,20 @@
#include "test_helpers.hpp"
#include <cmath>
#include <cstddef>
#include <iterator>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Geometry.hpp"
#include "libslic3r/Surface.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/Line.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/BoundingBox.hpp"
#include <map>
#include <set>
#include <string>
+15
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "test_helpers.hpp"
#include "libslic3r/GCode/SeamPlacer.hpp"
#include "libslic3r/Layer.hpp"
@@ -7,6 +12,16 @@
#include <algorithm>
#include <cmath>
#include "libslic3r/Model.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <utility>
#include <cstddef>
#include "libslic3r/Point.hpp"
#include <vector>
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/libslic3r.h"
using namespace Slic3r;
+16
View File
@@ -1,5 +1,11 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/GCodeReader.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Geometry.hpp"
@@ -9,6 +15,16 @@
#include <boost/algorithm/string.hpp>
#include <cmath>
#include <cstddef>
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Polyline.hpp"
#include <string>
#include "libslic3r/Model.hpp"
#include <vector>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/libslic3r.h"
#include <string_view>
#include "test_helpers.hpp" // get access to init_print, etc
@@ -1,4 +1,14 @@
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Config.hpp"
#include "libslic3r/Model.hpp"
#include <cstddef>
#include <string>
#include "libslic3r/Surface.hpp"
#include <utility>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Point.hpp"
#include <catch2/matchers/catch_matchers.hpp>
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "test_helpers.hpp"
using namespace Slic3r;
+16
View File
@@ -1,12 +1,28 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/GCodeReader.hpp"
#include "libslic3r/Layer.hpp"
#include <cmath>
#include <cstddef>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/PrintBase.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/PrintConfig.hpp"
#include <map>
#include <math.h>
#include <mutex>
#include <set>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "test_helpers.hpp" // get access to init_print, etc
@@ -1,10 +1,22 @@
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <catch2/catch_all.hpp>
#include <cstddef>
#include <cstdint>
#include <fstream>
#include <ios>
#include <iterator>
#include <boost/filesystem.hpp>
#include <memory>
#include <vector>
#include <utility>
#include <string>
#include "libslic3r/PrintConfig.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/Model.hpp"
#include "libslic3r/PNGReadWrite.hpp"
#include "libslic3r/Print.hpp"
+8
View File
@@ -1,7 +1,15 @@
#include <catch2/catch_all.hpp>
#include <algorithm>
#include <initializer_list>
#include "libslic3r/Config.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Point.hpp"
#include <cstddef>
#include "libslic3r/libslic3r.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/Layer.hpp"
#include "libslic3r/TriangleMesh.hpp"
+7
View File
@@ -1,5 +1,6 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/TriangleMeshSlicer.hpp"
#include "libslic3r/Point.hpp"
@@ -8,8 +9,14 @@
#include "libslic3r/libslic3r.h"
#include <algorithm>
#include <cstdlib>
#include <cstddef>
#include <cmath>
#include <future>
#include <chrono>
#include <vector>
#include <math.h>
#include "libslic3r/ExPolygon.hpp"
//#include "test_options.hpp"
#include "test_helpers.hpp"
+16
View File
@@ -2,11 +2,27 @@
#include <algorithm>
#include <cmath>
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include <cstddef>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Print.hpp"
#include "libslic3r/calib.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
#include <map>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "libslic3r/GCodeReader.hpp"
#include "libslic3r/PrintConfig.hpp"
+15
View File
@@ -1,8 +1,23 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include "libslic3r/Config.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/Point.hpp"
#include "libslic3r/Polygon.hpp"
#include <cstddef>
#include "libslic3r/Model.hpp"
#include "libslic3r/Print.hpp"
#include <string>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/GCode/GCodeProcessor.hpp"
@@ -2,13 +2,18 @@
#define FG_TEST_EVALUATOR_HPP
#include "fg_test_serialization.hpp"
#include <cstddef>
#include <libslic3r/FilamentGroup.hpp>
#include <libslic3r/GCode/ToolOrderUtils.hpp>
#include <libslic3r/MultiNozzleUtils.hpp>
#include <chrono>
#include <map>
#include <ratio>
#include <sstream>
#include <string>
#include <unordered_set>
#include <vector>
namespace Slic3r {
namespace FGTest {
@@ -1,6 +1,7 @@
#ifndef FG_TEST_SERIALIZATION_HPP
#define FG_TEST_SERIALIZATION_HPP
#include <cstdio>
#include <nlohmann/json.hpp>
#include <libslic3r/FilamentGroup.hpp>
#include <libslic3r/FilamentGroupUtils.hpp>
@@ -10,6 +11,7 @@
#include <fstream>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
+7
View File
@@ -2,9 +2,16 @@
#define FG_TEST_UTILS_HPP
#include "fg_test_serialization.hpp"
#include "libslic3r/FilamentGroupUtils.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/FilamentGroup.hpp"
#include <iterator>
#include <random>
#include <algorithm>
#include <cassert>
#include <vector>
#include <set>
#include <string>
namespace Slic3r {
namespace FGTest {
@@ -11,13 +11,19 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/generators/catch_generators_range.hpp>
#include "fg_test_serialization.hpp"
#include "fg_test_evaluator.hpp"
#include "fg_test_utils.hpp"
#include <cstddef>
#include <filesystem>
#include <iostream>
#include <fstream>
#include "libslic3r/FilamentGroup.hpp"
#include <string>
#include <vector>
#include <algorithm>
+3
View File
@@ -8,7 +8,10 @@
// it here and include this header from every libnest2d test file.
#include <cstdint>
#include <iostream>
#include "libnest2d/common.hpp"
#include "libnest2d/geometry_traits_nfp.hpp"
#include <libnest2d/libnest2d.hpp>
#include <libnest2d/utils/rotcalipers.hpp>
+5
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include "libnest2d/libnest2d.hpp"
#include <vector>
#include <cstddef>
#include "libnest2d/nester.hpp"
#include <catch2/catch_test_macros.hpp>
#include "libnest2d_test_utils.hpp"
using namespace libnest2d;
+1
View File
@@ -1,6 +1,7 @@
#ifndef PRINTER_PARTS_H
#define PRINTER_PARTS_H
#include "libnest2d/backends/libslic3r/geometries.hpp"
#include <vector>
#include <libnest2d/libnest2d.hpp>
+19
View File
@@ -1,5 +1,24 @@
#include <algorithm>
#include <boost/rational.hpp>
#include <boost/multiprecision/fwd.hpp>
#include <catch2/catch_all.hpp>
#include <vector>
#include "libnest2d/libnest2d.hpp"
#include "libnest2d/geometry_traits.hpp"
#include "libnest2d/backends/libslic3r/geometries.hpp"
#include "libnest2d/common.hpp"
#include <type_traits>
#include <cstdlib>
#include "libnest2d/placers/nfpplacer.hpp"
#include <cmath>
#include <cstdint>
#include <limits>
#include <iterator>
#include "libnest2d/utils/rotcalipers.hpp"
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libnest2d_test_utils.hpp"
#include "printer_parts.hpp"
+12
View File
@@ -1,5 +1,17 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include "libnest2d/libnest2d.hpp"
#include <vector>
#include "libnest2d/geometry_traits.hpp"
#include "libnest2d/backends/libslic3r/geometries.hpp"
#include "libnest2d/geometry_traits_nfp.hpp"
#include "libnest2d/utils/boost_alg.hpp"
#include "libnest2d/placers/nfpplacer.hpp"
#include <iterator>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libnest2d_test_utils.hpp"
using namespace libnest2d;
+8
View File
@@ -1,5 +1,13 @@
#include <catch2/catch_all.hpp>
#include "libnest2d/libnest2d.hpp"
#include <vector>
#include <cstddef>
#include "libnest2d/geometry_traits.hpp"
#include "libnest2d/common.hpp"
#include <catch2/catch_message.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libnest2d_test_utils.hpp"
using namespace libnest2d;
+5
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include <vector>
#include "libslic3r/libslic3r.h"
#include <string>
#include <cstdio>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Utils.hpp"
#define NANOSVG_IMPLEMENTATION
#include "nanosvg/nanosvg.h"
+18
View File
@@ -1,4 +1,9 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/Model.hpp"
#include "libslic3r/Format/3mf.hpp"
#include "libslic3r/Format/bbs_3mf.hpp"
@@ -15,6 +20,15 @@
#include "test_utils.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Geometry.hpp"
#include <cstddef>
#include <miniz.h>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/TriangleSelector.hpp"
#include <memory>
#include <cstdint>
#include <ios>
#include <nlohmann/json.hpp>
#include <boost/filesystem/operations.hpp>
@@ -26,8 +40,12 @@
#include <catch2/catch_tostring.hpp>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include <string>
#include <sstream>
#include <type_traits> // for std::enable_if_t
#include <typeinfo> // for typeid
#include <vector>
#include <utility>
namespace Catch {
template <typename T>
+5
View File
@@ -1,8 +1,13 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "test_utils.hpp"
#include <igl/Hit.h>
#include <cstddef>
#include <libslic3r/TriangleMesh.hpp>
#include <libslic3r/AABBTreeIndirect.hpp>
#include <vector>
using namespace Slic3r;
+1
View File
@@ -1,5 +1,6 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/AppConfig.hpp"
using namespace Slic3r;
+11
View File
@@ -17,6 +17,9 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/Arachne/WallToolPaths.hpp"
#include "libslic3r/Arachne/SkeletalTrapezoidation.hpp"
#include "libslic3r/Arachne/utils/ExtrusionLine.hpp"
@@ -31,6 +34,14 @@
#include <algorithm>
#include <cmath>
#include <cstddef>
#include "libslic3r/libslic3r.h"
#include <vector>
#include <utility>
#include <math.h>
#include "libslic3r/Arachne/utils/ExtrusionJunction.hpp"
#include "libslic3r/PerimeterGenerator.hpp"
#include "libslic3r/PrintConfig.hpp"
using namespace Slic3r;
using namespace Slic3r::Arachne;
+14
View File
@@ -1,5 +1,19 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Point.hpp"
#include <string>
#include "libslic3r/Config.hpp"
#include <vector>
#include <limits>
#include <cstddef>
#include <cmath>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/Arrange.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/ClipperUtils.hpp"
@@ -1,5 +1,6 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "slic3r/Utils/bambu_networking.hpp"
using namespace Slic3r;
+5
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include <vector>
#include "libslic3r/Point.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/BuildVolume.hpp"
using namespace Slic3r;
+19
View File
@@ -1,4 +1,23 @@
#include <catch2/catch_message.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <Standard_TypeDef.hxx>
#include <algorithm>
#include <TopAbs_ShapeEnum.hxx>
#include <GeomAbs_CurveType.hxx>
#include <catch2/catch_all.hpp> // mainline OrcaSlicer ships Catch2 v3 (v2 was catch2/catch.hpp)
#include <vector>
#include <math.h>
#include <utility>
#include <sstream>
#include <cstdint>
#include <ios>
#include <iterator>
#include "libslic3r/TriangleMesh.hpp"
#include <exception>
#include <string>
// Substring assertions, spelled so this file compiles UNCHANGED on both forks.
// Catch2 v2 (Snapmaker) spells it Matchers::Contains; v3 (orca_cad / mainline) spells it
+4
View File
@@ -1,9 +1,13 @@
#include <catch2/catch_all.hpp>
#include <algorithm>
#include "libslic3r/CustomGCode.hpp"
#include <sstream>
#include <string>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/calib.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/TriangleMesh.hpp"
+7
View File
@@ -1,8 +1,15 @@
#include <catch2/catch_all.hpp>
#include <cmath>
#include <iostream>
#include <boost/filesystem.hpp>
#include "libslic3r/libslic3r.h"
#include <vector>
#include "libslic3r/Polygon.hpp"
#include <math.h>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/ExPolygon.hpp"
#include "libslic3r/SVG.hpp"
+8
View File
@@ -1,9 +1,17 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Polyline.hpp"
#include <cstddef>
#include "libslic3r/libslic3r.h"
#include <numeric>
#include <iostream>
#include <boost/filesystem.hpp>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/ExPolygon.hpp"
#include "libslic3r/SVG.hpp"
+12
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/PrintConfigConstants.hpp"
#include "libslic3r/LocalesUtils.hpp"
@@ -13,9 +18,16 @@
#include <boost/filesystem.hpp>
#include <boost/nowide/fstream.hpp>
#include "libslic3r/Config.hpp"
#include <memory>
#include <map>
#include <iterator>
#include <nlohmann/json.hpp>
#include <set>
#include <sstream>
#include <vector>
#include <utility>
using namespace Slic3r;
@@ -1,5 +1,15 @@
#include <catch2/catch_all.hpp>
#include "libslic3r/Config.hpp"
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_vector.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_approx.hpp>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Preset.hpp"
+9
View File
@@ -1,12 +1,21 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Format/DRC.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <boost/nowide/fstream.hpp>
#include <draco/attributes/geometry_attribute.h>
#include <cstdint>
#include <draco/attributes/geometry_indices.h>
#include <draco/compression/config/compression_shared.h>
#include <draco/compression/encode.h>
#include <draco/core/draco_types.h>
#include <draco/core/encoder_buffer.h>
#include <draco/mesh/mesh.h>
#include <string>
#include <ios>
#include "test_utils.hpp"
@@ -2,7 +2,11 @@
#include <iostream>
#include <boost/filesystem.hpp>
#include "libslic3r/Point.hpp"
#include <vector>
#include "libslic3r/libslic3r.h"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/ElephantFootCompensation.hpp"
#include "libslic3r/ExPolygon.hpp"
+8
View File
@@ -1,5 +1,13 @@
#include <catch2/catch_all.hpp>
#include <vector>
#include <cstddef>
#include "libslic3r/Config.hpp"
#include <string>
#include <cstdlib>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/FilamentMixer.hpp"
#include "libslic3r/PrintConfig.hpp"
@@ -2,8 +2,12 @@
#include <algorithm>
#include <cmath>
#include "libslic3r/Point.hpp"
#include <cstddef>
#include "libslic3r/Polygon.hpp"
#include <limits>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Fill/FillCornerSmoothing.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/libslic3r.h"
+9
View File
@@ -2,9 +2,18 @@
#include <algorithm>
#include <cmath>
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/Fill/FillBase.hpp"
#include <cstddef>
#include <iterator>
#include "libslic3r/Config.hpp"
#include <limits>
#include <utility>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/Fill/FillPlanePath.hpp"
#include "libslic3r/PrintConfig.hpp"
+10
View File
@@ -1,5 +1,8 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/Point.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Polygon.hpp"
@@ -17,7 +20,14 @@
#include "../libnest2d/printer_parts.hpp"
#include "libslic3r/libslic3r.h"
#include <cstddef>
#include <cstdlib>
#include <math.h>
#include <functional>
#include <string>
#include <unordered_set>
#include <vector>
using namespace Slic3r;
+3
View File
@@ -1,7 +1,10 @@
#include <iostream>
#include <fstream>
#include <catch2/catch_all.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/libslic3r.h"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/SLA/Hollowing.hpp"
#include "test_utils.hpp"
@@ -1,8 +1,17 @@
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <fstream>
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include <limits>
#include <random>
#include <catch2/catch_all.hpp>
#include <vector>
#include <string>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "test_utils.hpp"
+2
View File
@@ -1,3 +1,4 @@
#include <boost/filesystem/operations.hpp>
#include <catch2/catch_all.hpp>
#include <atomic>
@@ -6,6 +7,7 @@
#include <boost/filesystem.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/InstanceLock.hpp"
#include "test_utils.hpp"
+10
View File
@@ -1,5 +1,15 @@
#include <catch2/catch_all.hpp>
#include "libslic3r/Point.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <utility>
#include <vector>
#include "libslic3r/libslic3r.h"
#include <cstddef>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/LayOnFace.hpp"
#include "libslic3r/Model.hpp"
+21
View File
@@ -1,7 +1,9 @@
#include <catch2/catch_all.hpp>
#include <clocale>
#include <locale.h>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/LocalesUtils.hpp"
using namespace Slic3r;
@@ -67,3 +69,22 @@ TEST_CASE("a setter nested in another sets C again when the locale changed betwe
CHECK_FALSE(is_decimal_separator_point());
}
}
TEST_CASE("atof_decimal_point parses what atof parses in the C locale", "[LocalesUtils]")
{
const auto [text, value] = GENERATE(table<const char*, double>({
{ "5", 5. },
{ " 12.5", 12.5 },
{ "\t+3", 3. },
{ "\r\n7", 7. },
{ "-1.25", -1.25 },
{ "1e2", 100. },
{ ".5", 0.5 },
{ "12.5;comment", 12.5 },
{ "+-5", 0. },
{ "", 0. },
{ "abc", 0. },
}));
INFO(text);
CHECK_THAT(atof_decimal_point(text), Catch::Matchers::WithinAbs(value, 1e-12));
}
+22
View File
@@ -2,6 +2,28 @@
#define NOMINMAX
#endif
#include "libslic3r/Point.hpp"
#include <cstddef>
#include "libslic3r/libslic3r.h"
#include <utility>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Polygon.hpp"
#include <algorithm>
#include <iterator>
#include "libslic3r/SLA/RasterBase.hpp"
#include <agg/agg_gamma_functions.h>
#include <vector>
#include <cmath>
#include <string>
#include "libslic3r/ExPolygon.hpp"
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include <cstdlib>
#include <catch2/benchmark/catch_benchmark.hpp>
#include <catch2/catch_all.hpp>
#include "test_utils.hpp"
+2
View File
@@ -1,4 +1,6 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "test_utils.hpp"
#include <libslic3r/TriangleMesh.hpp>
@@ -1,7 +1,11 @@
#include <catch2/catch_all.hpp>
#include <algorithm>
#include <vector>
#include <cstddef>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/MinimumSpanningTree.hpp"
#include "libslic3r/Point.hpp"
+10
View File
@@ -1,5 +1,12 @@
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/file_status.hpp>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/miniz_extension.hpp"
#include "test_utils.hpp"
@@ -7,8 +14,11 @@
#include <boost/filesystem.hpp>
#include <algorithm>
#include <cstddef>
#include <fstream>
#include <ios>
#include <iterator>
#include <miniz.h>
#include <string>
#include <utility>
#include <vector>
+5
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Point.hpp"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Model.hpp"
using namespace Slic3r;
@@ -3,6 +3,12 @@
// MultiMaterialSegmentation.hpp declares boost::polygon traits for ColoredLine, so its
// geometry/boost dependencies must be included first.
#include <boost/polygon/polygon.hpp>
#include <catch2/catch_test_macros.hpp>
#include <string>
#include <vector>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/Line.hpp"
#include "libslic3r/Flow.hpp"
#include "libslic3r/MultiMaterialSegmentation.hpp"
+4
View File
@@ -1,5 +1,9 @@
#include <catch2/catch_all.hpp>
#include <cstddef>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Polygon.hpp"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Point.hpp"
#include "libslic3r/MutablePolygon.hpp"
@@ -1,8 +1,15 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <queue>
#include <cstddef>
#include <iterator>
#include <functional>
#include <cstdlib>
#include <random>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/MutablePriorityQueue.hpp"
// based on https://raw.githubusercontent.com/rollbear/prio_queue/master/self_test.cpp
@@ -1,5 +1,9 @@
#include <catch2/catch_all.hpp>
#include <set>
#include "libslic3r/Config.hpp"
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/PrintConfig.hpp"
using namespace Slic3r;
+7
View File
@@ -1,9 +1,16 @@
#include <array>
#include <catch2/catch_all.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Format/OBJ.hpp"
#include <boost/nowide/fstream.hpp>
#include <string>
#include "libslic3r/Point.hpp"
#include <cstddef>
#include "test_utils.hpp"
+4
View File
@@ -1,9 +1,13 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "test_utils.hpp"
#include <cstdlib>
#include <libslic3r/Optimize/BruteforceOptimizer.hpp>
#include <libslic3r/Optimize/NLoptOptimizer.hpp>
#include "libslic3r/Optimize/Optimizer.hpp"
#include "libslic3r/libslic3r.h"
void check_opt_result(double score, double ref, double abs_err, double rel_err)
{
@@ -1,4 +1,12 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_all.hpp>
#include <vector>
#include <cstddef>
#include <math.h>
#include "libslic3r/libslic3r.h"
#include <cmath>
#include <cstdint>
#include <limits>
#define SLIC3R_TEST_HARNESS
@@ -1,5 +1,6 @@
#include <catch2/catch_all.hpp>
#include <cstddef>
#include <numeric>
#include <stdexcept>
#include <thread>
@@ -9,6 +10,7 @@
#include <tbb/parallel_for.h>
#include <tbb/task_group.h>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/ParallelResolve.hpp"
using namespace Slic3r;
@@ -1,5 +1,12 @@
#include <catch2/catch_all.hpp>
#include <string>
#include <memory>
#include "libslic3r/Config.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include "libslic3r/PlaceholderParser.hpp"
#include "libslic3r/PrintConfig.hpp"
+4
View File
@@ -1,5 +1,9 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <cstddef>
#include "libslic3r/libslic3r.h"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Point.hpp"
#include "libslic3r/Polygon.hpp"
+11
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include "test_utils.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/PrintConfig.hpp"
@@ -12,7 +17,13 @@
#include <algorithm>
#include <array>
#include "libslic3r/Config.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <cstddef>
#include "libslic3r/Geometry.hpp"
#include <miniz.h>
#include <string>
#include <utility>
#include <vector>
using namespace Slic3r;
@@ -1,9 +1,19 @@
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/file_status.hpp>
#include <catch2/catch_all.hpp>
#include <algorithm>
#include <boost/filesystem.hpp>
#include <cstddef>
#include <fstream>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/IMEXHelpers.hpp"
#include "libslic3r/ParallelResolve.hpp"
@@ -18,6 +28,19 @@
#include <algorithm>
#include <iostream>
#include <initializer_list>
#include <vector>
#include <string>
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Preset.hpp"
#include <utility>
#include "libslic3r/Config.hpp"
#include <map>
#include "libslic3r/libslic3r.h"
#include "libslic3r/PublishSettings.hpp"
#include <set>
#include "libslic3r/TriangleSelector.hpp"
#include <iterator>
#include <miniz.h>
#ifndef _WIN32
#include <unistd.h> // geteuid
@@ -5815,6 +5838,131 @@ TEST_CASE("A system preset no vendor lists is not resolved", "[Preset][Bundle]")
namespace {
// Writes each vendor's preset cache into dir, then deletes its profile JSONs: what a release build installs.
void reduce_vendors_to_caches(const fs::path &dir, const std::vector<std::string> &vendor_ids)
{
const std::string lib(PresetBundle::ORCA_FILAMENT_LIBRARY);
PresetBundle library;
if (fs::exists(dir / (lib + ".json"))) {
library.set_generate_vendor_caches(true);
library.load_vendor_configs_from_json(dir.string(), lib, PresetBundle::LoadSystem,
ForwardCompatibilitySubstitutionRule::EnableSilent);
}
for (const std::string &vendor_id : vendor_ids) {
if (vendor_id == lib)
continue;
PresetBundle writer;
writer.set_generate_vendor_caches(true);
writer.load_vendor_configs_from_json(dir.string(), vendor_id, PresetBundle::LoadSystem,
ForwardCompatibilitySubstitutionRule::EnableSilent, &library);
}
for (const std::string &vendor_id : vendor_ids) {
REQUIRE(fs::exists(dir / (vendor_id + ".opc")));
fs::remove(dir / (vendor_id + ".json"));
fs::remove_all(dir / vendor_id);
}
}
// The filament library with one abstract base filament, and an "Acme" vendor whose one filament inherits it.
void write_library_and_acme_filament(const fs::path &root)
{
const std::string lib(PresetBundle::ORCA_FILAMENT_LIBRARY);
fs::create_directories(root / lib / "filament");
std::ofstream((root / (lib + ".json")).string())
<< R"({"version":"1.0.0","name":")" << lib << R"(",)"
<< R"("filament_list":[{"name":"Generic PLA","sub_path":"filament/generic_pla.json"}]})";
std::ofstream((root / lib / "filament" / "generic_pla.json").string())
<< R"({"type":"filament","name":"Generic PLA","from":"system","instantiation":"false","filament_id":"GFL99","filament_cost":"27"})";
fs::create_directories(root / "Acme" / "filament");
std::ofstream((root / "Acme.json").string())
<< R"({"version":"1.0.0","name":"Acme","filament_list":[{"name":"Acme PLA","sub_path":"filament/pla.json"}]})";
std::ofstream((root / "Acme" / "filament" / "pla.json").string())
<< R"({"type":"filament","name":"Acme PLA","from":"system","instantiation":"true","inherits":"Generic PLA"})";
}
} // namespace
TEST_CASE("A read-only load resolves a user preset against vendors installed as their cache alone", "[Preset][Bundle][Regression]")
{
ScopedTemporaryDir temp_dir;
const fs::path data = temp_dir.path() / "data";
const fs::path system = data / PRESET_SYSTEM_DIR;
ScopedDataDir scoped_data(data);
ScopedResourcesDir scoped_resources(temp_dir.path() / "resources");
write_acme_printer_vendor(system, 33.);
reduce_vendors_to_caches(system, {"Acme"});
fs::create_directories(data / PRESET_USER_DIR / DEFAULT_USER_FOLDER_NAME / PRESET_PRINTER_NAME);
std::ofstream((data / PRESET_USER_DIR / DEFAULT_USER_FOLDER_NAME / PRESET_PRINTER_NAME / "My Acme.json").string())
<< R"({"type":"machine","name":"My Acme","from":"User","version":"2.3.0.0","inherits":"Acme Printer","printable_height":"123"})";
AppConfig app_config;
PresetBundle bundle;
std::string errors;
bundle.load_presets(app_config, ForwardCompatibilitySubstitutionRule::EnableSilent, PresetBundle::PresetPreferences(),
&errors, true);
CHECK(errors.empty());
const Preset *preset = bundle.printers.find_preset("My Acme");
REQUIRE(preset != nullptr);
CHECK_THAT(preset->config.opt_float("printable_height"), Catch::Matchers::WithinAbs(123., 1e-6));
CHECK_THAT(preset->config.opt_float("extruder_clearance_dist_to_rod"), Catch::Matchers::WithinAbs(33., 1e-6));
}
TEST_CASE("A read-only load writes no preset cache", "[Preset][Bundle][Regression]")
{
ScopedTemporaryDir temp_dir;
const fs::path system = temp_dir.path() / "data" / PRESET_SYSTEM_DIR;
ScopedDataDir scoped_data(temp_dir.path() / "data");
ScopedResourcesDir scoped_resources(temp_dir.path() / "resources");
write_acme_printer_vendor(system, 33.);
AppConfig app_config;
PresetBundle bundle;
std::string errors;
bundle.load_presets(app_config, ForwardCompatibilitySubstitutionRule::EnableSilent, PresetBundle::PresetPreferences(),
&errors, true);
CHECK(errors.empty());
CHECK(bundle.printers.find_preset("Acme Printer") != nullptr);
CHECK_FALSE(fs::exists(system / "Acme.opc"));
}
TEST_CASE("A vendor updated over the air resolves against the library installed as its cache alone", "[Preset][Bundle][Regression]")
{
ScopedTemporaryDir temp_dir;
const fs::path system = temp_dir.path() / "data" / PRESET_SYSTEM_DIR;
ScopedDataDir scoped_data(temp_dir.path() / "data");
ScopedResourcesDir scoped_resources(temp_dir.path() / "resources");
// System presets are found by name through the bundled profiles.
write_library_and_acme_filament(temp_dir.path() / "resources" / PRESET_PROFILES_DIR);
// The release install, then an update that brings Acme back as JSONs while the library stays a cache.
write_library_and_acme_filament(system);
reduce_vendors_to_caches(system, {PresetBundle::ORCA_FILAMENT_LIBRARY, "Acme"});
write_library_and_acme_filament(temp_dir.path() / "update");
fs::copy_file(temp_dir.path() / "update" / "Acme.json", system / "Acme.json");
fs::create_directories(system / "Acme" / "filament");
fs::copy_file(temp_dir.path() / "update" / "Acme" / "filament" / "pla.json", system / "Acme" / "filament" / "pla.json");
SECTION("by name") {
PresetBundle bundle;
DynamicPrintConfig config;
std::string error;
REQUIRE(bundle.resolve_system_preset(config, Preset::TYPE_FILAMENT, "Acme PLA",
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
CHECK_THAT(config.opt<ConfigOptionFloats>("filament_cost")->values.front(), Catch::Matchers::WithinAbs(27., 1e-6));
}
SECTION("by its source file") {
PresetBundle bundle;
DynamicPrintConfig config;
config.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "Generic PLA";
std::string error;
REQUIRE(bundle.resolve_preset_config(config, Preset::TYPE_FILAMENT, (system / "Acme" / "filament" / "pla.json").string(),
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
CHECK_THAT(config.opt<ConfigOptionFloats>("filament_cost")->values.front(), Catch::Matchers::WithinAbs(27., 1e-6));
}
}
namespace {
// A default preset config for type, built the way PresetBundle builds its default presets.
DynamicPrintConfig external_default_config(Preset::Type type)
{
+6
View File
@@ -1,9 +1,15 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/Preset.hpp"
#include "libslic3r/PrintConfig.hpp"
#include <algorithm>
#include "libslic3r/Config.hpp"
#include <vector>
#include <cstddef>
#include <string>
using namespace Slic3r;
+4
View File
@@ -16,10 +16,14 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/Preset.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Config.hpp"
#include <set>
#include <string>
using namespace Slic3r;
@@ -1,5 +1,8 @@
#include <catch2/catch_all.hpp>
#include <string>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/Preset.hpp"
using namespace Slic3r;
@@ -1,4 +1,11 @@
#include <catch2/catch_all.hpp> // mainline OrcaSlicer ships Catch2 v3 (v2 was catch2/catch.hpp)
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <vector>
#include "libslic3r/CAD/SketchConstraints.hpp"
#include "libslic3r/CAD/SketchEngine.hpp"
+7
View File
@@ -1,9 +1,16 @@
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Wire.hxx>
#include <catch2/catch_all.hpp> // mainline OrcaSlicer ships Catch2 v3 (v2 was catch2/catch.hpp)
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include "libslic3r/CAD/SketchEngine.hpp"
#include <cmath>
#include <algorithm>
#include <TopExp_Explorer.hxx>
#include <TopAbs.hxx>
#include <math.h>
#include <vector>
using namespace Slic3r;
+6
View File
@@ -1,10 +1,16 @@
#include <algorithm>
#include <catch2/catch_all.hpp> // mainline OrcaSlicer ships Catch2 v3 (v2 was catch2/catch.hpp)
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "libslic3r/CAD/SketchImport.hpp"
#include "libslic3r/Utils.hpp" // resources_dir
#include "test_utils.hpp" // ScopedTemporaryFile
#include <cstdlib>
#include <fstream>
#include "libslic3r/Point.hpp"
#include <string>
using namespace Slic3r;
+5
View File
@@ -1,4 +1,9 @@
#include <catch2/catch_approx.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_all.hpp> // mainline OrcaSlicer ships Catch2 v3 (v2 was catch2/catch.hpp)
#include "libslic3r/CAD/SketchEngine.hpp"
#include "libslic3r/Point.hpp"
#include <vector>
using Catch::Approx; // v3 scopes Approx into the Catch namespace; v2 had it at global scope
#include "libslic3r/CAD/SketchInference.hpp"
+8
View File
@@ -9,11 +9,19 @@
// So these cases assert the loop, not the coordinates. That is the invariant every sketch
// operation has to preserve and the only one that predicts whether the GUI can build a solid
// out of the result.
#include <TopoDS_Face.hxx>
#include <catch2/catch_all.hpp> // mainline OrcaSlicer ships Catch2 v3 (v2 was catch2/catch.hpp)
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include "libslic3r/CAD/SketchEngine.hpp"
#include <BRepGProp.hxx>
#include <GProp_GProps.hxx>
#include <cmath>
#include "libslic3r/Point.hpp"
#include <vector>
#include <math.h>
#include <cstddef>
using namespace Slic3r;
using Catch::Matchers::WithinAbs;
@@ -1,4 +1,9 @@
#include <catch2/catch_approx.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_all.hpp> // mainline OrcaSlicer ships Catch2 v3 (v2 was catch2/catch.hpp)
#include "libslic3r/Point.hpp"
#include <vector>
#include <cstddef>
using Catch::Approx; // v3 scopes Approx into the Catch namespace; v2 had it at global scope
#include "libslic3r/CAD/SketchSolver.hpp"
+4
View File
@@ -1,7 +1,11 @@
#include <catch2/catch_all.hpp>
#include <boost/nowide/fstream.hpp>
#include <string>
#include <ios>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/Model.hpp"
#include "libslic3r/Format/STEP.hpp"
#include "test_utils.hpp"
+3
View File
@@ -1,5 +1,8 @@
#include <catch2/catch_all.hpp>
#include <string>
#include "libslic3r/Point.hpp"
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Model.hpp"
#include "libslic3r/Format/STL.hpp"
@@ -1,6 +1,29 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <memory>
#include <vector>
#include <cstdint>
#include <cstddef>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <catch2/catch_test_macros.hpp>
#include <ios>
#include <iterator>
#include <utility>
#include "libslic3r/Point.hpp"
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <map>
#include <math.h>
#include "libslic3r/TextureBake/TextureBakeDisplace.hpp"
#include "libslic3r/TextureBake/TextureBakeIndex.hpp"
#include <tuple>
#include <Eigen/Geometry>
#include "libslic3r/libslic3r.h"
#include <catch2/catch_message.hpp>
#include <catch2/catch_all.hpp>
#include <algorithm>
+3
View File
@@ -1,10 +1,13 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Time.hpp"
#include <ctime>
#include <sstream>
#include <iomanip>
#include <locale>
#include <string>
using namespace Slic3r;
@@ -1,5 +1,9 @@
#include <boost/filesystem/operations.hpp>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include "libslic3r/FilamentGroupUtils.hpp"
#include "libslic3r/MultiNozzleUtils.hpp"
#include "libslic3r/PrintConfig.hpp"
@@ -11,7 +15,11 @@
#include "test_utils.hpp"
#include <algorithm>
#include "libslic3r/Config.hpp"
#include "libslic3r/GCode/ToolOrderUtils.hpp"
#include "libslic3r/PrintBase.hpp"
#include <map>
#include <memory>
#include <set>
#include <unordered_map>
#include <vector>
@@ -1,9 +1,16 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/TriangleSelector.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include <algorithm>
#include "libslic3r/libslic3r.h"
#include <vector>
#include <cstddef>
#include <string>
using namespace Slic3r;
+25
View File
@@ -1,5 +1,14 @@
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/file_status.hpp>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/Utils.hpp"
#include "test_utils.hpp"
@@ -8,10 +17,14 @@
#include <algorithm>
#include <cctype>
#include <cstddef>
#include <fstream>
#include <ios>
#include <iterator>
#include <string>
#include <thread>
#include <system_error>
#include <utility>
#ifndef _WIN32
#include <unistd.h> // getuid
@@ -496,3 +509,15 @@ TEST_CASE("is_safe_to_open_file_name rejects programs and anything it does not k
INFO(unsafe);
CHECK_FALSE(is_safe_to_open_file_name(unsafe));
}
TEST_CASE("ascii_iequals compares ASCII letters regardless of case", "[Utils]") {
CHECK(ascii_iequals("set_velocity_limit", "SET_VELOCITY_LIMIT"));
CHECK(ascii_iequals("G28", "g28"));
CHECK(ascii_iequals("", ""));
CHECK_FALSE(ascii_iequals("G28", "G29"));
CHECK_FALSE(ascii_iequals("G2", "G28"));
CHECK_FALSE(ascii_iequals("G28", "G2"));
// Non-letters 0x20 apart are not equal.
CHECK_FALSE(ascii_iequals("[", "{"));
CHECK_FALSE(ascii_iequals("@", "`"));
}
+15
View File
@@ -1,3 +1,5 @@
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <catch2/catch_all.hpp>
#include <boost/filesystem.hpp>
@@ -5,19 +7,32 @@
#include <cereal/archives/binary.hpp>
#include <algorithm>
#include <atomic>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <functional>
#include <ios>
#include <iterator>
#include "libslic3r/Semver.hpp"
#include "libslic3r/Config.hpp"
#include <memory>
#include <numeric>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <stdexcept>
#include <tbb/blocked_range.h>
#include <tbb/parallel_for.h>
#include <tbb/task_group.h>
#include <vector>
#include <utility>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/catch_message.hpp>
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/PresetCacheFormat.hpp"
#include "libslic3r/Preset.hpp"
+11
View File
@@ -1,6 +1,14 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include "test_utils.hpp"
#include "libslic3r/Geometry/Voronoi.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Line.hpp"
#include <cmath>
#include <cstddef>
#include "libslic3r/BoundingBox.hpp"
#include <libslic3r/Polygon.hpp>
#include <libslic3r/Polyline.hpp>
#include <libslic3r/EdgeGrid.hpp>
@@ -9,8 +17,11 @@
#include <libslic3r/Geometry/VoronoiOffset.hpp>
#include <libslic3r/Geometry/VoronoiVisualUtils.hpp>
#include "libslic3r/libslic3r.h"
#include <math.h>
#include <numeric>
#include <random>
#include <vector>
// #define VORONOI_DEBUG_OUT
+10
View File
@@ -1,5 +1,10 @@
#include <catch2/catch_all.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_message.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/GCode/WipePathHelpers.hpp"
#include "libslic3r/AABBTreeLines.hpp"
#include "libslic3r/Polyline.hpp"
@@ -9,7 +14,12 @@
#include <algorithm>
#include <cmath>
#include "libslic3r/ExtrusionEntity.hpp"
#include <cstddef>
#include <limits>
#include <vector>
#include <utility>
#include <optional>
using namespace Slic3r;
using Slic3r::AABBTreeLines::LinesDistancer;
+10
View File
@@ -1,7 +1,17 @@
#include <catch2/catch_all.hpp>
#include <cmath>
#include <vector>
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Point.hpp"
#include <math.h>
#include <utility>
#include "libslic3r/libslic3r.h"
#include <cstddef>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/GCode/WipeTower.hpp"
@@ -1,5 +1,10 @@
#include <algorithm>
#include <catch2/catch_all.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/ClipperUtils.hpp"
#include "libslic3r/GCode/WipeTower.hpp"
@@ -9,8 +14,14 @@
#include "libslic3r/FilamentMixer.hpp"
#include <cmath>
#include "libslic3r/Config.hpp"
#include <cstddef>
#include "libslic3r/Polygon.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include <numeric>
#include <string>
#include <vector>
using namespace Slic3r;
using Catch::Matchers::WithinAbs;

Some files were not shown because too many files have changed in this diff Show More