summaryrefslogtreecommitdiff
path: root/src/CGALEvaluator.h
blob: 8af64e30d581342352771f261464a4674ca6c1a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef CGALEVALUATOR_H_
#define CGALEVALUATOR_H_

#include "myqhash.h"
#include "visitor.h"
#include "Tree.h"
#include "CGAL_Nef_polyhedron.h"
#include "PolySetCGALEvaluator.h"

#include <string>
#include <map>
#include <list>

using std::string;
using std::map;
using std::list;
using std::pair;

class CGALEvaluator : public Visitor
{
public:
	enum CsgOp {CGE_UNION, CGE_INTERSECTION, CGE_DIFFERENCE, CGE_MINKOWSKI, CGE_HULL};
	// FIXME: If a cache is not given, we need to fix this ourselves
	CGALEvaluator(QHash<string, CGAL_Nef_polyhedron> &cache, const Tree &tree) : cache(cache), tree(tree), psevaluator(*this) {}
  virtual ~CGALEvaluator() {}

  virtual Response visit(State &state, const AbstractNode &node);
 	virtual Response visit(State &state, const AbstractIntersectionNode &node);
 	virtual Response visit(State &state, const CsgNode &node);
 	virtual Response visit(State &state, const TransformNode &node);
	virtual Response visit(State &state, const AbstractPolyNode &node);

 	CGAL_Nef_polyhedron evaluateCGALMesh(const AbstractNode &node);
	CGAL_Nef_polyhedron evaluateCGALMesh(const PolySet &polyset);

	const Tree &getTree() const { return this->tree; }

private:
  void addToParent(const State &state, const AbstractNode &node);
  bool isCached(const AbstractNode &node) const;
	void process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedron &src, CGALEvaluator::CsgOp op);
	void applyToChildren(const AbstractNode &node, CGALEvaluator::CsgOp op);

  string currindent;
  typedef list<pair<const AbstractNode *, string> > ChildList;
  map<int, ChildList> visitedchildren;

	QHash<string, CGAL_Nef_polyhedron> &cache;
	const Tree &tree;
	PolySetCGALEvaluator psevaluator;
};

#endif
contact: Jan Huwald // Impressum