diff options
author | Marius Kintel <marius@kintel.net> | 2010-03-19 03:07:01 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2010-10-31 00:42:34 (GMT) |
commit | 311d1befb425a684349fcd7255bb76217ac9f4b6 (patch) | |
tree | a2aef95af99c6dc999d1658296dd5110e6742df0 /src/CGALRenderer.h | |
parent | 0b06db6bc925a5cf5f3bb9f80dd07efd9402bc16 (diff) |
Added CGALRenderer + some minor fixes
Diffstat (limited to 'src/CGALRenderer.h')
-rw-r--r-- | src/CGALRenderer.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/CGALRenderer.h b/src/CGALRenderer.h new file mode 100644 index 0000000..b30a24b --- /dev/null +++ b/src/CGALRenderer.h @@ -0,0 +1,48 @@ +#ifndef CGALRENDERER_H_ +#define CGALRENDERER_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 CGALRenderer : public Visitor +{ +public: + enum CsgOp {UNION, INTERSECTION, DIFFERENCE, MINKOWSKI}; + CGALRenderer(const NodeCache<string> &dumpcache) : root(NULL), dumpcache(dumpcache) {} + virtual ~CGALRenderer() {} + + 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 handleVisitedChildren(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, CGALRenderer::CsgOp op); + void applyToChildren(const AbstractNode &node, CGALRenderer::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 |