Skip to content

Commit

Permalink
Apply code-review comments.
Browse files Browse the repository at this point in the history
- Add comments to previously undocumented function.
- Add round brackets to a foruma for readability.
- Add assert to detect situations where the closed polygon loop has a strange numner of vertices.

part of CURA-9474
  • Loading branch information
rburema committed Jun 11, 2024
1 parent 8554db4 commit f9daec4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ class InsetOrderOptimizer
Shape retraction_region_; // After printing an outer wall, move into this region so that retractions do not leave visible blobs. Calculated lazily if needed (see
// retraction_region_calculated).

/*!
* Given a closed polygon, insert a seam point at the point where the seam should be placed.
* This should result in the seam-finding algorithm finding that exact point, instead of the
* 'best' vertex on that polygon. Under certain circumstances, the seam-placing algorithm can
* however still deviate from this, for example when the seam-point placed here isn't suppored
* by the layer below.
*/
void insertSeamPoint(ExtrusionLine& closed_line);

/*!
Expand Down
3 changes: 2 additions & 1 deletion src/InsetOrderOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ bool InsetOrderOptimizer::addToLayer()
void InsetOrderOptimizer::insertSeamPoint(ExtrusionLine& closed_line)
{
assert(closed_line.is_closed_);
assert(closed_line.size() >= 3);

Point2LL request_point;
switch (z_seam_config_.type_)
Expand Down Expand Up @@ -212,7 +213,7 @@ void InsetOrderOptimizer::insertSeamPoint(ExtrusionLine& closed_line)
const coord_t total_dist = vSize(end_pt.p_ - start_pt.p_);
const coord_t start_dist = vSize(closest_point - start_pt.p_);
const coord_t end_dist = vSize(closest_point - end_pt.p_);
const coord_t w = end_pt.w_ * end_dist / total_dist + start_pt.w_ * start_dist / total_dist;
const coord_t w = (end_pt.w_ * (end_dist / total_dist)) + (start_pt.w_ * (start_dist / total_dist));

closed_line.junctions_.insert(closed_line.junctions_.begin() + closest_junction_idx + 1, ExtrusionJunction(closest_point, w, start_pt.perimeter_index_));
}
Expand Down

0 comments on commit f9daec4

Please sign in to comment.