mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-18 05:25:59 +08:00
Fix of ThickPolyline::clip_end()
This commit is contained in:
parent
6734ad6c3c
commit
9ecf1e4134
@ -267,13 +267,17 @@ ThickLines ThickPolyline::thicklines() const
|
||||
// Removes the given distance from the end of the ThickPolyline
|
||||
void ThickPolyline::clip_end(double distance)
|
||||
{
|
||||
if (! this->empty()) {
|
||||
assert(this->width.size() == (this->points.size() - 1) * 2);
|
||||
while (distance > 0) {
|
||||
Vec2d last_point = this->last_point().cast<double>();
|
||||
coordf_t last_width = this->width.back();
|
||||
this->points.pop_back();
|
||||
this->width.pop_back();
|
||||
if (this->points.empty())
|
||||
if (this->points.empty()) {
|
||||
assert(this->width.empty());
|
||||
break;
|
||||
}
|
||||
coordf_t last_width = this->width.back();
|
||||
this->width.pop_back();
|
||||
|
||||
Vec2d vec = this->last_point().cast<double>() - last_point;
|
||||
coordf_t width_diff = this->width.back() - last_width;
|
||||
@ -289,7 +293,8 @@ void ThickPolyline::clip_end(double distance)
|
||||
|
||||
distance -= std::sqrt(vec_length_sqr);
|
||||
}
|
||||
assert(this->width.size() == (this->points.size() - 1) * 2);
|
||||
}
|
||||
assert(this->points.empty() ? this->width.empty() : this->width.size() == (this->points.size() - 1) * 2);
|
||||
}
|
||||
|
||||
void ThickPolyline::start_at_index(int index)
|
||||
|
@ -187,6 +187,7 @@ struct ThickPolyline {
|
||||
const Point& last_point() const { return this->points.back(); }
|
||||
size_t size() const { return this->points.size(); }
|
||||
bool is_valid() const { return this->points.size() >= 2; }
|
||||
bool empty() const { return this->points.empty(); }
|
||||
double length() const { return Slic3r::length(this->points); }
|
||||
|
||||
void clear() { this->points.clear(); this->width.clear(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user