diff options
author | bubnikv <bubnikv@gmail.com> | 2017-01-19 15:43:29 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-01-19 15:43:29 +0300 |
commit | 0b90ebd74e0c0c9d70d08b7202531cf5e0f81a7e (patch) | |
tree | b1bc8e3fc3c587734ff2f255e7a9d74d86afa41e /xs/src/libslic3r/Polyline.hpp | |
parent | 50cdf8e6d12d0ba699ab598889800da709163bb1 (diff) |
Move semantics on MultiPoint, Polygon, Polyline.
Append methods on Polyline.
squared length function on point->DistanceTo
Diffstat (limited to 'xs/src/libslic3r/Polyline.hpp')
-rw-r--r-- | xs/src/libslic3r/Polyline.hpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/xs/src/libslic3r/Polyline.hpp b/xs/src/libslic3r/Polyline.hpp index b8c04a12a..007fcba62 100644 --- a/xs/src/libslic3r/Polyline.hpp +++ b/xs/src/libslic3r/Polyline.hpp @@ -15,7 +15,36 @@ typedef std::vector<Polyline> Polylines; typedef std::vector<ThickPolyline> ThickPolylines; class Polyline : public MultiPoint { - public: +public: + Polyline() {}; + Polyline(const Polyline &other) : MultiPoint(other.points) {} + Polyline(Polyline &&other) : MultiPoint(std::move(other.points)) {} + Polyline& operator=(const Polyline &other) { points = other.points; return *this; } + Polyline& operator=(Polyline &&other) { points = std::move(other.points); return *this; } + + void append(const Point &point) { this->points.push_back(point); } + void append(const Points &src) { this->append(src.begin(), src.end()); } + void append(const Points::const_iterator &begin, const Points::const_iterator &end) { this->points.insert(this->points.end(), begin, end); } + void append(Points &&src) + { + if (this->points.empty()) + this->points = std::move(src); + else + std::move(std::begin(src), std::end(src), std::back_inserter(this->points)); + } + void append(const Polyline &src) + { + points.insert(points.end(), src.points.begin(), src.points.end()); + } + + void append(Polyline &&src) + { + if (this->points.empty()) + this->points = std::move(src.points); + else + std::move(std::begin(src.points), std::end(src.points), std::back_inserter(this->points)); + } + operator Polylines() const; operator Line() const; Point last_point() const; @@ -63,6 +92,19 @@ inline Lines to_lines(const Polylines &polys) return lines; } +inline void polylines_append(Polylines &dst, const Polylines &src) +{ + dst.insert(dst.end(), src.begin(), src.end()); +} + +inline void polylines_append(Polylines &dst, Polylines &&src) +{ + if (dst.empty()) + dst = std::move(src); + else + std::move(std::begin(src), std::end(src), std::back_inserter(dst)); +} + class ThickPolyline : public Polyline { public: std::vector<coordf_t> width; |