Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RasterOrganizationModifier does not sort the points, only reverses them if necessary #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading