summaryrefslogtreecommitdiff
path: root/src/CSGTermEvaluator.h
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-07-30 23:58:51 (GMT)
committerMarius Kintel <marius@kintel.net>2011-07-30 23:58:51 (GMT)
commit6882228058d313bb7b98fddd90239bdb1a3e25ef (patch)
tree9e3f0077a319939df7496fc6b18350c44cc4b0ec /src/CSGTermEvaluator.h
parentdd9dfcb4ece4dcd1ae7f3374ef03a4babdb91dd8 (diff)
parentc79ad5010e4ae8a612de5423cd52a518ed6b4d65 (diff)
Merge branch 'master' into visitor
Conflicts: src/GLView.h src/glview.cc src/mainwin.cc src/render-opencsg.cc
Diffstat (limited to 'src/CSGTermEvaluator.h')
-rw-r--r--src/CSGTermEvaluator.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/CSGTermEvaluator.h b/src/CSGTermEvaluator.h
new file mode 100644
index 0000000..d1ea28e
--- /dev/null
+++ b/src/CSGTermEvaluator.h
@@ -0,0 +1,53 @@
+#ifndef CSGTERMEVALUATOR_H_
+#define CSGTERMEVALUATOR_H_
+
+#include <string>
+#include <map>
+#include <list>
+#include <vector>
+#include "Tree.h"
+#include "visitor.h"
+#include "node.h"
+
+using std::string;
+using std::map;
+using std::list;
+using std::vector;
+
+class CSGTermEvaluator : public Visitor
+{
+public:
+ CSGTermEvaluator(const Tree &tree, class PolySetEvaluator *psevaluator = NULL)
+ : highlights(NULL), background(NULL), tree(tree), psevaluator(psevaluator) {
+ }
+ virtual ~CSGTermEvaluator() {}
+
+ 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);
+
+ class CSGTerm *evaluateCSGTerm(const AbstractNode &node,
+ vector<CSGTerm*> *highlights, vector<CSGTerm*> *background);
+
+private:
+ enum CsgOp {UNION, INTERSECTION, DIFFERENCE, MINKOWSKI};
+ void addToParent(const State &state, const AbstractNode &node);
+ void applyToChildren(const AbstractNode &node, CSGTermEvaluator::CsgOp op);
+
+ const AbstractNode *root;
+ typedef list<const AbstractNode *> ChildList;
+ map<int, ChildList> visitedchildren;
+
+public:
+ map<int, class CSGTerm*> stored_term; // The term evaluated from each node index
+
+ vector<CSGTerm*> *highlights;
+ vector<CSGTerm*> *background;
+ const Tree &tree;
+ class PolySetEvaluator *psevaluator;
+};
+
+#endif
contact: Jan Huwald // Impressum