mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-15 11:15:55 +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
|
//don't collide with objects
|
||||||
brimmable_areas = diff_ex(brimmable_areas, unbrimmable_areas, true);
|
brimmable_areas = diff_ex(brimmable_areas, unbrimmable_areas, true);
|
||||||
|
|
||||||
|
this->throw_if_canceled();
|
||||||
//now get all holes, use them to create loops
|
//now get all holes, use them to create loops
|
||||||
Polylines loops;
|
Polylines loops;
|
||||||
ExPolygons bigger_islands;
|
ExPolygons bigger_islands;
|
||||||
|
|
||||||
//grow a half of spacing, to go to the first extrusion polyline.
|
//grow a half of spacing, to go to the first extrusion polyline.
|
||||||
Polygons unbrimmable_polygons;
|
Polygons unbrimmable_polygons;
|
||||||
for (ExPolygon &expoly : islands) {
|
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());
|
unbrimmable_polygons.insert(unbrimmable_polygons.end(), big_expoly.holes.begin(), big_expoly.holes.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//frontiers = to_polygons(union_ex(frontiers));
|
|
||||||
islands = bigger_islands;
|
islands = bigger_islands;
|
||||||
for (size_t i = 0; i < num_loops; ++i) {
|
for (size_t i = 0; i < num_loops; ++i) {
|
||||||
this->throw_if_canceled();
|
this->throw_if_canceled();
|
||||||
@ -1876,8 +1875,18 @@ ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityColl
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
this->throw_if_canceled();
|
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;
|
return brimmable_areas;
|
||||||
}
|
}
|
||||||
@ -1924,6 +1933,7 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit
|
|||||||
}
|
}
|
||||||
brimmable_areas = union_ex(brimmable_areas);
|
brimmable_areas = union_ex(brimmable_areas);
|
||||||
|
|
||||||
|
this->throw_if_canceled();
|
||||||
//create loops (same as standard brim)
|
//create loops (same as standard brim)
|
||||||
Polygons loops;
|
Polygons loops;
|
||||||
islands = offset_ex(islands, -0.5f * double(flow.scaled_spacing()));
|
islands = offset_ex(islands, -0.5f * double(flow.scaled_spacing()));
|
||||||
@ -1961,9 +1971,20 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit
|
|||||||
|
|
||||||
//intersection
|
//intersection
|
||||||
Polylines lines = intersection_pl(loops, mouse_ears);
|
Polylines lines = intersection_pl(loops, mouse_ears);
|
||||||
|
this->throw_if_canceled();
|
||||||
|
|
||||||
//reorder & extrude them
|
//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);
|
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);
|
Polylines lines = intersection_pl(loops, frontiers);
|
||||||
|
|
||||||
//reorder & extrude them
|
//TODO: reorder when it can work with loops
|
||||||
_extrude_brim_polyline(lines, out);
|
|
||||||
|
//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;
|
return brimmable_areas;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// reorder & join polyline if their ending are near enough, then extrude the brim from the polyline into 'out'.
|
/// 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();
|
Flow flow = this->brim_flow();
|
||||||
|
|
||||||
//reorder them
|
//reorder them
|
||||||
@ -2120,15 +2150,7 @@ void Print::_extrude_brim_polyline(Polylines lines, ExtrusionEntityCollection &o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//push into extrusions
|
return lines_sorted;
|
||||||
extrusion_entities_append_paths(
|
|
||||||
out.entities,
|
|
||||||
lines_sorted,
|
|
||||||
erSkirt,
|
|
||||||
float(flow.mm3_per_mm()),
|
|
||||||
float(flow.width),
|
|
||||||
float(this->skirt_first_layer_height())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wipe tower support.
|
// Wipe tower support.
|
||||||
|
@ -397,7 +397,7 @@ private:
|
|||||||
ExPolygons _make_brim(const PrintObjectPtrs &objects, ExtrusionEntityCollection &out);
|
ExPolygons _make_brim(const PrintObjectPtrs &objects, ExtrusionEntityCollection &out);
|
||||||
ExPolygons _make_brim_ears(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);
|
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 _make_wipe_tower();
|
||||||
void _simplify_slices(double distance);
|
void _simplify_slices(double distance);
|
||||||
|
|
||||||
|
@ -206,12 +206,11 @@ SCENARIO( "CLI Export Arguments", "[!mayfail]") {
|
|||||||
SCENARIO("CLI positioning arguments") {
|
SCENARIO("CLI positioning arguments") {
|
||||||
char* args_cli[20];
|
char* args_cli[20];
|
||||||
std::vector<std::string> in_args{};
|
std::vector<std::string> in_args{};
|
||||||
in_args.reserve(20);
|
|
||||||
in_args.emplace_back("gui_test"s);
|
in_args.emplace_back("gui_test"s);
|
||||||
GIVEN( " 3D Model for a 20mm box, centered around 0,0 and gcode export" ) {
|
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, "-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"));
|
in_args.emplace(in_args.cend()-1, testfile("test_cli/20mmbox_config.ini"));
|
||||||
CLI cut{};
|
CLI cut{};
|
||||||
|
|
||||||
@ -221,7 +220,7 @@ SCENARIO("CLI positioning arguments") {
|
|||||||
cut.run(in_args.size(), to_cstr_array(in_args, args_cli));
|
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") {
|
THEN ("The first layer of the print should be centered around 0,0") {
|
||||||
std::string exported { read_to_string("test_cli/20mmbox.gcode"s)};
|
std::string exported { read_to_string(testfile("test_cli/20mmbox.gcode"))};
|
||||||
GCodeReader reader;
|
GCodeReader reader;
|
||||||
REQUIRE(exported != ""s);
|
REQUIRE(exported != ""s);
|
||||||
double min_x = 50.0, max_x = -50.0, min_y = 50.0, max_y = -50.0;
|
double min_x = 50.0, max_x = -50.0, min_y = 50.0, max_y = -50.0;
|
||||||
@ -284,7 +283,7 @@ SCENARIO("CLI positioning arguments") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
clean_array(in_args.size(), args_cli);
|
clean_array(in_args.size(), args_cli);
|
||||||
clean_file("test_cli/20mmbox", "gcode");
|
clean_file("test_cli/20mmbox", "gcode");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ extrusion_width = 0
|
|||||||
fill_density = 0%
|
fill_density = 0%
|
||||||
fill_gaps = 1
|
fill_gaps = 1
|
||||||
first_layer_extrusion_width = 0.2
|
first_layer_extrusion_width = 0.2
|
||||||
first_layer_height = 0.3
|
first_layer_height = 0.1
|
||||||
infill_extrusion_width = 0
|
infill_extrusion_width = 0
|
||||||
interface_shells = 0
|
interface_shells = 0
|
||||||
interior_brim_width = 0
|
interior_brim_width = 0
|
||||||
layer_height = 0.3
|
layer_height = 0.1
|
||||||
min_shell_thickness = 0
|
min_shell_thickness = 0
|
||||||
only_retract_when_crossing_perimeters = 1
|
only_retract_when_crossing_perimeters = 1
|
||||||
ooze_prevention = 0
|
ooze_prevention = 0
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "../test_data.hpp"
|
#include "../test_data.hpp"
|
||||||
#include "../../libslic3r/libslic3r.h"
|
#include "../../libslic3r/libslic3r.h"
|
||||||
|
#include "../../libslic3r/SVG.hpp"
|
||||||
|
|
||||||
using namespace Slic3r::Test;
|
using namespace Slic3r::Test;
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
@ -78,6 +79,13 @@ SCENARIO("Print: Brim generation") {
|
|||||||
Print print{};
|
Print print{};
|
||||||
Slic3r::Test::init_print(print, { m }, model, config);
|
Slic3r::Test::init_print(print, { m }, model, config);
|
||||||
print.process();
|
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") {
|
THEN("Brim Extrusion collection has 3 loops in it") {
|
||||||
REQUIRE(print.brim().items_count() == 3);
|
REQUIRE(print.brim().items_count() == 3);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user