1 #pragma once
2 
3 #include "Geometry.h"
4 #include "linalg.h"
5 #include "GeometryUtils.h"
6 #include "Polygon2d.h"
7 #include "GLView.h"
8 #include "boost-utils.h"
9 #include <vector>
10 #include <string>
11 
12 class PolySet : public Geometry
13 {
14 public:
15 	VISITABLE_GEOMETRY();
16 	Polygons polygons;
17 
18 	PolySet(unsigned int dim, boost::tribool convex = unknown);
19 	PolySet(const Polygon2d &origin);
20 	~PolySet();
21 
getPolygon()22 	const Polygon2d &getPolygon() const { return polygon; }
23 
24 	size_t memsize() const override;
25 	BoundingBox getBoundingBox() const override;
26 	std::string dump() const override;
getDimension()27 	unsigned int getDimension() const override { return this->dim; }
isEmpty()28 	bool isEmpty() const override { return polygons.size() == 0; }
copy()29 	Geometry *copy() const override { return new PolySet(*this); }
30 
31 	void quantizeVertices();
numFacets()32 	size_t numFacets() const override { return polygons.size(); }
33 	void append_poly();
34 	void append_poly(const Polygon &poly);
35 	void append_vertex(double x, double y, double z = 0.0);
36 	void append_vertex(const Vector3d &v);
37 	void append_vertex(const Vector3f &v);
38 	void insert_vertex(double x, double y, double z = 0.0);
39 	void insert_vertex(const Vector3d &v);
40 	void insert_vertex(const Vector3f &v);
41 	void append(const PolySet &ps);
42 
43 	void transform(const Transform3d &mat);
44 	void resize(const Vector3d &newsize, const Eigen::Matrix<bool,3,1> &autosize);
45 
46 	bool is_convex() const;
convexValue()47 	boost::tribool convexValue() const { return this->convex; }
48 
49 private:
50 	Polygon2d polygon;
51 	unsigned int dim;
52 	mutable boost::tribool convex;
53 	mutable BoundingBox bbox;
54 	mutable bool dirty;
55 };
56