mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 14:44:19 -06:00
Rest of the path chaining has been replaced with the new algorithm.
PolylineCollection.cpp/hpp was removed, use Polylines instead. Various first_point() / last_point() now return references, not copies.
This commit is contained in:
parent
4b35ebe6e5
commit
331c187b39
29 changed files with 266 additions and 364 deletions
|
@ -23,18 +23,17 @@ Polyline::operator Line() const
|
|||
return Line(this->points.front(), this->points.back());
|
||||
}
|
||||
|
||||
Point
|
||||
Polyline::leftmost_point() const
|
||||
const Point& Polyline::leftmost_point() const
|
||||
{
|
||||
Point p = this->points.front();
|
||||
for (Points::const_iterator it = this->points.begin() + 1; it != this->points.end(); ++it) {
|
||||
if ((*it)(0) < p(0)) p = *it;
|
||||
const Point *p = &this->points.front();
|
||||
for (Points::const_iterator it = this->points.begin() + 1; it != this->points.end(); ++ it) {
|
||||
if (it->x() < p->x())
|
||||
p = &(*it);
|
||||
}
|
||||
return p;
|
||||
return *p;
|
||||
}
|
||||
|
||||
Lines
|
||||
Polyline::lines() const
|
||||
Lines Polyline::lines() const
|
||||
{
|
||||
Lines lines;
|
||||
if (this->points.size() >= 2) {
|
||||
|
@ -205,6 +204,20 @@ BoundingBox get_extents(const Polylines &polylines)
|
|||
return bb;
|
||||
}
|
||||
|
||||
const Point& leftmost_point(const Polylines &polylines)
|
||||
{
|
||||
if (polylines.empty())
|
||||
throw std::invalid_argument("leftmost_point() called on empty PolylineCollection");
|
||||
Polylines::const_iterator it = polylines.begin();
|
||||
const Point *p = &it->leftmost_point();
|
||||
for (++ it; it != polylines.end(); ++it) {
|
||||
const Point *p2 = &it->leftmost_point();
|
||||
if (p2->x() < p->x())
|
||||
p = p2;
|
||||
}
|
||||
return *p;
|
||||
}
|
||||
|
||||
bool remove_degenerate(Polylines &polylines)
|
||||
{
|
||||
bool modified = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue