diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/AboutDialog.html | 8 | ||||
-rw-r--r-- | src/CGALRenderer.cc | 2 | ||||
-rw-r--r-- | src/CGAL_Nef_polyhedron.cc | 2 | ||||
-rw-r--r-- | src/CGAL_Nef_polyhedron_DxfData.cc | 2 | ||||
-rw-r--r-- | src/PolySetCGALEvaluator.cc | 137 | ||||
-rw-r--r-- | src/dxftess-cgal.cc | 6 | ||||
-rw-r--r-- | src/dxftess-glu.cc | 6 | ||||
-rw-r--r-- | src/dxftess.h | 4 | ||||
-rw-r--r-- | src/expr.cc | 27 | ||||
-rw-r--r-- | src/expression.h | 2 | ||||
-rw-r--r-- | src/import.cc | 2 | ||||
-rw-r--r-- | src/linearextrude.cc | 11 | ||||
-rw-r--r-- | src/linearextrudenode.h | 5 | ||||
-rw-r--r-- | src/mainwin.cc | 6 | ||||
-rw-r--r-- | src/modcontext.cc | 26 | ||||
-rw-r--r-- | src/modcontext.h | 2 | ||||
-rw-r--r-- | src/module.cc | 20 | ||||
-rw-r--r-- | src/module.h | 3 | ||||
-rw-r--r-- | src/primitives.cc | 2 |
19 files changed, 157 insertions, 116 deletions
diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 6203e83..005f61f 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -67,7 +67,7 @@ Please visit this link for a copy of the license: <a href="http://www.gnu.org/li </p> <p> -<b>Acknowledgements</b> +<b>OpenSCAD Maintainer:</b> <a href="https://github.com/kintel">Marius Kintel </a> </p> <p> @@ -101,11 +101,13 @@ Please visit this link for a copy of the license: <a href="http://www.gnu.org/li <li><a href="https://github.com/iamwilhelm">iamwilhelm</a> <li><a href="https://github.com/clothbot">clothbot</a> <li><a href="https://github.com/colah">colah</a> +<li><a href="https://github.com/peteruithoven">Peter Uithoven</a> + </lu> <p> -<b>Mailing list, bug reports, testing, contribs, &c</b> +<b>Mailing list, bug reports, testing, contribs, help, &c</b> </p> nop head, Triffid Hunter, Len Trigg, Kliment Yanev, Christian Siefkes, @@ -115,7 +117,7 @@ Brett Sutton, hmnapier, Eero af Heurlin, caliston, 5263, ghost, 42loop, uniqx, Michael Thomson, Michael Ivko, Pierre Doucet, myglc2, Alan Cox, Peter Falke, Michael Ambrus, Gordon Wrigley, Ed Nisley, Stony Smith, Pasca Andrei, David Goodenough, William A Adams, mrrobinson, 1i7, -benhowes, 5263, Craig Trader, Miro Hrončok, ... and many others +benhowes, 5263, Craig Trader, Miro Hrončok, Tony Theodore ... and many others <p> <b>Hosting & resources</b> diff --git a/src/CGALRenderer.cc b/src/CGALRenderer.cc index 4357e44..0a75266 100644 --- a/src/CGALRenderer.cc +++ b/src/CGALRenderer.cc @@ -52,7 +52,7 @@ CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root) this->polyhedron = NULL; this->polyset = new PolySet(); this->polyset->is2d = true; - dxf_tesselate(this->polyset, *dd, 0, true, false, 0); + dxf_tesselate(this->polyset, *dd, 0, Vector2d(1,1), true, false, 0); delete dd; } else if (root.dim == 3) { diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index 8906595..440f4ed 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -90,7 +90,7 @@ PolySet *CGAL_Nef_polyhedron::convertToPolyset() ps = new PolySet(); DxfData *dd = this->convertToDxfData(); ps->is2d = true; - dxf_tesselate(ps, *dd, 0, true, false, 0); + dxf_tesselate(ps, *dd, 0, Vector2d(1,1), true, false, 0); dxf_border_to_ps(ps, *dd); delete dd; } diff --git a/src/CGAL_Nef_polyhedron_DxfData.cc b/src/CGAL_Nef_polyhedron_DxfData.cc index 0388fe5..c4347e8 100644 --- a/src/CGAL_Nef_polyhedron_DxfData.cc +++ b/src/CGAL_Nef_polyhedron_DxfData.cc @@ -123,7 +123,7 @@ void CGAL_Nef_polyhedron::transform( const Transform3d &matrix ) PolySet ps; ps.is2d = true; - dxf_tesselate(&ps, *dd, 0, true, false, 0); + dxf_tesselate(&ps, *dd, 0, Vector2d(1,1), true, false, 0); Tree nulltree; CGALEvaluator tmpeval(nulltree); diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc index 5976daf..f0c274f 100644 --- a/src/PolySetCGALEvaluator.cc +++ b/src/PolySetCGALEvaluator.cc @@ -202,27 +202,38 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node) return ps; } -static void add_slice(PolySet *ps, const DxfData &dxf, DxfData::Path &path, double rot1, double rot2, double h1, double h2) +static void add_slice(PolySet *ps, const DxfData &dxf, DxfData::Path &path, + double rot1, double rot2, + double h1, double h2, + double scale1_x, double scale1_y, + double scale2_x, double scale2_y) { + // FIXME: If scale2 == 0 we need to handle tessellation separately bool splitfirst = sin(rot2 - rot1) >= 0.0; - for (size_t j = 1; j < path.indices.size(); j++) - { + for (size_t j = 1; j < path.indices.size(); j++) { int k = j - 1; - double jx1 = dxf.points[path.indices[j]][0] * cos(rot1*M_PI/180) + dxf.points[path.indices[j]][1] * sin(rot1*M_PI/180); - double jy1 = dxf.points[path.indices[j]][0] * -sin(rot1*M_PI/180) + dxf.points[path.indices[j]][1] * cos(rot1*M_PI/180); + double jx1 = scale1_x * (dxf.points[path.indices[j]][0] * cos(rot1*M_PI/180) + + dxf.points[path.indices[j]][1] * sin(rot1*M_PI/180)); + double jy1 = scale1_y * (dxf.points[path.indices[j]][0] * -sin(rot1*M_PI/180) + + dxf.points[path.indices[j]][1] * cos(rot1*M_PI/180)); - double jx2 = dxf.points[path.indices[j]][0] * cos(rot2*M_PI/180) + dxf.points[path.indices[j]][1] * sin(rot2*M_PI/180); - double jy2 = dxf.points[path.indices[j]][0] * -sin(rot2*M_PI/180) + dxf.points[path.indices[j]][1] * cos(rot2*M_PI/180); + double jx2 = scale2_x * (dxf.points[path.indices[j]][0] * cos(rot2*M_PI/180) + + dxf.points[path.indices[j]][1] * sin(rot2*M_PI/180)); + double jy2 = scale2_y * (dxf.points[path.indices[j]][0] * -sin(rot2*M_PI/180) + + dxf.points[path.indices[j]][1] * cos(rot2*M_PI/180)); - double kx1 = dxf.points[path.indices[k]][0] * cos(rot1*M_PI/180) + dxf.points[path.indices[k]][1] * sin(rot1*M_PI/180); - double ky1 = dxf.points[path.indices[k]][0] * -sin(rot1*M_PI/180) + dxf.points[path.indices[k]][1] * cos(rot1*M_PI/180); + double kx1 = scale1_x * (dxf.points[path.indices[k]][0] * cos(rot1*M_PI/180) + + dxf.points[path.indices[k]][1] * sin(rot1*M_PI/180)); + double ky1 = scale1_y * (dxf.points[path.indices[k]][0] * -sin(rot1*M_PI/180) + + dxf.points[path.indices[k]][1] * cos(rot1*M_PI/180)); - double kx2 = dxf.points[path.indices[k]][0] * cos(rot2*M_PI/180) + dxf.points[path.indices[k]][1] * sin(rot2*M_PI/180); - double ky2 = dxf.points[path.indices[k]][0] * -sin(rot2*M_PI/180) + dxf.points[path.indices[k]][1] * cos(rot2*M_PI/180); + double kx2 = scale2_x * (dxf.points[path.indices[k]][0] * cos(rot2*M_PI/180) + + dxf.points[path.indices[k]][1] * sin(rot2*M_PI/180)); + double ky2 = scale2_y * (dxf.points[path.indices[k]][0] * -sin(rot2*M_PI/180) + + dxf.points[path.indices[k]][1] * cos(rot2*M_PI/180)); - if (splitfirst) - { + if (splitfirst) { ps->append_poly(); if (path.is_inner) { ps->append_vertex(kx1, ky1, h1); @@ -234,19 +245,20 @@ static void add_slice(PolySet *ps, const DxfData &dxf, DxfData::Path &path, doub ps->insert_vertex(jx2, jy2, h2); } - ps->append_poly(); - if (path.is_inner) { - ps->append_vertex(kx2, ky2, h2); - ps->append_vertex(kx1, ky1, h1); - ps->append_vertex(jx2, jy2, h2); - } else { - ps->insert_vertex(kx2, ky2, h2); - ps->insert_vertex(kx1, ky1, h1); - ps->insert_vertex(jx2, jy2, h2); + if (scale2_x > 0 || scale2_y > 0) { + ps->append_poly(); + if (path.is_inner) { + ps->append_vertex(kx2, ky2, h2); + ps->append_vertex(kx1, ky1, h1); + ps->append_vertex(jx2, jy2, h2); + } else { + ps->insert_vertex(kx2, ky2, h2); + ps->insert_vertex(kx1, ky1, h1); + ps->insert_vertex(jx2, jy2, h2); + } } } - else - { + else { ps->append_poly(); if (path.is_inner) { ps->append_vertex(kx1, ky1, h1); @@ -258,15 +270,17 @@ static void add_slice(PolySet *ps, const DxfData &dxf, DxfData::Path &path, doub ps->insert_vertex(kx2, ky2, h2); } - ps->append_poly(); - if (path.is_inner) { - ps->append_vertex(jx2, jy2, h2); - ps->append_vertex(kx2, ky2, h2); - ps->append_vertex(jx1, jy1, h1); - } else { - ps->insert_vertex(jx2, jy2, h2); - ps->insert_vertex(kx2, ky2, h2); - ps->insert_vertex(jx1, jy1, h1); + if (scale2_x > 0 || scale2_y > 0) { + ps->append_poly(); + if (path.is_inner) { + ps->append_vertex(jx2, jy2, h2); + ps->append_vertex(kx2, ky2, h2); + ps->append_vertex(jx1, jy1, h1); + } else { + ps->insert_vertex(jx2, jy2, h2); + ps->insert_vertex(kx2, ky2, h2); + ps->insert_vertex(jx1, jy1, h1); + } } } } @@ -298,7 +312,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const LinearExtrudeNode &node) if (sum.isNull()) return NULL; dxf = sum.convertToDxfData();; } else { - dxf = new DxfData(node.fn, node.fs, node.fa, node.filename, node.layername, node.origin_x, node.origin_y, node.scale); + dxf = new DxfData(node.fn, node.fs, node.fa, node.filename, node.layername, node.origin_x, node.origin_y, node.scale_x); } PolySet *ps = extrudeDxfData(node, *dxf); @@ -322,50 +336,49 @@ PolySet *PolySetCGALEvaluator::extrudeDxfData(const LinearExtrudeNode &node, Dxf } bool first_open_path = true; - for (size_t i = 0; i < dxf.paths.size(); i++) - { - if (dxf.paths[i].is_closed) - continue; + for (size_t i = 0; i < dxf.paths.size(); i++) { + if (dxf.paths[i].is_closed) continue; if (first_open_path) { PRINTB("WARNING: Open paths in dxf_linear_extrude(file = \"%s\", layer = \"%s\"):", node.filename % node.layername); first_open_path = false; } PRINTB(" %9.5f %10.5f ... %10.5f %10.5f", - (dxf.points[dxf.paths[i].indices.front()][0] / node.scale + node.origin_x) % - (dxf.points[dxf.paths[i].indices.front()][1] / node.scale + node.origin_y) % - (dxf.points[dxf.paths[i].indices.back()][0] / node.scale + node.origin_x) % - (dxf.points[dxf.paths[i].indices.back()][1] / node.scale + node.origin_y)); + (dxf.points[dxf.paths[i].indices.front()][0] / node.scale_x + node.origin_x) % + (dxf.points[dxf.paths[i].indices.front()][1] / node.scale_y + node.origin_y) % + (dxf.points[dxf.paths[i].indices.back()][0] / node.scale_x + node.origin_x) % + (dxf.points[dxf.paths[i].indices.back()][1] / node.scale_y + node.origin_y)); } - if (node.has_twist) - { - dxf_tesselate(ps, dxf, 0, false, true, h1); - dxf_tesselate(ps, dxf, node.twist, true, true, h2); - for (int j = 0; j < node.slices; j++) - { + if (node.has_twist) { + dxf_tesselate(ps, dxf, 0, Vector2d(1,1), false, true, h1); // bottom + if (node.scale_x > 0 || node.scale_y > 0) { + dxf_tesselate(ps, dxf, node.twist, Vector2d(node.scale_x, node.scale_y), true, true, h2); // top + } + for (int j = 0; j < node.slices; j++) { double t1 = node.twist*j / node.slices; double t2 = node.twist*(j+1) / node.slices; double g1 = h1 + (h2-h1)*j / node.slices; double g2 = h1 + (h2-h1)*(j+1) / node.slices; - for (size_t i = 0; i < dxf.paths.size(); i++) - { - if (!dxf.paths[i].is_closed) - continue; - add_slice(ps, dxf, dxf.paths[i], t1, t2, g1, g2); + double s1x = 1 - (1-node.scale_x)*j / node.slices; + double s1y = 1 - (1-node.scale_y)*j / node.slices; + double s2x = 1 - (1-node.scale_x)*(j+1) / node.slices; + double s2y = 1 - (1-node.scale_y)*(j+1) / node.slices; + for (size_t i = 0; i < dxf.paths.size(); i++) { + if (!dxf.paths[i].is_closed) continue; + add_slice(ps, dxf, dxf.paths[i], t1, t2, g1, g2, s1x, s1y, s2x, s2y); } } } - else - { - dxf_tesselate(ps, dxf, 0, false, true, h1); - dxf_tesselate(ps, dxf, 0, true, true, h2); - for (size_t i = 0; i < dxf.paths.size(); i++) - { - if (!dxf.paths[i].is_closed) - continue; - add_slice(ps, dxf, dxf.paths[i], 0, 0, h1, h2); + else { + dxf_tesselate(ps, dxf, 0, Vector2d(1,1), false, true, h1); //bottom + if (node.scale_x > 0 || node.scale_y > 0) { + dxf_tesselate(ps, dxf, 0, Vector2d(node.scale_x, node.scale_y), true, true, h2); // top + } + for (size_t i = 0; i < dxf.paths.size(); i++) { + if (!dxf.paths[i].is_closed) continue; + add_slice(ps, dxf, dxf.paths[i], 0, 0, h1, h2, 1, 1, node.scale_x, node.scale_y); } } diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index 0197473..16eaf9f 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -101,7 +101,7 @@ void mark_inner_outer(std::vector<struct triangle> &tri, Grid2d<point_info_t> &p } } -void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_triangle_splitting */, double h) +void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, Vector2d scale, bool up, bool /* do_triangle_splitting */, double h) { CDT cdt; @@ -314,8 +314,8 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool /* do_tr int idx = up ? j : (2-j); double px = tri[i].p[idx].x; double py = tri[i].p[idx].y; - ps->append_vertex(px * cos(rot*M_PI/180) + py * sin(rot*M_PI/180), - px * -sin(rot*M_PI/180) + py * cos(rot*M_PI/180), h); + ps->append_vertex(scale[0] * (px * cos(rot*M_PI/180) + py * sin(rot*M_PI/180)), + scale[1] * (px * -sin(rot*M_PI/180) + py * cos(rot*M_PI/180)), h); path[j] = point_info.data(px, py).pathidx; point[j] = point_info.data(px, py).pointidx; } diff --git a/src/dxftess-glu.cc b/src/dxftess-glu.cc index 3f87729..89999c3 100644 --- a/src/dxftess-glu.cc +++ b/src/dxftess-glu.cc @@ -201,7 +201,7 @@ inline void do_emplace( boost::unordered_multimap<int, pair_ii> &tri_by_atan2, i rot: CLOCKWISE rotation around positive Z axis */ -void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_triangle_splitting, double h) +void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, Vector2d scale, bool up, bool do_triangle_splitting, double h) { GLUtesselator *tobj = gluNewTess(); @@ -244,8 +244,8 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian dxf.points[dxf.paths[i].indices[j]][1], h) = std::pair<int,int>(i, j); vl.push_back(tess_vdata()); - vl.back().v[0] = dxf.points[dxf.paths[i].indices[j]][0]; - vl.back().v[1] = dxf.points[dxf.paths[i].indices[j]][1]; + vl.back().v[0] = scale[0] * dxf.points[dxf.paths[i].indices[j]][0]; + vl.back().v[1] = scale[1] * dxf.points[dxf.paths[i].indices[j]][1]; vl.back().v[2] = h; gluTessVertex(tobj, vl.back().v, vl.back().v); } diff --git a/src/dxftess.h b/src/dxftess.h index d3af36e..f0f27b5 100644 --- a/src/dxftess.h +++ b/src/dxftess.h @@ -1,9 +1,11 @@ #ifndef DXFTESS_H_ #define DXFTESS_H_ +#include "linalg.h" + class DxfData; class PolySet; -void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_triangle_splitting, double h); +void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, Vector2d scale, bool up, bool do_triangle_splitting, double h); void dxf_border_to_ps(PolySet *ps, const DxfData &dxf); #endif diff --git a/src/expr.cc b/src/expr.cc index 746c0e3..4355400 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -31,28 +31,29 @@ #include <sstream> #include <algorithm> #include "stl-utils.h" +#include "printutils.h" #include <boost/bind.hpp> #include <boost/foreach.hpp> -Expression::Expression() +Expression::Expression() : recursioncount(0) { } Expression::Expression(const std::string &type, Expression *left, Expression *right) - : type(type) + : type(type), recursioncount(0) { this->children.push_back(left); this->children.push_back(right); } Expression::Expression(const std::string &type, Expression *expr) - : type(type) + : type(type), recursioncount(0) { this->children.push_back(expr); } -Expression::Expression(const Value &val) : const_value(val), type("C") +Expression::Expression(const Value &val) : const_value(val), type("C"), recursioncount(0) { } @@ -61,6 +62,18 @@ Expression::~Expression() std::for_each(this->children.begin(), this->children.end(), del_fun<Expression>()); } +class FuncRecursionGuard +{ +public: + FuncRecursionGuard(const Expression &e) : expr(e) { + expr.recursioncount++; + } + ~FuncRecursionGuard() { expr.recursioncount--; } + bool recursion_detected() const { return (expr.recursioncount > 100); } +private: + const Expression &expr; +}; + Value Expression::evaluate(const Context *context) const { if (this->type == "!") @@ -141,6 +154,12 @@ Value Expression::evaluate(const Context *context) const return Value(); } if (this->type == "F") { + FuncRecursionGuard g(*this); + if (g.recursion_detected()) { + PRINTB("ERROR: Recursion detected calling function '%s'", this->call_funcname); + return Value(); + } + EvalContext c(context, this->call_arguments); return context->evaluate_function(this->call_funcname, &c); } diff --git a/src/expression.h b/src/expression.h index 6c03f52..3629704 100644 --- a/src/expression.h +++ b/src/expression.h @@ -40,6 +40,8 @@ public: Value evaluate(const class Context *context) const; std::string toString() const; + + mutable int recursioncount; }; std::ostream &operator<<(std::ostream &stream, const Expression &expr); diff --git a/src/import.cc b/src/import.cc index bb44d70..2180684 100644 --- a/src/import.cc +++ b/src/import.cc @@ -294,7 +294,7 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const p = new PolySet(); DxfData dd(this->fn, this->fs, this->fa, this->filename, this->layername, this->origin_x, this->origin_y, this->scale); p->is2d = true; - dxf_tesselate(p, dd, 0, true, false, 0); + dxf_tesselate(p, dd, 0, Vector2d(1,1), true, false, 0); dxf_border_to_ps(p, dd); } else diff --git a/src/linearextrude.cc b/src/linearextrude.cc index bc678e6..9a7365b 100644 --- a/src/linearextrude.cc +++ b/src/linearextrude.cc @@ -91,7 +91,10 @@ AbstractNode *LinearExtrudeModule::instantiate(const Context *ctx, const ModuleI node->height = height.toDouble(); node->convexity = (int)convexity.toDouble(); origin.getVec2(node->origin_x, node->origin_y); - node->scale = scale.toDouble(); + node->scale_x = node->scale_y = 1; + scale.getDouble(node->scale_x); + scale.getDouble(node->scale_y); + scale.getVec2(node->scale_x, node->scale_y); if (center.type() == Value::BOOL) node->center = center.toBool(); @@ -102,8 +105,8 @@ AbstractNode *LinearExtrudeModule::instantiate(const Context *ctx, const ModuleI if (node->convexity <= 0) node->convexity = 1; - if (node->scale <= 0) - node->scale = 1; + if (node->scale_x < 0) node->scale_x = 0; + if (node->scale_y < 0) node->scale_y = 0; if (twist.type() == Value::NUMBER) { node->twist = twist.toDouble(); @@ -151,7 +154,6 @@ std::string LinearExtrudeNode::toString() const "file = " << this->filename << ", " "layer = " << QuotedString(this->layername) << ", " "origin = [" << this->origin_x << ", " << this->origin_y << "], " - "scale = " << this->scale << ", " #ifndef OPENSCAD_TESTING // timestamp is needed for caching, but disturbs the test framework << "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) << ", " @@ -166,6 +168,7 @@ std::string LinearExtrudeNode::toString() const if (this->has_twist) { stream << ", twist = " << this->twist << ", slices = " << this->slices; } + stream << ", scale = [" << this->scale_x << ", " << this->scale_y << "]"; stream << ", $fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; return stream.str(); diff --git a/src/linearextrudenode.h b/src/linearextrudenode.h index 112eccc..6ff8c56 100644 --- a/src/linearextrudenode.h +++ b/src/linearextrudenode.h @@ -11,7 +11,8 @@ public: LinearExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { convexity = slices = 0; fn = fs = fa = height = twist = 0; - origin_x = origin_y = scale = 0; + origin_x = origin_y = 0; + scale_x = scale_y = 1; center = has_twist = false; } virtual Response accept(class State &state, Visitor &visitor) const { @@ -22,7 +23,7 @@ public: int convexity, slices; double fn, fs, fa, height, twist; - double origin_x, origin_y, scale; + double origin_x, origin_y, scale_x, scale_y; bool center, has_twist; Filename filename; std::string layername; diff --git a/src/mainwin.cc b/src/mainwin.cc index 5f9d633..da3501d 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1765,6 +1765,12 @@ void MainWindow::helpLibrary() OPENCSG_VERSION_STRING, qVersion()); +#if defined( __MINGW64__ ) + libinfo += QString("Compiled for MingW64\n\n"); +#elif defined( __MINGW32__ ) + libinfo += QString("Compiled for MingW32\n\n"); +#endif + if (!this->openglbox) { this->openglbox = new QMessageBox(QMessageBox::Information, "OpenGL Info", "OpenSCAD Detailed Library Info ", diff --git a/src/modcontext.cc b/src/modcontext.cc index 44c2002..3879811 100644 --- a/src/modcontext.cc +++ b/src/modcontext.cc @@ -27,20 +27,6 @@ void ModuleContext::initializeModule(const class Module &module) } } -class RecursionGuard -{ -public: - RecursionGuard(const ModuleContext &c, const std::string &name) : c(c), name(name) { - c.recursioncount[name]++; - } - ~RecursionGuard() { if (--c.recursioncount[name] == 0) c.recursioncount.erase(name); } - bool recursion_detected() const { return (c.recursioncount[name] > 100); } -private: - const ModuleContext &c; - const std::string &name; -}; - - /*! Only used to initialize builtins for the top-level root context */ @@ -81,12 +67,6 @@ const AbstractModule *ModuleContext::findLocalModule(const std::string &name) co Value ModuleContext::evaluate_function(const std::string &name, const EvalContext *evalctx) const { - RecursionGuard g(*this, name); - if (g.recursion_detected()) { - PRINTB("Recursion detected calling function '%s'", name); - return Value(); - } - const AbstractFunction *foundf = findLocalFunction(name); if (foundf) return foundf->evaluate(this, evalctx); @@ -141,12 +121,6 @@ FileContext::FileContext(const class FileModule &module, const Context *parent) Value FileContext::evaluate_function(const std::string &name, const EvalContext *evalctx) const { - RecursionGuard g(*this, name); - if (g.recursion_detected()) { - PRINTB("Recursion detected calling function '%s'", name); - return Value(); - } - const AbstractFunction *foundf = findLocalFunction(name); if (foundf) return foundf->evaluate(this, evalctx); diff --git a/src/modcontext.h b/src/modcontext.h index 4479051..0b3e48c 100644 --- a/src/modcontext.h +++ b/src/modcontext.h @@ -36,8 +36,6 @@ public: #ifdef DEBUG virtual void dump(const class AbstractModule *mod, const ModuleInstantiation *inst); #endif - - mutable boost::unordered_map<std::string, int> recursioncount; }; class FileContext : public ModuleContext diff --git a/src/module.cc b/src/module.cc index 8b84c07..e853457 100644 --- a/src/module.cc +++ b/src/module.cc @@ -135,8 +135,28 @@ Module::~Module() { } +class ModRecursionGuard +{ +public: + ModRecursionGuard(const ModuleInstantiation &inst) : inst(inst) { + inst.recursioncount++; + } + ~ModRecursionGuard() { + inst.recursioncount--; + } + bool recursion_detected() const { return (inst.recursioncount > 100); } +private: + const ModuleInstantiation &inst; +}; + AbstractNode *Module::instantiate(const Context *ctx, const ModuleInstantiation *inst, const EvalContext *evalctx) const { + ModRecursionGuard g(*inst); + if (g.recursion_detected()) { + PRINTB("ERROR: Recursion detected calling module '%s'", inst->name()); + return NULL; + } + ModuleContext c(ctx, evalctx); c.initializeModule(*this); c.set_variable("$children", Value(double(inst->scope.children.size()))); diff --git a/src/module.h b/src/module.h index 8f1ccb7..9f46d37 100644 --- a/src/module.h +++ b/src/module.h @@ -13,7 +13,7 @@ class ModuleInstantiation { public: ModuleInstantiation(const std::string &name = "") - : tag_root(false), tag_highlight(false), tag_background(false), modname(name) { } + : tag_root(false), tag_highlight(false), tag_background(false), recursioncount(0), modname(name) { } virtual ~ModuleInstantiation(); std::string dump(const std::string &indent) const; @@ -35,6 +35,7 @@ public: bool tag_root; bool tag_highlight; bool tag_background; + mutable int recursioncount; protected: std::string modname; std::string modpath; diff --git a/src/primitives.cc b/src/primitives.cc index be1ec6f..9b755ef 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -546,7 +546,7 @@ sphere_next_r2: p->is2d = true; p->convexity = convexity; - dxf_tesselate(p, dd, 0, true, false, 0); + dxf_tesselate(p, dd, 0, Vector2d(1,1), true, false, 0); dxf_border_to_ps(p, dd); } |