Skip to content

Commit

Permalink
Avoid placing seams on overhang areas calculated by supports
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Mar 21, 2024
1 parent 794357b commit 89beded
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
15 changes: 14 additions & 1 deletion include/PathOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class PathOrderOptimizer
*/
ZSeamConfig seam_config_;

const std::vector<Polygons> overhang_areas_;

static const std::unordered_multimap<Path, Path> no_order_requirements_;

/*!
Expand All @@ -110,8 +112,10 @@ class PathOrderOptimizer
const Polygons* combing_boundary = nullptr,
const bool reverse_direction = false,
const std::unordered_multimap<Path, Path>& order_requirements = no_order_requirements_,
const bool group_outer_walls = false)
const bool group_outer_walls = false,
const std::vector<Polygons>& overhang_areas = {})
: start_point_(start_point)
, overhang_areas_(overhang_areas)
, seam_config_(seam_config)
, combing_boundary_((combing_boundary != nullptr && ! combing_boundary->empty()) ? combing_boundary : nullptr)
, detect_loops_(detect_loops)
Expand Down Expand Up @@ -718,6 +722,15 @@ class PathOrderOptimizer
}
}

for (const Polygons& overhang_area : overhang_areas_)
{
if (overhang_area.inside(here))
{
score *= 50;
break;
}
}

constexpr double EPSILON = 5.0;
if (std::abs(best_score - score) <= EPSILON)
{
Expand Down
14 changes: 13 additions & 1 deletion src/InsetOrderOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,20 @@ bool InsetOrderOptimizer::addToLayer()
const auto group_outer_walls = settings_.get<bool>("group_outer_walls");
// When we alternate walls, also alternate the direction at which the first wall starts in.
// On even layers we start with normal direction, on odd layers with inverted direction.

std::vector<Polygons> overhang_areas;
for (const std::shared_ptr<SliceMeshStorage>& mesh : storage_.meshes)
{
if (layer_nr_ > 0 && layer_nr_ < mesh->overhang_areas.size())
{
// For the offset we should take the support XY distance plus a few line_widths
overhang_areas.push_back(mesh->overhang_areas[layer_nr_].offset(5000));
svg.writePolygons(mesh->overhang_areas[layer_nr_].offset(5000), SVG::Color::BLACK, 0.05);
}
}

PathOrderOptimizer<const ExtrusionLine*>
order_optimizer(gcode_layer_.getLastPlannedPositionOrStartingPosition(), z_seam_config_, detect_loops, combing_boundary, reverse, order, group_outer_walls);
order_optimizer(gcode_layer_.getLastPlannedPositionOrStartingPosition(), z_seam_config_, detect_loops, combing_boundary, reverse, order, group_outer_walls, overhang_areas);

for (const auto& line : walls_to_be_added)
{
Expand Down

0 comments on commit 89beded

Please sign in to comment.