mirror of https://github.com/vitalif/openscad
Added REMOVE_DUMP define
parent
e8b84d36c5
commit
9bb4fc829a
|
@ -9,6 +9,8 @@ UI_DIR = objects
|
|||
RCC_DIR = objects
|
||||
INCLUDEPATH += src
|
||||
|
||||
DEFINES += REMOVE_DUMP
|
||||
|
||||
macx {
|
||||
DEPLOYDIR = $$(MACOSX_DEPLOY_DIR)
|
||||
!isEmpty(DEPLOYDIR) {
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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...");
|
||||
}
|
||||
|
|
23
src/node.cc
23
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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -7,6 +7,7 @@ UI_DIR = objects
|
|||
RCC_DIR = objects
|
||||
INCLUDEPATH += ../src
|
||||
|
||||
DEFINES += REMOVE_DUMP
|
||||
TARGET = dumptest
|
||||
macx {
|
||||
CONFIG -= app_bundle
|
||||
|
|
Loading…
Reference in New Issue