Skip to content

Commit

Permalink
wall ordering fixing with line width
Browse files Browse the repository at this point in the history
  • Loading branch information
saumyaj3 committed Jan 4, 2024
1 parent b8e0085 commit d4d66f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class InsetOrderOptimizer
*
* \param outer_to_inner Whether the wall polygons with a lower inset_idx should go before those with a higher one.
*/
static value_type getRegionOrder(const std::vector<ExtrusionLine>& input, const bool outer_to_inner);
static value_type getRegionOrder(const std::vector<ExtrusionLine>& input, const bool outer_to_inner, const coord_t line_width);

/*!
* Get the order constraints of the insets when printing walls per inset.
Expand Down
11 changes: 7 additions & 4 deletions src/InsetOrderOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ bool InsetOrderOptimizer::addToLayer()
const auto pack_by_inset = ! settings_.get<bool>("optimize_wall_printing_order");
const auto inset_direction = settings_.get<InsetDirection>("inset_direction");
const auto alternate_walls = settings_.get<bool>("material_alternate_walls");
const auto line_width = settings_.get<coord_t>("line_width");

const bool outer_to_inner = inset_direction == InsetDirection::OUTSIDE_IN;
const bool use_one_extruder = wall_0_extruder_nr_ == wall_x_extruder_nr_;
Expand All @@ -83,7 +84,7 @@ bool InsetOrderOptimizer::addToLayer()
const bool reverse = shouldReversePath(use_one_extruder, current_extruder_is_wall_x, outer_to_inner);
auto walls_to_be_added = getWallsToBeAdded(reverse, use_one_extruder);

const auto order = pack_by_inset ? getInsetOrder(walls_to_be_added, outer_to_inner) : getRegionOrder(walls_to_be_added, outer_to_inner);
const auto order = pack_by_inset ? getInsetOrder(walls_to_be_added, outer_to_inner) : getRegionOrder(walls_to_be_added, outer_to_inner, line_width);

constexpr Ratio flow = 1.0_r;

Expand Down Expand Up @@ -136,7 +137,7 @@ bool InsetOrderOptimizer::addToLayer()
return added_something;
}

InsetOrderOptimizer::value_type InsetOrderOptimizer::getRegionOrder(const std::vector<ExtrusionLine>& extrusion_lines, const bool outer_to_inner)
InsetOrderOptimizer::value_type InsetOrderOptimizer::getRegionOrder(const std::vector<ExtrusionLine>& extrusion_lines, const bool outer_to_inner, const coord_t line_width)
{
if (extrusion_lines.empty())
{
Expand Down Expand Up @@ -185,7 +186,9 @@ InsetOrderOptimizer::value_type InsetOrderOptimizer::getRegionOrder(const std::v
// Create a polygon representing the inner area of the extrusion line; any
// point inside this polygon is considered to the child of the extrusion line.
Polygons hole_polygons;
for (const auto& poly : extrusion_line->toExtrusionPolygons().splitIntoParts())
Polygons outer_polygons;
outer_polygons.add(extrusion_line->toPolygon());
for (const auto& poly : outer_polygons.offsetPolyLine(line_width/2, ClipperLib::JoinType::jtRound).splitIntoParts())
{
// drop first path, as this is the outer contour
for (const auto& hole : poly.paths | ranges::views::drop(1))
Expand All @@ -195,7 +198,7 @@ InsetOrderOptimizer::value_type InsetOrderOptimizer::getRegionOrder(const std::v
}
}
// increase the size of the hole polygons by 10um to make sure we don't miss any invariant parents
hole_polygons = hole_polygons.offset(10);
hole_polygons = hole_polygons.offset(line_width/2);

// go through all the invariant parents and see if they are inside the hole polygon
// if they are, then that means we have found a child for this extrusion line
Expand Down

0 comments on commit d4d66f1

Please sign in to comment.