2014-05-23 06:26:46 +04:00
|
|
|
#pragma once
|
2013-03-28 01:50:25 +04:00
|
|
|
|
|
|
|
#include "Geometry.h"
|
|
|
|
#include "linalg.h"
|
|
|
|
#include <vector>
|
|
|
|
|
2014-08-15 20:13:04 +04:00
|
|
|
/*!
|
|
|
|
A single contour.
|
|
|
|
positive is (optionally) used to distinguish between polygon contours and hold contours.
|
|
|
|
*/
|
2013-12-27 08:05:11 +04:00
|
|
|
struct Outline2d {
|
|
|
|
Outline2d() : positive(true) {}
|
|
|
|
std::vector<Vector2d> vertices;
|
|
|
|
bool positive;
|
|
|
|
};
|
2013-03-28 01:50:25 +04:00
|
|
|
|
|
|
|
class Polygon2d : public Geometry
|
|
|
|
{
|
|
|
|
public:
|
2013-12-26 20:09:46 +04:00
|
|
|
Polygon2d() : sanitized(false) {}
|
2013-03-28 01:50:25 +04:00
|
|
|
virtual size_t memsize() const;
|
|
|
|
virtual BoundingBox getBoundingBox() const;
|
|
|
|
virtual std::string dump() const;
|
2013-10-31 08:45:00 +04:00
|
|
|
virtual unsigned int getDimension() const { return 2; }
|
2013-12-29 06:37:08 +04:00
|
|
|
virtual bool isEmpty() const;
|
2014-07-18 01:03:03 +04:00
|
|
|
virtual Geometry *copy() const { return new Polygon2d(*this); }
|
2013-10-31 08:45:00 +04:00
|
|
|
|
|
|
|
void addOutline(const Outline2d &outline) { this->theoutlines.push_back(outline); }
|
|
|
|
class PolySet *tessellate() const;
|
|
|
|
|
|
|
|
typedef std::vector<Outline2d> Outlines2d;
|
|
|
|
const Outlines2d &outlines() const { return theoutlines; }
|
2013-03-28 01:50:25 +04:00
|
|
|
|
2013-10-31 08:45:00 +04:00
|
|
|
void transform(const Transform2d &mat);
|
2013-12-17 10:35:12 +04:00
|
|
|
void resize(Vector2d newsize, const Eigen::Matrix<bool,2,1> &autosize);
|
2013-12-26 20:09:46 +04:00
|
|
|
|
|
|
|
bool isSanitized() const { return this->sanitized; }
|
|
|
|
void setSanitized(bool s) { this->sanitized = s; }
|
2014-09-18 19:48:32 +04:00
|
|
|
bool is_convex() const;
|
2013-03-28 01:50:25 +04:00
|
|
|
private:
|
2013-10-31 08:45:00 +04:00
|
|
|
Outlines2d theoutlines;
|
2013-12-26 20:09:46 +04:00
|
|
|
bool sanitized;
|
2013-03-28 01:50:25 +04:00
|
|
|
};
|