Fix brim entity collection handling

supermerill/SuperSlicer#2331
This commit is contained in:
remi durand 2022-02-08 19:57:32 +01:00 committed by supermerill
parent bee8247cb2
commit 4eecaa943a

View File

@ -2261,7 +2261,8 @@ void Print::_extrude_brim_from_tree(std::vector<std::vector<BrimLoop>>& loops, c
//nothing
} else if (i_have_line && to_cut.children.empty()) {
ExtrusionEntitiesPtr to_add;
for(Polyline& line : to_cut.lines)
for (Polyline& line : to_cut.lines) {
assert(line.size() > 0);
if (line.points.back() == line.points.front()) {
ExtrusionPath path(erSkirt, mm3_per_mm, width, height);
path.polyline.points = line.points;
@ -2271,6 +2272,7 @@ void Print::_extrude_brim_from_tree(std::vector<std::vector<BrimLoop>>& loops, c
to_add.emplace_back(extrusion_path);
extrusion_path->polyline = line;
}
}
parent->append(std::move(to_add));
} else if (!i_have_line && !to_cut.children.empty()) {
if (to_cut.children.size() == 1) {
@ -2292,10 +2294,11 @@ void Print::_extrude_brim_from_tree(std::vector<std::vector<BrimLoop>>& loops, c
}
} else {
ExtrusionEntityCollection* print_me_first = new ExtrusionEntityCollection();
ExtrusionEntitiesPtr to_add;
to_add.emplace_back(print_me_first);
print_me_first->set_can_sort_reverse(false, false);
for (Polyline& line : to_cut.lines)
parent->append({ print_me_first });
ExtrusionEntitiesPtr to_add;
for (Polyline& line : to_cut.lines) {
assert(line.size() > 0);
if (line.points.back() == line.points.front()) {
ExtrusionPath path(erSkirt, mm3_per_mm, width, height);
path.polyline.points = line.points;
@ -2305,7 +2308,8 @@ void Print::_extrude_brim_from_tree(std::vector<std::vector<BrimLoop>>& loops, c
to_add.emplace_back(extrusion_path);
extrusion_path->polyline = line;
}
parent->append(std::move(to_add));
}
print_me_first->append(std::move(to_add));
if (to_cut.children.size() == 1) {
(*extrude_ptr)(to_cut.children[0], print_me_first);
} else {
@ -2315,14 +2319,15 @@ void Print::_extrude_brim_from_tree(std::vector<std::vector<BrimLoop>>& loops, c
(*extrude_ptr)(child, children);
//remove un-needed collection if possible
if (children->entities().size() == 1) {
parent->append(*children->entities().front());
print_me_first->append(*children->entities().front());
delete children;
} else if (children->entities().size() == 0) {
delete children;
} else {
parent->append(ExtrusionEntitiesPtr{ children });
print_me_first->append(ExtrusionEntitiesPtr{ children });
}
}
assert(print_me_first.size() > 0);
}
};
extrude_ptr = &extrude;