mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-26 02:01:12 -06:00
Ported point_along_segment(), Polyline::length(), Polyline::clip_end() to XS
This commit is contained in:
parent
26a18a2a52
commit
29b83517cb
12 changed files with 64 additions and 57 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue