summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2010-03-14 04:12:18 (GMT)
committerMarius Kintel <marius@kintel.net>2010-10-31 00:42:34 (GMT)
commit9bb4fc829ad9466fe59ad35803ed1db82042342a (patch)
tree0e17313197ff8910b12b0a3bf44eec157e10fa99
parente8b84d36c51327447334ce3bd6909501bab44805 (diff)
Added REMOVE_DUMP define
-rw-r--r--openscad.pro2
-rw-r--r--src/cgaladv.cc8
-rw-r--r--src/csgnode.h2
-rw-r--r--src/csgops.cc2
-rw-r--r--src/dxflinextrude.cc2
-rw-r--r--src/dxflinextrudenode.h2
-rw-r--r--src/dxfrotextrude.cc2
-rw-r--r--src/dxfrotextrudenode.h2
-rw-r--r--src/import.cc2
-rw-r--r--src/importnode.h2
-rw-r--r--src/mainwin.cc6
-rw-r--r--src/node.cc23
-rw-r--r--src/node.h8
-rw-r--r--src/primitives.cc4
-rw-r--r--src/projection.cc2
-rw-r--r--src/projectionnode.h2
-rw-r--r--src/render.cc6
-rw-r--r--src/surface.cc4
-rw-r--r--src/transform.cc4
-rw-r--r--test-code/dumptest.cc4
-rw-r--r--test-code/dumptest.pro1
21 files changed, 80 insertions, 10 deletions
diff --git a/openscad.pro b/openscad.pro
index fec7a79..8415b1f 100644
--- a/openscad.pro
+++ b/openscad.pro
@@ -9,6 +9,8 @@ UI_DIR = objects
RCC_DIR = objects
INCLUDEPATH += src
+DEFINES += REMOVE_DUMP
+
macx {
DEPLOYDIR = $$(MACOSX_DEPLOY_DIR)
!isEmpty(DEPLOYDIR) {
diff --git a/src/cgaladv.cc b/src/cgaladv.cc
index e391ea8..4a7ba31 100644
--- a/src/cgaladv.cc
+++ b/src/cgaladv.cc
@@ -71,7 +71,9 @@ public:
virtual CGAL_Nef_polyhedron renderCSGMesh() const;
#endif
virtual CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
AbstractNode *CgaladvModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
@@ -155,11 +157,11 @@ CGAL_Nef_polyhedron CgaladvNode::renderCSGMesh() const
if (v->modinst->tag_background)
continue;
if (first) {
- N = v->renderCsgMesh();
+ N = v->renderCSGMesh();
if (N.dim != 0)
first = false;
} else {
- CGAL_Nef_polyhedron tmp = v->renderCsgMesh();
+ CGAL_Nef_polyhedron tmp = v->renderCSGMesh();
if (N.dim == 3 && tmp.dim == 3) {
N.p3 = minkowski3(N.p3, tmp.p3);
}
@@ -212,6 +214,7 @@ CSGTerm *CgaladvNode::render_csg_term(double m[20], QVector<CSGTerm*> *highlight
#endif // ENABLE_CGAL
+#ifndef REMOVE_DUMP
QString CgaladvNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -231,6 +234,7 @@ QString CgaladvNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string CgaladvNode::toString() const
{
diff --git a/src/csgnode.h b/src/csgnode.h
index 405dd96..3d08b81 100644
--- a/src/csgnode.h
+++ b/src/csgnode.h
@@ -27,7 +27,9 @@ public:
virtual CGAL_Nef_polyhedron renderCSGMesh() const;
#endif
CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
#endif
diff --git a/src/csgops.cc b/src/csgops.cc
index 5baa149..da2c2e5 100644
--- a/src/csgops.cc
+++ b/src/csgops.cc
@@ -134,6 +134,7 @@ CSGTerm *CsgNode::render_csg_term(double m[20], QVector<CSGTerm*> *highlights, Q
return t1;
}
+#ifndef REMOVE_DUMP
QString CsgNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -150,6 +151,7 @@ QString CsgNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string CsgNode::toString() const
{
diff --git a/src/dxflinextrude.cc b/src/dxflinextrude.cc
index 1f6bc8c..741602d 100644
--- a/src/dxflinextrude.cc
+++ b/src/dxflinextrude.cc
@@ -299,6 +299,7 @@ PolySet *DxfLinearExtrudeNode::render_polyset(render_mode_e) const
return ps;
}
+#ifndef REMOVE_DUMP
QString DxfLinearExtrudeNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -326,6 +327,7 @@ QString DxfLinearExtrudeNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string DxfLinearExtrudeNode::toString() const
{
diff --git a/src/dxflinextrudenode.h b/src/dxflinextrudenode.h
index 2df52c8..3fa87c1 100644
--- a/src/dxflinextrudenode.h
+++ b/src/dxflinextrudenode.h
@@ -24,7 +24,9 @@ public:
bool center, has_twist;
QString filename, layername;
virtual PolySet *render_polyset(render_mode_e mode) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
#endif
diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc
index 98f91f3..b32a949 100644
--- a/src/dxfrotextrude.cc
+++ b/src/dxfrotextrude.cc
@@ -197,6 +197,7 @@ PolySet *DxfRotateExtrudeNode::render_polyset(render_mode_e) const
return ps;
}
+#ifndef REMOVE_DUMP
QString DxfRotateExtrudeNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -217,6 +218,7 @@ QString DxfRotateExtrudeNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string DxfRotateExtrudeNode::toString() const
{
diff --git a/src/dxfrotextrudenode.h b/src/dxfrotextrudenode.h
index fbe2b85..b2f4a38 100644
--- a/src/dxfrotextrudenode.h
+++ b/src/dxfrotextrudenode.h
@@ -22,7 +22,9 @@ public:
double origin_x, origin_y, scale;
QString filename, layername;
virtual PolySet *render_polyset(render_mode_e mode) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
#endif
diff --git a/src/import.cc b/src/import.cc
index 5d0a497..c977b53 100644
--- a/src/import.cc
+++ b/src/import.cc
@@ -188,6 +188,7 @@ PolySet *ImportNode::render_polyset(render_mode_e) const
return p;
}
+#ifndef REMOVE_DUMP
QString ImportNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -212,6 +213,7 @@ QString ImportNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string ImportNode::toString() const
{
diff --git a/src/importnode.h b/src/importnode.h
index b226569..7e71d45 100644
--- a/src/importnode.h
+++ b/src/importnode.h
@@ -26,7 +26,9 @@ public:
double fn, fs, fa;
double origin_x, origin_y, scale;
virtual PolySet *render_polyset(render_mode_e mode) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
#endif
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 1bf2695..8b7fac5 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -650,7 +650,9 @@ void MainWindow::compile(bool procevents)
if (!(this->root_node = find_root_tag(absolute_root_node))) {
this->root_node = absolute_root_node;
}
- root_node->dump("");
+ // Dump the tree (to initialize caches). I guess we wouldn't really need to do
+ // this explicitly..
+ root_node->dump();
if (1) {
PRINT("Compilation finished.");
@@ -1228,7 +1230,7 @@ void MainWindow::actionDisplayCSGTree()
e->setWindowTitle("CSG Tree Dump");
e->setReadOnly(true);
if (root_node) {
- e->setPlainText(root_node->dump(""));
+ e->setPlainText(root_node->dump());
} else {
e->setPlainText("No CSG to dump. Please try compiling first...");
}
diff --git a/src/node.cc b/src/node.cc
index 437fdfa..c28dff0 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -30,6 +30,8 @@
#include "progress.h"
#include "polyset.h"
#include "visitor.h"
+#include "nodedumper.h"
+
#include <QRegExp>
#include <sstream>
@@ -62,9 +64,15 @@ Response AbstractPolyNode::accept(const class State &state, Visitor &visitor) co
return visitor.visit(state, *this);
}
+/*!
+ Create a cache id of the entire tree under this node. This cache id
+ is a non-whitespace plaintext of the evaluated scad tree and is used
+ for lookup in cgal_nef_cache.
+*/
QString AbstractNode::mk_cache_id() const
{
- QString cache_id = dump("");
+ QString cache_id = dump();
+ // Remove all node class names and whitespace
cache_id.remove(QRegExp("[a-zA-Z_][a-zA-Z_0-9]*:"));
cache_id.remove(' ');
cache_id.remove('\t');
@@ -165,6 +173,7 @@ CSGTerm *AbstractIntersectionNode::render_csg_term(double m[20], QVector<CSGTerm
return render_csg_term_backend(this, true, m, highlights, background);
}
+#ifndef REMOVE_DUMP
QString AbstractNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -175,6 +184,16 @@ QString AbstractNode::dump(QString indent) const
}
return dump_cache;
}
+#else
+// Temporarily offer a top-level dump function to keep existing code running
+QString AbstractNode::dump() const
+{
+ NodeDumper dumper;
+ Traverser trav(dumper, *this, Traverser::PRE_AND_POSTFIX);
+ trav.execute();
+ return QString::fromStdString(dumper.getDump() + "\n");
+}
+#endif
std::string AbstractNode::toString() const
{
@@ -183,6 +202,7 @@ std::string AbstractNode::toString() const
return stream.str();
}
+#ifndef REMOVE_DUMP
QString AbstractIntersectionNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -193,6 +213,7 @@ QString AbstractIntersectionNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string AbstractIntersectionNode::toString() const
{
diff --git a/src/node.h b/src/node.h
index f3a5b0b..ad5b033 100644
--- a/src/node.h
+++ b/src/node.h
@@ -52,9 +52,11 @@ public:
int idx; // Node index (unique per tree)
// FIXME: Remove these three with dump() method
- QString dump_cache;
virtual QString mk_cache_id() const;
- virtual QString dump(QString indent) const;
+ QString dump() const;
+#ifndef REMOVE_DUMP
+ QString dump_cache;
+#endif
// FIXME: Rewrite to visitor
virtual class CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
@@ -84,7 +86,9 @@ public:
virtual CGAL_Nef_polyhedron renderCSGMesh() const;
#endif
virtual CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
class AbstractPolyNode : public AbstractNode
diff --git a/src/primitives.cc b/src/primitives.cc
index 8838547..84e6a6d 100644
--- a/src/primitives.cc
+++ b/src/primitives.cc
@@ -69,7 +69,9 @@ public:
int convexity;
Value points, paths, triangles;
virtual PolySet *render_polyset(render_mode_e mode) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
AbstractNode *PrimitiveModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
@@ -526,6 +528,7 @@ sphere_next_r2:
return p;
}
+#ifndef REMOVE_DUMP
QString PrimitiveNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -548,6 +551,7 @@ QString PrimitiveNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string PrimitiveNode::toString() const
{
diff --git a/src/projection.cc b/src/projection.cc
index 985ed20..2176b4d 100644
--- a/src/projection.cc
+++ b/src/projection.cc
@@ -274,6 +274,7 @@ PolySet *ProjectionNode::render_polyset(render_mode_e) const
#endif // ENABLE_CGAL
+#ifndef REMOVE_DUMP
QString ProjectionNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -287,6 +288,7 @@ QString ProjectionNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string ProjectionNode::toString() const
{
diff --git a/src/projectionnode.h b/src/projectionnode.h
index d5ba6da..e59088c 100644
--- a/src/projectionnode.h
+++ b/src/projectionnode.h
@@ -18,7 +18,9 @@ public:
int convexity;
bool cut_mode;
virtual PolySet *render_polyset(render_mode_e mode) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
#endif
diff --git a/src/render.cc b/src/render.cc
index 5bd57fc..fb7dd59 100644
--- a/src/render.cc
+++ b/src/render.cc
@@ -62,8 +62,10 @@ public:
#ifdef ENABLE_CGAL
virtual CGAL_Nef_polyhedron renderCSGMesh() const;
#endif
- CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
+ CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
AbstractNode *RenderModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
@@ -256,6 +258,7 @@ CSGTerm *RenderNode::render_csg_term(double m[20], QVector<CSGTerm*> *highlights
#endif
+#ifndef REMOVE_DUMP
QString RenderNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -266,6 +269,7 @@ QString RenderNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string RenderNode::toString() const
{
diff --git a/src/surface.cc b/src/surface.cc
index 57b3f59..c28d9ba 100644
--- a/src/surface.cc
+++ b/src/surface.cc
@@ -56,7 +56,9 @@ public:
bool center;
int convexity;
virtual PolySet *render_polyset(render_mode_e mode) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
AbstractNode *SurfaceModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
@@ -204,6 +206,7 @@ PolySet *SurfaceNode::render_polyset(render_mode_e) const
return p;
}
+#ifndef REMOVE_DUMP
QString SurfaceNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -214,6 +217,7 @@ QString SurfaceNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string SurfaceNode::toString() const
{
diff --git a/src/transform.cc b/src/transform.cc
index 8f61c26..d49f3ff 100644
--- a/src/transform.cc
+++ b/src/transform.cc
@@ -66,7 +66,9 @@ public:
virtual CGAL_Nef_polyhedron renderCSGMesh() const;
#endif
virtual CSGTerm *render_csg_term(double m[20], QVector<CSGTerm*> *highlights, QVector<CSGTerm*> *background) const;
+#ifndef REMOVE_DUMP
virtual QString dump(QString indent) const;
+#endif
};
AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
@@ -353,6 +355,7 @@ CSGTerm *TransformNode::render_csg_term(double c[20], QVector<CSGTerm*> *highlig
return t1;
}
+#ifndef REMOVE_DUMP
QString TransformNode::dump(QString indent) const
{
if (dump_cache.isEmpty()) {
@@ -374,6 +377,7 @@ QString TransformNode::dump(QString indent) const
}
return dump_cache;
}
+#endif
std::string TransformNode::toString() const
{
diff --git a/test-code/dumptest.cc b/test-code/dumptest.cc
index cb2b13c..36261b6 100644
--- a/test-code/dumptest.cc
+++ b/test-code/dumptest.cc
@@ -144,8 +144,8 @@ int main(int argc, char **argv)
root_node = root_module->evaluate(&root_ctx, &root_inst);
// Cache test
- QString dumpstr = root_node->dump("");
- QString dumpstr_cached = root_node->dump("");
+ QString dumpstr = root_node->dump();
+ QString dumpstr_cached = root_node->dump();
if (dumpstr != dumpstr_cached) rc = 1;
NodeDumper dumper;
diff --git a/test-code/dumptest.pro b/test-code/dumptest.pro
index d196cda..f3ba27e 100644
--- a/test-code/dumptest.pro
+++ b/test-code/dumptest.pro
@@ -7,6 +7,7 @@ UI_DIR = objects
RCC_DIR = objects
INCLUDEPATH += ../src
+DEFINES += REMOVE_DUMP
TARGET = dumptest
macx {
CONFIG -= app_bundle
contact: Jan Huwald // Impressum