Skip to content

Commit

Permalink
RasterOrganizationModifier does not sort the points, only reverses t…
Browse files Browse the repository at this point in the history
…hem if necessary.
  • Loading branch information
Iñigo Moreno committed Jan 24, 2024
1 parent 9c4a258 commit 0bdd4bb
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ ToolPaths RasterOrganizationModifier::modify(ToolPaths tool_paths) const
// Sort the waypoints within each tool path segment by their distance along the reference direction
for (ToolPathSegment& segment : tool_path)
{
std::sort(segment.begin(),
segment.end(),
[segment, reference_segment_dir](const ToolPathWaypoint& a, const ToolPathWaypoint& b) {
Eigen::Vector3d diff_from_start_b = b.translation() - segment.at(0).translation();
Eigen::Vector3d diff_from_start_a = a.translation() - segment.at(0).translation();
return diff_from_start_a.dot(reference_segment_dir) < diff_from_start_b.dot(reference_segment_dir);
});
Eigen::Vector3d diff_from_start_end = segment.at(segment.size() - 1).translation() - segment.at(0).translation();
if (diff_from_start_end.dot(reference_segment_dir) < 0.0)
{
std::reverse(segment.begin(), segment.end());
}
}

// Sort the tool path segments within each tool path by the distance of their first waypoints along the reference
Expand Down

0 comments on commit 0bdd4bb

Please sign in to comment.