mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-06-04 11:14:17 +08:00

WIP GCode/SmoothPath.cpp,hpp cache for interpolating extrusion path with arches. Removed Perl test t/geometry.t, replaced with C++ tests. Refactored ExtrusionEntity and derived classes to hold extrusion attributes in new ExtrusionFlow/ExtrusionAttributes classes. Reworked path ordering in G-code export to never copy polylines, but to work with a new "flipped" attribute. Reworked G-code export to interpolate extrusion paths with smooth paths and to extrude those smooth paths. New parameters: arc_fitting, arc_fitting_tolerance Renamed GCode class to GCodeGenerator Moved GCodeWriter.cpp/hpp to GCode/ Moved Wipe from from GCode.cpp,hpp to GCode/Wipe.cpp,hpp Moved WipeTowerIntegration from GCode.cpp,hpp to GCode/WipeTowerIntegration.cpp,hpp New variant of douglas_peucker() to simplify range of iterators in place. Refactored wipe in general and wipe on perimeters / hiding seams. WIP: Convert estimate_speed_from_extrusion_quality() and its application to smooth paths. WIP: Cooling buffer to process G2G3, disable arc fitting for filters that cannot process it.
48 lines
1.7 KiB
C++
48 lines
1.7 KiB
C++
#include <catch2/catch.hpp>
|
|
|
|
#include "libslic3r/Point.hpp"
|
|
#include "libslic3r/Polyline.hpp"
|
|
|
|
using namespace Slic3r;
|
|
|
|
SCENARIO("Simplify polyne, template", "[Polyline]")
|
|
{
|
|
Points polyline{ {0,0}, {1000,0}, {2000,0}, {2000,1000}, {2000,2000}, {1000,2000}, {0,2000}, {0,1000}, {0,0} };
|
|
WHEN("simplified with Douglas-Peucker with back inserter") {
|
|
Points out;
|
|
douglas_peucker<int64_t>(polyline.begin(), polyline.end(), std::back_inserter(out), 10, [](const Point &p) { return p; });
|
|
THEN("simplified correctly") {
|
|
REQUIRE(out == Points{ {0,0}, {2000,0}, {2000,2000}, {0,2000}, {0,0} });
|
|
}
|
|
}
|
|
WHEN("simplified with Douglas-Peucker in place") {
|
|
Points out{ polyline };
|
|
out.erase(douglas_peucker<int64_t>(out.begin(), out.end(), out.begin(), 10, [](const Point &p) { return p; }), out.end());
|
|
THEN("simplified correctly") {
|
|
REQUIRE(out == Points{ {0,0}, {2000,0}, {2000,2000}, {0,2000}, {0,0} });
|
|
}
|
|
}
|
|
}
|
|
|
|
SCENARIO("Simplify polyline", "[Polyline]")
|
|
{
|
|
GIVEN("polyline 1") {
|
|
auto polyline = Polyline{ {0,0},{1,0},{2,0},{2,1},{2,2},{1,2},{0,2},{0,1},{0,0} };
|
|
WHEN("simplified with Douglas-Peucker") {
|
|
polyline.simplify(1.);
|
|
THEN("simplified correctly") {
|
|
REQUIRE(polyline == Polyline{ {0,0}, {2,0}, {2,2}, {0,2}, {0,0} });
|
|
}
|
|
}
|
|
}
|
|
GIVEN("polyline 2") {
|
|
auto polyline = Polyline{ {0,0}, {50,50}, {100,0}, {125,-25}, {150,50} };
|
|
WHEN("simplified with Douglas-Peucker") {
|
|
polyline.simplify(25.);
|
|
THEN("not simplified") {
|
|
REQUIRE(polyline == Polyline{ {0,0}, {50,50}, {125,-25}, {150,50} });
|
|
}
|
|
}
|
|
}
|
|
}
|