diff options
author | Marius Kintel <kintel@sim.no> | 2010-03-02 18:22:31 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2010-10-31 00:42:34 (GMT) |
commit | 393c5a19fedfa4f97ca939fbcf52c2ccab1cde6a (patch) | |
tree | fbcb75d32e8763aac3f0ad28528936a0ec11930b /src/render.cc | |
parent | 746159d1838e895e80725cdc892f7bef85feb1af (diff) |
Committed current version of visitor refactoring
Diffstat (limited to 'src/render.cc')
-rw-r--r-- | src/render.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/render.cc b/src/render.cc index d851fc8..5bd57fc 100644 --- a/src/render.cc +++ b/src/render.cc @@ -33,13 +33,14 @@ #include "builtin.h" #include "printutils.h" #include "progress.h" +#include "visitor.h" #ifdef ENABLE_CGAL # include "cgal.h" #endif -#include <QProgressDialog> #include <QApplication> #include <QTime> +#include <sstream> class RenderModule : public AbstractModule { @@ -51,10 +52,15 @@ public: class RenderNode : public AbstractNode { public: - int convexity; RenderNode(const ModuleInstantiation *mi) : AbstractNode(mi), convexity(1) { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + + int convexity; #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + virtual CGAL_Nef_polyhedron renderCSGMesh() const; #endif CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const; virtual QString dump(QString indent) const; @@ -90,7 +96,7 @@ void register_builtin_render() #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron RenderNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron RenderNode::renderCSGMesh() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -108,13 +114,13 @@ CGAL_Nef_polyhedron RenderNode::render_cgal_nef_polyhedron() const if (v->modinst->tag_background) continue; if (first) { - N = v->render_cgal_nef_polyhedron(); + N = v->renderCSGMesh(); if (N.dim != 0) first = false; } else if (N.dim == 2) { - N.p2 += v->render_cgal_nef_polyhedron().p2; + N.p2 += v->renderCSGMesh().p2; } else if (N.dim == 3) { - N.p3 += v->render_cgal_nef_polyhedron().p3; + N.p3 += v->renderCSGMesh().p3; } v->progress_report(); } @@ -153,7 +159,7 @@ CSGTerm *AbstractNode::render_csg_term_from_nef(double m[20], QVector<CSGTerm*> QTime t; t.start(); - N = this->render_cgal_nef_polyhedron(); + N = this->renderCSGMesh(); int s = t.elapsed() / 1000; PRINTF_NOCACHE("..rendering time: %d hours, %d minutes, %d seconds", s / (60*60), (s / 60) % 60, s % 60); @@ -261,3 +267,12 @@ QString RenderNode::dump(QString indent) const return dump_cache; } +std::string RenderNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + stream << "render(convexity = " << convexity << ")"; + + return stream.str(); +} |