Bugfix: prevent crash in brim code. #3981

This commit is contained in:
Alessandro Ranellucci 2017-06-01 10:33:32 +02:00
parent b3d33ff3da
commit 5493f4b0a6

View File

@ -753,6 +753,7 @@ Print::skirt_first_layer_height() const
return this->objects.front()->config.get_abs_value("first_layer_height"); return this->objects.front()->config.get_abs_value("first_layer_height");
} }
// This will throw an exception when called without PrintObjects
Flow Flow
Print::brim_flow() const Print::brim_flow() const
{ {
@ -778,6 +779,7 @@ Print::brim_flow() const
return flow; return flow;
} }
// This will throw an exception when called without PrintObjects
Flow Flow
Print::skirt_flow() const Print::skirt_flow() const
{ {
@ -808,15 +810,15 @@ Print::_make_brim()
// checking whether we need to generate them // checking whether we need to generate them
this->brim.clear(); this->brim.clear();
if (this->config.brim_width == 0 if (this->objects.empty()
&& this->config.interior_brim_width == 0 || (this->config.brim_width == 0
&& this->config.brim_connections_width == 0) { && this->config.interior_brim_width == 0
&& this->config.brim_connections_width == 0)) {
this->state.set_done(psBrim); this->state.set_done(psBrim);
return; return;
} }
// brim is only printed on first layer and uses perimeter extruder // brim is only printed on first layer and uses perimeter extruder
const double first_layer_height = this->skirt_first_layer_height();
const Flow flow = this->brim_flow(); const Flow flow = this->brim_flow();
const double mm3_per_mm = flow.mm3_per_mm(); const double mm3_per_mm = flow.mm3_per_mm();
@ -864,7 +866,7 @@ Print::_make_brim()
{ {
Polygons chained = union_pt_chained(loops); Polygons chained = union_pt_chained(loops);
for (Polygons::const_reverse_iterator p = chained.rbegin(); p != chained.rend(); ++p) { for (Polygons::const_reverse_iterator p = chained.rbegin(); p != chained.rend(); ++p) {
ExtrusionPath path(erSkirt, mm3_per_mm, flow.width, first_layer_height); ExtrusionPath path(erSkirt, mm3_per_mm, flow.width, flow.height);
path.polyline = p->split_at_first_point(); path.polyline = p->split_at_first_point();
this->brim.append(ExtrusionLoop(path)); this->brim.append(ExtrusionLoop(path));
} }
@ -920,7 +922,7 @@ Print::_make_brim()
const Polylines paths = filler->fill_surface(Surface(stBottom, *ex)); const Polylines paths = filler->fill_surface(Surface(stBottom, *ex));
for (Polylines::const_iterator pl = paths.begin(); pl != paths.end(); ++pl) { for (Polylines::const_iterator pl = paths.begin(); pl != paths.end(); ++pl) {
ExtrusionPath path(erSkirt, mm3_per_mm, flow.width, first_layer_height); ExtrusionPath path(erSkirt, mm3_per_mm, flow.width, flow.height);
path.polyline = *pl; path.polyline = *pl;
this->brim.append(path); this->brim.append(path);
} }
@ -963,7 +965,7 @@ Print::_make_brim()
loops = union_pt_chained(loops); loops = union_pt_chained(loops);
for (const Polygon &p : loops) { for (const Polygon &p : loops) {
ExtrusionPath path(erSkirt, mm3_per_mm, flow.width, first_layer_height); ExtrusionPath path(erSkirt, mm3_per_mm, flow.width, flow.height);
path.polyline = p.split_at_first_point(); path.polyline = p.split_at_first_point();
this->brim.append(ExtrusionLoop(path)); this->brim.append(ExtrusionLoop(path));
} }