diff options
-rw-r--r-- | RELEASE_NOTES | 8 | ||||
-rw-r--r-- | bison.pri | 10 | ||||
-rw-r--r-- | boost.pri | 7 | ||||
-rw-r--r-- | cgal.pri | 6 | ||||
-rw-r--r-- | doc/TODO.txt | 9 | ||||
-rw-r--r-- | flex.pri | 2 | ||||
-rw-r--r-- | glew.pri | 2 | ||||
-rw-r--r-- | mjau.gdb | 2 | ||||
-rw-r--r-- | openscad.pro | 2 | ||||
-rwxr-xr-x | scripts/macosx-build-dependencies.sh | 11 | ||||
-rwxr-xr-x | scripts/macosx-sanity-check.py | 14 | ||||
-rw-r--r-- | src/dxfrotextrude.cc | 15 | ||||
-rw-r--r-- | src/grid.h | 14 | ||||
-rw-r--r-- | src/lexer.l | 7 | ||||
-rw-r--r-- | src/openscad.cc | 181 | ||||
-rw-r--r-- | src/parser.y | 2 | ||||
-rw-r--r-- | src/primitives.cc | 11 |
17 files changed, 186 insertions, 117 deletions
diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 972da0a..3cfb955 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,8 +1,4 @@ -OpenSCAD 20XX.YY -================ - - -OpenSCAD 2011.01 +OpenSCAD 2011.XX ================ o Added rands() function @@ -11,7 +7,7 @@ o Now supports escaping of the following characters in strings: \n, \t, \r, \\, o Support nested includes o Improved parsing of numbers o DXF: output LWPOLYLINE instead of just LINE entities -o Bugfixes: More robust DXF export +o Bugfixes: More robust DXF export, setting $fs/$fa to 0 caused a crash o Some bugs fixed, maybe some new bugs added OpenSCAD 2010.05 @@ -1,15 +1,17 @@ #setup bison for qmake
bison.name = Bison ${QMAKE_FILE_IN}
bison.input = BISONSOURCES
-bison.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.parser.cpp
-bison.commands = bison -d -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.parser.cpp ${QMAKE_FILE_IN}
+bison.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp
+bison.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN}
+bison.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h
bison.CONFIG += target_predeps
bison.variable_out = GENERATED_SOURCES
silent:bison.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands
QMAKE_EXTRA_COMPILERS += bison
bison_header.input = BISONSOURCES
-bison_header.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.parser.hpp
-bison_header.commands = bison -d -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.parser.cpp ${QMAKE_FILE_IN}
+bison_header.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h
+bison_header.commands = bison -d -p ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.cpp ${QMAKE_FILE_IN}
+bison_header.commands += && mv ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.hpp ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}_yacc.h
bison_header.CONFIG += target_predeps no_link
silent:bison_header.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands
QMAKE_EXTRA_COMPILERS += bison_header
@@ -6,6 +6,13 @@ boost { !isEmpty(BOOST_DIR) {
INCLUDEPATH += $$BOOST_DIR
message("boost location: $$BOOST_DIR")
+ win32:LIBS += -L$$BOOST_DIR/lib
}
}
+
+ win32 {
+ LIBS += -llibboost_thread-vc90-mt-s-1_46_1 -llibboost_program_options-vc90-mt-s-1_46_1
+ } else {
+ LIBS += -lboost_thread -lboost_program_options
+ }
}
@@ -7,16 +7,16 @@ cgal { CGAL_DIR = $$(CGALDIR) !isEmpty(CGAL_DIR) { INCLUDEPATH += $$CGAL_DIR/include + win32: INCLUDEPATH += $$CGAL_DIR/auxiliary/gmp/include LIBS += -L$$CGAL_DIR/lib message("CGAL location: $$CGAL_DIR") } } - LIBS += -lCGAL -lmpfr -lboost_thread win32 { - LIBS += -lmpir + LIBS += $$CGAL_DIR/auxiliary/gmp/lib/libmpfr-4.lib -lCGAL-vc90-mt-gd } else { - LIBS += -lgmp + LIBS += -lgmp -lmpfr -lCGAL } QMAKE_CXXFLAGS += -frounding-math } diff --git a/doc/TODO.txt b/doc/TODO.txt index 29c4d87..cca4a2a 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -75,12 +75,16 @@ o 3D View - Improve mouse rotation - Add modifier key combos to handle pan and zoom on 1 mouse button systems - Show grid + - Measurement ticks on the axes that look like rulers that one can turn off and on. - 4 x split view w/orthogonal cameras? - Quick highlighting of object under the cursor in the editor - View All + - Allow specifying viewpoint in the scad file - overlay indicator displaying current view mode - OpenCSG rendering: Coincident surfaces causes z-buffer fighting. Is this somehow avoidable tuning the depth tests in OpenCSG? + - Use OpenGL picking to facilitate ray-tracing like features like measuring + thicknesses, distances, slot thicknesses etc. o Editor wishlist - More infrastructure for external editor (allow communication from the outside) - Preferences GUI for the features below @@ -138,12 +142,11 @@ o Language Frontend the "Flex & Bison" O'Reilly book, "Start States and Nested Input Files", page 28, for an example. - Allow local variables and functions everywhere (not only on module level) - - allow 0/1 f/t FALSE/TRUE as boolean values - - allow any expression to be evaluated as boolean (e.g. 1 = true, 0 = false) + - allow any expression to be evaluated as boolean (!0 = true, 0 = false) - Rethink for vs. intersection_for vs. group. Should for loops generate child lists instead, and make these passable to other modules or accessible by child()? - - constants: PI, TRUE, FALSE + - constants: PI o DXF Import/Export - Use dxflib from RibbonSoft for import/export? -> investigate - Import @@ -3,7 +3,7 @@ flex.name = Flex ${QMAKE_FILE_IN}
flex.input = FLEXSOURCES
flex.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp
-flex.commands = flex -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp ${QMAKE_FILE_IN}
+flex.commands = flex -P ${QMAKE_FILE_BASE} -o ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.lexer.cpp ${QMAKE_FILE_IN}
flex.CONFIG += target_predeps
flex.variable_out = GENERATED_SOURCES
silent:flex.commands = @echo Lex ${QMAKE_FILE_IN} && $$flex.commands
@@ -15,5 +15,5 @@ glew { } unix:LIBS += -lGLEW - win32:LIBS += -lglew32 + win32:LIBS += -lglew32s } @@ -1 +1 @@ -set environment DYLD_LIBRARY_PATH=/Users/kintel/code/metalab/checkout/OpenSCAD/OpenCSG-1.3.0/lib:/Users/kintel/code/metalab/checkout/OpenSCAD/qcodeedit-2.2.3/install/lib
\ No newline at end of file +set environment DYLD_LIBRARY_PATH=/Users/kintel/code/metalab/checkout/OpenSCAD/libraries/install/lib diff --git a/openscad.pro b/openscad.pro index d83606f..5b3a398 100644 --- a/openscad.pro +++ b/openscad.pro @@ -32,7 +32,7 @@ win32 { } DEFINES += OPENSCAD_VERSION=$$VERSION -win32:DEFINES += _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS +win32:DEFINES += _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS YY_NO_UNISTD_H #disable warning about too long decorated names win32:QMAKE_CXXFLAGS += -wd4503 diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index ef4653c..f5a44d0 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -100,17 +100,18 @@ build_boost() { version=$1 bversion=`echo $version | tr "." "_"` - echo "Building boost::thread" $version "..." + echo "Building boost" $version "..." cd $BASEDIR/src rm -rf boost* curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2 tar xjf boost_$bversion.tar.bz2 cd boost_$bversion - # We only need the thread library for now - ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread + # We only need the thread and program_options libraries + ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options ./bjam cflags="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" linkflags="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" ./bjam install install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib + install_name_tool -id $DEPLOYDIR/lib/libboost_program_options.dylib $DEPLOYDIR/lib/libboost_program_options.dylib } build_cgal() @@ -158,7 +159,7 @@ echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR build_gmp 5.0.1 build_mpfr 3.0.0 -build_boost 1.44.0 +build_boost 1.46.1 build_cgal 3.7 -build_glew 1.5.6 +build_glew 1.5.8 build_opencsg 1.3.0 diff --git a/scripts/macosx-sanity-check.py b/scripts/macosx-sanity-check.py index 243020f..3938d74 100755 --- a/scripts/macosx-sanity-check.py +++ b/scripts/macosx-sanity-check.py @@ -9,6 +9,9 @@ # # Author: Marius Kintel <marius@kintel.net> # +# This script lives here: +# https://github.com/kintel/MacOSX-tools +# import sys import os @@ -49,9 +52,14 @@ def lookup_library(file): def find_dependencies(file): libs = [] - p = subprocess.Popen(["otool", "-L", file], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output = p.communicate()[0] - if p.returncode != 0: return None + args = ["otool", "-L", file] + if DEBUG: print "Executing " + " ".join(args) + p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output,err = p.communicate() + if p.returncode != 0: + print "Failed with return code " + str(p.returncode) + ":" + print err + return None deps = output.split('\n') for dep in deps: # print dep diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc index a7a6cf1..1be2265 100644 --- a/src/dxfrotextrude.cc +++ b/src/dxfrotextrude.cc @@ -159,7 +159,13 @@ PolySet *DxfRotateExtrudeNode::render_polyset(render_mode_e) const int fragments = get_fragments_from_r(max_x, fn, fs, fa); - double points[fragments][dxf->paths[i].points.count()][3]; + double ***points; + points = new double**[fragments]; + for (int j=0; j < fragments; j++) { + points[j] = new double*[dxf->paths[i].points.count()]; + for (int k=0; k < dxf->paths[i].points.count(); k++) + points[j][k] = new double[3]; + } for (int j = 0; j < fragments; j++) { double a = (j*2*M_PI) / fragments; @@ -203,6 +209,13 @@ PolySet *DxfRotateExtrudeNode::render_polyset(render_mode_e) const } } } + + for (int j=0; j < fragments; j++) { + for (int k=0; k < dxf->paths[i].points.count(); k++) + delete[] points[j][k]; + delete[] points[j]; + } + delete[] points; } PolySet::ps_cache.insert(key, new PolySet::ps_cache_entry(ps->link())); @@ -2,7 +2,11 @@ #define GRID_H_ #include "mathc99.h" +#ifdef WIN32 +typedef __int64 int64_t; +#else #include <stdint.h> +#endif #include <stdlib.h> #include <QHash> @@ -33,8 +37,9 @@ public: for (int64_t jy = iy - 1; jy <= iy + 1; jy++) { if (!db.contains(QPair<int64_t,int64_t>(jx, jy))) continue; - if (abs(ix-jx) + abs(iy-jy) < dist) { - dist = abs(ix-jx) + abs(iy-jy); + int d = abs(int(ix-jx)) + abs(int(iy-jy)); + if (d < dist) { + dist = d; ix = jx; iy = jy; } @@ -92,8 +97,9 @@ public: for (int64_t jz = iz - 1; jz <= iz + 1; jz++) { if (!db.contains(QPair<QPair<int64_t,int64_t>,int64_t>(QPair<int64_t,int64_t>(jx, jy), jz))) continue; - if (abs(ix-jx) + abs(iy-jy) + abs(iz-jz) < dist) { - dist = abs(ix-jx) + abs(iy-jy) + abs(iz-jz); + int d = abs(int(ix-jx)) + abs(int(iy-jy)) + abs(int(iz-jz)); + if (d < dist) { + dist = d; ix = jx; iy = jy; iz = jz; diff --git a/src/lexer.l b/src/lexer.l index 985dbbe..0da3f5d 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -32,6 +32,13 @@ #include <QStack> #include <QFileInfo> #include <QDir> + +//isatty for visual c++ +#ifdef _MSC_VER +int __cdecl _isatty(int _FileHandle); +#define isatty _isatty +#endif + QString* stringcontents; int lexerget_lineno(void); #ifdef __GNUC__ diff --git a/src/openscad.cc b/src/openscad.cc index 7bae683..bc1d845 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -33,6 +33,9 @@ #include "export.h" #include "builtin.h" +#include <string> +#include <vector> + #ifdef ENABLE_CGAL #include "cgal.h" #include <CGAL/assertions_behaviour.h> @@ -43,17 +46,23 @@ #include <QDir> #include <QSet> #include <QSettings> -#include <getopt.h> +#include <boost/program_options.hpp> #ifdef Q_WS_MAC #include "EventFilter.h" #include "AppleEvents.h" #endif +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + +namespace po = boost::program_options; + static void help(const char *progname) { fprintf(stderr, "Usage: %s [ { -s stl_file | -o off_file | -x dxf_file } [ -d deps_file ] ]\\\n" - "%*s[ -m make_command ] [ -D var=val [..] ] filename\n", - progname, int(strlen(progname))+8, ""); + "%*s[ -m make_command ] [ -D var=val [..] ] filename\n", + progname, int(strlen(progname))+8, ""); exit(1); } @@ -72,6 +81,9 @@ QString currentdir; QString examplesdir; QString librarydir; +using std::string; +using std::vector; + void handle_dep(QString filename) { if (filename.startsWith("/")) @@ -123,76 +135,72 @@ int main(int argc, char **argv) const char *off_output_file = NULL; const char *dxf_output_file = NULL; const char *deps_output_file = NULL; + + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "help message") + ("version,v", "print the version") + ("s", po::value<string>(), "stl-file") + ("o", po::value<string>(), "off-file") + ("x", po::value<string>(), "dxf-file") + ("d", po::value<string>(), "deps-file") + ("m", po::value<string>(), "make file") + ("D", po::value<vector<string> >(), "var=val") + ; + + po::positional_options_description p; + p.add("input-file", -1); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm); +// po::notify(vm); - static struct option long_options[] = - { - {"version", no_argument, 0, 'v'}, - {"help", no_argument, 0, 'h'}, - {0, 0, 0, 0} - }; - int option_index = 0; - - int opt; - while ((opt = getopt_long(argc, argv, "s:o:x:d:m:D:vh", long_options, &option_index)) != -1) - { - switch (opt) - { - case 0: - switch (option_index) - { - case 'v': - version(); - break; - case 'h': - help(argv[0]); - break; - } - break; - case 'v': - version(); - break; - case 'h': + if (vm.count("help")) help(argv[0]); + if (vm.count("version")) version(); + + if (vm.count("s")) { + if (stl_output_file || off_output_file || dxf_output_file) help(argv[0]); - break; - case 's': - if (stl_output_file || off_output_file || dxf_output_file) - help(argv[0]); - stl_output_file = optarg; - break; - case 'o': - if (stl_output_file || off_output_file || dxf_output_file) - help(argv[0]); - off_output_file = optarg; - break; - case 'x': - if (stl_output_file || off_output_file || dxf_output_file) - help(argv[0]); - dxf_output_file = optarg; - break; - case 'd': - if (deps_output_file) - help(argv[0]); - deps_output_file = optarg; - break; - case 'm': - if (make_command) - help(argv[0]); - make_command = optarg; - break; - case 'D': - commandline_commands += QString(optarg) + QString(";\n"); - break; - default: + stl_output_file = vm["s"].as<string>().c_str(); + } + if (vm.count("o")) { + if (stl_output_file || off_output_file || dxf_output_file) help(argv[0]); + off_output_file = vm["o"].as<string>().c_str(); + } + if (vm.count("x")) { + if (stl_output_file || off_output_file || dxf_output_file) + help(argv[0]); + dxf_output_file = vm["x"].as<string>().c_str(); + } + if (vm.count("d")) { + if (deps_output_file) + help(argv[0]); + deps_output_file = vm["d"].as<string>().c_str(); + } + if (vm.count("m")) { + if (make_command) + help(argv[0]); + make_command = vm["m"].as<string>().c_str(); + } + + if (vm.count("D")) { + const vector<string> &commands = vm["D"].as<vector<string> >(); + + for (vector<string>::const_iterator i = commands.begin(); i != commands.end(); i++) { + commandline_commands.append(i->c_str()); + commandline_commands.append(";\n"); } } - if (optind < argc) - filename = argv[optind++]; + if (vm.count("input-file")) { + filename = vm["input-file"].as< vector<string> >().begin()->c_str(); + } #ifndef ENABLE_MDI - if (optind != argc) + if (vm.count("input-file") > 1) { help(argv[0]); + } #endif currentdir = QDir::currentPath(); @@ -205,16 +213,16 @@ int main(int argc, char **argv) if (exdir.cd("../share/openscad/examples")) { examplesdir = exdir.path(); } else - if (exdir.cd("../../share/openscad/examples")) { - examplesdir = exdir.path(); - } else - if (exdir.cd("../../examples")) { - examplesdir = exdir.path(); - } else + if (exdir.cd("../../share/openscad/examples")) { + examplesdir = exdir.path(); + } else + if (exdir.cd("../../examples")) { + examplesdir = exdir.path(); + } else #endif - if (exdir.cd("examples")) { - examplesdir = exdir.path(); - } + if (exdir.cd("examples")) { + examplesdir = exdir.path(); + } QDir libdir(QApplication::instance()->applicationDirPath()); #ifdef Q_WS_MAC @@ -224,16 +232,16 @@ int main(int argc, char **argv) if (libdir.cd("../share/openscad/libraries")) { librarydir = libdir.path(); } else - if (libdir.cd("../../share/openscad/libraries")) { - librarydir = libdir.path(); - } else - if (libdir.cd("../../libraries")) { - librarydir = libdir.path(); - } else + if (libdir.cd("../../share/openscad/libraries")) { + librarydir = libdir.path(); + } else + if (libdir.cd("../../libraries")) { + librarydir = libdir.path(); + } else #endif - if (libdir.cd("libraries")) { - librarydir = libdir.path(); - } + if (libdir.cd("libraries")) { + librarydir = libdir.path(); + } if (stl_output_file || off_output_file || dxf_output_file) { @@ -338,8 +346,13 @@ int main(int argc, char **argv) #endif #ifdef ENABLE_MDI new MainWindow(qfilename); - while (optind < argc) - new MainWindow(QFileInfo(original_path, argv[optind++]).absoluteFilePath()); + vector<string> inputFiles; + if (vm.count("input-file")) { + inputFiles = vm["input-files"].as<vector<string> >(); + for (vector<string>::const_iterator i = inputFiles.begin()+1; i != inputFiles.end(); i++) { + new MainWindow(QFileInfo(original_path, i->c_str()).absoluteFilePath()); + } + } app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); #else MainWindow *m = new MainWindow(qfilename); diff --git a/src/parser.y b/src/parser.y index 26cd118..aad5ba0 100644 --- a/src/parser.y +++ b/src/parser.y @@ -35,7 +35,9 @@ #include <sys/types.h> #include <sys/stat.h> +#ifndef _MSC_VER #include <unistd.h> +#endif #include "module.h" #include "expression.h" diff --git a/src/primitives.cc b/src/primitives.cc index cdbb18e..1e411e0 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -57,6 +57,7 @@ class PrimitiveNode : public AbstractPolyNode public: bool center; double x, y, z, h, r1, r2; + static const double F_MINIMUM = 0.01; double fn, fs, fa; primitive_type_e type; int convexity; @@ -105,6 +106,16 @@ AbstractNode *PrimitiveModule::evaluate(const Context *ctx, const ModuleInstanti node->fs = c.lookup_variable("$fs").num; node->fa = c.lookup_variable("$fa").num; + if (node->fs < PrimitiveNode::F_MINIMUM) { + PRINTF("WARNING: $fs too small - clamping to %f", PrimitiveNode::F_MINIMUM); + node->fs = PrimitiveNode::F_MINIMUM; + } + if (node->fa < PrimitiveNode::F_MINIMUM) { + PRINTF("WARNING: $fa too small - clamping to %f", PrimitiveNode::F_MINIMUM); + node->fa = PrimitiveNode::F_MINIMUM; + } + + if (type == CUBE) { Value size = c.lookup_variable("size"); Value center = c.lookup_variable("center"); |