Skip to content

Commit

Permalink
fix support, update on layer gcode change
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jun 29, 2024
2 parents 9d8e43d + 41f00c3 commit 9f974ef
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/libslic3r/Fill/FillBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3653,9 +3653,11 @@ FillWithPerimeter::fill_surface_extrusion(const Surface* surface, const FillPara

// === extrude perimeter & associated surface at the same time, in the right order ===
//generate perimeter:
ExPolygons path_perimeter = offset2_ex(ExPolygons{ surface->expolygon },
scale_d(-this->get_spacing()), scale_d(this->get_spacing() / 2),
ClipperLib::jtMiter, scale_d(this->get_spacing()) * 10);
coord_t offset_for_overlap = scale_d(this->get_spacing() / 2) * ((1 - overlap_ratio) / 2);
ExPolygons path_perimeter = offset2_ex(ExPolygons{surface->expolygon},
scale_d(-this->get_spacing()) / 2 - offset_for_overlap,
offset_for_overlap,
ClipperLib::jtMiter, scale_d(this->get_spacing()) * 10);
//fix a bug that can happens when (positive) offsetting with a big miter limit and two island merge. See https://github.com/supermerill/SuperSlicer/issues/609
path_perimeter = intersection_ex(path_perimeter, offset_ex(surface->expolygon, scale_d(-this->get_spacing() / 2)));
for (ExPolygon& expolygon : path_perimeter) {
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/Fill/FillBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ namespace NaiveConnect {
class FillWithPerimeter : public Fill
{
public:
// bewteen 0 (0%) and 1 (100%) overlap
float overlap_ratio = 0;
std::unique_ptr<Fill> infill{ nullptr };
float ratio_fill_inside = 0.f;
FillWithPerimeter() : Fill() {}
Expand Down
16 changes: 9 additions & 7 deletions src/libslic3r/SupportMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <tbb/parallel_for.h>
#include <tbb/spin_mutex.h>
#include <tbb/task_group.h>

#pragma optimize("", off)
#define SUPPORT_USE_AGG_RASTERIZER

#ifdef SUPPORT_USE_AGG_RASTERIZER
Expand Down Expand Up @@ -3912,10 +3912,10 @@ void modulate_extrusion_by_overlapping_layers(
const PrintObjectSupportMaterial::MyLayer &overlapping_layer = *overlapping_layers[i_overlapping_layer];
bbox.merge(get_extents(overlapping_layer.polygons));
}
for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.begin(); it != extrusions_in_out.end(); ++ it) {
for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.set_entities().begin(); it != extrusions_in_out.set_entities().end(); ++ it) {
ExtrusionPath *path = dynamic_cast<ExtrusionPath*>(*it);
assert(path != nullptr);
bbox.merge(get_extents(path->polyline));
bbox.merge(get_extents(path->polyline.as_polyline()));
}
SVG svg(debug_out_path("support-fragments-%d-%lf.svg", iRun, this_layer.print_z).c_str(), bbox);
const float transparency = 0.5f;
Expand All @@ -3932,10 +3932,10 @@ void modulate_extrusion_by_overlapping_layers(
svg.draw(to_polylines(overlapping_layer.polygons), dbg_index_to_color(int(i_overlapping_layer)), scale_(0.1));
}
// Fill extrusion, the source.
for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.begin(); it != extrusions_in_out.end(); ++ it) {
for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.set_entities().begin(); it != extrusions_in_out.set_entities().end(); ++ it) {
ExtrusionPath *path = dynamic_cast<ExtrusionPath*>(*it);
std::string color_name;
switch ((it - extrusions_in_out.begin()) % 9) {
switch ((it - extrusions_in_out.set_entities().begin()) % 9) {
case 0: color_name = "magenta"; break;
case 1: color_name = "deepskyblue"; break;
case 2: color_name = "coral"; break;
Expand All @@ -3946,7 +3946,7 @@ void modulate_extrusion_by_overlapping_layers(
case 7: color_name = "brown"; break;
default: color_name = "orchid"; break;
}
svg.draw(path->polyline, color_name, scale_(0.2));
svg.draw(path->polyline.as_polyline(), color_name, scale_(0.2));
}
#endif /* SLIC3R_DEBUG */

Expand Down Expand Up @@ -4171,8 +4171,10 @@ void PrintObjectSupportMaterial::generate_toolpaths(
std::unique_ptr<Fill> filler_interface = std::unique_ptr<Fill>(Fill::new_from_type(m_support_params.contact_fill_pattern)); //m_support_params.interface_fill_pattern)); FIXME choose
std::unique_ptr<Fill> filler_support = std::unique_ptr<Fill>(Fill::new_from_type(m_support_params.base_fill_pattern));
std::unique_ptr<FillWithPerimeter> filler_support_with_sheath = std::make_unique<FillWithPerimeter>((Fill::new_from_type(m_support_params.base_fill_pattern)));
filler_support_with_sheath->overlap = m_support_params.gap_xy == 0 ? 0 : 1; // allow periemter overlap is not touching perimeters
filler_support_with_sheath->ratio_fill_inside = 0.2f;
std::unique_ptr<FillWithPerimeter> filler_dense = std::make_unique<FillWithPerimeter>((Fill::new_from_type(ipRectilinear)));
filler_dense->overlap = m_support_params.gap_xy == 0 ? 0 : 1;
filler_dense->ratio_fill_inside = 0.2f;
filler_interface->set_bounding_box(bbox_object);
filler_support->set_bounding_box(bbox_object);
Expand Down Expand Up @@ -4489,7 +4491,7 @@ void PrintObjectSupportMaterial::generate_toolpaths(
// Destination
base_layer.extrusions.set_entities(),
// Regions to fill
closing_ex(base_layer.polygons_to_extrude(), float(SCALED_EPSILON), float(SCALED_EPSILON + 0.5 * flow.scaled_width())),
closing_ex(base_layer.polygons_to_extrude(), float(SCALED_EPSILON), float(SCALED_EPSILON)),
// Filler and its parameters
filler, density,
// Extrusion parameters
Expand Down
8 changes: 7 additions & 1 deletion src/slic3r/GUI/GUI_Preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,15 @@ wxBoxSizer* Preview::create_layers_slider_sizer()
Bind(DoubleSlider::wxCUSTOMEVT_TICKSCHANGED, [this](wxEvent&) {
Model& model = wxGetApp().plater()->model();
Info custom_gcode_per_print_z = m_layers_slider->GetTicksValues();
auto num_of_old_gcodes = model.custom_gcode_per_print_z.gcodes.size();
model.custom_gcode_per_print_z = custom_gcode_per_print_z;
m_schedule_background_process();
std::string operation_message = (num_of_old_gcodes == model.custom_gcode_per_print_z.gcodes.size()) ? "Edit" :
(num_of_old_gcodes < model.custom_gcode_per_print_z.gcodes.size()) ? "Add" :
"Remove";

m_schedule_background_process();
wxGetApp().plater()->take_snapshot(from_u8(
(boost::format(_utf8(L("Change layer gcode: %s element"))) % operation_message).str()));
m_keep_current_preview_type = false;
reload_print(false);
});
Expand Down

0 comments on commit 9f974ef

Please sign in to comment.