2011-07-31 03:58:51 +04:00
|
|
|
#ifndef CSGTERMEVALUATOR_H_
|
|
|
|
#define CSGTERMEVALUATOR_H_
|
2010-07-15 04:48:00 +04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include <list>
|
|
|
|
#include <vector>
|
2010-11-03 21:26:06 +03:00
|
|
|
#include "Tree.h"
|
2010-07-15 04:48:00 +04:00
|
|
|
#include "visitor.h"
|
|
|
|
#include "node.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::map;
|
|
|
|
using std::list;
|
|
|
|
using std::vector;
|
|
|
|
|
2011-07-31 03:58:51 +04:00
|
|
|
class CSGTermEvaluator : public Visitor
|
2010-07-15 04:48:00 +04:00
|
|
|
{
|
|
|
|
public:
|
2011-07-31 03:58:51 +04:00
|
|
|
CSGTermEvaluator(const Tree &tree, class PolySetEvaluator *psevaluator = NULL)
|
2011-08-06 03:08:11 +04:00
|
|
|
: tree(tree), psevaluator(psevaluator) {
|
2010-09-07 04:02:22 +04:00
|
|
|
}
|
2011-07-31 03:58:51 +04:00
|
|
|
virtual ~CSGTermEvaluator() {}
|
2010-07-15 04:48:00 +04:00
|
|
|
|
2010-08-28 19:34:22 +04:00
|
|
|
virtual Response visit(State &state, const AbstractNode &node);
|
|
|
|
virtual Response visit(State &state, const AbstractIntersectionNode &node);
|
|
|
|
virtual Response visit(State &state, const AbstractPolyNode &node);
|
|
|
|
virtual Response visit(State &state, const CsgNode &node);
|
|
|
|
virtual Response visit(State &state, const TransformNode &node);
|
|
|
|
virtual Response visit(State &state, const RenderNode &node);
|
2010-07-15 04:48:00 +04:00
|
|
|
|
2011-07-31 03:58:51 +04:00
|
|
|
class CSGTerm *evaluateCSGTerm(const AbstractNode &node,
|
2011-08-06 03:08:11 +04:00
|
|
|
vector<CSGTerm*> &highlights,
|
|
|
|
vector<CSGTerm*> &background);
|
2010-09-07 04:02:22 +04:00
|
|
|
|
2010-07-15 04:48:00 +04:00
|
|
|
private:
|
|
|
|
enum CsgOp {UNION, INTERSECTION, DIFFERENCE, MINKOWSKI};
|
|
|
|
void addToParent(const State &state, const AbstractNode &node);
|
2011-07-31 03:58:51 +04:00
|
|
|
void applyToChildren(const AbstractNode &node, CSGTermEvaluator::CsgOp op);
|
2010-07-15 04:48:00 +04:00
|
|
|
|
|
|
|
const AbstractNode *root;
|
|
|
|
typedef list<const AbstractNode *> ChildList;
|
|
|
|
map<int, ChildList> visitedchildren;
|
2010-08-28 23:35:48 +04:00
|
|
|
|
|
|
|
public:
|
2011-07-31 03:58:51 +04:00
|
|
|
map<int, class CSGTerm*> stored_term; // The term evaluated from each node index
|
2010-07-15 04:48:00 +04:00
|
|
|
|
2011-08-06 03:08:11 +04:00
|
|
|
vector<CSGTerm*> highlights;
|
|
|
|
vector<CSGTerm*> background;
|
2010-11-03 21:26:06 +03:00
|
|
|
const Tree &tree;
|
2011-07-31 03:58:51 +04:00
|
|
|
class PolySetEvaluator *psevaluator;
|
2010-07-15 04:48:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|