diff options
Diffstat (limited to 'src/CGALRenderer.h')
-rw-r--r-- | src/CGALRenderer.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/CGALRenderer.h b/src/CGALRenderer.h index 3933823..c14cacd 100644 --- a/src/CGALRenderer.h +++ b/src/CGALRenderer.h @@ -6,6 +6,12 @@ #include <list> #include "visitor.h" #include "nodecache.h" +#include "cgal.h" + +#ifdef ENABLE_CGAL +extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); +extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +#endif using std::string; using std::map; @@ -16,33 +22,41 @@ class CGALRenderer : public Visitor { public: enum CsgOp {UNION, INTERSECTION, DIFFERENCE, MINKOWSKI}; + // FIXME: If a cache is not give, we need to fix this ourselves 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 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; + QHash<QString, CGAL_Nef_polyhedron> &getCache() { return this->cache; } + + CGAL_Nef_polyhedron renderCGALMesh(const AbstractNode &node); + CGAL_Nef_polyhedron renderCGALMesh(const PolySet &polyset); + + // FIXME: Questionable design... + static CGALRenderer *renderer() { return global_renderer; } + static void setRenderer(CGALRenderer *r) { global_renderer = r; } private: void addToParent(const State &state, const AbstractNode &node); - bool isCached(const AbstractNode &node); + bool isCached(const AbstractNode &node) const; QString mk_cache_id(const AbstractNode &node) const; - void process(string &target, const string &src, CGALRenderer::CsgOp op); + void process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedron &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; + // FIXME: enforce some maximum cache size (old version had 100K vertices as limit) + QHash<QString, CGAL_Nef_polyhedron> cache; const NodeCache<string> &dumpcache; + + static CGALRenderer *global_renderer; }; #endif |