-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix in splitting the loop at a new point.
- Loading branch information
Showing
1 changed file
with
18 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,7 @@ ExtrusionLoop::split_at_vertex(const Point &point) | |
} else { | ||
// new paths list starts with the second half of current path | ||
ExtrusionPaths new_paths; | ||
new_paths.reserve(this->paths.size() + 1); | ||
{ | ||
ExtrusionPath p = *path; | ||
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); | ||
} | ||
// 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; | ||
} | ||
|
@@ -240,14 +241,24 @@ ExtrusionLoop::split_at(const Point &point) | |
} | ||
|
||
// now split path_idx in two parts | ||
ExtrusionPath p1 = this->paths[path_idx]; | ||
ExtrusionPath p2 = p1; | ||
ExtrusionPath p1(this->paths[path_idx].role), p2(this->paths[path_idx].role); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bubnikv
via email
Author
Collaborator
|
||
this->paths[path_idx].polyline.split_at(p, &p1.polyline, &p2.polyline); | ||
|
||
// 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); | ||
if (this->paths.size() == 1) { | ||
This comment has been minimized.
Sorry, something went wrong.
lordofhyphens
Contributor
|
||
if (! p1.polyline.is_valid()) | ||
std::swap(this->paths.front().polyline.points, p2.polyline.points); | ||
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 | ||
this->split_at_vertex(p); | ||
|
So, what was the problem with using the (default) copy constructor here?