diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index 9ab0838a51..ee8c7f219e 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -1376,6 +1376,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_ // Get the regions needing a suport, collapse very tiny spots. //FIXME cache the lower layer offset if this layer has multiple regions. #if 1 + //FIXME this solution will trigger stupid supports for sharp corners, see GH #4874 diff_polygons = offset2( diff(layerm_polygons, offset2(lower_layer_polygons, - 0.5f * fw, lower_layer_offset + 0.5f * fw, SUPPORT_SURFACES_OFFSET_PARAMETERS)), @@ -1602,7 +1603,10 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_ slices_margin_cached); SupportGridPattern support_grid_pattern( // Support islands, to be stretched into a grid. - dense_interface_polygons, + //FIXME The regularization of dense_interface_polygons above may stretch dense_interface_polygons outside of the contact polygons, + // thus some dense interface areas may not get supported. Trim the excess with contact_polygons at the following line. + // See for example GH #4874. + intersection(dense_interface_polygons, *new_layer.contact_polygons), // Trimming polygons, to trim the stretched support islands. slices_margin_cached, // Grid resolution. @@ -1611,50 +1615,30 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_ m_support_material_flow.spacing()); new_layer.polygons = support_grid_pattern.extract_support(m_support_material_flow.scaled_spacing()/2 + 5, false); #ifdef SLIC3R_DEBUG - { - BoundingBox bbox = get_extents(dense_interface_polygons); - bbox.merge(get_extents(slices_margin_cached)); - bbox.merge(get_extents(new_layer.polygons)); - ::Slic3r::SVG svg(debug_out_path("support-top-contacts-grid-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), bbox); - svg.draw(union_ex(lower_layer_polygons, false), "gray", 0.2f); - svg.draw(union_ex(*new_layer.contact_polygons, false), "gray", 0.5f); - svg.draw(union_ex(slices_margin_cached, false), "blue", 0.5f); - svg.draw(union_ex(dense_interface_polygons, false), "green", 0.5f); - svg.draw(union_ex(new_layer.polygons, true), "red", 0.5f); - svg.draw_outline(union_ex(new_layer.polygons, true), "black", "black", scale_(0.1f)); - } - #endif /* SLIC3R_DEBUG */ - #ifdef SLIC3R_DEBUG - { - //support_grid_pattern.serialize(debug_out_path("support-top-contacts-final-run%d-layer%d-z%f.bin", iRun, layer_id, layer.print_z)); - - BoundingBox bbox = get_extents(contact_polygons); - bbox.merge(get_extents(new_layer.polygons)); - ::Slic3r::SVG svg(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), bbox); - svg.draw(union_ex(lower_layer_polygons, false), "gray", 0.2f); - svg.draw(union_ex(*new_layer.contact_polygons, false), "gray", 0.5f); - svg.draw(union_ex(contact_polygons, false), "blue", 0.5f); - svg.draw(union_ex(dense_interface_polygons, false), "green", 0.5f); - svg.draw(union_ex(new_layer.polygons, true), "red", 0.5f); - svg.draw_outline(union_ex(new_layer.polygons, true), "black", "black", scale_(0.1f)); - } + SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), + { { { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "gray", 0.2f } }, + { { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } }, + { { union_ex(slices_margin_cached, false) }, { "slices_margin_cached", "blue", 0.5f } }, + { { union_ex(dense_interface_polygons, false) }, { "dense_interface_polygons", "green", 0.5f } }, + { { union_ex(new_layer.polygons, true) }, { "new_layer.polygons", "red", "black", "", scaled(0.1f), 0.5f } } }); + //support_grid_pattern.serialize(debug_out_path("support-top-contacts-final-run%d-layer%d-z%f.bin", iRun, layer_id, layer.print_z)); + SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), + { { { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "gray", 0.2f } }, + { { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } }, + { { union_ex(contact_polygons, false) }, { "contact_polygons", "blue", 0.5f } }, + { { union_ex(dense_interface_polygons, false) }, { "dense_interface_polygons", "green", 0.5f } }, + { { union_ex(new_layer.polygons, true) }, { "new_layer.polygons", "red", "black", "", scaled(0.1f), 0.5f } } }); #endif /* SLIC3R_DEBUG */ } } #ifdef SLIC3R_DEBUG - { - BoundingBox bbox = get_extents(contact_polygons); - bbox.merge(get_extents(new_layer.polygons)); - bbox.merge(get_extents(overhang_polygons)); - ::Slic3r::SVG svg(debug_out_path("support-top-contacts-final-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), bbox); - svg.draw(union_ex(lower_layer_polygons, false), "gray", 0.2f); - svg.draw(union_ex(*new_layer.contact_polygons, false), "gray", 0.5f); - svg.draw(union_ex(contact_polygons, false), "blue", 0.5f); - svg.draw(union_ex(overhang_polygons, false), "green", 0.5f); - svg.draw(union_ex(new_layer.polygons, true), "red", 0.5f); - svg.draw_outline(union_ex(new_layer.polygons, true), "black", "black", scale_(0.1f)); - } - #endif /* SLIC3R_DEBUG */ + SVG::export_expolygons(debug_out_path("support-top-contacts-final0-run%d-layer%d-z%f.svg", iRun, layer_id, layer.print_z), + { { { union_ex(lower_layer_polygons, false) }, { "lower_layer_polygons", "gray", 0.2f } }, + { { union_ex(*new_layer.contact_polygons, false) }, { "new_layer.contact_polygons", "yellow", 0.5f } }, + { { union_ex(contact_polygons, false) }, { "contact_polygons", "blue", 0.5f } }, + { { union_ex(overhang_polygons, false) }, { "overhang_polygons", "green", 0.5f } }, + { { union_ex(new_layer.polygons, true) }, { "new_layer.polygons", "red", "black", "", scaled(0.1f), 0.5f } } }); + #endif /* SLIC3R_DEBUG */ // 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.