mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
Ported point_along_segment(), Polyline::length(), Polyline::clip_end() to XS
This commit is contained in:
@@ -19,6 +19,27 @@ Polyline::lines() const
|
||||
return lines;
|
||||
}
|
||||
|
||||
// removes the given distance from the end of the polyline
|
||||
void
|
||||
Polyline::clip_end(double distance)
|
||||
{
|
||||
while (distance > 0) {
|
||||
Point last_point = *this->last_point();
|
||||
this->points.pop_back();
|
||||
if (this->points.empty()) break;
|
||||
|
||||
double last_segment_length = last_point.distance_to(this->last_point());
|
||||
if (last_segment_length <= distance) {
|
||||
distance -= last_segment_length;
|
||||
continue;
|
||||
}
|
||||
|
||||
Line segment(last_point, *this->last_point());
|
||||
this->points.push_back(*segment.point_at(distance));
|
||||
distance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
SV*
|
||||
Polyline::to_SV_ref()
|
||||
|
||||
Reference in New Issue
Block a user