Fix in splitting the loop at a new point.
This commit is contained in:
parent
f518e0675c
commit
c443f49da3
1 changed files with 18 additions and 7 deletions
|
@ -193,6 +193,7 @@ ExtrusionLoop::split_at_vertex(const Point &point)
|
||||||
} else {
|
} else {
|
||||||
// new paths list starts with the second half of current path
|
// new paths list starts with the second half of current path
|
||||||
ExtrusionPaths new_paths;
|
ExtrusionPaths new_paths;
|
||||||
|
new_paths.reserve(this->paths.size() + 1);
|
||||||
{
|
{
|
||||||
ExtrusionPath p = *path;
|
ExtrusionPath p = *path;
|
||||||
p.polyline.points.erase(p.polyline.points.begin(), p.polyline.points.begin() + idx);
|
p.polyline.points.erase(p.polyline.points.begin(), p.polyline.points.begin() + idx);
|
||||||
|
@ -212,7 +213,7 @@ ExtrusionLoop::split_at_vertex(const Point &point)
|
||||||
if (p.polyline.is_valid()) new_paths.push_back(p);
|
if (p.polyline.is_valid()) new_paths.push_back(p);
|
||||||
}
|
}
|
||||||
// we can now override the old path list with the new one and stop looping
|
// we can now override the old path list with the new one and stop looping
|
||||||
this->paths = new_paths;
|
std::swap(this->paths, new_paths);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -240,14 +241,24 @@ ExtrusionLoop::split_at(const Point &point)
|
||||||
}
|
}
|
||||||
|
|
||||||
// now split path_idx in two parts
|
// now split path_idx in two parts
|
||||||
ExtrusionPath p1 = this->paths[path_idx];
|
ExtrusionPath p1(this->paths[path_idx].role), p2(this->paths[path_idx].role);
|
||||||
ExtrusionPath p2 = p1;
|
|
||||||
this->paths[path_idx].polyline.split_at(p, &p1.polyline, &p2.polyline);
|
this->paths[path_idx].polyline.split_at(p, &p1.polyline, &p2.polyline);
|
||||||
|
|
||||||
// install the two paths
|
if (this->paths.size() == 1) {
|
||||||
this->paths.erase(this->paths.begin() + path_idx);
|
if (! p1.polyline.is_valid())
|
||||||
if (p2.polyline.is_valid()) this->paths.insert(this->paths.begin() + path_idx, p2);
|
std::swap(this->paths.front().polyline.points, p2.polyline.points);
|
||||||
if (p1.polyline.is_valid()) this->paths.insert(this->paths.begin() + path_idx, p1);
|
else if (! p2.polyline.is_valid())
|
||||||
|
std::swap(this->paths.front().polyline.points, p1.polyline.points);
|
||||||
|
else {
|
||||||
|
p2.polyline.points.insert(p2.polyline.points.end(), p1.polyline.points.begin() + 1, p1.polyline.points.end());
|
||||||
|
std::swap(this->paths.front().polyline.points, p2.polyline.points);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// install the two paths
|
||||||
|
this->paths.erase(this->paths.begin() + path_idx);
|
||||||
|
if (p2.polyline.is_valid()) this->paths.insert(this->paths.begin() + path_idx, p2);
|
||||||
|
if (p1.polyline.is_valid()) this->paths.insert(this->paths.begin() + path_idx, p1);
|
||||||
|
}
|
||||||
|
|
||||||
// split at the new vertex
|
// split at the new vertex
|
||||||
this->split_at_vertex(p);
|
this->split_at_vertex(p);
|
||||||
|
|
Loading…
Reference in a new issue