PrusaSlicer-NonPlainar/xs/src/libslic3r/MultiPoint.hpp

69 lines
2.4 KiB
C++
Raw Normal View History

#ifndef slic3r_MultiPoint_hpp_
#define slic3r_MultiPoint_hpp_
#include "libslic3r.h"
#include <algorithm>
#include <vector>
#include "Line.hpp"
#include "Point.hpp"
namespace Slic3r {
class BoundingBox;
class MultiPoint
{
public:
Points points;
operator Points() const;
MultiPoint() {};
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; }
void scale(double factor);
void translate(double x, double y);
2014-11-09 14:27:34 +00:00
void translate(const Point &vector);
void rotate(double angle);
void rotate(double angle, const Point &center);
void reverse();
Point first_point() const;
virtual Point last_point() const = 0;
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; }
int find_point(const Point &point) const;
bool has_boundary_point(const Point &point) const;
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();
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;
std::string dump_perl() const;
static Points _douglas_peucker(const Points &points, const double tolerance);
};
extern BoundingBox get_extents(const MultiPoint &mp);
extern BoundingBox get_extents_rotated(const std::vector<Point> &points, double angle);
extern BoundingBox get_extents_rotated(const MultiPoint &mp, double angle);
} // namespace Slic3r
#endif