Skip to content

Commit

Permalink
Fix solid_over_perimeters
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Aug 10, 2022
1 parent 1cb0fbf commit 16db2fd
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,20 +1835,24 @@ bool PrintObject::invalidate_state_by_config_options(
float max_perimeter_infill_spacing = float(layerm.flow(frSolidInfill).scaled_spacing()) * 1.75f;
// Top surfaces.
auto& cache = cache_top_botom_regions[idx_layer];
cache.top_surfaces = offset_ex(to_expolygons(layerm.slices().filter_by_type(stPosTop | stDensSolid)), min_perimeter_infill_spacing);
append(cache.top_surfaces, offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_type(stPosTop | stDensSolid)), min_perimeter_infill_spacing));
if (nb_perimeter_layers_for_solid_fill != 0 && (idx_layer > min_layer_no_solid || layer.print_z < min_z_no_solid)) {
ExPolygons raw_slice_temp = to_expolygons(layerm.slices().filter_by_type(stPosTop | stDensSolid));
ExPolygons raw_fill_temp = to_expolygons(layerm.fill_surfaces.filter_by_type(stPosTop | stDensSolid));
cache.top_surfaces = offset_ex(raw_slice_temp, min_perimeter_infill_spacing);
append(cache.top_surfaces, offset_ex(raw_fill_temp, min_perimeter_infill_spacing));
if (nb_perimeter_layers_for_solid_fill != 0) {
//it needs to be activated and we don't check the firs layers, where everything have to be solid.
cache.top_fill_surfaces = offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_type(stPosTop | stDensSolid)), max_perimeter_infill_spacing);
cache.top_perimeter_surfaces = to_expolygons(layerm.slices().filter_by_type(stPosTop | stDensSolid));
cache.top_fill_surfaces = offset_ex(raw_fill_temp, max_perimeter_infill_spacing);
cache.top_perimeter_surfaces = raw_slice_temp;
}
// Bottom surfaces.
const SurfaceType surfaces_bottom[2] = { stPosBottom | stDensSolid, stPosBottom | stDensSolid | stModBridge };
cache.bottom_surfaces = offset_ex(to_expolygons(layerm.slices().filter_by_types(surfaces_bottom, 2)), min_perimeter_infill_spacing);
append(cache.bottom_surfaces, offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_types(surfaces_bottom, 2)), min_perimeter_infill_spacing));
if (nb_perimeter_layers_for_solid_fill != 0 && (idx_layer > min_layer_no_solid || layer.print_z < min_z_no_solid)) {
cache.bottom_fill_surfaces = offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_types(surfaces_bottom, 2)), max_perimeter_infill_spacing);
cache.bottom_perimeter_surfaces = to_expolygons(layerm.slices().filter_by_types(surfaces_bottom, 2));
raw_slice_temp = to_expolygons(layerm.slices().filter_by_types(surfaces_bottom, 2));
raw_fill_temp = to_expolygons(layerm.fill_surfaces.filter_by_types(surfaces_bottom, 2));
cache.bottom_surfaces = offset_ex(raw_slice_temp, min_perimeter_infill_spacing);
append(cache.bottom_surfaces, offset_ex(raw_fill_temp, min_perimeter_infill_spacing));
if (nb_perimeter_layers_for_solid_fill != 0) {
cache.bottom_perimeter_surfaces = raw_slice_temp;
cache.bottom_fill_surfaces = offset_ex(raw_fill_temp, max_perimeter_infill_spacing);
}
// Holes over all regions. Only collect them once, they are valid for all idx_region iterations.
if (cache.holes.empty()) {
Expand Down Expand Up @@ -1888,7 +1892,7 @@ bool PrintObject::invalidate_state_by_config_options(
coord_t infill_line_spacing = solid_infill_flow.scaled_spacing();
// Find a union of perimeters below / above this surface to guarantee a minimum shell thickness.
ExPolygons shell;
ExPolygons fill_shell;
ExPolygons fill_shell; // for nb_perimeter_layers_for_solid_fill
ExPolygons max_perimeter_shell; // for nb_perimeter_layers_for_solid_fill
ExPolygons holes;
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
Expand Down Expand Up @@ -2043,9 +2047,9 @@ bool PrintObject::invalidate_state_by_config_options(
shell = intersection_ex(shell, polygonsInternal, ApplySafetyOffset::Yes);
expolygons_append(shell, diff_ex(polygonsInternal, holes));
shell = union_ex(shell);
ExPolygons toadd;
//check if a polygon is only over perimeter, in this case evict it (depends from nb_perimeter_layers_for_solid_fill value)
if (nb_perimeter_layers_for_solid_fill != 0 && (idx_layer > min_layer_no_solid || layer->print_z < min_z_no_solid)) {
ExPolygons toadd;
for (int i = 0; i < shell.size(); i++) {
if (nb_perimeter_layers_for_solid_fill < 2 || intersection_ex(ExPolygons{ shell[i] }, max_perimeter_shell, ApplySafetyOffset::No).empty()) {
ExPolygons expoly = intersection_ex(ExPolygons{ shell[i] }, fill_shell);
Expand Down
49 changes: 49 additions & 0 deletions src/libslic3r/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,53 @@ bool export_to_svg(const char *path, const Surfaces &surfaces, const float trans
return true;
}


std::string surfaceType_to_string(SurfaceType st)
{
std::string str;
if ((st & stPosTop) != 0)
str += "posTop";
if ((st & stPosBottom) != 0) {
if (!str.empty())
str += "||";
str += "posBottom";
}
if ((st & stPosInternal) != 0) {
if (!str.empty())
str += "||";
str += "posInternal";
}
if ((st & stPosPerimeter) != 0) {
if (!str.empty())
str += "||";
str += "posPerimeter";
}
if ((st & stDensSolid) != 0) {
if (!str.empty())
str += "||";
str += "densSolid";
}
if ((st & stDensSparse) != 0) {
if (!str.empty())
str += "||";
str += "densSparse";
}
if ((st & stDensVoid) != 0) {
if (!str.empty())
str += "||";
str += "densVoid";
}
if ((st & stModBridge) != 0) {
if (!str.empty())
str += "||";
str += "modBridge";
}
if ((st & stModOverBridge) != 0) {
if (!str.empty())
str += "||";
str += "modOverBridge";
}
return str.empty() ? "none" : str;
}

}
1 change: 1 addition & 0 deletions src/libslic3r/Surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ inline SurfaceType operator&=(SurfaceType& a, SurfaceType b) {
//inline bool operator!=(SurfaceType a, SurfaceType b) {
// return static_cast<uint16_t>(a) ^ static_cast<uint16_t>(b) != 0;
//}
std::string surfaceType_to_string(SurfaceType st);


class Surface
Expand Down

0 comments on commit 16db2fd

Please sign in to comment.