2014-04-28 21:09:25 +04:00
|
|
|
#pragma once
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2011-09-03 08:30:48 +04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2011-09-11 09:33:18 +04:00
|
|
|
#include "memory.h"
|
2011-10-01 03:36:30 +04:00
|
|
|
#include "linalg.h"
|
|
|
|
|
2013-10-31 08:45:00 +04:00
|
|
|
class Geometry;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
|
|
|
class CSGTerm
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum type_e {
|
|
|
|
TYPE_PRIMITIVE,
|
|
|
|
TYPE_UNION,
|
|
|
|
TYPE_INTERSECTION,
|
|
|
|
TYPE_DIFFERENCE
|
|
|
|
};
|
|
|
|
|
2013-05-25 02:40:09 +04:00
|
|
|
enum Flag {
|
|
|
|
FLAG_NONE = 0x00,
|
|
|
|
FLAG_BACKGROUND = 0x01,
|
|
|
|
FLAG_HIGHLIGHT = 0x03
|
|
|
|
};
|
|
|
|
|
2011-12-22 07:12:15 +04:00
|
|
|
static shared_ptr<CSGTerm> createCSGTerm(type_e type, shared_ptr<CSGTerm> left, shared_ptr<CSGTerm> right);
|
|
|
|
static shared_ptr<CSGTerm> createCSGTerm(type_e type, CSGTerm *left, CSGTerm *right);
|
|
|
|
|
2010-01-30 07:26:05 +03:00
|
|
|
type_e type;
|
2013-10-31 08:45:00 +04:00
|
|
|
shared_ptr<const Geometry> geom;
|
2011-09-03 08:30:48 +04:00
|
|
|
std::string label;
|
2011-12-06 04:16:54 +04:00
|
|
|
shared_ptr<CSGTerm> left;
|
|
|
|
shared_ptr<CSGTerm> right;
|
2011-12-22 07:12:15 +04:00
|
|
|
BoundingBox bbox;
|
2013-05-25 02:40:09 +04:00
|
|
|
Flag flag;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2013-10-31 08:45:00 +04:00
|
|
|
CSGTerm(const shared_ptr<const Geometry> &geom, const Transform3d &matrix, const Color4f &color, const std::string &label);
|
2011-12-06 04:16:54 +04:00
|
|
|
~CSGTerm();
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2011-12-22 07:12:15 +04:00
|
|
|
const BoundingBox &getBoundingBox() const { return this->bbox; }
|
|
|
|
|
2011-09-03 08:30:48 +04:00
|
|
|
std::string dump();
|
2011-12-22 07:12:15 +04:00
|
|
|
private:
|
|
|
|
CSGTerm(type_e type, shared_ptr<CSGTerm> left, shared_ptr<CSGTerm> right);
|
|
|
|
CSGTerm(type_e type, CSGTerm *left, CSGTerm *right);
|
|
|
|
|
|
|
|
void initBoundingBox();
|
|
|
|
|
|
|
|
Transform3d m;
|
2011-12-26 03:38:03 +04:00
|
|
|
Color4f color;
|
2011-12-22 07:12:15 +04:00
|
|
|
|
|
|
|
friend class CSGChain;
|
2010-01-30 07:26:05 +03:00
|
|
|
};
|
|
|
|
|
2013-05-25 02:40:09 +04:00
|
|
|
class CSGChainObject
|
|
|
|
{
|
|
|
|
public:
|
2013-10-31 08:45:00 +04:00
|
|
|
CSGChainObject(shared_ptr<const Geometry> geom,
|
2013-05-25 02:40:09 +04:00
|
|
|
const Transform3d &matrix,
|
|
|
|
const Color4f &color,
|
|
|
|
CSGTerm::type_e type,
|
|
|
|
const std::string &label,
|
|
|
|
CSGTerm::Flag flag = CSGTerm::FLAG_NONE)
|
2013-10-31 08:45:00 +04:00
|
|
|
: geom(geom), matrix(matrix), color(color), type(type), label(label), flag(flag) {}
|
2013-05-25 02:40:09 +04:00
|
|
|
|
2013-10-31 08:45:00 +04:00
|
|
|
shared_ptr<const Geometry> geom;
|
2013-05-25 02:40:09 +04:00
|
|
|
Transform3d matrix;
|
|
|
|
Color4f color;
|
|
|
|
CSGTerm::type_e type;
|
|
|
|
std::string label;
|
|
|
|
CSGTerm::Flag flag;
|
|
|
|
};
|
|
|
|
|
2010-01-30 07:26:05 +03:00
|
|
|
class CSGChain
|
|
|
|
{
|
|
|
|
public:
|
2013-05-25 02:40:09 +04:00
|
|
|
std::vector<CSGChainObject> objects;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2013-05-25 02:40:09 +04:00
|
|
|
CSGChain() {};
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2013-05-25 02:40:09 +04:00
|
|
|
void import(shared_ptr<CSGTerm> term, CSGTerm::type_e type = CSGTerm::TYPE_UNION,
|
|
|
|
CSGTerm::Flag flag = CSGTerm::FLAG_NONE);
|
2012-08-18 21:00:00 +04:00
|
|
|
std::string dump(bool full = false);
|
2011-08-05 04:11:20 +04:00
|
|
|
|
|
|
|
BoundingBox getBoundingBox() const;
|
2010-01-30 07:26:05 +03:00
|
|
|
};
|