This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
neofx-zoomedit/Polygon.h

44 lines
1 KiB
C
Raw Normal View History

2007-09-16 19:06:02 +00:00
#ifndef POLYGON_H_
#define POLYGON_H_
#include "Vertex.h"
#include "Line.h"
#include "Triangle.h"
2007-09-16 19:06:02 +00:00
#include <vector>
#include <list>
2007-09-16 19:06:02 +00:00
class Polygon : public std::vector<Vertex> {
private:
struct Intersection {
size_t va1, va2, vb1, vb2;
Vertex v;
};
typedef Triangle::Direction Direction;
2007-09-16 19:06:02 +00:00
int quadrant(const Vertex &v) const;
float signedArea() const;
bool isConcave(const Triangle::Direction &dir, const Vertex &v1, const Vertex &v2, const Vertex &v3) const;
bool intersections(std::vector<Intersection> *intersections = NULL) const;
void doTriangulate(std::vector<Triangle> &triangles) const;
2007-09-16 19:06:02 +00:00
public:
float area() const;
float perimeter() const;
2007-09-16 19:06:02 +00:00
bool contains(const Vertex &v) const;
2007-09-16 20:59:04 +00:00
bool intersects(const Line &l) const;
2007-10-31 23:03:04 +00:00
Triangle::Direction getDirection() const;
bool isSimple() const;
bool simplify(std::list<Polygon> &polygons) const;
void triangulate(std::vector<Triangle> &triangles) const;
2007-09-16 19:06:02 +00:00
};
#endif /*POLYGON_H_*/