summaryrefslogtreecommitdiff
path: root/src/render.cc
diff options
context:
space:
mode:
authorkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-10-31 01:19:06 (GMT)
committerkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-10-31 01:19:06 (GMT)
commit53337ff65426ff1ebd87160b502ec383d201ac7b (patch)
treefbcb75d32e8763aac3f0ad28528936a0ec11930b /src/render.cc
parent746159d1838e895e80725cdc892f7bef85feb1af (diff)
Committed current version of visitor refactoring
git-svn-id: http://svn.clifford.at/openscad/trunk@571 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'src/render.cc')
-rw-r--r--src/render.cc31
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();
+}
contact: Jan Huwald // Impressum