2014-04-28 21:09:25 +04:00
|
|
|
#pragma once
|
2010-07-15 04:48:00 +04:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <list>
|
|
|
|
#include <vector>
|
2011-10-20 20:59:34 +04:00
|
|
|
#include <cstddef>
|
2010-07-15 04:48:00 +04:00
|
|
|
#include "visitor.h"
|
2011-12-06 04:16:54 +04:00
|
|
|
#include "memory.h"
|
2010-07-15 04:48:00 +04:00
|
|
|
|
2011-07-31 03:58:51 +04:00
|
|
|
class CSGTermEvaluator : public Visitor
|
2010-07-15 04:48:00 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-10-31 08:45:00 +04:00
|
|
|
CSGTermEvaluator(const class Tree &tree, class GeometryEvaluator *geomevaluator = NULL)
|
|
|
|
: tree(tree), geomevaluator(geomevaluator) {
|
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
|
|
|
|
2011-10-01 03:36:30 +04:00
|
|
|
virtual Response visit(State &state, const class AbstractNode &node);
|
|
|
|
virtual Response visit(State &state, const class AbstractIntersectionNode &node);
|
|
|
|
virtual Response visit(State &state, const class AbstractPolyNode &node);
|
|
|
|
virtual Response visit(State &state, const class CsgNode &node);
|
|
|
|
virtual Response visit(State &state, const class TransformNode &node);
|
|
|
|
virtual Response visit(State &state, const class ColorNode &node);
|
|
|
|
virtual Response visit(State &state, const class RenderNode &node);
|
|
|
|
virtual Response visit(State &state, const class CgaladvNode &node);
|
2010-07-15 04:48:00 +04:00
|
|
|
|
2011-12-06 04:16:54 +04:00
|
|
|
shared_ptr<class CSGTerm> evaluateCSGTerm(const AbstractNode &node,
|
|
|
|
std::vector<shared_ptr<CSGTerm> > &highlights,
|
|
|
|
std::vector<shared_ptr<CSGTerm> > &background);
|
2010-09-07 04:02:22 +04:00
|
|
|
|
2010-07-15 04:48:00 +04:00
|
|
|
private:
|
2011-08-13 03:48:59 +04:00
|
|
|
enum CsgOp {CSGT_UNION, CSGT_INTERSECTION, CSGT_DIFFERENCE, CSGT_MINKOWSKI};
|
2010-07-15 04:48:00 +04:00
|
|
|
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;
|
2011-10-01 03:36:30 +04:00
|
|
|
typedef std::list<const AbstractNode *> ChildList;
|
|
|
|
std::map<int, ChildList> visitedchildren;
|
2010-08-28 23:35:48 +04:00
|
|
|
|
|
|
|
public:
|
2011-12-06 04:16:54 +04:00
|
|
|
std::map<int, shared_ptr<CSGTerm> > stored_term; // The term evaluated from each node index
|
2010-07-15 04:48:00 +04:00
|
|
|
|
2011-12-06 04:16:54 +04:00
|
|
|
std::vector<shared_ptr<CSGTerm> > highlights;
|
|
|
|
std::vector<shared_ptr<CSGTerm> > background;
|
2010-11-03 21:26:06 +03:00
|
|
|
const Tree &tree;
|
2013-10-31 08:45:00 +04:00
|
|
|
class GeometryEvaluator *geomevaluator;
|
2010-07-15 04:48:00 +04:00
|
|
|
};
|