mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-15 02:16:01 +08:00
debug brim & test_cli
This commit is contained in:
parent
6fa6c1a925
commit
43aac7d57c
@ -1812,10 +1812,10 @@ ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityColl
|
||||
//don't collide with objects
|
||||
brimmable_areas = diff_ex(brimmable_areas, unbrimmable_areas, true);
|
||||
|
||||
this->throw_if_canceled();
|
||||
//now get all holes, use them to create loops
|
||||
Polylines loops;
|
||||
ExPolygons bigger_islands;
|
||||
|
||||
//grow a half of spacing, to go to the first extrusion polyline.
|
||||
Polygons unbrimmable_polygons;
|
||||
for (ExPolygon &expoly : islands) {
|
||||
@ -1826,7 +1826,6 @@ ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityColl
|
||||
unbrimmable_polygons.insert(unbrimmable_polygons.end(), big_expoly.holes.begin(), big_expoly.holes.end());
|
||||
}
|
||||
}
|
||||
//frontiers = to_polygons(union_ex(frontiers));
|
||||
islands = bigger_islands;
|
||||
for (size_t i = 0; i < num_loops; ++i) {
|
||||
this->throw_if_canceled();
|
||||
@ -1876,8 +1875,18 @@ ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityColl
|
||||
//}
|
||||
|
||||
this->throw_if_canceled();
|
||||
//reorder & extrude them
|
||||
_extrude_brim_polyline(lines, out);
|
||||
|
||||
//TODO: reorder when it will work with loops (ie do not overextrude)
|
||||
|
||||
//push into extrusions
|
||||
extrusion_entities_append_paths(
|
||||
out.entities,
|
||||
lines,
|
||||
erSkirt,
|
||||
float(flow.mm3_per_mm()),
|
||||
float(flow.width),
|
||||
float(this->skirt_first_layer_height())
|
||||
);
|
||||
|
||||
return brimmable_areas;
|
||||
}
|
||||
@ -1924,6 +1933,7 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit
|
||||
}
|
||||
brimmable_areas = union_ex(brimmable_areas);
|
||||
|
||||
this->throw_if_canceled();
|
||||
//create loops (same as standard brim)
|
||||
Polygons loops;
|
||||
islands = offset_ex(islands, -0.5f * double(flow.scaled_spacing()));
|
||||
@ -1961,9 +1971,20 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit
|
||||
|
||||
//intersection
|
||||
Polylines lines = intersection_pl(loops, mouse_ears);
|
||||
this->throw_if_canceled();
|
||||
|
||||
//reorder & extrude them
|
||||
_extrude_brim_polyline(lines, out);
|
||||
Polylines lines_sorted = _reorder_brim_polyline(lines, out);
|
||||
|
||||
//push into extrusions
|
||||
extrusion_entities_append_paths(
|
||||
out.entities,
|
||||
lines_sorted,
|
||||
erSkirt,
|
||||
float(flow.mm3_per_mm()),
|
||||
float(flow.width),
|
||||
float(this->skirt_first_layer_height())
|
||||
);
|
||||
|
||||
return intersection_ex(brimmable_areas, mouse_ears_ex);
|
||||
}
|
||||
@ -2042,14 +2063,23 @@ ExPolygons Print::_make_brim_interior(const PrintObjectPtrs &objects, const ExPo
|
||||
|
||||
Polylines lines = intersection_pl(loops, frontiers);
|
||||
|
||||
//reorder & extrude them
|
||||
_extrude_brim_polyline(lines, out);
|
||||
//TODO: reorder when it can work with loops
|
||||
|
||||
//push into extrusions
|
||||
extrusion_entities_append_paths(
|
||||
out.entities,
|
||||
lines,
|
||||
erSkirt,
|
||||
float(flow.mm3_per_mm()),
|
||||
float(flow.width),
|
||||
float(this->skirt_first_layer_height())
|
||||
);
|
||||
|
||||
return brimmable_areas;
|
||||
}
|
||||
|
||||
/// reorder & join polyline if their ending are near enough, then extrude the brim from the polyline into 'out'.
|
||||
void Print::_extrude_brim_polyline(Polylines lines, ExtrusionEntityCollection &out) {
|
||||
Polylines Print::_reorder_brim_polyline(Polylines lines, ExtrusionEntityCollection &out) {
|
||||
Flow flow = this->brim_flow();
|
||||
|
||||
//reorder them
|
||||
@ -2120,15 +2150,7 @@ void Print::_extrude_brim_polyline(Polylines lines, ExtrusionEntityCollection &o
|
||||
}
|
||||
}
|
||||
|
||||
//push into extrusions
|
||||
extrusion_entities_append_paths(
|
||||
out.entities,
|
||||
lines_sorted,
|
||||
erSkirt,
|
||||
float(flow.mm3_per_mm()),
|
||||
float(flow.width),
|
||||
float(this->skirt_first_layer_height())
|
||||
);
|
||||
return lines_sorted;
|
||||
}
|
||||
|
||||
// Wipe tower support.
|
||||
|
@ -397,7 +397,7 @@ private:
|
||||
ExPolygons _make_brim(const PrintObjectPtrs &objects, ExtrusionEntityCollection &out);
|
||||
ExPolygons _make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntityCollection &out);
|
||||
ExPolygons _make_brim_interior(const PrintObjectPtrs &objects, const ExPolygons &unbrimmable, ExtrusionEntityCollection &out);
|
||||
void _extrude_brim_polyline(Polylines lines, ExtrusionEntityCollection &out);
|
||||
Polylines _reorder_brim_polyline(Polylines lines, ExtrusionEntityCollection &out);
|
||||
void _make_wipe_tower();
|
||||
void _simplify_slices(double distance);
|
||||
|
||||
|
@ -69,7 +69,7 @@ SCENARIO( "CLI Export Arguments", "[!mayfail]") {
|
||||
clean_array(in_args.size(), args_cli);
|
||||
clean_file("test_cli/20mmbox", "gcode");
|
||||
}
|
||||
// doesn't work anymore
|
||||
// doesn't work anymore
|
||||
//WHEN ( "[ ACTION ] is export-obj") {
|
||||
// in_args.emplace(in_args.cend()-1, "--export-obj");
|
||||
// CLI().run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
@ -79,7 +79,7 @@ SCENARIO( "CLI Export Arguments", "[!mayfail]") {
|
||||
// clean_array(in_args.size(), args_cli);
|
||||
// clean_file("test_cli/20mmbox", "obj");
|
||||
//}
|
||||
//doesn't work
|
||||
//doesn't work
|
||||
//WHEN ( "[ ACTION ] is export-pov") {
|
||||
// in_args.emplace(in_args.cend()-1, "--export-pov");
|
||||
// CLI().run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
@ -107,7 +107,7 @@ SCENARIO( "CLI Export Arguments", "[!mayfail]") {
|
||||
clean_array(in_args.size(), args_cli);
|
||||
clean_file("test_cli/20mmbox", "3mf");
|
||||
}
|
||||
// now export-sla
|
||||
// now export-sla
|
||||
//WHEN ( "[ ACTION ] is export-svg") {
|
||||
// in_args.emplace(in_args.cend()-1, "--export-svg");
|
||||
// CLI().run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
@ -134,24 +134,24 @@ SCENARIO( "CLI Export Arguments", "[!mayfail]") {
|
||||
// clean_array(in_args.size(), args_cli);
|
||||
// clean_file("test_cli/20mmbox", "svg", true);
|
||||
//}
|
||||
//WHEN("[ ACTION ] is sla") {
|
||||
// in_args.emplace(in_args.cend() - 1, "--sla");
|
||||
// CLI().run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
// THEN("SVG file is created.") {
|
||||
// REQUIRE(file_exists("test_cli/20mmbox", "svg"));
|
||||
// }
|
||||
// clean_array(in_args.size(), args_cli);
|
||||
// clean_file("test_cli/20mmbox", "svg", true);
|
||||
//}
|
||||
//WHEN("[ ACTION ] is sla for sl1") {
|
||||
// in_args.emplace(in_args.cend() - 1, "--sla");
|
||||
// CLI().run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
// THEN("SVG file is created.") {
|
||||
// REQUIRE(file_exists("test_cli/20mmbox", "sl1"));
|
||||
// }
|
||||
// clean_array(in_args.size(), args_cli);
|
||||
// clean_file("test_cli/20mmbox", "sl1", true);
|
||||
//}
|
||||
//WHEN("[ ACTION ] is sla") {
|
||||
// in_args.emplace(in_args.cend() - 1, "--sla");
|
||||
// CLI().run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
// THEN("SVG file is created.") {
|
||||
// REQUIRE(file_exists("test_cli/20mmbox", "svg"));
|
||||
// }
|
||||
// clean_array(in_args.size(), args_cli);
|
||||
// clean_file("test_cli/20mmbox", "svg", true);
|
||||
//}
|
||||
//WHEN("[ ACTION ] is sla for sl1") {
|
||||
// in_args.emplace(in_args.cend() - 1, "--sla");
|
||||
// CLI().run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
// THEN("SVG file is created.") {
|
||||
// REQUIRE(file_exists("test_cli/20mmbox", "sl1"));
|
||||
// }
|
||||
// clean_array(in_args.size(), args_cli);
|
||||
// clean_file("test_cli/20mmbox", "sl1", true);
|
||||
//}
|
||||
//WHEN ( "[ ACTION ] is sla and --output is output.svg") {
|
||||
// in_args.emplace(in_args.cend()-1, "--sla");
|
||||
// in_args.emplace(in_args.cend()-1, "--output");
|
||||
@ -206,12 +206,11 @@ SCENARIO( "CLI Export Arguments", "[!mayfail]") {
|
||||
SCENARIO("CLI positioning arguments") {
|
||||
char* args_cli[20];
|
||||
std::vector<std::string> in_args{};
|
||||
in_args.reserve(20);
|
||||
in_args.emplace_back("gui_test"s);
|
||||
GIVEN( " 3D Model for a 20mm box, centered around 0,0 and gcode export" ) {
|
||||
in_args.emplace_back(testfile("test_cli/20mmbox.stl"s));
|
||||
in_args.emplace_back(testfile("test_cli/20mmbox.stl"));
|
||||
in_args.emplace(in_args.cend()-1, "-g");
|
||||
in_args.emplace(in_args.cend()-1, "--load"s);
|
||||
in_args.emplace(in_args.cend()-1, "--load");
|
||||
in_args.emplace(in_args.cend()-1, testfile("test_cli/20mmbox_config.ini"));
|
||||
CLI cut{};
|
||||
|
||||
@ -221,8 +220,8 @@ SCENARIO("CLI positioning arguments") {
|
||||
cut.run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
|
||||
THEN ("The first layer of the print should be centered around 0,0") {
|
||||
std::string exported { read_to_string("test_cli/20mmbox.gcode"s)};
|
||||
GCodeReader reader;
|
||||
std::string exported { read_to_string(testfile("test_cli/20mmbox.gcode"))};
|
||||
GCodeReader reader;
|
||||
REQUIRE(exported != ""s);
|
||||
double min_x = 50.0, max_x = -50.0, min_y = 50.0, max_y = -50.0;
|
||||
reader.apply_config(cut.full_print_config());
|
||||
@ -249,27 +248,27 @@ SCENARIO("CLI positioning arguments") {
|
||||
AND_THEN("Maximum Y encountered is about 49.9") {
|
||||
REQUIRE(max_y == Approx(49.9));
|
||||
}
|
||||
}
|
||||
}
|
||||
WHEN("--dont-arrange is supplied") {
|
||||
in_args.emplace(in_args.cend()-1, "--dont-arrange");
|
||||
cut.run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
}
|
||||
WHEN("--dont-arrange is supplied") {
|
||||
in_args.emplace(in_args.cend()-1, "--dont-arrange");
|
||||
cut.run(in_args.size(), to_cstr_array(in_args, args_cli));
|
||||
|
||||
THEN ("The first layer of the print should be centered around 0,0") {
|
||||
auto reader {GCodeReader()};
|
||||
std::string exported { read_to_string("test_cli/20mmbox.gcode"s)};
|
||||
REQUIRE(exported != ""s);
|
||||
double min_x = 50.0, max_x = -50.0, min_y = 50.0, max_y = -50.0;
|
||||
reader.apply_config(cut.full_print_config());
|
||||
reader.parse_buffer(exported, [&min_x, &min_y, &max_x, &max_y] (GCodeReader& self, const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
if (self.z() < 0.6) {
|
||||
min_x = std::min(min_x, static_cast<double>(self.x()));
|
||||
min_y = std::min(min_y, static_cast<double>(self.y()));
|
||||
max_x = std::max(max_x, static_cast<double>(self.x()));
|
||||
max_y = std::max(max_y, static_cast<double>(self.y()));
|
||||
}
|
||||
});
|
||||
THEN ("The first layer of the print should be centered around 0,0") {
|
||||
auto reader {GCodeReader()};
|
||||
std::string exported { read_to_string("test_cli/20mmbox.gcode"s)};
|
||||
REQUIRE(exported != ""s);
|
||||
double min_x = 50.0, max_x = -50.0, min_y = 50.0, max_y = -50.0;
|
||||
reader.apply_config(cut.full_print_config());
|
||||
reader.parse_buffer(exported, [&min_x, &min_y, &max_x, &max_y] (GCodeReader& self, const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
if (self.z() < 0.6) {
|
||||
min_x = std::min(min_x, static_cast<double>(self.x()));
|
||||
min_y = std::min(min_y, static_cast<double>(self.y()));
|
||||
max_x = std::max(max_x, static_cast<double>(self.x()));
|
||||
max_y = std::max(max_y, static_cast<double>(self.y()));
|
||||
}
|
||||
});
|
||||
AND_THEN("Minimum X encountered is about -9.9") {
|
||||
REQUIRE(min_x == Approx(-9.9));
|
||||
}
|
||||
@ -284,7 +283,7 @@ SCENARIO("CLI positioning arguments") {
|
||||
}
|
||||
}
|
||||
}
|
||||
clean_array(in_args.size(), args_cli);
|
||||
clean_file("test_cli/20mmbox", "gcode");
|
||||
}
|
||||
clean_array(in_args.size(), args_cli);
|
||||
clean_file("test_cli/20mmbox", "gcode");
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ extrusion_width = 0
|
||||
fill_density = 0%
|
||||
fill_gaps = 1
|
||||
first_layer_extrusion_width = 0.2
|
||||
first_layer_height = 0.3
|
||||
first_layer_height = 0.1
|
||||
infill_extrusion_width = 0
|
||||
interface_shells = 0
|
||||
interior_brim_width = 0
|
||||
layer_height = 0.3
|
||||
layer_height = 0.1
|
||||
min_shell_thickness = 0
|
||||
only_retract_when_crossing_perimeters = 1
|
||||
ooze_prevention = 0
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
#include "../test_data.hpp"
|
||||
#include "../../libslic3r/libslic3r.h"
|
||||
#include "../../libslic3r/SVG.hpp"
|
||||
|
||||
using namespace Slic3r::Test;
|
||||
using namespace Slic3r;
|
||||
@ -78,6 +79,13 @@ SCENARIO("Print: Brim generation") {
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
print.process();
|
||||
//{
|
||||
// std::stringstream stri;
|
||||
// stri << "20mm_cube_brim_test_" << ".svg";
|
||||
// SVG svg(stri.str());
|
||||
// svg.draw(print.brim().as_polylines(), "red");
|
||||
// svg.Close();
|
||||
//}
|
||||
THEN("Brim Extrusion collection has 3 loops in it") {
|
||||
REQUIRE(print.brim().items_count() == 3);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user