summaryrefslogtreecommitdiff
path: root/tests/CSGTextRenderer.h
blob: 79a8a96f66b8faa4c6dc16e5cf46a0c10ca55b0f (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
#ifndef CSGTEXTRENDERER_H_
#define CSGTEXTRENDERER_H_

#include "visitor.h"
#include "CSGTextCache.h"

#include <map>
#include <list>

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

class CSGTextRenderer : public Visitor
{
public:
	CSGTextRenderer(CSGTextCache &cache) : cache(cache) {}
  virtual ~CSGTextRenderer() {}

  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);

private:
	enum CsgOp {UNION, INTERSECTION, DIFFERENCE, MINKOWSKI};
  void addToParent(const State &state, const AbstractNode &node);
  bool isCached(const AbstractNode &node);
	void process(string &target, const string &src, CSGTextRenderer::CsgOp op);
	void applyToChildren(const AbstractNode &node, CSGTextRenderer::CsgOp op);

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

	CSGTextCache &cache;
};

#endif
contact: Jan Huwald // Impressum