2013-07-15 20:57:22 +00:00
|
|
|
#ifndef slic3r_MultiPoint_hpp_
|
|
|
|
#define slic3r_MultiPoint_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2013-07-15 20:57:22 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
2014-05-22 17:34:49 +00:00
|
|
|
#include "Line.hpp"
|
|
|
|
#include "Point.hpp"
|
2013-07-15 20:57:22 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2014-05-22 17:34:49 +00:00
|
|
|
class BoundingBox;
|
|
|
|
|
2013-07-15 20:57:22 +00:00
|
|
|
class MultiPoint
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Points points;
|
2014-05-22 17:34:49 +00:00
|
|
|
|
|
|
|
operator Points() const;
|
2014-12-07 18:53:22 +00:00
|
|
|
MultiPoint() {};
|
2017-01-19 12:43:29 +00:00
|
|
|
MultiPoint(const MultiPoint &other) : points(other.points) {}
|
|
|
|
MultiPoint(MultiPoint &&other) : points(std::move(other.points)) {}
|
|
|
|
explicit MultiPoint(const Points &_points): points(_points) {}
|
|
|
|
MultiPoint& operator=(const MultiPoint &other) { points = other.points; return *this; }
|
|
|
|
MultiPoint& operator=(MultiPoint &&other) { points = std::move(other.points); return *this; }
|
2013-07-15 20:57:22 +00:00
|
|
|
void scale(double factor);
|
|
|
|
void translate(double x, double y);
|
2014-11-09 14:27:34 +00:00
|
|
|
void translate(const Point &vector);
|
2016-04-10 17:06:46 +00:00
|
|
|
void rotate(double angle);
|
2014-04-24 11:43:24 +00:00
|
|
|
void rotate(double angle, const Point ¢er);
|
2013-07-15 20:57:22 +00:00
|
|
|
void reverse();
|
2014-04-24 14:40:10 +00:00
|
|
|
Point first_point() const;
|
|
|
|
virtual Point last_point() const = 0;
|
2013-10-27 21:57:25 +00:00
|
|
|
virtual Lines lines() const = 0;
|
|
|
|
double length() const;
|
2016-09-13 07:46:41 +00:00
|
|
|
bool is_valid() const { return this->points.size() >= 2; }
|
|
|
|
|
2014-05-08 09:07:37 +00:00
|
|
|
int find_point(const Point &point) const;
|
2015-01-06 19:52:36 +00:00
|
|
|
bool has_boundary_point(const Point &point) const;
|
2015-01-19 17:53:04 +00:00
|
|
|
BoundingBox bounding_box() const;
|
2016-04-15 16:01:08 +00:00
|
|
|
// Return true if there are exact duplicates.
|
|
|
|
bool has_duplicate_points() const;
|
|
|
|
// Remove exact duplicates, return true if any duplicate has been removed.
|
|
|
|
bool remove_duplicate_points();
|
2017-01-19 12:43:29 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2016-03-19 14:33:58 +00:00
|
|
|
bool intersection(const Line& line, Point* intersection) const;
|
2016-05-20 04:24:05 +00:00
|
|
|
std::string dump_perl() const;
|
2014-05-22 17:34:49 +00:00
|
|
|
|
2013-11-22 15:01:50 +00:00
|
|
|
static Points _douglas_peucker(const Points &points, const double tolerance);
|
2013-07-15 20:57:22 +00:00
|
|
|
};
|
|
|
|
|
2016-09-13 11:30:00 +00:00
|
|
|
extern BoundingBox get_extents(const MultiPoint &mp);
|
2016-11-07 21:49:11 +00:00
|
|
|
extern BoundingBox get_extents_rotated(const std::vector<Point> &points, double angle);
|
|
|
|
extern BoundingBox get_extents_rotated(const MultiPoint &mp, double angle);
|
2016-09-13 11:30:00 +00:00
|
|
|
|
|
|
|
} // namespace Slic3r
|
2013-07-15 20:57:22 +00:00
|
|
|
|
|
|
|
#endif
|