Keep brim always attached to the object when support material is enabled. #2981

This commit is contained in:
Alessandro Ranellucci 2017-04-01 17:23:07 +02:00
parent 4304c2a1f4
commit 678ae9de72
5 changed files with 33 additions and 8 deletions

View File

@ -8,7 +8,7 @@ use Slic3r::ExtrusionPath ':roles';
use Slic3r::Flow ':roles'; use Slic3r::Flow ':roles';
use Slic3r::Geometry qw(epsilon scale scaled_epsilon PI rad2deg deg2rad convex_hull); use Slic3r::Geometry qw(epsilon scale scaled_epsilon PI rad2deg deg2rad convex_hull);
use Slic3r::Geometry::Clipper qw(offset diff union union_ex intersection offset_ex offset2 use Slic3r::Geometry::Clipper qw(offset diff union union_ex intersection offset_ex offset2
intersection_pl offset2_ex diff_pl); intersection_pl offset2_ex diff_pl diff_ex);
use Slic3r::Surface ':types'; use Slic3r::Surface ':types';
has 'print_config' => (is => 'rw', required => 1); has 'print_config' => (is => 'rw', required => 1);
@ -782,7 +782,7 @@ sub generate_toolpaths {
my $base_flow = $_flow; my $base_flow = $_flow;
# find centerline of the external loop/extrusions # find centerline of the external loop/extrusions
my $to_infill = offset2_ex($base, +scaled_epsilon, -(scaled_epsilon + $_flow->scaled_width/2)); my $to_infill = offset2($base, +scaled_epsilon, -(scaled_epsilon + $_flow->scaled_width/2));
my @paths = (); my @paths = ();
@ -796,6 +796,15 @@ sub generate_toolpaths {
# use the proper spacing for first layer as we don't need to align # use the proper spacing for first layer as we don't need to align
# its pattern to the other layers # its pattern to the other layers
$filler->set_min_spacing($base_flow->spacing); $filler->set_min_spacing($base_flow->spacing);
# subtract brim so that it goes around the object fully (and support gets its own brim)
if ($self->print_config->brim_width > 0) {
my $d = +scale $self->print_config->brim_width*2;
$to_infill = diff_ex(
$to_infill,
offset($object->get_layer(0)->slices->polygons, $d),
);
}
} else { } else {
# draw a perimeter all around support infill # draw a perimeter all around support infill
# TODO: use brim ordering algorithm # TODO: use brim ordering algorithm
@ -806,10 +815,10 @@ sub generate_toolpaths {
mm3_per_mm => $mm3_per_mm, mm3_per_mm => $mm3_per_mm,
width => $_flow->width, width => $_flow->width,
height => $layer->height, height => $layer->height,
), map @$_, @$to_infill; ), @$to_infill;
# TODO: use offset2_ex() # TODO: use offset2_ex()
$to_infill = offset_ex([ map @$_, @$to_infill ], -$_flow->scaled_spacing); $to_infill = offset_ex($to_infill, -$_flow->scaled_spacing);
} }
my $mm3_per_mm = $base_flow->mm3_per_mm; my $mm3_per_mm = $base_flow->mm3_per_mm;

View File

@ -1,3 +1,6 @@
#define DEBUG
#undef NDEBUG
#include <cassert>
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>

View File

@ -50,6 +50,11 @@ Flow::spacing() const {
return this->width - OVERLAP_FACTOR * (this->width - min_flow_spacing); return this->width - OVERLAP_FACTOR * (this->width - min_flow_spacing);
} }
void
Flow::set_spacing(float spacing) {
this->width = Flow::_width_from_spacing(spacing, this->nozzle_diameter, this->height, this->bridge);
}
/* This method returns the centerline spacing between an extrusion using this /* This method returns the centerline spacing between an extrusion using this
flow and another one using another flow. flow and another one using another flow.
this->spacing(other) shall return the same value as other.spacing(*this) */ this->spacing(other) shall return the same value as other.spacing(*this) */

View File

@ -30,6 +30,7 @@ class Flow
: width(_w), height(_h), nozzle_diameter(_nd), bridge(_bridge) {}; : width(_w), height(_h), nozzle_diameter(_nd), bridge(_bridge) {};
float spacing() const; float spacing() const;
float spacing(const Flow &other) const; float spacing(const Flow &other) const;
void set_spacing(float spacing);
double mm3_per_mm() const; double mm3_per_mm() const;
coord_t scaled_width() const { coord_t scaled_width() const {
return scale_(this->width); return scale_(this->width);
@ -48,7 +49,6 @@ class Flow
static float _bridge_width(float nozzle_diameter, float bridge_flow_ratio); static float _bridge_width(float nozzle_diameter, float bridge_flow_ratio);
static float _auto_width(FlowRole role, float nozzle_diameter, float height); static float _auto_width(FlowRole role, float nozzle_diameter, float height);
static float _width_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge); static float _width_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge);
static float _spacing(float width, float nozzle_diameter, float height, float bridge_flow_ratio);
}; };
} }

View File

@ -163,6 +163,10 @@ Print::invalidate_state_by_config(const PrintConfigBase &config)
|| opt_key == "min_skirt_length" || opt_key == "min_skirt_length"
|| opt_key == "ooze_prevention") { || opt_key == "ooze_prevention") {
steps.insert(psSkirt); steps.insert(psSkirt);
} else if (opt_key == "brim_width") {
steps.insert(psBrim);
steps.insert(psSkirt);
osteps.insert(posSupportMaterial);
} else if (opt_key == "brim_width" } else if (opt_key == "brim_width"
|| opt_key == "interior_brim_width" || opt_key == "interior_brim_width"
|| opt_key == "brim_connections_width") { || opt_key == "brim_connections_width") {
@ -759,13 +763,17 @@ Print::brim_flow() const
extruders and take the one with, say, the smallest index. extruders and take the one with, say, the smallest index.
The same logic should be applied to the code that selects the extruder during G-code The same logic should be applied to the code that selects the extruder during G-code
generation as well. */ generation as well. */
return Flow::new_from_config_width( Flow flow = Flow::new_from_config_width(
frPerimeter, frPerimeter,
width, width,
this->config.nozzle_diameter.get_at(this->regions.front()->config.perimeter_extruder-1), this->config.nozzle_diameter.get_at(this->regions.front()->config.perimeter_extruder-1),
this->skirt_first_layer_height(), this->skirt_first_layer_height(),
0 0
); );
flow.set_spacing(unscale(Fill::adjust_solid_spacing(scale_(this->config.brim_width.value), scale_(flow.spacing()))));
return flow;
} }
Flow Flow
@ -844,8 +852,8 @@ Print::_make_brim()
// perimeters because here we're offsetting outwards) // perimeters because here we're offsetting outwards)
append_to(loops, offset2( append_to(loops, offset2(
islands, islands,
flow.scaled_width() + flow.scaled_spacing() * (i - 1.0 + 0.5), flow.scaled_width() + flow.scaled_spacing() * (i - 1.5 + 0.5),
flow.scaled_spacing() * -1.0, flow.scaled_spacing() * -0.5,
100000, 100000,
ClipperLib::jtSquare ClipperLib::jtSquare
)); ));