diff options
author | Marius Kintel <marius@kintel.net> | 2010-03-28 16:03:44 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2010-10-31 00:42:35 (GMT) |
commit | d3ae994eb8873e23acccffe4dceb2ce418ba16c1 (patch) | |
tree | 2e6176ee400a3716661b6a07f108f5bab2549fd2 /src/CSGTextRenderer.h | |
parent | 7468c940672b31e569cbb2310676fb1ac841e2d0 (diff) |
Saved text-based renderer as own file for future testing
Diffstat (limited to 'src/CSGTextRenderer.h')
-rw-r--r-- | src/CSGTextRenderer.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/CSGTextRenderer.h b/src/CSGTextRenderer.h new file mode 100644 index 0000000..84f3d30 --- /dev/null +++ b/src/CSGTextRenderer.h @@ -0,0 +1,48 @@ +#ifndef CSGTEXTRENDERER_H_ +#define CSGTEXTRENDERER_H_ + +#include <string> +#include <map> +#include <list> +#include "visitor.h" +#include "nodecache.h" + +using std::string; +using std::map; +using std::list; +using std::pair; + +class CSGTextRenderer : public Visitor +{ +public: + enum CsgOp {UNION, INTERSECTION, DIFFERENCE, MINKOWSKI}; + CSGTextRenderer(const NodeCache<string> &dumpcache) : root(NULL), dumpcache(dumpcache) {} + virtual ~CSGTextRenderer() {} + + virtual Response visit(const State &state, const AbstractNode &node); + virtual Response visit(const State &state, const AbstractIntersectionNode &node); + virtual Response visit(const State &state, const CsgNode &node); + virtual Response visit(const State &state, const TransformNode &node); + virtual Response visit(const State &state, const AbstractPolyNode &node); + + string getCGALMesh() const; +// CGAL_Nef_polyhedron getCGALMesh() const; +private: + void addToParent(const State &state, const AbstractNode &node); + bool isCached(const AbstractNode &node); + QString mk_cache_id(const AbstractNode &node) const; + void process(string &target, const string &src, CSGTextRenderer::CsgOp op); + void applyToChildren(const AbstractNode &node, CSGTextRenderer::CsgOp op); + + string currindent; + const AbstractNode *root; + typedef list<pair<const AbstractNode *, QString> > ChildList; + map<int, ChildList> visitedchildren; +// hashmap<string, CGAL_Nef_polyhedron> cache; + + // For now use strings instead of Nef polyhedrons for testing caching + QHash<QString, string> cache; + const NodeCache<string> &dumpcache; +}; + +#endif |