From ad54d5ca245f0a2a1dc90c9894c2e8573dd1e19f Mon Sep 17 00:00:00 2001 From: don bright Date: Thu, 16 Aug 2012 04:31:19 +0200 Subject: fix issue 174 by maintaining order of pointdata during dxf import diff --git a/src/dxfdata.cc b/src/dxfdata.cc index 4b542d1..4258a4c 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "value.h" @@ -397,7 +398,7 @@ DxfData::DxfData(double fn, double fs, double fa, // Extract paths from parsed data - typedef boost::unordered_map LineMap; + typedef std::map LineMap; LineMap enabled_lines; for (size_t i = 0; i < lines.size(); i++) { enabled_lines[i] = i; -- cgit v0.10.1 From 42043dd97d8902c50dbd0b4ed4bde22b0104c88c Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 15:40:15 +0200 Subject: maintain order of polygons in evaluateCGALMesh to fix issue 177. add option to dump more info to csgchain diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 1b307be..ee04e05 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -34,8 +34,8 @@ #include #include -#include #include +#include CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const AbstractNode &node) { @@ -445,9 +445,9 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const PolySet &ps) struct PolyReducer { Grid2d grid; - boost::unordered_map, std::pair > edge_to_poly; - boost::unordered_map points; - typedef boost::unordered_map > PolygonMap; + std::map, std::pair > edge_to_poly; + std::map points; + typedef std::map > PolygonMap; PolygonMap polygons; int poly_n; diff --git a/src/csgterm.cc b/src/csgterm.cc index 4e6912b..8b0c8a4 100644 --- a/src/csgterm.cc +++ b/src/csgterm.cc @@ -178,7 +178,7 @@ void CSGChain::import(shared_ptr term, CSGTerm::type_e type) } } -std::string CSGChain::dump() +std::string CSGChain::dump(bool full=false) { std::stringstream dump; @@ -193,6 +193,11 @@ std::string CSGChain::dump() else if (types[i] == CSGTerm::TYPE_INTERSECTION) dump << " *"; dump << labels[i]; + if (full) { + dump << " polyset: \n" << polysets[i]->dump() << "\n"; + dump << " matrix: \n" << matrices[i].matrix() << "\n"; + dump << " color: \n" << colors[i] << "\n"; + } } dump << "\n"; return dump.str(); diff --git a/src/csgterm.h b/src/csgterm.h index 4278d85..95cfafd 100644 --- a/src/csgterm.h +++ b/src/csgterm.h @@ -59,7 +59,7 @@ public: void add(const shared_ptr &polyset, const Transform3d &m, const Color4f &color, CSGTerm::type_e type, std::string label); void import(shared_ptr term, CSGTerm::type_e type = CSGTerm::TYPE_UNION); - std::string dump(); + std::string dump(bool full); BoundingBox getBoundingBox() const; }; -- cgit v0.10.1 From 47a06c074fa6321224d5c6d6cc85bf9336fb8765 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 18:38:24 +0200 Subject: detect flaws in 'use' and 'include' statements. make locate_file consider directories as 'non files'. diff --git a/src/lexer.l b/src/lexer.l index f939330..1e3bd5b 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -122,10 +122,16 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); } } } /* Only accept regular files which exists */ - if (usepath.has_parent_path() && fs::exists(usepath)) { + if (usepath.has_parent_path() && fs::exists(usepath) && !fs::is_directory(usepath)) { handle_dep(usepath.string()); parserlval.text = strdup(usepath.string().c_str()); return TOK_USE; + } else { + PRINTB("WARNING: Can't open 'use' file '%s'.", filename); + if ( filename.size() == 0 ) + PRINT("WARNING: 'use' filename is blank"); + else if ( fs::is_directory( usepath ) ) + PRINTB("WARNING: 'use' file points to a directory: %s",filename); } } } @@ -217,6 +223,10 @@ void includefile() finfo = locate_file((fs::path(filepath) / filename).string()); } + if (finfo.empty()) { + PRINTB("WARNING: Can't find 'include' file '%s'.", filename); + } + filepath.clear(); path_stack.push_back(finfo.parent_path()); @@ -225,7 +235,7 @@ void includefile() currmodule->registerInclude(fullname); yyin = fopen(fullname.c_str(), "r"); if (!yyin) { - PRINTB("WARNING: Can't open input file '%s'.", filename); + PRINTB("WARNING: Can't open 'include' file '%s'.", filename); path_stack.pop_back(); return; } diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 53b34f4..9409add 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -15,13 +15,13 @@ void add_librarydir(const std::string &libdir) /*! Searces for the given file in library paths and returns the full path if found. - Returns an empty path if file cannot be found. + Returns an empty path if file cannot be found or filename is a directory. */ std::string locate_file(const std::string &filename) { BOOST_FOREACH(const std::string &dir, librarypath) { fs::path usepath = fs::path(dir) / filename; - if (fs::exists(usepath)) return usepath.string(); + if (fs::exists(usepath) && !fs::is_directory(usepath)) return usepath.string(); } return std::string(); } diff --git a/testdata/scad/templates/use-tests-template.scad b/testdata/scad/templates/use-tests-template.scad index 24591f8..f92e550 100644 --- a/testdata/scad/templates/use-tests-template.scad +++ b/testdata/scad/templates/use-tests-template.scad @@ -1,3 +1,6 @@ +//Test blank +use <> + //Test that the entire path is pushed onto the stack upto the last '/' use -- cgit v0.10.1 From f53375733413b840d10f8a02ab51eee033529baa Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 18 Aug 2012 13:00:00 -0400 Subject: bugfix: default parameters should be in class declaration only diff --git a/src/csgterm.cc b/src/csgterm.cc index 8b0c8a4..0e68320 100644 --- a/src/csgterm.cc +++ b/src/csgterm.cc @@ -178,7 +178,7 @@ void CSGChain::import(shared_ptr term, CSGTerm::type_e type) } } -std::string CSGChain::dump(bool full=false) +std::string CSGChain::dump(bool full) { std::stringstream dump; diff --git a/src/csgterm.h b/src/csgterm.h index 95cfafd..566ebc3 100644 --- a/src/csgterm.h +++ b/src/csgterm.h @@ -59,7 +59,7 @@ public: void add(const shared_ptr &polyset, const Transform3d &m, const Color4f &color, CSGTerm::type_e type, std::string label); void import(shared_ptr term, CSGTerm::type_e type = CSGTerm::TYPE_UNION); - std::string dump(bool full); + std::string dump(bool full = false); BoundingBox getBoundingBox() const; }; -- cgit v0.10.1 From 8740ac3574c5249c9c22f5436d3b14f4f0563a66 Mon Sep 17 00:00:00 2001 From: don bright Date: Sat, 18 Aug 2012 19:40:21 +0200 Subject: avoid compiler warning about unusued parameter diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 529d8b4..34122a0 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -7,7 +7,7 @@ class AboutDialog : public QDialog, public Ui::AboutDialog { Q_OBJECT; public: - AboutDialog(QWidget *parent) { + AboutDialog(QWidget *) { setupUi(this); this->aboutText->setOpenExternalLinks(true); QUrl flattr_qurl(":icons/flattr.png" ); -- cgit v0.10.1 From 3ee8c09db244a4131db188d590e70329ae1fb854 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 18 Aug 2012 19:08:07 -0400 Subject: Make OS checks independent of Qt diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 9409add..47859c7 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -33,10 +33,10 @@ void parser_init(const std::string &applicationpath) std::string librarydir; fs::path libdir(applicationpath); fs::path tmpdir; -#ifdef Q_WS_MAC +#ifdef __APPLE__ libdir /= "../Resources"; // Libraries can be bundled if (!is_directory(libdir / "libraries")) libdir /= "../../.."; -#elif defined(Q_OS_UNIX) +#elif !defined(WIN32) if (is_directory(tmpdir = libdir / "../share/openscad/libraries")) { librarydir = boosty::stringy( tmpdir ); } else if (is_directory(tmpdir = libdir / "../../share/openscad/libraries")) { -- cgit v0.10.1 From 3ac6b033b786347e1fb183a18fe80fd306f99f76 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 18 Aug 2012 19:08:50 -0400 Subject: Lion compile fix diff --git a/src/value.cc b/src/value.cc index 3b7f357..7744a18 100644 --- a/src/value.cc +++ b/src/value.cc @@ -25,8 +25,9 @@ */ #include "value.h" +#include #include -#include // fmod +#include #include #include #include -- cgit v0.10.1