2010-01-30 07:26:05 +03:00
|
|
|
#ifndef CSGTERM_H_
|
|
|
|
#define CSGTERM_H_
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
class PolySet;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
|
|
|
class CSGTerm
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum type_e {
|
|
|
|
TYPE_PRIMITIVE,
|
|
|
|
TYPE_UNION,
|
|
|
|
TYPE_INTERSECTION,
|
|
|
|
TYPE_DIFFERENCE
|
|
|
|
};
|
|
|
|
|
|
|
|
type_e type;
|
2011-09-11 09:33:18 +04:00
|
|
|
shared_ptr<PolySet> polyset;
|
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-10-04 05:41:43 +04:00
|
|
|
Transform3d m;
|
2011-09-03 01:35:10 +04:00
|
|
|
double color[4];
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2011-10-04 05:41:43 +04:00
|
|
|
CSGTerm(const shared_ptr<PolySet> &polyset, const Transform3d &matrix, const double color[4], const std::string &label);
|
2011-12-06 04:16:54 +04:00
|
|
|
CSGTerm(type_e type, shared_ptr<CSGTerm> left, shared_ptr<CSGTerm> right);
|
2010-01-30 07:26:05 +03:00
|
|
|
CSGTerm(type_e type, CSGTerm *left, CSGTerm *right);
|
2011-12-06 04:16:54 +04:00
|
|
|
~CSGTerm();
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2011-12-06 04:16:54 +04:00
|
|
|
static shared_ptr<CSGTerm> normalize(shared_ptr<CSGTerm> &term);
|
|
|
|
static shared_ptr<CSGTerm> normalize_tail(shared_ptr<CSGTerm> &term);
|
2010-01-30 07:26:05 +03:00
|
|
|
|
2011-09-03 08:30:48 +04:00
|
|
|
std::string dump();
|
2010-01-30 07:26:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class CSGChain
|
|
|
|
{
|
|
|
|
public:
|
2011-09-11 09:33:18 +04:00
|
|
|
std::vector<shared_ptr<PolySet> > polysets;
|
2011-10-04 05:41:43 +04:00
|
|
|
std::vector<Transform3d> matrices;
|
2011-09-03 08:30:48 +04:00
|
|
|
std::vector<double*> colors;
|
|
|
|
std::vector<CSGTerm::type_e> types;
|
|
|
|
std::vector<std::string> labels;
|
2010-01-30 07:26:05 +03:00
|
|
|
|
|
|
|
CSGChain();
|
|
|
|
|
2011-10-04 05:41:43 +04:00
|
|
|
void add(const shared_ptr<PolySet> &polyset, const Transform3d &m, double *color, CSGTerm::type_e type, std::string label);
|
2011-12-06 04:16:54 +04:00
|
|
|
void import(shared_ptr<CSGTerm> term, CSGTerm::type_e type = CSGTerm::TYPE_UNION);
|
2011-09-03 08:30:48 +04:00
|
|
|
std::string dump();
|
2011-08-05 04:11:20 +04:00
|
|
|
|
|
|
|
BoundingBox getBoundingBox() const;
|
2010-01-30 07:26:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|