File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -2168,13 +2168,17 @@ LayerPlan::TravelDurations LayerPlan::computeTravelDurations(const GCodeExport&
21682168 {
21692169 const Velocity& travel_speed = path.config .getSpeed ();
21702170 Point2LL start_position = gcode.getPosition ().toPoint2LL ();
2171- for (const Point3LL& travel_point : path.points )
2172- {
2173- const Point2LL travel_point_2d = travel_point.toPoint2LL ();
2174- const coord_t travel_segment_length = vSize (travel_point_2d - start_position);
2175- travel_durations.travel += (travel_segment_length / travel_speed) / 1000.0 ;
2176- start_position = travel_point_2d;
2177- }
2171+ const coord_t travel_distance = ranges::accumulate (
2172+ path.points ,
2173+ 0 ,
2174+ [&start_position](const coord_t total_distance, const Point3LL& travel_point)
2175+ {
2176+ const Point2LL travel_point_2d = travel_point.toPoint2LL ();
2177+ const coord_t travel_segment_length = vSize (travel_point_2d - start_position);
2178+ start_position = travel_point_2d;
2179+ return total_distance + travel_segment_length;
2180+ });
2181+ travel_durations.travel = (travel_distance / travel_speed) / 1000.0 ;
21782182 }
21792183
21802184 return travel_durations;
You can’t perform that action at this time.
0 commit comments