mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-24 16:48:49 -07:00
* Get libslic3r tests closer to passing
I can't get geometry tests to do anything useful. I've added extra
output, but it hasn't helped me figure out why they don't work
yet. That's also probably the last broken 3mf test doesn't work.
The config tests were mostly broken because of config name changes.
The placeholder_parser tests have some things that may-or-may-not
still apply to Orca.
* Vendor a 3.x version of Catch2
Everything is surely broken at this point.
* Allow building tests separately from Orca with build_linux.sh
* Remove unnecessary log message screwing up ctest
Same solution as Prusaslicer
* Make 2 TriangleMesh methods const
Since they can be.
* Move method comment to the header where it belongsc
* Add indirectly-included header directly
Transform3d IIRC
* libslic3r tests converted to Catch2 v3
Still has 3 failing tests, but builds and runs.
* Disable 2D convex hull test and comment what I've learned
Not sure the best way to solve this yet.
* Add diff compare method for DynamicConfig
Help the unit test report errors better.
* Perl no longer used, remove comment line
* Clang-format Config.?pp
So difficult to work with ATM
* Remove cpp17 unit tests
Who gives a shit
* Don't need explicit "example" test
We have lots of tests to serve as examples.
* Leave breadcrumb to enable sla_print tests
* Fix serialization of DynamicConfig
Add comments to test, because these code paths might not be even used
anymore.
* Update run_unit_tests to run all the tests
By the time I'm done with the PR all tests will either excluded by
default or passing, so just do all.
* Update how-to-test now that build_linux.sh builds tests separately
* Update cmake regenerate instructions
Read this online; hopefully works.
* Enable slic3rutils test with Catch2 v3
* Port libnest2d and fff_print to Catch2 v3
They build. Many failing.
* Add slightly more info to Objects not fit on bed exception
* Disable failing fff_print tests from running
They're mostly failing for "objects don't fit on bed" for an
infinite-sized bed. Given infinite bed is probably only used in tests,
it probably was incidentally broken long ago.
* Must checkout tests directory in GH Actions
So we get the test data
* Missed a failing fff_print test
* Disable (most/all) broken libnest2d tests
Trying all, not checking yet though
* Fix Polygon convex/concave detection tests
Document the implementation too. Reorganize the tests to be cleaner.
* Update the test script to run tests in parallel
* Get sla_print tests to build
Probably not passing
* Don't cause full project rebuild when updating test CMakeLists.txts
* Revert "Clang-format Config.?pp"
This reverts commit 771e4c0ad2.
---------
Co-authored-by: SoftFever <softfeverever@gmail.com>
171 lines
7.2 KiB
C++
171 lines
7.2 KiB
C++
#include <catch2/catch_all.hpp>
|
|
|
|
#include <numeric>
|
|
#include <sstream>
|
|
|
|
#include "test_data.hpp" // get access to init_print, etc
|
|
|
|
#include "libslic3r/Config.hpp"
|
|
#include "libslic3r/Model.hpp"
|
|
#include "libslic3r/Config.hpp"
|
|
#include "libslic3r/GCodeReader.hpp"
|
|
#include "libslic3r/Flow.hpp"
|
|
#include "libslic3r/libslic3r.h"
|
|
|
|
using namespace Slic3r::Test;
|
|
using namespace Slic3r;
|
|
|
|
SCENARIO("Extrusion width specifics", "[Flow][.]") {
|
|
GIVEN("A config with a skirt, brim, some fill density, 3 perimeters, and 1 bottom solid layer and a 20mm cube mesh") {
|
|
// this is a sharedptr
|
|
DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
|
config.set_deserialize_strict({
|
|
{ "brim_width", 2 },
|
|
{ "skirts", 1 },
|
|
{ "perimeters", 3 },
|
|
{ "fill_density", "40%" },
|
|
{ "first_layer_height", 0.3 }
|
|
});
|
|
|
|
WHEN("first layer width set to 2mm") {
|
|
Slic3r::Model model;
|
|
config.set("first_layer_extrusion_width", 2);
|
|
Slic3r::Print print;
|
|
Slic3r::Test::init_print({TestMesh::cube_20x20x20}, print, model, config);
|
|
|
|
std::vector<double> E_per_mm_bottom;
|
|
std::string gcode = Test::gcode(print);
|
|
Slic3r::GCodeReader parser;
|
|
const double layer_height = config.opt_float("layer_height");
|
|
parser.parse_buffer(gcode, [&E_per_mm_bottom, layer_height] (Slic3r::GCodeReader& self, const Slic3r::GCodeReader::GCodeLine& line)
|
|
{
|
|
if (self.z() == Catch::Approx(layer_height).margin(0.01)) { // only consider first layer
|
|
if (line.extruding(self) && line.dist_XY(self) > 0) {
|
|
E_per_mm_bottom.emplace_back(line.dist_E(self) / line.dist_XY(self));
|
|
}
|
|
}
|
|
});
|
|
THEN(" First layer width applies to everything on first layer.") {
|
|
bool pass = false;
|
|
double avg_E = std::accumulate(E_per_mm_bottom.cbegin(), E_per_mm_bottom.cend(), 0.0) / static_cast<double>(E_per_mm_bottom.size());
|
|
|
|
pass = (std::count_if(E_per_mm_bottom.cbegin(), E_per_mm_bottom.cend(), [avg_E] (const double& v) { return v == Catch::Approx(avg_E); }) == 0);
|
|
REQUIRE(pass == true);
|
|
REQUIRE(E_per_mm_bottom.size() > 0); // make sure it actually passed because of extrusion
|
|
}
|
|
THEN(" First layer width does not apply to upper layer.") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// needs gcode export
|
|
SCENARIO(" Bridge flow specifics.", "[Flow]") {
|
|
GIVEN("A default config with no cooling and a fixed bridge speed, flow ratio and an overhang mesh.") {
|
|
WHEN("bridge_flow_ratio is set to 1.0") {
|
|
THEN("Output flow is as expected.") {
|
|
}
|
|
}
|
|
WHEN("bridge_flow_ratio is set to 0.5") {
|
|
THEN("Output flow is as expected.") {
|
|
}
|
|
}
|
|
WHEN("bridge_flow_ratio is set to 2.0") {
|
|
THEN("Output flow is as expected.") {
|
|
}
|
|
}
|
|
}
|
|
GIVEN("A default config with no cooling and a fixed bridge speed, flow ratio, fixed extrusion width of 0.4mm and an overhang mesh.") {
|
|
WHEN("bridge_flow_ratio is set to 1.0") {
|
|
THEN("Output flow is as expected.") {
|
|
}
|
|
}
|
|
WHEN("bridge_flow_ratio is set to 0.5") {
|
|
THEN("Output flow is as expected.") {
|
|
}
|
|
}
|
|
WHEN("bridge_flow_ratio is set to 2.0") {
|
|
THEN("Output flow is as expected.") {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Test the expected behavior for auto-width,
|
|
/// spacing, etc
|
|
SCENARIO("Flow: Flow math for non-bridges", "[Flow]") {
|
|
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
|
|
ConfigOptionFloatOrPercent width(1.0, false);
|
|
float nozzle_diameter = 0.4f;
|
|
float layer_height = 0.4f;
|
|
|
|
// Spacing for non-bridges is has some overlap
|
|
THEN("External perimeter flow has spacing fixed to 1.125 * nozzle_diameter") {
|
|
auto flow = Flow::new_from_config_width(frExternalPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
|
REQUIRE(flow.spacing() == Catch::Approx(1.125 * nozzle_diameter - layer_height * (1.0 - PI / 4.0)));
|
|
}
|
|
|
|
THEN("Internal perimeter flow has spacing fixed to 1.125 * nozzle_diameter") {
|
|
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
|
REQUIRE(flow.spacing() == Catch::Approx(1.125 *nozzle_diameter - layer_height * (1.0 - PI / 4.0)));
|
|
}
|
|
THEN("Spacing for supplied width is 0.8927f") {
|
|
auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height);
|
|
REQUIRE(flow.spacing() == Catch::Approx(width.value - layer_height * (1.0 - PI / 4.0)));
|
|
flow = Flow::new_from_config_width(frPerimeter, width, nozzle_diameter, layer_height);
|
|
REQUIRE(flow.spacing() == Catch::Approx(width.value - layer_height * (1.0 - PI / 4.0)));
|
|
}
|
|
}
|
|
/// Check the min/max
|
|
GIVEN("Nozzle Diameter of 0.25") {
|
|
float nozzle_diameter = 0.25f;
|
|
float layer_height = 0.5f;
|
|
WHEN("layer height is set to 0.2") {
|
|
layer_height = 0.15f;
|
|
THEN("Max width is set.") {
|
|
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
|
REQUIRE(flow.width() == Catch::Approx(1.125 * nozzle_diameter));
|
|
}
|
|
}
|
|
WHEN("Layer height is set to 0.25") {
|
|
layer_height = 0.25f;
|
|
THEN("Min width is set.") {
|
|
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
|
REQUIRE(flow.width() == Catch::Approx(1.125 * nozzle_diameter));
|
|
}
|
|
}
|
|
}
|
|
|
|
#if 0
|
|
/// Check for an edge case in the maths where the spacing could be 0; original
|
|
/// math is 0.99. Slic3r issue #4654
|
|
GIVEN("Input spacing of 0.414159 and a total width of 2") {
|
|
double in_spacing = 0.414159;
|
|
double total_width = 2.0;
|
|
auto flow = Flow::new_from_spacing(1.0, 0.4, 0.3);
|
|
WHEN("solid_spacing() is called") {
|
|
double result = flow.solid_spacing(total_width, in_spacing);
|
|
THEN("Yielded spacing is greater than 0") {
|
|
REQUIRE(result > 0);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
}
|
|
|
|
/// Spacing, width calculation for bridge extrusions
|
|
SCENARIO("Flow: Flow math for bridges", "[Flow]") {
|
|
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
|
|
float nozzle_diameter = 0.4f;
|
|
float bridge_flow = 1.0f;
|
|
WHEN("Flow role is frExternalPerimeter") {
|
|
auto flow = Flow::bridging_flow(nozzle_diameter * sqrt(bridge_flow), nozzle_diameter);
|
|
THEN("Bridge width is same as nozzle diameter") {
|
|
REQUIRE(flow.width() == Catch::Approx(nozzle_diameter));
|
|
}
|
|
THEN("Bridge spacing is same as nozzle diameter + BRIDGE_EXTRA_SPACING") {
|
|
REQUIRE(flow.spacing() == Catch::Approx(nozzle_diameter + BRIDGE_EXTRA_SPACING));
|
|
}
|
|
}
|
|
}
|
|
}
|