Added new option for additional overlap between regions printed with distinct extruders or settings

This commit is contained in:
Alessandro Ranellucci 2017-06-19 11:25:11 +02:00
parent abc96ad3bf
commit 2ee32bb244
4 changed files with 60 additions and 29 deletions

View File

@ -467,7 +467,7 @@ sub options {
perimeter_extruder infill_extruder solid_infill_extruder perimeter_extruder infill_extruder solid_infill_extruder
support_material_extruder support_material_interface_extruder support_material_extruder support_material_interface_extruder
ooze_prevention standby_temperature_delta ooze_prevention standby_temperature_delta
interface_shells interface_shells regions_overlap
extrusion_width first_layer_extrusion_width perimeter_extrusion_width extrusion_width first_layer_extrusion_width perimeter_extrusion_width
external_perimeter_extrusion_width infill_extrusion_width solid_infill_extrusion_width external_perimeter_extrusion_width infill_extrusion_width solid_infill_extrusion_width
top_infill_extrusion_width support_material_extrusion_width top_infill_extrusion_width support_material_extrusion_width
@ -665,6 +665,7 @@ sub build {
} }
{ {
my $optgroup = $page->new_optgroup('Advanced'); my $optgroup = $page->new_optgroup('Advanced');
$optgroup->append_single_option_line('regions_overlap');
$optgroup->append_single_option_line('interface_shells'); $optgroup->append_single_option_line('interface_shells');
} }
} }

View File

@ -967,6 +967,14 @@ PrintConfigDef::PrintConfigDef()
def->min = 0; def->min = 0;
def->default_value = new ConfigOptionInt(0); def->default_value = new ConfigOptionInt(0);
def = this->add("regions_overlap", coFloat);
def->label = "Regions/extruders overlap";
def->category = "Extruders";
def->tooltip = "This setting applies an additional overlap between regions printed with distinct extruders or distinct settings. This shouldn't be needed under normal circumstances.";
def->sidetext = "mm";
def->cli = "regions-overlap=s";
def->default_value = new ConfigOptionFloat(0);
def = this->add("raft_offset", coFloat); def = this->add("raft_offset", coFloat);
def->label = "Raft offset"; def->label = "Raft offset";
def->category = "Support material"; def->category = "Support material";

View File

@ -161,6 +161,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
ConfigOptionBool interface_shells; ConfigOptionBool interface_shells;
ConfigOptionFloat layer_height; ConfigOptionFloat layer_height;
ConfigOptionInt raft_layers; ConfigOptionInt raft_layers;
ConfigOptionFloat regions_overlap;
ConfigOptionEnum<SeamPosition> seam_position; ConfigOptionEnum<SeamPosition> seam_position;
ConfigOptionBool support_material; ConfigOptionBool support_material;
ConfigOptionInt support_material_angle; ConfigOptionInt support_material_angle;
@ -192,6 +193,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
OPT_PTR(interface_shells); OPT_PTR(interface_shells);
OPT_PTR(layer_height); OPT_PTR(layer_height);
OPT_PTR(raft_layers); OPT_PTR(raft_layers);
OPT_PTR(regions_overlap);
OPT_PTR(seam_position); OPT_PTR(seam_position);
OPT_PTR(support_material); OPT_PTR(support_material);
OPT_PTR(support_material_angle); OPT_PTR(support_material_angle);

View File

@ -224,7 +224,8 @@ PrintObject::invalidate_state_by_config(const PrintConfigBase &config)
if (opt_key == "layer_height" if (opt_key == "layer_height"
|| opt_key == "first_layer_height" || opt_key == "first_layer_height"
|| opt_key == "xy_size_compensation" || opt_key == "xy_size_compensation"
|| opt_key == "raft_layers") { || opt_key == "raft_layers"
|| opt_key == "regions_overlap") {
steps.insert(posSlice); steps.insert(posSlice);
} else if (opt_key == "support_material_contact_distance") { } else if (opt_key == "support_material_contact_distance") {
steps.insert(posSlice); steps.insert(posSlice);
@ -737,38 +738,57 @@ void PrintObject::_slice()
} }
this->delete_layer(int(this->layers.size()) - 1); this->delete_layer(int(this->layers.size()) - 1);
} }
for (size_t layer_id = 0; layer_id < layers.size(); ++ layer_id) { // Apply size compensation and perform clipping of multi-part objects.
Layer *layer = this->layers[layer_id]; const coord_t xy_size_compensation = scale_(this->config.xy_size_compensation.value);
// Apply size compensation and perform clipping of multi-part objects. for (Layer* layer : this->layers) {
float delta = float(scale_(this->config.xy_size_compensation.value)); if (xy_size_compensation > 0) {
bool scale = delta != 0.f; if (layer->regions.size() == 1) {
if (layer->regions.size() == 1) {
if (scale) {
// Single region, growing or shrinking. // Single region, growing or shrinking.
LayerRegion *layerm = layer->regions.front(); LayerRegion* layerm = layer->regions.front();
layerm->slices.set(offset_ex(to_expolygons(std::move(layerm->slices.surfaces)), delta), stInternal); layerm->slices.set(
} offset_ex(to_expolygons(std::move(layerm->slices.surfaces)), xy_size_compensation),
} else if (scale) { stInternal
// Multiple regions, growing, shrinking or just clipping one region by the other. );
// When clipping the regions, priority is given to the first regions. } else {
Polygons processed; // Multiple regions, growing, shrinking or just clipping one region by the other.
for (size_t region_id = 0; region_id < layer->regions.size(); ++ region_id) { // When clipping the regions, priority is given to the first regions.
LayerRegion *layerm = layer->regions[region_id]; Polygons processed;
ExPolygons slices = to_expolygons(std::move(layerm->slices.surfaces)); for (size_t region_id = 0; region_id < layer->regions.size(); ++region_id) {
if (scale) LayerRegion* layerm = layer->regions[region_id];
slices = offset_ex(slices, delta); Polygons slices = layerm->slices;
if (region_id > 0)
// Trim by the slices of already processed regions. if (xy_size_compensation > 0)
slices = diff_ex(to_polygons(std::move(slices)), processed); slices = offset(slices, xy_size_compensation);
if (region_id + 1 < layer->regions.size())
// Collect the already processed regions to trim the to be processed regions. if (region_id > 0)
processed += to_polygons(slices); // Trim by the slices of already processed regions.
layerm->slices.set(std::move(slices), stInternal); slices = diff(std::move(slices), processed);
if (region_id + 1 < layer->regions.size())
// Collect the already processed regions to trim the to be processed regions.
append_to(processed, slices);
layerm->slices.set(union_ex(slices), stInternal);
}
} }
} }
// Merge all regions' slices to get islands, chain them by a shortest path. // Merge all regions' slices to get islands, chain them by a shortest path.
layer->make_slices(); layer->make_slices();
// Apply regions overlap
if (this->config.regions_overlap.value > 0) {
const coord_t delta = scale_(this->config.regions_overlap.value)/2;
for (LayerRegion* layerm : layer->regions)
layerm->slices.set(
intersection_ex(
offset(layerm->slices, +delta),
layer->slices
),
stInternal
);
}
} }
} }