When the support extruders are set to 0, support is printed with the current material without a tool change.

A fix of support path generator.
This commit is contained in:
bubnikv 2017-01-30 19:56:46 +01:00
parent 4e90ae9a28
commit 4ab972b87a
7 changed files with 77 additions and 53 deletions

View file

@ -323,13 +323,26 @@ std::set<size_t>
Print::support_material_extruders() const
{
std::set<size_t> extruders;
bool support_uses_current_extruder = false;
FOREACH_OBJECT(this, object) {
if ((*object)->has_support_material()) {
extruders.insert((*object)->config.support_material_extruder - 1);
extruders.insert((*object)->config.support_material_interface_extruder - 1);
if ((*object)->config.support_material_extruder == 0)
support_uses_current_extruder = true;
else
extruders.insert((*object)->config.support_material_extruder - 1);
if ((*object)->config.support_material_interface_extruder == 0)
support_uses_current_extruder = true;
else
extruders.insert((*object)->config.support_material_interface_extruder - 1);
}
}
if (support_uses_current_extruder) {
// Add all object extruders to the support extruders as it is not know which one will be used to print supports.
std::set<size_t> object_extruders = this->object_extruders();
extruders.insert(object_extruders.begin(), object_extruders.end());
}
return extruders;
}
@ -653,6 +666,17 @@ Print::validate() const
FOREACH_OBJECT(this, i_object) {
PrintObject* object = *i_object;
if ((object->config.support_material_extruder == -1 || object->config.support_material_interface_extruder == -1) &&
(object->config.raft_layers > 0 || object->config.support_material.value)) {
// The object has some form of support and either support_material_extruder or support_material_interface_extruder
// will be printed with the current tool without a forced tool change. Play safe, assert that all object nozzles
// are of the same diameter.
if (nozzle_diameters.size() > 1)
return "Printing with multiple extruders of differing nozzle diameters. "
"If support is to be printed with the current extruder (support_material_extruder == 0 or support_material_interface_extruder == 0), ",
"all nozzles have to be of the same diameter.";
}
// validate first_layer_height
double first_layer_height = object->config.get_abs_value("first_layer_height");
@ -662,7 +686,9 @@ Print::validate() const
size_t first_layer_extruder = object->config.raft_layers == 1
? object->config.support_material_interface_extruder-1
: object->config.support_material_extruder-1;
first_layer_min_nozzle_diameter = this->config.nozzle_diameter.get_at(first_layer_extruder);
first_layer_min_nozzle_diameter = (first_layer_extruder == size_t(-1)) ?
min_nozzle_diameter :
this->config.nozzle_diameter.get_at(first_layer_extruder);
} else {
// if we don't have raft layers, any nozzle diameter is potentially used in first layer
first_layer_min_nozzle_diameter = min_nozzle_diameter;

View file

@ -1176,9 +1176,9 @@ PrintConfigDef::PrintConfigDef()
def = this->add("support_material_extruder", coInt);
def->label = "Support material/raft/skirt extruder";
def->category = "Extruders";
def->tooltip = "The extruder to use when printing support material, raft and skirt.";
def->tooltip = "The extruder to use when printing support material, raft and skirt (1+, 0 to use the current extruder to minimize tool changes).";
def->cli = "support-material-extruder=i";
def->min = 1;
def->min = 0;
def->default_value = new ConfigOptionInt(1);
def = this->add("support_material_extrusion_width", coFloatOrPercent);
@ -1199,9 +1199,9 @@ PrintConfigDef::PrintConfigDef()
def = this->add("support_material_interface_extruder", coInt);
def->label = "Support material/raft interface extruder";
def->category = "Extruders";
def->tooltip = "The extruder to use when printing support material interface. This affects raft too.";
def->tooltip = "The extruder to use when printing support material interface (1+, 0 to use the current extruder to minimize tool changes). This affects raft too.";
def->cli = "support-material-interface-extruder=i";
def->min = 1;
def->min = 0;
def->default_value = new ConfigOptionInt(1);
def = this->add("support_material_interface_layers", coInt);

View file

@ -27,6 +27,11 @@ SlicingParameters SlicingParameters::create_from_config(
coordf_t first_layer_height = (object_config.first_layer_height.value <= 0) ?
object_config.layer_height.value :
object_config.first_layer_height.get_abs_value(object_config.layer_height.value);
// If object_config.support_material_extruder == 0 resp. object_config.support_material_interface_extruder == 0,
// print_config.nozzle_diameter.get_at(size_t(-1)) returns the 0th nozzle diameter,
// which is consistent with the requirement that if support_material_extruder == 0 resp. support_material_interface_extruder == 0,
// support will not trigger tool change, but it will use the current nozzle instead.
// In that case all the nozzles have to be of the same diameter.
coordf_t support_material_extruder_dmr = print_config.nozzle_diameter.get_at(object_config.support_material_extruder.value - 1);
coordf_t support_material_interface_extruder_dmr = print_config.nozzle_diameter.get_at(object_config.support_material_interface_extruder.value - 1);
bool soluble_interface = object_config.support_material_contact_distance.value == 0.;

View file

@ -150,6 +150,7 @@ PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object
frSupportMaterial,
// The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution.
(object->config.support_material_extrusion_width.value > 0) ? object->config.support_material_extrusion_width : object->config.extrusion_width,
// if object->config.support_material_extruder == 0 (which means to not trigger tool change, but use the current extruder instead), get_at will return the 0th component.
float(object->print()->config.nozzle_diameter.get_at(object->config.support_material_extruder-1)),
float(slicing_params.layer_height),
false)),
@ -157,6 +158,7 @@ PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object
frSupportMaterialInterface,
// The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution.
(object->config.support_material_extrusion_width > 0) ? object->config.support_material_extrusion_width : object->config.extrusion_width,
// if object->config.support_material_interface_extruder == 0 (which means to not trigger tool change, but use the current extruder instead), get_at will return the 0th component.
float(object->print()->config.nozzle_diameter.get_at(object->config.support_material_interface_extruder-1)),
float(slicing_params.layer_height),
false)),
@ -636,7 +638,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_
#ifdef SLIC3R_DEBUG
Slic3r::SVG::export_expolygons(
debug_out_path("support-top-contacts-filtered-run%d-layer%d-region%d.svg", iRun, layer_id, it_layerm - layer.regions.begin()),
debug_out_path("support-top-contacts-filtered-run%d-layer%d-region%d-z%f.svg", iRun, layer_id, it_layerm - layer.regions.begin(), layer.print_z),
union_ex(diff_polygons, false));
#endif /* SLIC3R_DEBUG */
@ -758,7 +760,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_
bbox.align_to_grid(grid_resolution);
grid.set_bbox(bbox);
grid.create(contact_polygons, grid_resolution);
grid.calculate_sdf();
grid.calculate_sdf();
// Extract a bounding contour from the grid, trim by the object.
// 1) infill polygons, expand them by half the extrusion width + a tiny bit of extra.
new_layer.polygons = diff(
@ -772,6 +774,9 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_
false));
}
#endif
// Even after the contact layer was expanded into a grid, some of the contact islands may be too tiny to be extruded.
// Remove those tiny islands from new_layer.polygons and new_layer.contact_polygons.
// Store the overhang polygons.
// The overhang polygons are used in the path generator for planning of the contact loops.
@ -2182,33 +2187,20 @@ void PrintObjectSupportMaterial::generate_toolpaths(
MyLayerExtruded top_contact_layer;
MyLayerExtruded base_layer;
MyLayerExtruded interface_layer;
MyLayerExtrudedPtrs mylayers;
// Increment the layer indices to find a layer at support_layer.print_z.
for (; idx_layer_bottom_contact < bottom_contacts .size() && bottom_contacts [idx_layer_bottom_contact]->print_z < support_layer.print_z - EPSILON; ++ idx_layer_bottom_contact) ;
for (; idx_layer_top_contact < top_contacts .size() && top_contacts [idx_layer_top_contact ]->print_z < support_layer.print_z - EPSILON; ++ idx_layer_top_contact ) ;
for (; idx_layer_intermediate < intermediate_layers.size() && intermediate_layers[idx_layer_intermediate ]->print_z < support_layer.print_z - EPSILON; ++ idx_layer_intermediate ) ;
for (; idx_layer_inteface < interface_layers .size() && interface_layers [idx_layer_inteface ]->print_z < support_layer.print_z - EPSILON; ++ idx_layer_inteface ) ;
// Copy polygons from the layers.
mylayers.reserve(4);
if (idx_layer_bottom_contact < bottom_contacts.size() && bottom_contacts[idx_layer_bottom_contact]->print_z < support_layer.print_z + EPSILON) {
if (idx_layer_bottom_contact < bottom_contacts.size() && bottom_contacts[idx_layer_bottom_contact]->print_z < support_layer.print_z + EPSILON)
bottom_contact_layer.layer = bottom_contacts[idx_layer_bottom_contact];
mylayers.push_back(&bottom_contact_layer);
}
if (idx_layer_top_contact < top_contacts.size() && top_contacts[idx_layer_top_contact]->print_z < support_layer.print_z + EPSILON) {
if (idx_layer_top_contact < top_contacts.size() && top_contacts[idx_layer_top_contact]->print_z < support_layer.print_z + EPSILON)
top_contact_layer.layer = top_contacts[idx_layer_top_contact];
mylayers.push_back(&top_contact_layer);
}
if (idx_layer_inteface < interface_layers.size() && interface_layers[idx_layer_inteface]->print_z < support_layer.print_z + EPSILON) {
if (idx_layer_inteface < interface_layers.size() && interface_layers[idx_layer_inteface]->print_z < support_layer.print_z + EPSILON)
interface_layer.layer = interface_layers[idx_layer_inteface];
mylayers.push_back(&interface_layer);
}
if (idx_layer_intermediate < intermediate_layers.size() && intermediate_layers[idx_layer_intermediate]->print_z < support_layer.print_z + EPSILON) {
if (idx_layer_intermediate < intermediate_layers.size() && intermediate_layers[idx_layer_intermediate]->print_z < support_layer.print_z + EPSILON)
base_layer.layer = intermediate_layers[idx_layer_intermediate];
mylayers.push_back(&base_layer);
}
// Sort the layers with the same print_z coordinate by their heights, thickest first.
std::sort(mylayers.begin(), mylayers.end(), [](const MyLayerExtruded *p1, const MyLayerExtruded *p2) { return p1->layer->height > p2->layer->height; });
if (m_object_config->support_material_interface_layers == 0) {
// If no interface layers were requested, we treat the contact layer exactly as a generic base layer.
@ -2316,6 +2308,18 @@ void PrintObjectSupportMaterial::generate_toolpaths(
erSupportMaterial, flow);
}
MyLayerExtrudedPtrs mylayers;
mylayers.reserve(4);
if (! bottom_contact_layer.empty())
mylayers.push_back(&bottom_contact_layer);
if (! top_contact_layer.empty())
mylayers.push_back(&top_contact_layer);
if (! interface_layer.empty())
mylayers.push_back(&interface_layer);
if (! base_layer.empty())
mylayers.push_back(&base_layer);
// Sort the layers with the same print_z coordinate by their heights, thickest first.
std::sort(mylayers.begin(), mylayers.end(), [](const MyLayerExtruded *p1, const MyLayerExtruded *p2) { return p1->layer->height > p2->layer->height; });
// Collect the support areas with this print_z into islands, as there is no need
// for retraction over these islands.
Polygons polys;