2014-04-28 21:09:25 +04:00
|
|
|
#pragma once
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2013-03-28 01:50:25 +04:00
|
|
|
#include "Geometry.h"
|
2011-10-01 03:36:30 +04:00
|
|
|
#include "system-gl.h"
|
|
|
|
#include "linalg.h"
|
2015-01-15 22:47:05 +03:00
|
|
|
#include "GeometryUtils.h"
|
2013-11-24 04:04:05 +04:00
|
|
|
#include "renderer.h"
|
|
|
|
#include "Polygon2d.h"
|
2011-08-05 04:11:20 +04:00
|
|
|
#include <vector>
|
2012-02-14 04:43:38 +04:00
|
|
|
#include <string>
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2014-06-01 02:35:05 +04:00
|
|
|
#include <boost/logic/tribool.hpp>
|
|
|
|
BOOST_TRIBOOL_THIRD_STATE(unknown)
|
|
|
|
|
2013-03-28 01:50:25 +04:00
|
|
|
class PolySet : public Geometry
|
2010-01-30 07:26:05 +03:00
|
|
|
{
|
|
|
|
public:
|
2014-11-26 23:22:15 +03:00
|
|
|
Polygons polygons;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2014-06-01 02:35:05 +04:00
|
|
|
PolySet(unsigned int dim, boost::tribool convex = unknown);
|
2013-11-24 04:04:05 +04:00
|
|
|
PolySet(const Polygon2d &origin);
|
2013-10-31 08:45:00 +04:00
|
|
|
virtual ~PolySet();
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2013-03-28 01:50:25 +04:00
|
|
|
virtual size_t memsize() const;
|
|
|
|
virtual BoundingBox getBoundingBox() const;
|
|
|
|
virtual std::string dump() const;
|
2013-12-29 06:37:08 +04:00
|
|
|
virtual unsigned int getDimension() const { return this->dim; }
|
|
|
|
virtual bool isEmpty() const { return polygons.size() == 0; }
|
2014-07-18 01:03:03 +04:00
|
|
|
virtual Geometry *copy() const { return new PolySet(*this); }
|
2013-03-28 01:50:25 +04:00
|
|
|
|
2014-12-19 10:27:56 +03:00
|
|
|
void quantizeVertices();
|
2013-12-22 10:43:08 +04:00
|
|
|
size_t numPolygons() const { return polygons.size(); }
|
2010-01-30 07:26:05 +03:00
|
|
|
void append_poly();
|
2015-03-09 02:32:10 +03:00
|
|
|
void append_poly(const Polygon &poly);
|
2011-08-05 04:11:20 +04:00
|
|
|
void append_vertex(double x, double y, double z = 0.0);
|
2015-01-15 22:47:05 +03:00
|
|
|
void append_vertex(const Vector3d &v);
|
|
|
|
void append_vertex(const Vector3f &v);
|
2011-08-05 04:11:20 +04:00
|
|
|
void insert_vertex(double x, double y, double z = 0.0);
|
2015-01-15 22:47:05 +03:00
|
|
|
void insert_vertex(const Vector3d &v);
|
|
|
|
void insert_vertex(const Vector3f &v);
|
2013-11-02 02:57:36 +04:00
|
|
|
void append(const PolySet &ps);
|
|
|
|
|
2013-10-31 08:45:00 +04:00
|
|
|
void render_surface(Renderer::csgmode_e csgmode, const Transform3d &m, GLint *shaderinfo = NULL) const;
|
|
|
|
void render_edges(Renderer::csgmode_e csgmode) const;
|
2013-11-24 04:04:05 +04:00
|
|
|
|
2013-12-16 03:27:25 +04:00
|
|
|
void transform(const Transform3d &mat);
|
2013-12-17 10:35:12 +04:00
|
|
|
void resize(Vector3d newsize, const Eigen::Matrix<bool,3,1> &autosize);
|
2013-12-16 03:27:25 +04:00
|
|
|
|
2014-06-01 02:35:05 +04:00
|
|
|
bool is_convex() const;
|
2015-01-06 01:38:42 +03:00
|
|
|
boost::tribool convexValue() const { return this->convex; }
|
2014-06-01 02:35:05 +04:00
|
|
|
|
2013-11-24 04:04:05 +04:00
|
|
|
private:
|
2014-06-01 02:35:05 +04:00
|
|
|
Polygon2d polygon;
|
2013-12-29 06:37:08 +04:00
|
|
|
unsigned int dim;
|
2014-06-01 02:35:05 +04:00
|
|
|
mutable boost::tribool convex;
|
2015-03-09 02:32:10 +03:00
|
|
|
mutable BoundingBox bbox;
|
|
|
|
mutable bool dirty;
|
2010-01-30 07:26:05 +03:00
|
|
|
};
|