From 48735d958351445aba2be42f9b0b484d9c305443 Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 12 Apr 2010 13:38:32 +0000 Subject: Merge branch 'qcodeedit' of http://www.gilesbathgate.com/openscad into tmp git-svn-id: http://svn.clifford.at/openscad/trunk@521 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/qxs/openscad.qnfa b/qxs/openscad.qnfa index fc13975..bdd64f2 100644 --- a/qxs/openscad.qnfa +++ b/qxs/openscad.qnfa @@ -23,7 +23,25 @@ \n \\[nrtvf\\"'\n] - + + + use + \n + + < + > + + + + + include + \n + + < + > + + + ( ) { @@ -31,15 +49,9 @@ \[ \] - - public - protected - private - - module - func + function @@ -48,39 +60,12 @@ else - - using - - - asm false true - template - typename - return - sizeof - typeid - typedef - - - - \?\? - \( - \) - < - > - = - / - ' - ! - - + undef - q$w+_cast - -?[0-9]*.[0-9]+f? - 0[xX][0-9a-fA-F]+[ulUL]* - 0[0-7]+ -?[0-9]+[ulUL]* -- cgit v0.10.1 From b3ddb169d58d6219098ce3073d7507d1831f30dc Mon Sep 17 00:00:00 2001 From: clifford Date: Thu, 15 Apr 2010 15:40:42 +0000 Subject: Clifford Wolf: Indent fixes git-svn-id: http://svn.clifford.at/openscad/trunk@522 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/openscad.cc b/src/openscad.cc index a8017e6..bf24c9f 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -112,11 +112,10 @@ int main(int argc, char **argv) #endif QDir original_path = QDir::current(); - // set up groups for QSettings - QCoreApplication::setOrganizationName("OpenSCAD"); - QCoreApplication::setOrganizationDomain("openscad.org"); - QCoreApplication::setApplicationName("OpenSCAD"); - + // set up groups for QSettings + QCoreApplication::setOrganizationName("OpenSCAD"); + QCoreApplication::setOrganizationDomain("openscad.org"); + QCoreApplication::setApplicationName("OpenSCAD"); const char *filename = NULL; const char *stl_output_file = NULL; -- cgit v0.10.1 From 3237b64b7f2e8f212a8d1916bf9d35c589de9eff Mon Sep 17 00:00:00 2001 From: clifford Date: Sun, 18 Apr 2010 11:47:19 +0000 Subject: Clifford Wolf: Fixed TabStopWidth (at least for QTextEdit) git-svn-id: http://svn.clifford.at/openscad/trunk@523 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/mainwin.cc b/src/mainwin.cc index b9ce5c7..4d7ed00 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -166,6 +166,8 @@ MainWindow::MainWindow(const QString &filename) QLanguageFactory *languages = new QLanguageFactory(formats,this); languages->addDefinitionPath("qxs"); languages->setLanguage(editor, "openscad"); +#else + editor->setTabStopWidth(30); #endif editor->setLineWrapping(true); // Not designable setFont("", 0); // Init default font -- cgit v0.10.1 From 7134322673785b5ba3963f166de8a6543d4f1420 Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 22 Apr 2010 23:24:07 +0000 Subject: sync git-svn-id: http://svn.clifford.at/openscad/trunk@524 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index ef3a0e4..e6b4ac5 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -39,6 +39,7 @@ o MDI - currentPath is global but is used by each document, e.g. parser and handle_dep. o 3D View + - OpenGL 2.0 test: What, exactly, is needed from OpenGL 2.0? Can we use 1.x with extensions? - Improve mouse rotation - Add modifier key combos to handle pan on 1 mouse button systems - Show grid -- cgit v0.10.1 From 6cfef9af8a821e610275cc67a44c9f442a86561e Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 24 Apr 2010 19:48:18 +0000 Subject: Output renderer info when OpenGL 2.0 is not found git-svn-id: http://svn.clifford.at/openscad/trunk@525 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/glview.cc b/src/glview.cc index 29046e0..270aed6 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -187,11 +187,19 @@ void GLView::initializeGL() #ifdef ENABLE_OPENCSG void GLView::display_opengl20_warning() { + QString rendererinfo; + rendererinfo.sprintf("GLEW version %s\n" + "%s (%s)\n" + "OpenGL version %s\n", + glewGetString(GLEW_VERSION), + glGetString(GL_RENDERER), glGetString(GL_VENDOR), + glGetString(GL_VERSION)); + QMessageBox::warning(NULL, "GLEW: GL_VERSION_2_0 is not supported!", - "Warning: No support for OpenGL 2.0 found! OpenCSG View has been disabled.\n\n" + QString("Warning: No support for OpenGL 2.0 found! OpenCSG View has been disabled.\n\n" "It is highly recommended to use OpenSCAD on a system with OpenGL 2.0 " - "support. Please check if OpenGL 2.0 drivers are available for your " - "graphics hardware."); + "support. Please check if OpenGL 2.0 drivers are available for your " + "graphics hardware.\n\n%1").arg(rendererinfo)); } #endif -- cgit v0.10.1 From 098f96fee29bc4bfe1670b89328849e6266af0cf Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 7 May 2010 16:02:51 +0000 Subject: How to build a development version of OpenSCAD, checklist-macosx.txt is meant for deployment builds git-svn-id: http://svn.clifford.at/openscad/trunk@526 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/build-macosx.txt b/doc/build-macosx.txt new file mode 100644 index 0000000..ad050ad --- /dev/null +++ b/doc/build-macosx.txt @@ -0,0 +1,40 @@ +o Prerequisites (MacPorts): + - NB! CGAL requires gcc >= 4.2 (This is default in 10.6 Snow Leopard) + - eigen + - boost + - gmp + - mpfr + - cmake + - qt4-mac-devel + - glew + +o An important note about paths: + You can choose where to put the libs you build yourself as long as + this is reflected in the environment variables as specified under + 'Build OpenSCAD'. + +o Build CGAL >= 3.5 + + tar xzf CGAL-3.6.tar.gz + cd CGAL-3.6 + cmake -DCMAKE_INSTALL_PREFIX=$PWD/../install/CGAL-3.6 -DBUILD_SHARED_LIBS=FALSE + make -j4 + make install + +o Patch OpenCSG >= 1.3.0 + + tar xzf OpenCSG-1.3.0.tar.gz + cd OpenCSG-1.3.0 + patch -p1 < ../openscad/patches/OpenCSG-1.3.0-MacOSX-port.patch + +o Build OpenCSG + + qmake -recursive + make + +o Build OpenSCAD + + cd openscad + export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 + export CGALDIR=$PWD/../install/CGAL-3.6 + ./scripts/release-common.sh -- cgit v0.10.1 From ceee08d7243cc90001059473cc3989e3e2820d15 Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 7 May 2010 16:16:47 +0000 Subject: Don't use the release script for development builds git-svn-id: http://svn.clifford.at/openscad/trunk@527 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/build-macosx.txt b/doc/build-macosx.txt index ad050ad..71750b8 100644 --- a/doc/build-macosx.txt +++ b/doc/build-macosx.txt @@ -37,4 +37,5 @@ o Build OpenSCAD cd openscad export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 export CGALDIR=$PWD/../install/CGAL-3.6 - ./scripts/release-common.sh + qmake + make -- cgit v0.10.1 From a35283f294ad4c8f2ef536d38fa69c19513f3566 Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 7 May 2010 16:24:22 +0000 Subject: Added sanity check script git-svn-id: http://svn.clifford.at/openscad/trunk@528 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-sanity-check.py b/scripts/macosx-sanity-check.py new file mode 100755 index 0000000..2438906 --- /dev/null +++ b/scripts/macosx-sanity-check.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python + +# +# This is be used to verify that all the dependant libraries of a Mac OS X executable +# are present and that they are backwards compatible with at least 10.5. +# Run with an executable as parameter +# + +import sys +import os +import subprocess +import re + +DEBUG = False + +def usage(): + print >> sys.stderr, "Usage: " + sys.argv[0] + " " + sys.exit(1) + +# Try to find the given library by searching in the typical locations +# Returns the full path to the library or None if the library is not found. +def lookup_library(file): + found = None + if not re.match("/", file): + if re.search("@executable_path", file): + abs = re.sub("^@executable_path", executable_path, file) + if os.path.exists(abs): found = abs + if DEBUG: print "Lib in @executable_path found: " + found + elif re.search("\.app/", file): + found = file + if DEBUG: print "App found: " + found + elif re.search("\.framework/", file): + found = os.path.join("/Library/Frameworks", file) + if DEBUG: print "Framework found: " + found + else: + for path in os.getenv("DYLD_LIBRARY_PATH").split(':'): + abs = os.path.join(path, file) + if os.path.exists(abs): found = abs + if DEBUG: print "Library found: " + found + else: + found = file + return found + +# Returns a list of dependent libraries, excluding system libs +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 + deps = output.split('\n') + for dep in deps: +# print dep + dep = re.sub(".*:$", "", dep) # Take away header line + dep = re.sub("^\t", "", dep) # Remove initial tabs + dep = re.sub(" \(.*\)$", "", dep) # Remove trailing parentheses + if len(dep) > 0 and not re.search("/System/Library", dep) and not re.search("/usr/lib", dep): + libs.append(dep) + return libs + +def validate_lib(lib): + p = subprocess.Popen(["otool", "-l", lib], stdout=subprocess.PIPE) + output = p.communicate()[0] + if p.returncode != 0: return False + if re.search("LC_DYLD_INFO_ONLY", output): + print "Error: Requires Snow Leopard: " + lib + return False + return True + +if __name__ == '__main__': + if len(sys.argv) != 2: usage() + executable = sys.argv[1] + if DEBUG: print "Processing " + executable + executable_path = os.path.dirname(executable) + # processed is a dict {libname : [parents]} - each parent is dependant on libname + processed = {} + pending = [executable] + while len(pending) > 0: + dep = pending.pop() + if DEBUG: print "Evaluating " + dep + deps = find_dependencies(dep) + assert(deps) + for d in deps: + absfile = lookup_library(d) + if absfile == None: + print "Not found: " + d + print " ..required by " + str(processed[dep]) + continue + if absfile in processed: + processed[absfile].append(dep) + else: + processed[absfile] = [dep] + if DEBUG: print "Pending: " + absfile + pending.append(absfile) + + for dep in processed: + if DEBUG: print "Validating: " + dep +# print " " + str(processed[dep]) + if not validate_lib(dep): + print "..required by " + str(processed[dep]) -- cgit v0.10.1 From f5b3b30e51a5658918af52521ddb48eebcc1b6dc Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 7 May 2010 16:24:26 +0000 Subject: Improved Mac OS X deployment - hopefully this doesn't break builds on other platforms git-svn-id: http://svn.clifford.at/openscad/trunk@529 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/cgal.pri b/cgal.pri index 70c7fcc..0c1fd30 100644 --- a/cgal.pri +++ b/cgal.pri @@ -1,22 +1,17 @@ cgal { DEFINES += ENABLE_CGAL - LIBS += -lCGAL - # Optionally specify location of CGAL using the - # CGALDIR env. variable - CGAL_DIR = $$(CGALDIR) - !isEmpty(CGAL_DIR) { - INCLUDEPATH += $$CGAL_DIR/include - LIBS += -L$$CGAL_DIR/lib - message("CGAL location: $$CGAL_DIR") + !deploy { + # Optionally specify location of CGAL using the + # CGALDIR env. variable + CGAL_DIR = $$(CGALDIR) + !isEmpty(CGAL_DIR) { + INCLUDEPATH += $$CGAL_DIR/include + LIBS += -L$$CGAL_DIR/lib + message("CGAL location: $$CGAL_DIR") + } } - macx { - # The -L/usr/lib is to force the linker to use system libraries over MacPort libraries - LIBS += -L/usr/lib -L/opt/local/lib /opt/local/lib/libgmp.a /opt/local/lib/libmpfr.a /opt/local/lib/libboost_thread-mt.a - } - else { - LIBS += -lmpfr - } - win32:LIBS += -lboost_thread -lgmp + + LIBS += -lCGAL -lmpfr -lgmp -lboost_thread QMAKE_CXXFLAGS += -frounding-math } diff --git a/doc/TODO.txt b/doc/TODO.txt index e6b4ac5..b6643c4 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -41,7 +41,7 @@ o MDI o 3D View - OpenGL 2.0 test: What, exactly, is needed from OpenGL 2.0? Can we use 1.x with extensions? - Improve mouse rotation - - Add modifier key combos to handle pan on 1 mouse button systems + - Add modifier key combos to handle pan and zoom on 1 mouse button systems - Show grid - 4 x split view w/orthogonal cameras? - Quick highlighting of object under the cursor in the editor @@ -170,6 +170,8 @@ MISC o Streamline the cmd-line interface a bit - Implicit output file format o Mac OS X: - - universal binary -> fix cgal and opencsg + - 32-bit compatibility + o Build everything including i386 arch + o Write checklists for typical extension work (add new module, add new function) -> make sure new test files are added diff --git a/doc/checklist-macosx.txt b/doc/checklist-macosx.txt index 6db2033..26ef208 100644 --- a/doc/checklist-macosx.txt +++ b/doc/checklist-macosx.txt @@ -1,30 +1,60 @@ -o Prerequisites (MacPorts): - - NB! CGAL requires gcc >= 4.2 - - eigen - - boost - - gmp - - mpfr - - cmake - - Qt4 +NB! This is the Mac OS X deployment checklist. + See build-macosx.txt for how to build a development build of + OpenSCAD for your system only without manually compiling all + dependencies. + +o MacPorts libs + port install eigen + +o Qt4 + - Download and install the combined 32-bit and 64-bit build for 10.5-10.6 from here: + http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x + +o Build gmp + + tar xjz gmp-5.0.1.tar.bz2 + cd gmp-5.0.1 + ./configure --prefix=$PWD/../../deploy CFLAGS=-mmacosx-version-min=10.5 LDFLAGS=-mmacosx-version-min=10.5 + make install + +o Build mpfr + tar xjz mpfr-2.4.2.tar.bz2 + cd mpfr-2.4.2 + ./configure --prefix=$PWD/../../deploy --with-gmp=$PWD/../../deploy CFLAGS=-mmacosx-version-min=10.5 LDFLAGS=-mmacosx-version-min=10.5 + make install + +o Build boost::thread + tar xjz boost_1_42_0.tar.bz2 + cd boost_1_42_0 + ./bootstrap.sh --prefix=$PWD/../../deploy --with-libraries=thread + ./bjam cflags="-mmacosx-version-min=10.5" linkflags="-mmacosx-version-min=10.5" + ./bjam install o Build CGAL >= 3.5 tar xzf CGAL-3.6.tar.gz cd CGAL-3.6 - cmake -DCMAKE_INSTALL_PREFIX=$PWD/../install/CGAL-3.6 -DBUILD_SHARED_LIBS=FALSE + cmake -DCMAKE_INSTALL_PREFIX=$PWD/../../deploy -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" make -j4 make install -o Patch OpenCSG >= 1.3.0 +o Patch & build GLEW + + tar xzf glew-1.5.3.tar.gz + cd glew-1.5.3 + patch -p1 < ../openscad/patches/glew-1.5.3-MacOSX.patch + mkdir ../../deploy/lib/pkgconfig + GLEW_DEST=$PWD/../../deploy make install + +o Patch and build OpenCSG >= 1.3.0 + FIXME: Update patch tar xzf OpenCSG-1.3.0.tar.gz cd OpenCSG-1.3.0 patch -p1 < ../openscad/patches/OpenCSG-1.3.0-MacOSX-port.patch - -o Build OpenCSG - - qmake -recursive + MACOSX_DEPLOY_DIR=$PWD/../../deploy qmake -r make + make install o Build and Deploy OpenSCAD diff --git a/opencsg.pri b/opencsg.pri index c9ed990..a3b70f7 100644 --- a/opencsg.pri +++ b/opencsg.pri @@ -1,23 +1,21 @@ opencsg { + DEFINES += ENABLE_OPENCSG + CONFIG += glew + include(glew.pri) + HEADERS += src/render-opencsg.h SOURCES += src/render-opencsg.cc - DEFINES += ENABLE_OPENCSG - LIBS += -lopencsg - unix:LIBS += -lGLEW - win32:LIBS += -lglew32 - - # Optionally specify location of OpenCSG using the - # OPENCSGDIR env. variable - OPENCSG_DIR = $$(OPENCSGDIR) - !isEmpty(OPENCSG_DIR) { - INCLUDEPATH += $$OPENCSG_DIR/include - LIBS += -L$$OPENCSG_DIR/lib - message("OpenCSG location: $$CGAL_DIR") - } - macx { - # For glew - INCLUDEPATH += /opt/local/include - LIBS += -L/opt/local/lib + !deploy { + # Optionally specify location of OpenCSG using the + # OPENCSGDIR env. variable + OPENCSG_DIR = $$(OPENCSGDIR) + !isEmpty(OPENCSG_DIR) { + INCLUDEPATH += $$OPENCSG_DIR/include + LIBS += -L$$OPENCSG_DIR/lib + message("OpenCSG location: $$OPENCSG_DIR") + } } + + LIBS += -lopencsg } diff --git a/openscad.pro b/openscad.pro index 8d0df63..bb3d387 100644 --- a/openscad.pro +++ b/openscad.pro @@ -10,6 +10,16 @@ RCC_DIR = objects INCLUDEPATH += src macx { + # add CONFIG+=deploy to the qmake command-line to make a deployment build + deploy { + message("Building deployment version") + DEPLOYDIR = $$(MACOSX_DEPLOY_DIR) + !isEmpty(DEPLOYDIR) { + INCLUDEPATH += $$DEPLOYDIR/include + LIBS += -L$$DEPLOYDIR/lib + } + } + TARGET = OpenSCAD ICON = icons/OpenSCAD.icns QMAKE_INFO_PLIST = Info.plist @@ -56,9 +66,9 @@ include(opencsg.pri) include(eigen2.pri) # Standard include path for misc external libs -macx { - INCLUDEPATH += /opt/local/include -} +#macx { +# INCLUDEPATH += /opt/local/include +#} # QMAKE_CFLAGS += -pg # QMAKE_CXXFLAGS += -pg diff --git a/scripts/macosx-sanity-check.py b/scripts/macosx-sanity-check.py index 2438906..1b5a7b7 100755 --- a/scripts/macosx-sanity-check.py +++ b/scripts/macosx-sanity-check.py @@ -5,6 +5,8 @@ # are present and that they are backwards compatible with at least 10.5. # Run with an executable as parameter # +# Author: Marius Kintel +# import sys import os diff --git a/scripts/release-common.sh b/scripts/release-common.sh index b782976..340266d 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -42,7 +42,7 @@ echo "Building openscad-$VERSION $CONFIGURATION..." case $OS in MACOSX) - CONFIG=mdi + CONFIG=deploy TARGET= ;; WIN) diff --git a/setenv_mjau.sh b/setenv_mjau.sh index ed466f7..5a1adb0 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -1,3 +1,6 @@ +export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy +export DYLD_LIBRARY_PATH=$MACOSX_DEPLOY_DIR/lib + export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 export CGALDIR=$PWD/../install/CGAL-3.6 export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install -- cgit v0.10.1 From a9f281e8ae2a9d1df02b49dd7823687f1c55736c Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 7 May 2010 16:24:29 +0000 Subject: Split out glew settings to separate .pri file git-svn-id: http://svn.clifford.at/openscad/trunk@530 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/glew.pri b/glew.pri new file mode 100644 index 0000000..67ed68f --- /dev/null +++ b/glew.pri @@ -0,0 +1,19 @@ +glew { + !deploy { + # Optionally specify location of GLEW using the + # GLEWDIR env. variable + GLEW_DIR = $$(GLEWDIR) + isEmpty(GLEW_DIR) { + # Default to MacPorts on Mac OS X + macx: GLEW_DIR = /opt/local + } + !isEmpty(GLEW_DIR) { + INCLUDEPATH += $$GLEW_DIR/include + LIBS += -L$$GLEW_DIR/lib + message("GLEW location: $$GLEW_DIR") + } + } + + unix:LIBS += -lGLEW + win32:LIBS += -lglew32 +} -- cgit v0.10.1 From a469ef9c67512137eee1181ee8c912dd3a39f1a1 Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 7 May 2010 19:04:12 +0000 Subject: mac deployment update git-svn-id: http://svn.clifford.at/openscad/trunk@531 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/checklist-macosx.txt b/doc/checklist-macosx.txt index 26ef208..977e105 100644 --- a/doc/checklist-macosx.txt +++ b/doc/checklist-macosx.txt @@ -29,6 +29,7 @@ o Build boost::thread ./bootstrap.sh --prefix=$PWD/../../deploy --with-libraries=thread ./bjam cflags="-mmacosx-version-min=10.5" linkflags="-mmacosx-version-min=10.5" ./bjam install + install_name_tool -id $PWD/../../deploy/lib/libboost_thread.dylib /Users/kintel/code/metalab/checkout/OpenSCAD/libraries/deploy/lib/libboost_thread.dylib o Build CGAL >= 3.5 diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index 3f14837..51d890e 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -3,9 +3,7 @@ VERSION=`date "+%Y.%m.%d"` #VERSION=2010.02 -export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 -export CGALDIR=$PWD/../install/CGAL-3.6 -export EIGEN2DIR=/opt/local/include/eigen2 +export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy `dirname $0`/release-common.sh -v $VERSION if [[ $? != 0 ]]; then -- cgit v0.10.1 From f0dbcc160882f5ea9a9c18a16b8fcdb204ee9ae9 Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 8 May 2010 03:55:18 +0000 Subject: Added check for 32-bit and 64-bit version git-svn-id: http://svn.clifford.at/openscad/trunk@532 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-sanity-check.py b/scripts/macosx-sanity-check.py index 1b5a7b7..a085bda 100755 --- a/scripts/macosx-sanity-check.py +++ b/scripts/macosx-sanity-check.py @@ -67,6 +67,18 @@ def validate_lib(lib): if re.search("LC_DYLD_INFO_ONLY", output): print "Error: Requires Snow Leopard: " + lib return False + + p = subprocess.Popen(["lipo", lib, "-verify_arch", "x86_64"], stdout=subprocess.PIPE) + output = p.communicate()[0] + if p.returncode != 0: + print "Error: x86_64 architecture not supported: " + lib + return False + + p = subprocess.Popen(["lipo", lib, "-verify_arch", "i386"], stdout=subprocess.PIPE) + output = p.communicate()[0] + if p.returncode != 0: + print "Error: i386 architecture not supported: " + lib + return False return True if __name__ == '__main__': @@ -77,6 +89,7 @@ if __name__ == '__main__': # processed is a dict {libname : [parents]} - each parent is dependant on libname processed = {} pending = [executable] + processed[executable] = [] while len(pending) > 0: dep = pending.pop() if DEBUG: print "Evaluating " + dep -- cgit v0.10.1 From a2d463cf2794c45c55cfc8f97050e1d8ffdcf4b7 Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 8 May 2010 03:55:42 +0000 Subject: Build fat 32- and 64-bit binaries git-svn-id: http://svn.clifford.at/openscad/trunk@533 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/checklist-macosx.txt b/doc/checklist-macosx.txt index 977e105..f9cb4e6 100644 --- a/doc/checklist-macosx.txt +++ b/doc/checklist-macosx.txt @@ -14,20 +14,40 @@ o Build gmp tar xjz gmp-5.0.1.tar.bz2 cd gmp-5.0.1 - ./configure --prefix=$PWD/../../deploy CFLAGS=-mmacosx-version-min=10.5 LDFLAGS=-mmacosx-version-min=10.5 + mkdir build-i386 + cd build-i386 + ../configure --prefix=$PWD/../../../deploy "CFLAGS=-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" ABI=32 --libdir=$PWD/../../../deploy/lib-i386 make install + cd .. + mkdir build-x86_64 + cd build-x86_64 + ../configure --prefix=$PWD/../../../deploy "CFLAGS=-mmacosx-version-min=10.5" LDFLAGS="-mmacosx-version-min=10.5" --libdir=$PWD/../../../deploy/lib-x86_64 + make install + cd ../../../deploy + lipo -create lib-i386/libgmp.dylib lib-x86_64/libgmp.dylib -output lib/libgmp.dylib + install_name_tool -id $PWD/lib/libgmp.dylib lib/libgmp.dylib o Build mpfr tar xjz mpfr-2.4.2.tar.bz2 cd mpfr-2.4.2 - ./configure --prefix=$PWD/../../deploy --with-gmp=$PWD/../../deploy CFLAGS=-mmacosx-version-min=10.5 LDFLAGS=-mmacosx-version-min=10.5 + mkdir build-i386 + cd build-i386 + ../configure --prefix=$PWD/../../../deploy --with-gmp=$PWD/../../../deploy CFLAGS="-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" --libdir=$PWD/../../../deploy/lib-i386 + make install + cd .. + mkdir build-x86_64 + cd build-x86_64 + ../configure --prefix=$PWD/../../../deploy --with-gmp=$PWD/../../../deploy CFLAGS="-mmacosx-version-min=10.5 -arch x86_64" LDFLAGS="-mmacosx-version-min=10.5 -arch x86_64" --libdir=$PWD/../../../deploy/lib-x86_64 make install + cd ../../../deploy + lipo -create lib-i386/libmpfr.dylib lib-x86_64/libmpfr.dylib -output lib/libmpfr.dylib + install_name_tool -id $PWD/lib/libmpfr.dylib lib/libmpfr.dylib o Build boost::thread tar xjz boost_1_42_0.tar.bz2 cd boost_1_42_0 ./bootstrap.sh --prefix=$PWD/../../deploy --with-libraries=thread - ./bjam cflags="-mmacosx-version-min=10.5" linkflags="-mmacosx-version-min=10.5" + ./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 $PWD/../../deploy/lib/libboost_thread.dylib /Users/kintel/code/metalab/checkout/OpenSCAD/libraries/deploy/lib/libboost_thread.dylib @@ -35,7 +55,7 @@ o Build CGAL >= 3.5 tar xzf CGAL-3.6.tar.gz cd CGAL-3.6 - cmake -DCMAKE_INSTALL_PREFIX=$PWD/../../deploy -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" + cmake -DCMAKE_INSTALL_PREFIX=$PWD/../../deploy -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" make -j4 make install @@ -45,7 +65,7 @@ o Patch & build GLEW cd glew-1.5.3 patch -p1 < ../openscad/patches/glew-1.5.3-MacOSX.patch mkdir ../../deploy/lib/pkgconfig - GLEW_DEST=$PWD/../../deploy make install + make GLEW_DEST=$PWD/../../deploy CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=10.5 -arch i386 -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" install o Patch and build OpenCSG >= 1.3.0 @@ -53,8 +73,7 @@ o Patch and build OpenCSG >= 1.3.0 tar xzf OpenCSG-1.3.0.tar.gz cd OpenCSG-1.3.0 patch -p1 < ../openscad/patches/OpenCSG-1.3.0-MacOSX-port.patch - MACOSX_DEPLOY_DIR=$PWD/../../deploy qmake -r - make + MACOSX_DEPLOY_DIR=$PWD/../../deploy qmake -r CONFIG+="x86 x86_64" make install o Build and Deploy OpenSCAD -- cgit v0.10.1 From 186ed3bdf30f02425cb0e86e7370e29c988df0e1 Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 8 May 2010 03:57:28 +0000 Subject: Removed obsolete config git-svn-id: http://svn.clifford.at/openscad/trunk@534 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/openscad.pro b/openscad.pro index bb3d387..5b4d7a7 100644 --- a/openscad.pro +++ b/openscad.pro @@ -26,7 +26,6 @@ macx { APP_RESOURCES.path = Contents/Resources APP_RESOURCES.files = OpenSCAD.sdef QMAKE_BUNDLE_DATA += APP_RESOURCES - #CONFIG += x86 ppc LIBS += -framework Carbon } else { -- cgit v0.10.1 From 4185b3128bc37067fd31c2bcdbcf9345aaab2a17 Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 8 May 2010 03:57:31 +0000 Subject: Build fat 32- and 64-bit binary when in deploy mode git-svn-id: http://svn.clifford.at/openscad/trunk@535 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/openscad.pro b/openscad.pro index 5b4d7a7..e5c740a 100644 --- a/openscad.pro +++ b/openscad.pro @@ -13,6 +13,7 @@ macx { # add CONFIG+=deploy to the qmake command-line to make a deployment build deploy { message("Building deployment version") + CONFIG += x86 x86_64 DEPLOYDIR = $$(MACOSX_DEPLOY_DIR) !isEmpty(DEPLOYDIR) { INCLUDEPATH += $$DEPLOYDIR/include -- cgit v0.10.1 From 7bfc4e224f8ed4d44f6cb9d90bb8459974e20f41 Mon Sep 17 00:00:00 2001 From: clifford Date: Sat, 8 May 2010 11:38:30 +0000 Subject: Clifford Wolf: Ask user when reloading with local midifications git-svn-id: http://svn.clifford.at/openscad/trunk@536 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/mainwin.cc b/src/mainwin.cc index 4d7ed00..72b3d7a 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -961,6 +961,17 @@ void MainWindow::pasteViewportRotation() void MainWindow::actionReloadCompile() { + if (editor->isContentModified()) { + QMessageBox::StandardButton ret; + ret = QMessageBox::warning(this, "Application", + "The document has been modified.\n" + "Do you really want to reload the file?", + QMessageBox::Yes | QMessageBox::No); + if (ret != QMessageBox::Yes) { + return; + } + } + console->clear(); load(); -- cgit v0.10.1 From 07a83867cc30fddd68f19888970dc6c43dd8eb40 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 May 2010 01:55:22 +0000 Subject: updated to support an installation dir git-svn-id: http://svn.clifford.at/openscad/trunk@537 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/patches/OpenCSG-1.3.0-MacOSX-port.patch b/patches/OpenCSG-1.3.0-MacOSX-port.patch index 372d086..bb55165 100644 --- a/patches/OpenCSG-1.3.0-MacOSX-port.patch +++ b/patches/OpenCSG-1.3.0-MacOSX-port.patch @@ -1,6 +1,147 @@ +diff -ru OpenCSG-1.3.0/Makefile OpenCSG-1.3.0-mac/Makefile +--- OpenCSG-1.3.0/Makefile 2010-02-06 21:35:10.000000000 +0100 ++++ OpenCSG-1.3.0-mac/Makefile 2010-05-09 02:50:55.000000000 +0200 +@@ -1,10 +1,130 @@ +-SUBDIRS = glew src example ++############################################################################# ++# Makefile for building: opencsg ++# Generated by qmake (2.01a) (Qt 4.6.2) on: Sun May 9 02:45:47 2010 ++# Project: opencsg.pro ++# Template: subdirs ++# Command: /usr/bin/qmake -macx CONFIG+=x86\ x86_64 -o Makefile opencsg.pro ++############################################################################# + +-all: +- for X in $(SUBDIRS); do make -C $$X ; done ++first: make_default ++MAKEFILE = Makefile ++QMAKE = /usr/bin/qmake ++DEL_FILE = rm -f ++CHK_DIR_EXISTS= test -d ++MKDIR = mkdir -p ++COPY = cp -f ++COPY_FILE = cp -f ++COPY_DIR = cp -f -R ++INSTALL_FILE = $(COPY_FILE) ++INSTALL_PROGRAM = $(COPY_FILE) ++INSTALL_DIR = $(COPY_DIR) ++DEL_FILE = rm -f ++SYMLINK = ln -f -s ++DEL_DIR = rmdir ++MOVE = mv -f ++CHK_DIR_EXISTS= test -d ++MKDIR = mkdir -p ++SUBTARGETS = \ ++ sub-src + +-clean: +- for X in $(SUBDIRS); do make -C $$X clean; done ++src/$(MAKEFILE): ++ @$(CHK_DIR_EXISTS) src/ || $(MKDIR) src/ ++ cd src/ && $(QMAKE) /Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/src/OpenCSG-1.3.0-patched/src/src.pro -macx CONFIG+=x86\ x86_64 -o $(MAKEFILE) ++sub-src-qmake_all: FORCE ++ @$(CHK_DIR_EXISTS) src/ || $(MKDIR) src/ ++ cd src/ && $(QMAKE) /Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/src/OpenCSG-1.3.0-patched/src/src.pro -macx CONFIG+=x86\ x86_64 -o $(MAKEFILE) ++sub-src: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) ++sub-src-make_default: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) ++sub-src-make_first: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) first ++sub-src-all: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) all ++sub-src-clean: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) clean ++sub-src-distclean: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) distclean ++sub-src-install_subtargets: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) install ++sub-src-uninstall_subtargets: src/$(MAKEFILE) FORCE ++ cd src/ && $(MAKE) -f $(MAKEFILE) uninstall ++ ++Makefile: opencsg.pro /usr/local/Qt4.6/mkspecs/macx-g++/qmake.conf /usr/local/Qt4.6/mkspecs/common/unix.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac-g++.conf \ ++ /usr/local/Qt4.6/mkspecs/qconfig.pri \ ++ /usr/local/Qt4.6/mkspecs/features/qt_functions.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt_config.prf \ ++ /usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/dwarf2.prf \ ++ /usr/local/Qt4.6/mkspecs/features/debug.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86.prf \ ++ /usr/local/Qt4.6/mkspecs/features/warn_on.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/thread.prf \ ++ /usr/local/Qt4.6/mkspecs/features/moc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/rez.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/sdk.prf \ ++ /usr/local/Qt4.6/mkspecs/features/resources.prf \ ++ /usr/local/Qt4.6/mkspecs/features/uic.prf \ ++ /usr/local/Qt4.6/mkspecs/features/yacc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/lex.prf \ ++ /usr/local/Qt4.6/mkspecs/features/include_source_dir.prf ++ $(QMAKE) -macx CONFIG+=x86\ x86_64 -o Makefile opencsg.pro ++/usr/local/Qt4.6/mkspecs/common/unix.conf: ++/usr/local/Qt4.6/mkspecs/common/mac.conf: ++/usr/local/Qt4.6/mkspecs/common/mac-g++.conf: ++/usr/local/Qt4.6/mkspecs/qconfig.pri: ++/usr/local/Qt4.6/mkspecs/features/qt_functions.prf: ++/usr/local/Qt4.6/mkspecs/features/qt_config.prf: ++/usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf: ++/usr/local/Qt4.6/mkspecs/features/default_pre.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/dwarf2.prf: ++/usr/local/Qt4.6/mkspecs/features/debug.prf: ++/usr/local/Qt4.6/mkspecs/features/default_post.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/default_post.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/x86.prf: ++/usr/local/Qt4.6/mkspecs/features/warn_on.prf: ++/usr/local/Qt4.6/mkspecs/features/qt.prf: ++/usr/local/Qt4.6/mkspecs/features/unix/thread.prf: ++/usr/local/Qt4.6/mkspecs/features/moc.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/rez.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/sdk.prf: ++/usr/local/Qt4.6/mkspecs/features/resources.prf: ++/usr/local/Qt4.6/mkspecs/features/uic.prf: ++/usr/local/Qt4.6/mkspecs/features/yacc.prf: ++/usr/local/Qt4.6/mkspecs/features/lex.prf: ++/usr/local/Qt4.6/mkspecs/features/include_source_dir.prf: ++qmake: qmake_all FORCE ++ @$(QMAKE) -macx CONFIG+=x86\ x86_64 -o Makefile opencsg.pro ++ ++qmake_all: sub-src-qmake_all FORCE ++ ++make_default: sub-src-make_default FORCE ++make_first: sub-src-make_first FORCE ++all: sub-src-all FORCE ++clean: sub-src-clean FORCE ++distclean: sub-src-distclean FORCE ++ -$(DEL_FILE) Makefile ++install_subtargets: sub-src-install_subtargets FORCE ++uninstall_subtargets: sub-src-uninstall_subtargets FORCE ++ ++mocclean: compiler_moc_header_clean compiler_moc_source_clean ++ ++mocables: compiler_moc_header_make_all compiler_moc_source_make_all ++install: install_subtargets FORCE ++ ++uninstall: uninstall_subtargets FORCE ++ ++FORCE: + +-distclean: +- for X in $(SUBDIRS); do make -C $$X distclean; done diff -ru OpenCSG-1.3.0/RenderTexture/RenderTexture.h OpenCSG-1.3.0-mac/RenderTexture/RenderTexture.h --- OpenCSG-1.3.0/RenderTexture/RenderTexture.h 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/RenderTexture/RenderTexture.h 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/RenderTexture/RenderTexture.h 2010-05-09 02:51:07.000000000 +0200 @@ -294,8 +294,8 @@ bool _BindDepthBuffer( ) const; @@ -23,9 +164,341 @@ diff -ru OpenCSG-1.3.0/RenderTexture/RenderTexture.h OpenCSG-1.3.0-mac/RenderTex unsigned short* _pPoorDepthTexture; // [Redge] +diff -ru OpenCSG-1.3.0/example/Makefile OpenCSG-1.3.0-mac/example/Makefile +--- OpenCSG-1.3.0/example/Makefile 2010-02-06 21:35:10.000000000 +0100 ++++ OpenCSG-1.3.0-mac/example/Makefile 2010-05-09 02:51:11.000000000 +0200 +@@ -1,106 +1,206 @@ + ############################################################################# +-# Makefile for building: opencsgexample +-# Generated by qmake (1.06c) (Qt 3.2.0) on: Thu Apr 22 16:05:34 2004 ++# Makefile for building: opencsgexample.app/Contents/MacOS/opencsgexample ++# Generated by qmake (2.01a) (Qt 4.6.2) on: Sun May 9 02:43:57 2010 + # Project: example.pro + # Template: app +-# Command: $(QMAKE) -o Makefile example.pro ++# Command: /usr/bin/qmake -macx CONFIG+=x86\ x86_64 -o Makefile example.pro + ############################################################################# + + ####### Compiler, tools and options + +-CC = gcc +-CXX = g++ +-LEX = flex +-YACC = yacc +-CFLAGS = -pipe -Wall -W -O2 +-CXXFLAGS = -pipe -Wall -W -O2 +-LEXFLAGS = +-YACCFLAGS= -d +-INCPATH = -I. -I../glew/include -I../include -I/usr/X11R6/include -I/usr/X11R6/include +-LINK = g++ +-LFLAGS = +-LIBS = $(SUBLIBS) -L/usr/X11R6/lib -L/usr/X11R6/lib -L../lib -lopencsg -lglut -L../glew/lib -lGLEW -lGLU -lGL -lXmu -lXext -lX11 -lm +-AR = ar cqs +-RANLIB = +-MOC = $(QTDIR)/bin/moc +-UIC = $(QTDIR)/bin/uic +-QMAKE = qmake +-TAR = tar -cf +-GZIP = gzip -9f +-COPY = cp -f +-COPY_FILE= $(COPY) +-COPY_DIR = $(COPY) -r +-DEL_FILE = rm -f +-SYMLINK = ln -sf +-DEL_DIR = rmdir +-MOVE = mv -f ++CC = gcc ++CXX = g++ ++DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED ++CFLAGS = -pipe -O2 -Wall -W -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -arch i386 $(DEFINES) ++CXXFLAGS = -pipe -O2 -Wall -W -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -arch i386 $(DEFINES) ++INCPATH = -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I../include -I/opt/local/include -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -F/Library/Frameworks ++LINK = g++ ++LFLAGS = -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -arch i386 ++LIBS = $(SUBLIBS) -F/Library/Frameworks -L/Library/Frameworks -L../lib -lopencsg -lGLEW -framework GLUT -L/opt/local/lib -framework OpenGL -framework AGL -framework QtGui -framework QtCore ++AR = ar cq ++RANLIB = ranlib -s ++QMAKE = /usr/bin/qmake ++TAR = tar -cf ++COMPRESS = gzip -9f ++COPY = cp -f ++SED = sed ++COPY_FILE = cp -f ++COPY_DIR = cp -f -R ++STRIP = ++INSTALL_FILE = $(COPY_FILE) ++INSTALL_DIR = $(COPY_DIR) ++INSTALL_PROGRAM = $(COPY_FILE) ++DEL_FILE = rm -f ++SYMLINK = ln -f -s ++DEL_DIR = rmdir ++MOVE = mv -f + CHK_DIR_EXISTS= test -d +-MKDIR = mkdir -p ++MKDIR = mkdir -p ++export MACOSX_DEPLOYMENT_TARGET = 10.4 + + ####### Output directory + +-OBJECTS_DIR = ./ ++OBJECTS_DIR = ./ + + ####### Files + +-HEADERS = displaylistPrimitive.h +-SOURCES = displaylistPrimitive.cpp \ +- main.cpp +-OBJECTS = displaylistPrimitive.o \ ++SOURCES = displaylistPrimitive.cpp \ ++ main.cpp ++OBJECTS = displaylistPrimitive.o \ + main.o +-FORMS = +-UICDECLS = +-UICIMPLS = +-SRCMOC = +-OBJMOC = +-DIST = example.pro +-QMAKE_TARGET = opencsgexample +-DESTDIR = +-TARGET = opencsgexample ++DIST = /usr/local/Qt4.6/mkspecs/common/unix.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac-g++.conf \ ++ /usr/local/Qt4.6/mkspecs/qconfig.pri \ ++ /usr/local/Qt4.6/mkspecs/features/qt_functions.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt_config.prf \ ++ /usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/release.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf \ ++ /usr/local/Qt4.6/mkspecs/features/warn_on.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/opengl.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/thread.prf \ ++ /usr/local/Qt4.6/mkspecs/features/moc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/rez.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/sdk.prf \ ++ /usr/local/Qt4.6/mkspecs/features/resources.prf \ ++ /usr/local/Qt4.6/mkspecs/features/uic.prf \ ++ /usr/local/Qt4.6/mkspecs/features/yacc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/lex.prf \ ++ /usr/local/Qt4.6/mkspecs/features/include_source_dir.prf \ ++ example.pro ++QMAKE_TARGET = opencsgexample ++DESTDIR = ++TARGET = opencsgexample.app/Contents/MacOS/opencsgexample ++ ++####### Custom Compiler Variables ++QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS = -pipe \ ++ -O2 \ ++ -Wall \ ++ -W \ ++ -arch \ ++ x86_64 \ ++ -Xarch_x86_64 \ ++ -mmacosx-version-min=10.5 \ ++ -arch \ ++ i386 ++ + + first: all + ####### Implicit rules + +-.SUFFIXES: .c .o .cpp .cc .cxx .C ++.SUFFIXES: .o .c .cpp .cc .cxx .C + + .cpp.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .cc.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .cxx.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .C.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .c.o: +- $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< ++ $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + + ####### Build rules + +-all: Makefile $(TARGET) +- +-$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) +- $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) $(OBJCOMP) +- +-mocables: $(SRCMOC) +-uicables: $(UICDECLS) $(UICIMPLS) +- +-$(MOC): +- ( cd $(QTDIR)/src/moc ; $(MAKE) ) ++all: Makefile opencsgexample.app/Contents/PkgInfo opencsgexample.app/Contents/Resources/empty.lproj opencsgexample.app/Contents/Info.plist $(TARGET) + ++$(TARGET): $(OBJECTS) ++ @$(CHK_DIR_EXISTS) opencsgexample.app/Contents/MacOS/ || $(MKDIR) opencsgexample.app/Contents/MacOS/ ++ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) ++ ++Makefile: example.pro /usr/local/Qt4.6/mkspecs/macx-g++/qmake.conf /usr/local/Qt4.6/mkspecs/common/unix.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac-g++.conf \ ++ /usr/local/Qt4.6/mkspecs/qconfig.pri \ ++ /usr/local/Qt4.6/mkspecs/features/qt_functions.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt_config.prf \ ++ /usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/release.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf \ ++ /usr/local/Qt4.6/mkspecs/features/warn_on.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/opengl.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/thread.prf \ ++ /usr/local/Qt4.6/mkspecs/features/moc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/rez.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/sdk.prf \ ++ /usr/local/Qt4.6/mkspecs/features/resources.prf \ ++ /usr/local/Qt4.6/mkspecs/features/uic.prf \ ++ /usr/local/Qt4.6/mkspecs/features/yacc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/lex.prf \ ++ /usr/local/Qt4.6/mkspecs/features/include_source_dir.prf \ ++ /Library/Frameworks/QtGui.framework/QtGui.prl \ ++ /Library/Frameworks/QtCore.framework/QtCore.prl ++ $(QMAKE) -macx CONFIG+=x86\ x86_64 -o Makefile example.pro ++/usr/local/Qt4.6/mkspecs/common/unix.conf: ++/usr/local/Qt4.6/mkspecs/common/mac.conf: ++/usr/local/Qt4.6/mkspecs/common/mac-g++.conf: ++/usr/local/Qt4.6/mkspecs/qconfig.pri: ++/usr/local/Qt4.6/mkspecs/features/qt_functions.prf: ++/usr/local/Qt4.6/mkspecs/features/qt_config.prf: ++/usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf: ++/usr/local/Qt4.6/mkspecs/features/default_pre.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf: ++/usr/local/Qt4.6/mkspecs/features/release.prf: ++/usr/local/Qt4.6/mkspecs/features/default_post.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/default_post.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf: ++/usr/local/Qt4.6/mkspecs/features/warn_on.prf: ++/usr/local/Qt4.6/mkspecs/features/unix/opengl.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/x86.prf: ++/usr/local/Qt4.6/mkspecs/features/qt.prf: ++/usr/local/Qt4.6/mkspecs/features/unix/thread.prf: ++/usr/local/Qt4.6/mkspecs/features/moc.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/rez.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/sdk.prf: ++/usr/local/Qt4.6/mkspecs/features/resources.prf: ++/usr/local/Qt4.6/mkspecs/features/uic.prf: ++/usr/local/Qt4.6/mkspecs/features/yacc.prf: ++/usr/local/Qt4.6/mkspecs/features/lex.prf: ++/usr/local/Qt4.6/mkspecs/features/include_source_dir.prf: ++/Library/Frameworks/QtGui.framework/QtGui.prl: ++/Library/Frameworks/QtCore.framework/QtCore.prl: ++qmake: FORCE ++ @$(QMAKE) -macx CONFIG+=x86\ x86_64 -o Makefile example.pro ++ ++opencsgexample.app/Contents/PkgInfo: ++ @$(CHK_DIR_EXISTS) opencsgexample.app/Contents || $(MKDIR) opencsgexample.app/Contents ++ @$(DEL_FILE) opencsgexample.app/Contents/PkgInfo ++ @echo "APPL????" >opencsgexample.app/Contents/PkgInfo ++opencsgexample.app/Contents/Resources/empty.lproj: ++ @$(CHK_DIR_EXISTS) opencsgexample.app/Contents/Resources || $(MKDIR) opencsgexample.app/Contents/Resources ++ @touch opencsgexample.app/Contents/Resources/empty.lproj ++ ++opencsgexample.app/Contents/Info.plist: ++ @$(CHK_DIR_EXISTS) opencsgexample.app/Contents || $(MKDIR) opencsgexample.app/Contents ++ @$(DEL_FILE) opencsgexample.app/Contents/Info.plist ++ @sed -e "s,@ICON@,,g" -e "s,@EXECUTABLE@,opencsgexample,g" -e "s,@TYPEINFO@,????,g" /usr/local/Qt4.6/mkspecs/macx-g++/Info.plist.app >opencsgexample.app/Contents/Info.plist + dist: +- @mkdir -p .tmp/opencsgexample && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/opencsgexample/ && ( cd `dirname .tmp/opencsgexample` && $(TAR) opencsgexample.tar opencsgexample && $(GZIP) opencsgexample.tar ) && $(MOVE) `dirname .tmp/opencsgexample`/opencsgexample.tar.gz . && $(DEL_FILE) -r .tmp/opencsgexample +- +-mocclean: ++ @$(CHK_DIR_EXISTS) .tmp/opencsgexample1.0.0 || $(MKDIR) .tmp/opencsgexample1.0.0 ++ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/opencsgexample1.0.0/ && $(COPY_FILE) --parents displaylistPrimitive.h .tmp/opencsgexample1.0.0/ && $(COPY_FILE) --parents displaylistPrimitive.cpp main.cpp .tmp/opencsgexample1.0.0/ && (cd `dirname .tmp/opencsgexample1.0.0` && $(TAR) opencsgexample1.0.0.tar opencsgexample1.0.0 && $(COMPRESS) opencsgexample1.0.0.tar) && $(MOVE) `dirname .tmp/opencsgexample1.0.0`/opencsgexample1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/opencsgexample1.0.0 + +-uiclean: + +-yaccclean: +-lexclean: +-clean: ++clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + +@@ -108,20 +208,50 @@ + ####### Sub-libraries + + distclean: clean +- -$(DEL_FILE) $(TARGET) $(TARGET) ++ -$(DEL_FILE) -r opencsgexample.app ++ -$(DEL_FILE) Makefile + + +-FORCE: ++mocclean: compiler_moc_header_clean compiler_moc_source_clean ++ ++mocables: compiler_moc_header_make_all compiler_moc_source_make_all ++ ++compiler_objective_c_make_all: ++compiler_objective_c_clean: ++compiler_moc_header_make_all: ++compiler_moc_header_clean: ++compiler_rcc_make_all: ++compiler_rcc_clean: ++compiler_image_collection_make_all: qmake_image_collection.cpp ++compiler_image_collection_clean: ++ -$(DEL_FILE) qmake_image_collection.cpp ++compiler_moc_source_make_all: ++compiler_moc_source_clean: ++compiler_rez_source_make_all: ++compiler_rez_source_clean: ++compiler_uic_make_all: ++compiler_uic_clean: ++compiler_yacc_decl_make_all: ++compiler_yacc_decl_clean: ++compiler_yacc_impl_make_all: ++compiler_yacc_impl_clean: ++compiler_lex_make_all: ++compiler_lex_clean: ++compiler_clean: + + ####### Compile + + displaylistPrimitive.o: displaylistPrimitive.cpp displaylistPrimitive.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o displaylistPrimitive.o displaylistPrimitive.cpp + + main.o: main.cpp displaylistPrimitive.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + + ####### Install + +-install: all ++install: FORCE + +-uninstall: ++uninstall: FORCE ++ ++FORCE: + diff -ru OpenCSG-1.3.0/example/example.pro OpenCSG-1.3.0-mac/example/example.pro --- OpenCSG-1.3.0/example/example.pro 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/example/example.pro 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/example/example.pro 2010-05-09 02:51:14.000000000 +0200 @@ -2,9 +2,16 @@ TARGET = opencsgexample @@ -48,7 +521,7 @@ diff -ru OpenCSG-1.3.0/example/example.pro OpenCSG-1.3.0-mac/example/example.pro SOURCES = displaylistPrimitive.cpp main.cpp diff -ru OpenCSG-1.3.0/example/main.cpp OpenCSG-1.3.0-mac/example/main.cpp --- OpenCSG-1.3.0/example/main.cpp 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/example/main.cpp 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/example/main.cpp 2010-05-09 02:51:20.000000000 +0200 @@ -22,7 +22,11 @@ // @@ -63,15 +536,547 @@ diff -ru OpenCSG-1.3.0/example/main.cpp OpenCSG-1.3.0-mac/example/main.cpp #include diff -ru OpenCSG-1.3.0/opencsg.pro OpenCSG-1.3.0-mac/opencsg.pro --- OpenCSG-1.3.0/opencsg.pro 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/opencsg.pro 2010-02-09 10:49:30.000000000 +0100 -@@ -1,2 +1,4 @@ ++++ OpenCSG-1.3.0-mac/opencsg.pro 2010-05-09 02:51:23.000000000 +0200 +@@ -1,2 +1,2 @@ TEMPLATE = subdirs - SUBDIRS = src example -+# On Mac we get glew from MacPorts -+!macx:SUBDIRS += glew +-SUBDIRS = src example ++SUBDIRS = src +diff -ru OpenCSG-1.3.0/src/Makefile OpenCSG-1.3.0-mac/src/Makefile +--- OpenCSG-1.3.0/src/Makefile 2010-02-06 21:35:10.000000000 +0100 ++++ OpenCSG-1.3.0-mac/src/Makefile 2010-05-09 02:51:27.000000000 +0200 +@@ -1,65 +1,50 @@ + ############################################################################# +-# Makefile for building: libopencsg.so.1.3.0 +-# Generated by qmake (1.07a) (Qt 3.3.8b) on: Fri Jan 29 22:15:11 2010 ++# Makefile for building: libopencsg.1.3.0.dylib ++# Generated by qmake (2.01a) (Qt 4.6.2) on: Sun May 9 02:45:47 2010 + # Project: src.pro + # Template: lib +-# Command: $(QMAKE) -o Makefile src.pro ++# Command: /usr/bin/qmake -macx CONFIG+=x86\ x86_64 -o Makefile src.pro + ############################################################################# + + ####### Compiler, tools and options + +-CC = gcc +-CXX = g++ +-LEX = flex +-YACC = yacc +-CFLAGS = -pipe -Wall -W -O2 -fPIC +-CXXFLAGS = -pipe -Wall -W -O2 -fPIC +-LEXFLAGS = +-YACCFLAGS= -d +-INCPATH = -I. -I../include -I../glew/include -I.. -I/usr/X11R6/include +-LINK = g++ +-LFLAGS = -shared -Wl,-soname,libopencsg.so.1 -Wl,-rpath,../lib +-LIBS = $(SUBLIBS) -L/usr/X11R6/lib -lGLU -lGL -lXmu +-AR = ar cqs +-RANLIB = +-QMAKE = qmake +-TAR = tar -cf +-GZIP = gzip -9f +-COPY = cp -f +-COPY_FILE= $(COPY) +-COPY_DIR = $(COPY) -r +-DEL_FILE = rm -f +-SYMLINK = ln -sf +-DEL_DIR = rmdir +-MOVE = mv -f ++CC = gcc ++CXX = g++ ++DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED ++CFLAGS = -pipe -O2 -Wall -W -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -arch i386 -fPIC $(DEFINES) ++CXXFLAGS = -pipe -O2 -Wall -W -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -arch i386 -fPIC $(DEFINES) ++INCPATH = -I/usr/local/Qt4.6/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I../include -I.. -I../../../deploy/include -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -F/Library/Frameworks ++LINK = g++ ++LFLAGS = -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -arch i386 -single_module -dynamiclib -compatibility_version 1.3 -current_version 1.3.0 -install_name /Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/libopencsg.1.dylib ++LIBS = $(SUBLIBS) -F/Library/Frameworks -L/Library/Frameworks -L/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib -lGLEW -framework OpenGL -framework AGL -framework QtGui -framework QtCore ++AR = ar cq ++RANLIB = ranlib -s ++QMAKE = /usr/bin/qmake ++TAR = tar -cf ++COMPRESS = gzip -9f ++COPY = cp -f ++SED = sed ++COPY_FILE = cp -f ++COPY_DIR = cp -f -R ++STRIP = ++INSTALL_FILE = $(COPY_FILE) ++INSTALL_DIR = $(COPY_DIR) ++INSTALL_PROGRAM = $(COPY_FILE) ++DEL_FILE = rm -f ++SYMLINK = ln -f -s ++DEL_DIR = rmdir ++MOVE = mv -f + CHK_DIR_EXISTS= test -d +-MKDIR = mkdir -p ++MKDIR = mkdir -p ++export MACOSX_DEPLOYMENT_TARGET = 10.4 + + ####### Output directory + +-OBJECTS_DIR = ./ ++OBJECTS_DIR = ./ + + ####### Files + +-HEADERS = ../include/opencsg.h \ +- opencsgConfig.h \ +- area.h \ +- batch.h \ +- context.h \ +- channelManager.h \ +- frameBufferObject.h \ +- frameBufferObjectExt.h \ +- occlusionQuery.h \ +- offscreenBuffer.h \ +- opencsgRender.h \ +- openglHelper.h \ +- pBufferTexture.h \ +- primitiveHelper.h \ +- scissorMemo.h \ +- settings.h \ +- stencilManager.h \ +- ../RenderTexture/RenderTexture.h +-SOURCES = area.cpp \ ++SOURCES = area.cpp \ + batch.cpp \ + context.cpp \ + channelManager.cpp \ +@@ -69,16 +54,14 @@ + offscreenBuffer.cpp \ + opencsgRender.cpp \ + openglHelper.cpp \ +- pBufferTexture.cpp \ + primitive.cpp \ + primitiveHelper.cpp \ + renderGoldfeather.cpp \ + renderSCS.cpp \ + scissorMemo.cpp \ + settings.cpp \ +- stencilManager.cpp \ +- ../RenderTexture/RenderTexture.cpp +-OBJECTS = area.o \ ++ stencilManager.cpp ++OBJECTS = area.o \ + batch.o \ + context.o \ + channelManager.o \ +@@ -88,81 +71,171 @@ + offscreenBuffer.o \ + opencsgRender.o \ + openglHelper.o \ +- pBufferTexture.o \ + primitive.o \ + primitiveHelper.o \ + renderGoldfeather.o \ + renderSCS.o \ + scissorMemo.o \ + settings.o \ +- stencilManager.o \ +- RenderTexture.o +-FORMS = +-UICDECLS = +-UICIMPLS = +-SRCMOC = +-OBJMOC = +-DIST = src.pro +-QMAKE_TARGET = opencsg +-DESTDIR = ../lib/ +-TARGET = libopencsg.so.1.3.0 +-TARGETA = ../lib/libopencsg.a +-TARGETD = libopencsg.so.1.3.0 +-TARGET0 = libopencsg.so +-TARGET1 = libopencsg.so.1 +-TARGET2 = libopencsg.so.1.3 ++ stencilManager.o ++DIST = /usr/local/Qt4.6/mkspecs/common/unix.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac-g++.conf \ ++ /usr/local/Qt4.6/mkspecs/qconfig.pri \ ++ /usr/local/Qt4.6/mkspecs/features/qt_functions.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt_config.prf \ ++ /usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/release.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf \ ++ /usr/local/Qt4.6/mkspecs/features/warn_on.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/opengl.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/thread.prf \ ++ /usr/local/Qt4.6/mkspecs/features/moc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/rez.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/sdk.prf \ ++ /usr/local/Qt4.6/mkspecs/features/resources.prf \ ++ /usr/local/Qt4.6/mkspecs/features/uic.prf \ ++ /usr/local/Qt4.6/mkspecs/features/yacc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/lex.prf \ ++ /usr/local/Qt4.6/mkspecs/features/include_source_dir.prf \ ++ src.pro ++QMAKE_TARGET = opencsg ++DESTDIR = ++TARGET = libopencsg.1.3.0.dylib ++TARGETA = libopencsg.a ++TARGETD = libopencsg.1.3.0.dylib ++TARGET0 = libopencsg.dylib ++TARGET1 = libopencsg.1.dylib ++TARGET2 = libopencsg.1.3.dylib ++ ++####### Custom Compiler Variables ++QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS = -pipe \ ++ -O2 \ ++ -Wall \ ++ -W \ ++ -arch \ ++ x86_64 \ ++ -Xarch_x86_64 \ ++ -mmacosx-version-min=10.5 \ ++ -arch \ ++ i386 ++ + + first: all + ####### Implicit rules + +-.SUFFIXES: .c .o .cpp .cc .cxx .C ++.SUFFIXES: .o .c .cpp .cc .cxx .C + + .cpp.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .cc.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .cxx.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .C.o: +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + + .c.o: +- $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< ++ $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + + ####### Build rules + +-all: Makefile ../lib/$(TARGET) ++all: Makefile $(TARGET) + +-../lib/$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) $(OBJCOMP) +- test -d ../lib/ || mkdir -p ../lib/ ++$(TARGET): $(OBJECTS) $(SUBLIBS) $(OBJCOMP) + -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) +- $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) $(OBJCOMP) ++ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP) + -ln -s $(TARGET) $(TARGET0) + -ln -s $(TARGET) $(TARGET1) + -ln -s $(TARGET) $(TARGET2) +- -$(DEL_FILE) ../lib/$(TARGET) +- -$(DEL_FILE) ../lib/$(TARGET0) +- -$(DEL_FILE) ../lib/$(TARGET1) +- -$(DEL_FILE) ../lib/$(TARGET2) +- -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) ../lib/ + + + + staticlib: $(TARGETA) + +-$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(OBJCOMP) ++$(TARGETA): $(OBJECTS) $(OBJCOMP) + -$(DEL_FILE) $(TARGETA) +- $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC) ++ $(AR) $(TARGETA) $(OBJECTS) ++ $(RANLIB) $(TARGETA) ++ ++Makefile: src.pro /usr/local/Qt4.6/mkspecs/macx-g++/qmake.conf /usr/local/Qt4.6/mkspecs/common/unix.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac.conf \ ++ /usr/local/Qt4.6/mkspecs/common/mac-g++.conf \ ++ /usr/local/Qt4.6/mkspecs/qconfig.pri \ ++ /usr/local/Qt4.6/mkspecs/features/qt_functions.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt_config.prf \ ++ /usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf \ ++ /usr/local/Qt4.6/mkspecs/features/release.prf \ ++ /usr/local/Qt4.6/mkspecs/features/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/default_post.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf \ ++ /usr/local/Qt4.6/mkspecs/features/warn_on.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/opengl.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/x86.prf \ ++ /usr/local/Qt4.6/mkspecs/features/qt.prf \ ++ /usr/local/Qt4.6/mkspecs/features/unix/thread.prf \ ++ /usr/local/Qt4.6/mkspecs/features/moc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/rez.prf \ ++ /usr/local/Qt4.6/mkspecs/features/mac/sdk.prf \ ++ /usr/local/Qt4.6/mkspecs/features/resources.prf \ ++ /usr/local/Qt4.6/mkspecs/features/uic.prf \ ++ /usr/local/Qt4.6/mkspecs/features/yacc.prf \ ++ /usr/local/Qt4.6/mkspecs/features/lex.prf \ ++ /usr/local/Qt4.6/mkspecs/features/include_source_dir.prf \ ++ /Library/Frameworks/QtGui.framework/QtGui.prl \ ++ /Library/Frameworks/QtCore.framework/QtCore.prl ++ $(QMAKE) -macx CONFIG+=x86\ x86_64 -o Makefile src.pro ++/usr/local/Qt4.6/mkspecs/common/unix.conf: ++/usr/local/Qt4.6/mkspecs/common/mac.conf: ++/usr/local/Qt4.6/mkspecs/common/mac-g++.conf: ++/usr/local/Qt4.6/mkspecs/qconfig.pri: ++/usr/local/Qt4.6/mkspecs/features/qt_functions.prf: ++/usr/local/Qt4.6/mkspecs/features/qt_config.prf: ++/usr/local/Qt4.6/mkspecs/features/exclusive_builds.prf: ++/usr/local/Qt4.6/mkspecs/features/default_pre.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/default_pre.prf: ++/usr/local/Qt4.6/mkspecs/features/release.prf: ++/usr/local/Qt4.6/mkspecs/features/default_post.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/default_post.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/objective_c.prf: ++/usr/local/Qt4.6/mkspecs/features/warn_on.prf: ++/usr/local/Qt4.6/mkspecs/features/unix/opengl.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/x86_64.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/x86.prf: ++/usr/local/Qt4.6/mkspecs/features/qt.prf: ++/usr/local/Qt4.6/mkspecs/features/unix/thread.prf: ++/usr/local/Qt4.6/mkspecs/features/moc.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/rez.prf: ++/usr/local/Qt4.6/mkspecs/features/mac/sdk.prf: ++/usr/local/Qt4.6/mkspecs/features/resources.prf: ++/usr/local/Qt4.6/mkspecs/features/uic.prf: ++/usr/local/Qt4.6/mkspecs/features/yacc.prf: ++/usr/local/Qt4.6/mkspecs/features/lex.prf: ++/usr/local/Qt4.6/mkspecs/features/include_source_dir.prf: ++/Library/Frameworks/QtGui.framework/QtGui.prl: ++/Library/Frameworks/QtCore.framework/QtCore.prl: ++qmake: FORCE ++ @$(QMAKE) -macx CONFIG+=x86\ x86_64 -o Makefile src.pro + + dist: +- @mkdir -p .tmp/opencsg && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/opencsg/ && ( cd `dirname .tmp/opencsg` && $(TAR) opencsg.tar opencsg && $(GZIP) opencsg.tar ) && $(MOVE) `dirname .tmp/opencsg`/opencsg.tar.gz . && $(DEL_FILE) -r .tmp/opencsg ++ @$(CHK_DIR_EXISTS) .tmp/opencsg1.3.0 || $(MKDIR) .tmp/opencsg1.3.0 ++ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/opencsg1.3.0/ && $(COPY_FILE) --parents ../include/opencsg.h opencsgConfig.h area.h batch.h context.h channelManager.h frameBufferObject.h frameBufferObjectExt.h occlusionQuery.h offscreenBuffer.h opencsgRender.h openglHelper.h primitiveHelper.h scissorMemo.h settings.h stencilManager.h .tmp/opencsg1.3.0/ && $(COPY_FILE) --parents area.cpp batch.cpp context.cpp channelManager.cpp frameBufferObject.cpp frameBufferObjectExt.cpp occlusionQuery.cpp offscreenBuffer.cpp opencsgRender.cpp openglHelper.cpp primitive.cpp primitiveHelper.cpp renderGoldfeather.cpp renderSCS.cpp scissorMemo.cpp settings.cpp stencilManager.cpp .tmp/opencsg1.3.0/ && (cd `dirname .tmp/opencsg1.3.0` && $(TAR) opencsg1.3.0.tar opencsg1.3.0 && $(COMPRESS) opencsg1.3.0.tar) && $(MOVE) `dirname .tmp/opencsg1.3.0`/opencsg1.3.0.tar.gz . && $(DEL_FILE) -r .tmp/opencsg1.3.0 ++ + +-yaccclean: +-lexclean: +-clean: ++clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + +@@ -170,44 +243,77 @@ + ####### Sub-libraries + + distclean: clean +- -$(DEL_FILE) ../lib/$(TARGET) $(TARGET) +- -$(DEL_FILE) ../lib/$(TARGET0) ../lib/$(TARGET1) ../lib/$(TARGET2) $(TARGETA) +- +- +-FORCE: ++ -$(DEL_FILE) $(TARGET) ++ -$(DEL_FILE) $(TARGET0) $(TARGET1) $(TARGET2) $(TARGETA) ++ -$(DEL_FILE) Makefile ++ ++ ++mocclean: compiler_moc_header_clean compiler_moc_source_clean ++ ++mocables: compiler_moc_header_make_all compiler_moc_source_make_all ++ ++compiler_objective_c_make_all: ++compiler_objective_c_clean: ++compiler_moc_header_make_all: ++compiler_moc_header_clean: ++compiler_rcc_make_all: ++compiler_rcc_clean: ++compiler_image_collection_make_all: qmake_image_collection.cpp ++compiler_image_collection_clean: ++ -$(DEL_FILE) qmake_image_collection.cpp ++compiler_moc_source_make_all: ++compiler_moc_source_clean: ++compiler_rez_source_make_all: ++compiler_rez_source_clean: ++compiler_uic_make_all: ++compiler_uic_clean: ++compiler_yacc_decl_make_all: ++compiler_yacc_decl_clean: ++compiler_yacc_impl_make_all: ++compiler_yacc_impl_clean: ++compiler_lex_make_all: ++compiler_lex_clean: ++compiler_clean: + + ####### Compile + + area.o: area.cpp opencsgConfig.h \ + area.h \ + openglHelper.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o area.o area.cpp + + batch.o: batch.cpp opencsgConfig.h \ + batch.h \ + primitiveHelper.h \ + area.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o batch.o batch.cpp + + context.o: context.cpp opencsgConfig.h \ + context.h \ + offscreenBuffer.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o context.o context.cpp + + channelManager.o: channelManager.cpp opencsgConfig.h \ + channelManager.h \ + offscreenBuffer.h \ + openglHelper.h \ +- settings.h \ +- area.h ++ area.h \ ++ settings.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o channelManager.o channelManager.cpp + + frameBufferObject.o: frameBufferObject.cpp opencsgConfig.h \ + frameBufferObject.h \ + offscreenBuffer.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o frameBufferObject.o frameBufferObject.cpp + + frameBufferObjectExt.o: frameBufferObjectExt.cpp opencsgConfig.h \ + frameBufferObjectExt.h \ + offscreenBuffer.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o frameBufferObjectExt.o frameBufferObjectExt.cpp + + occlusionQuery.o: occlusionQuery.cpp opencsgConfig.h \ + occlusionQuery.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o occlusionQuery.o occlusionQuery.cpp + + offscreenBuffer.o: offscreenBuffer.cpp opencsgConfig.h \ + context.h \ +@@ -215,27 +321,28 @@ + frameBufferObject.h \ + frameBufferObjectExt.h \ + pBufferTexture.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o offscreenBuffer.o offscreenBuffer.cpp + + opencsgRender.o: opencsgRender.cpp opencsgConfig.h \ + opencsgRender.h \ + primitiveHelper.h \ +- settings.h \ +- area.h ++ area.h \ ++ settings.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o opencsgRender.o opencsgRender.cpp + + openglHelper.o: openglHelper.cpp opencsgConfig.h \ + openglHelper.h \ + area.h +- +-pBufferTexture.o: pBufferTexture.cpp opencsgConfig.h \ +- pBufferTexture.h \ +- offscreenBuffer.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o openglHelper.o openglHelper.cpp + + primitive.o: primitive.cpp opencsgConfig.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o primitive.o primitive.cpp + + primitiveHelper.o: primitiveHelper.cpp opencsgConfig.h \ + openglHelper.h \ +- primitiveHelper.h \ +- area.h ++ area.h \ ++ primitiveHelper.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o primitiveHelper.o primitiveHelper.cpp + + renderGoldfeather.o: renderGoldfeather.cpp opencsgConfig.h \ + opencsgRender.h \ +@@ -243,10 +350,11 @@ + channelManager.h \ + occlusionQuery.h \ + openglHelper.h \ ++ area.h \ + primitiveHelper.h \ + scissorMemo.h \ +- stencilManager.h \ +- area.h ++ stencilManager.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o renderGoldfeather.o renderGoldfeather.cpp + + renderSCS.o: renderSCS.cpp opencsgConfig.h \ + opencsgRender.h \ +@@ -254,29 +362,57 @@ + channelManager.h \ + occlusionQuery.h \ + openglHelper.h \ ++ area.h \ + primitiveHelper.h \ +- scissorMemo.h \ +- area.h ++ scissorMemo.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o renderSCS.o renderSCS.cpp + + scissorMemo.o: scissorMemo.cpp opencsgConfig.h \ + openglHelper.h \ +- scissorMemo.h \ + area.h \ ++ scissorMemo.h \ + channelManager.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o scissorMemo.o scissorMemo.cpp + + settings.o: settings.cpp opencsgConfig.h ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o settings.o settings.cpp + + stencilManager.o: stencilManager.cpp opencsgConfig.h \ + area.h \ + openglHelper.h \ + stencilManager.h +- +-RenderTexture.o: ../RenderTexture/RenderTexture.cpp ../RenderTexture/RenderTexture.h +- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o RenderTexture.o ../RenderTexture/RenderTexture.cpp ++ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o stencilManager.o stencilManager.cpp + + ####### Install + +-install: all ++install_target: first FORCE ++ @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/ || $(MKDIR) $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/ ++ -$(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET)" ++ -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET0)" ++ -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET1)" ++ -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET2)" ++ ++uninstall_target: FORCE ++ -$(DEL_FILE) "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET)" ++ -$(DEL_FILE) "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET0)" ++ -$(DEL_FILE) "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET1)" ++ -$(DEL_FILE) "$(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/$(TARGET2)" ++ -$(DEL_DIR) $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/lib/ ++ ++ ++install_headers: first FORCE ++ @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/include/ || $(MKDIR) $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/include/ ++ -$(INSTALL_FILE) /Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/src/OpenCSG-1.3.0-patched/include/opencsg.h $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/include/ ++ + +-uninstall: ++uninstall_headers: FORCE ++ -$(DEL_FILE) -r $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/include/opencsg.h ++ -$(DEL_DIR) $(INSTALL_ROOT)/Users/kintel/code/metalab/checkout/OpenSCAD/libraries-tmp/deploy/include/ ++ ++ ++install: install_target install_headers FORCE ++ ++uninstall: uninstall_target uninstall_headers FORCE ++ ++FORCE: + diff -ru OpenCSG-1.3.0/src/channelManager.cpp OpenCSG-1.3.0-mac/src/channelManager.cpp --- OpenCSG-1.3.0/src/channelManager.cpp 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/src/channelManager.cpp 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/src/channelManager.cpp 2010-05-09 02:51:32.000000000 +0200 @@ -23,7 +23,7 @@ #include #ifdef _WIN32 @@ -96,7 +1101,7 @@ diff -ru OpenCSG-1.3.0/src/channelManager.cpp OpenCSG-1.3.0-mac/src/channelManag newOffscreenType = OpenCSG::PBuffer; diff -ru OpenCSG-1.3.0/src/frameBufferObject.h OpenCSG-1.3.0-mac/src/frameBufferObject.h --- OpenCSG-1.3.0/src/frameBufferObject.h 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/src/frameBufferObject.h 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/src/frameBufferObject.h 2010-05-09 02:51:36.000000000 +0200 @@ -79,10 +79,10 @@ /// Texture stuff @@ -111,10 +1116,9 @@ diff -ru OpenCSG-1.3.0/src/frameBufferObject.h OpenCSG-1.3.0-mac/src/frameBuffer bool initialized; }; -Only in OpenCSG-1.3.0-mac/src: frameBufferObject.h.orig diff -ru OpenCSG-1.3.0/src/occlusionQuery.cpp OpenCSG-1.3.0-mac/src/occlusionQuery.cpp --- OpenCSG-1.3.0/src/occlusionQuery.cpp 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/src/occlusionQuery.cpp 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/src/occlusionQuery.cpp 2010-05-09 02:51:40.000000000 +0200 @@ -57,7 +57,7 @@ } @@ -135,7 +1139,7 @@ diff -ru OpenCSG-1.3.0/src/occlusionQuery.cpp OpenCSG-1.3.0-mac/src/occlusionQue } diff -ru OpenCSG-1.3.0/src/openglHelper.cpp OpenCSG-1.3.0-mac/src/openglHelper.cpp --- OpenCSG-1.3.0/src/openglHelper.cpp 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/src/openglHelper.cpp 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/src/openglHelper.cpp 2010-05-09 02:51:44.000000000 +0200 @@ -29,13 +29,13 @@ GLfloat projection[16]; @@ -155,7 +1159,7 @@ diff -ru OpenCSG-1.3.0/src/openglHelper.cpp OpenCSG-1.3.0-mac/src/openglHelper.c const int dx = area.maxx - area.minx; diff -ru OpenCSG-1.3.0/src/openglHelper.h OpenCSG-1.3.0-mac/src/openglHelper.h --- OpenCSG-1.3.0/src/openglHelper.h 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/src/openglHelper.h 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/src/openglHelper.h 2010-05-09 02:51:48.000000000 +0200 @@ -36,17 +36,17 @@ // copy of the projection matrix during CSG computation extern GLfloat modelview[16]; @@ -179,7 +1183,7 @@ diff -ru OpenCSG-1.3.0/src/openglHelper.h OpenCSG-1.3.0-mac/src/openglHelper.h void scissor(const PCArea& area); diff -ru OpenCSG-1.3.0/src/pBufferTexture.h OpenCSG-1.3.0-mac/src/pBufferTexture.h --- OpenCSG-1.3.0/src/pBufferTexture.h 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/src/pBufferTexture.h 2010-02-09 10:49:30.000000000 +0100 ++++ OpenCSG-1.3.0-mac/src/pBufferTexture.h 2010-05-09 02:51:53.000000000 +0200 @@ -22,7 +22,7 @@ #ifndef __OpenCSG__pbuffer_texture_h__ @@ -217,33 +1221,44 @@ diff -ru OpenCSG-1.3.0/src/pBufferTexture.h OpenCSG-1.3.0-mac/src/pBufferTexture +#endif // __APPLE__ #endif // __OpenCSG__frame_buffer_object_h__ -Only in OpenCSG-1.3.0-mac/src: pBufferTexture.h.orig diff -ru OpenCSG-1.3.0/src/src.pro OpenCSG-1.3.0-mac/src/src.pro --- OpenCSG-1.3.0/src/src.pro 2010-02-06 21:35:10.000000000 +0100 -+++ OpenCSG-1.3.0-mac/src/src.pro 2010-02-09 10:49:30.000000000 +0100 -@@ -1,10 +1,19 @@ ++++ OpenCSG-1.3.0-mac/src/src.pro 2010-05-09 02:51:57.000000000 +0200 +@@ -1,10 +1,31 @@ TEMPLATE = lib TARGET = opencsg VERSION = 1.3.0 -DESTDIR = ../lib -+DESTDIR = $$(PWD)/lib CONFIG += opengl warn_on release -INCLUDEPATH += ../include ../glew/include ../ +INCLUDEPATH += ../include ../ + -+macx { -+ INCLUDEPATH += /opt/local/include -+ LIBS += -L/opt/local/lib -lGLEW ++# Optionally specify deployment location using the ++# MACOSX_DEPLOY_DIR env. variable ++DEPLOYDIR = $$(MACOSX_DEPLOY_DIR) ++ ++!isEmpty(DEPLOYDIR) { ++ message("Deploy") ++ INSTALLDIR = $$(MACOSX_DEPLOY_DIR) ++ INCLUDEPATH += $$(MACOSX_DEPLOY_DIR)/include ++ LIBS += -L$$(MACOSX_DEPLOY_DIR)/lib -lGLEW + CONFIG += absolute_library_soname ++ headers.files = ../include/opencsg.h ++ headers.path = $$INSTALLDIR/include ++ INSTALLS += target headers ++ target.path = $$INSTALLDIR/lib +} +else { -+INCLUDEPATH += ../glew/include ++ DESTDIR = ../lib ++ INCLUDEPATH += ../glew/include ++ INSTALLS += target ++ target.path = $$DESTDIR +} HEADERS = ../include/opencsg.h \ opencsgConfig.h \ -@@ -18,12 +27,11 @@ +@@ -18,12 +39,11 @@ offscreenBuffer.h \ opencsgRender.h \ openglHelper.h \ @@ -258,7 +1273,7 @@ diff -ru OpenCSG-1.3.0/src/src.pro OpenCSG-1.3.0-mac/src/src.pro SOURCES = area.cpp \ batch.cpp \ context.cpp \ -@@ -34,12 +42,21 @@ +@@ -34,12 +54,18 @@ offscreenBuffer.cpp \ opencsgRender.cpp \ openglHelper.cpp \ @@ -280,6 +1295,3 @@ diff -ru OpenCSG-1.3.0/src/src.pro OpenCSG-1.3.0-mac/src/src.pro + SOURCES += ../RenderTexture/RenderTexture.cpp \ + pBufferTexture.cpp +} -+ -+INSTALLS += target -+target.path = $$DESTDIR -- cgit v0.10.1 From b88eeb8cfe3dc254b744426a768b9b5d99c1b623 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 May 2010 01:56:03 +0000 Subject: Build all dependencies in one go with current architectures and compatibility modes git-svn-id: http://svn.clifford.at/openscad/trunk@538 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh new file mode 100755 index 0000000..4e33493 --- /dev/null +++ b/scripts/macosx-build-dependencies.sh @@ -0,0 +1,136 @@ +#!/bin/sh +# +# This script builds all library dependencies of OpenSCAD for Mac OS X. +# The libraries will be build in 32- and 64-bit mode and backwards compatible with +# 10.5 "Leopard". +# +# Usage: +# - Edit the BASEDIR variable. This is where libraries will be built and installed +# - Edit the OPENSCADDIR variable. This is where patches are fetched from +# +# Prerequisites: +# - MacPorts: curl eigen +# - Qt4 +# +# FIXME: +# o Verbose option +# o Port to other platforms? +# + +BASEDIR=/Users/kintel/code/metalab/checkout/OpenSCAD/libraries +OPENSCADDIR=/Users/kintel/code/metalab/checkout/OpenSCAD/openscad-release +SRCDIR=$BASEDIR/src +DEPLOYDIR=$BASEDIR/deploy + +build_gmp() +{ + version=$1 + echo "Building gmp" $version "..." + cd $BASEDIR/src + rm -rf gmp* + curl -O ftp://ftp.gmplib.org/pub/gmp-$version/gmp-$version.tar.bz2 + tar xjf gmp-$version.tar.bz2 + cd gmp-$version + mkdir build-i386 + cd build-i386 + ../configure --prefix=$DEPLOYDIR "CFLAGS=-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" ABI=32 --libdir=$DEPLOYDIR/lib-i386 + make install + cd .. + mkdir build-x86_64 + cd build-x86_64 + ../configure --prefix=$DEPLOYDIR "CFLAGS=-mmacosx-version-min=10.5" LDFLAGS="-mmacosx-version-min=10.5" --libdir=$DEPLOYDIR/lib-x86_64 + make install + cd $DEPLOYDIR + mkdir -p lib + lipo -create lib-i386/libgmp.dylib lib-x86_64/libgmp.dylib -output lib/libgmp.dylib + install_name_tool -id $DEPLOYDIR/lib/libgmp.dylib lib/libgmp.dylib +} + +build_mpfr() +{ + version=$1 + echo "Building mpfr" $version "..." + cd $BASEDIR/src + rm -rf mpfr* + curl -O http://www.mpfr.org/mpfr-current/mpfr-$version.tar.bz2 + tar xjf mpfr-$version.tar.bz2 + cd mpfr-$version + mkdir build-i386 + cd build-i386 + ../configure --prefix=$DEPLOYDIR --with-gmp=$DEPLOYDIR CFLAGS="-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" --libdir=$DEPLOYDIR/lib-i386 + make install + cd .. + mkdir build-x86_64 + cd build-x86_64 + ../configure --prefix=$DEPLOYDIR --with-gmp=$DEPLOYDIR CFLAGS="-mmacosx-version-min=10.5 -arch x86_64" LDFLAGS="-mmacosx-version-min=10.5 -arch x86_64" --libdir=$DEPLOYDIR/lib-x86_64 + make install + cd $DEPLOYDIR + lipo -create lib-i386/libmpfr.dylib lib-x86_64/libmpfr.dylib -output lib/libmpfr.dylib + install_name_tool -id $DEPLOYDIR/lib/libmpfr.dylib lib/libmpfr.dylib +} + + +build_boost() +{ + version=$1 + bversion=`echo $version | tr "." "_"` + echo "Building boost::thread" $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 + ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread + ./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 +} + +build_cgal() +{ + version=$1 + echo "Building CGAL" $version "..." + cd $BASEDIR/src + curl -O https://gforge.inria.fr/frs/download.php/26688/CGAL-$version.tar.gz + tar xzf CGAL-$version.tar.gz + cd CGAL-$version + cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" + make -j4 + make install +} + +build_glew() +{ + version=$1 + echo "Building GLEW" $version "..." + cd $BASEDIR/src + curl -LO http://downloads.sourceforge.net/project/glew/glew/$version/glew-$version.tgz + tar xzf glew-$version.tgz + cd glew-$version + mkdir -p $DEPLOYDIR/lib/pkgconfig + # To avoid running strip on a fat archive as this is not supported by strip + sed -i bak -e "s/\$(STRIP) -x lib\/\$(LIB.STATIC)//" Makefile + make GLEW_DEST=$DEPLOYDIR CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=10.5 -arch i386 -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" install +} + +build_opencsg() +{ + version=$1 + echo "Building OpenCSG" $version "..." + cd $BASEDIR/src + curl -O http://www.opencsg.org/OpenCSG-$version.tar.gz + tar xzf OpenCSG-$version.tar.gz + cd OpenCSG-$version + patch -p1 < $OPENSCADDIR/patches/OpenCSG-$version-MacOSX-port.patch + MACOSX_DEPLOY_DIR=$DEPLOYDIR qmake -r CONFIG+="x86 x86_64" + make install +} + +echo "Using basedir:" $BASEDIR +mkdir -p $SRCDIR $DEPLOYDIR +build_gmp 5.0.1 +build_mpfr 2.4.2 +build_boost 1.43.0 +build_cgal 3.6 +build_glew 1.5.4 +build_opencsg 1.3.0 -- cgit v0.10.1 From 408c3975db1ee5ab328d38187f637496a464a716 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 May 2010 01:56:39 +0000 Subject: minor update - most will be gone when the script is verified git-svn-id: http://svn.clifford.at/openscad/trunk@539 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/checklist-macosx.txt b/doc/checklist-macosx.txt index f9cb4e6..0f79e10 100644 --- a/doc/checklist-macosx.txt +++ b/doc/checklist-macosx.txt @@ -12,6 +12,7 @@ o Qt4 o Build gmp + curl -O ftp://ftp.gmplib.org/pub/gmp-5.0.1/gmp-5.0.1.tar.bz2 tar xjz gmp-5.0.1.tar.bz2 cd gmp-5.0.1 mkdir build-i386 @@ -26,8 +27,11 @@ o Build gmp cd ../../../deploy lipo -create lib-i386/libgmp.dylib lib-x86_64/libgmp.dylib -output lib/libgmp.dylib install_name_tool -id $PWD/lib/libgmp.dylib lib/libgmp.dylib + cd ../src o Build mpfr + + curl -O http://www.mpfr.org/mpfr-current/mpfr-2.4.2.tar.bz2 tar xjz mpfr-2.4.2.tar.bz2 cd mpfr-2.4.2 mkdir build-i386 @@ -42,39 +46,49 @@ o Build mpfr cd ../../../deploy lipo -create lib-i386/libmpfr.dylib lib-x86_64/libmpfr.dylib -output lib/libmpfr.dylib install_name_tool -id $PWD/lib/libmpfr.dylib lib/libmpfr.dylib + cd ../src o Build boost::thread + + curl -O http://downloads.sourceforge.net/project/boost/boost/1.42.0/boost_1_42_0.tar.bz2 tar xjz boost_1_42_0.tar.bz2 cd boost_1_42_0 ./bootstrap.sh --prefix=$PWD/../../deploy --with-libraries=thread ./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 $PWD/../../deploy/lib/libboost_thread.dylib /Users/kintel/code/metalab/checkout/OpenSCAD/libraries/deploy/lib/libboost_thread.dylib + cd .. o Build CGAL >= 3.5 + curl -O https://gforge.inria.fr/frs/download.php/26688/CGAL-3.6.tar.gz tar xzf CGAL-3.6.tar.gz cd CGAL-3.6 cmake -DCMAKE_INSTALL_PREFIX=$PWD/../../deploy -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" make -j4 make install + cd .. o Patch & build GLEW + curl -LO http://downloads.sourceforge.net/project/glew/glew/1.5.4/glew-1.5.4.tgz tar xzf glew-1.5.3.tar.gz cd glew-1.5.3 patch -p1 < ../openscad/patches/glew-1.5.3-MacOSX.patch mkdir ../../deploy/lib/pkgconfig make GLEW_DEST=$PWD/../../deploy CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=10.5 -arch i386 -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" install + cd .. o Patch and build OpenCSG >= 1.3.0 + curl -O http://www.opencsg.org/OpenCSG-1.3.0.tar.gz FIXME: Update patch tar xzf OpenCSG-1.3.0.tar.gz cd OpenCSG-1.3.0 patch -p1 < ../openscad/patches/OpenCSG-1.3.0-MacOSX-port.patch MACOSX_DEPLOY_DIR=$PWD/../../deploy qmake -r CONFIG+="x86 x86_64" make install + cd .. o Build and Deploy OpenSCAD -- cgit v0.10.1 From a3569b8da48834c54c2184444d137a4fabd39dad Mon Sep 17 00:00:00 2001 From: clifford Date: Sun, 9 May 2010 13:27:05 +0000 Subject: Clifford Wolf: Added "Design -> Automatic Reload and Compile" (for use with external editor) git-svn-id: http://svn.clifford.at/openscad/trunk@540 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/MainWindow.h b/src/MainWindow.h index 9eb1748..6b15889 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -24,6 +24,9 @@ public: QTimer *animate_timer; double tval, fps, fsteps; + QTimer *autoReloadTimer; + QString autoReloadInfo; + Context root_ctx; AbstractModule *root_module; // Result of parsing ModuleInstantiation root_inst; // Top level instance @@ -145,6 +148,8 @@ public slots: void helpManual(); void quit(); void actionReloadCompile(); + void checkAutoReload(); + void autoReloadSet(bool); }; #endif diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 03f8e2d..f61d240 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -23,7 +23,7 @@ Qt::Horizontal - + Monaco @@ -168,6 +168,7 @@ &Design + @@ -642,6 +643,14 @@ OpenSCAD Homepage + + + true + + + Automatic Reload and Compile + + @@ -650,6 +659,11 @@
GLView.h
1
+ + Editor + QWidget +
editor.h
+
diff --git a/src/mainwin.cc b/src/mainwin.cc index 72b3d7a..cdd7c6f 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -71,9 +71,14 @@ #include "qformatscheme.h" #include "qlanguagefactory.h" #endif + //for chdir #include +// for stat() +#include +#include + #ifdef ENABLE_CGAL #if 1 @@ -178,6 +183,10 @@ MainWindow::MainWindow(const QString &filename) animate_timer = new QTimer(this); connect(animate_timer, SIGNAL(timeout()), this, SLOT(updateTVal())); + autoReloadTimer = new QTimer(this); + autoReloadTimer->setSingleShot(false); + connect(autoReloadTimer, SIGNAL(timeout()), this, SLOT(checkAutoReload())); + connect(e_tval, SIGNAL(textChanged(QString)), this, SLOT(actionCompile())); connect(e_fps, SIGNAL(textChanged(QString)), this, SLOT(updatedFps())); @@ -242,6 +251,7 @@ MainWindow::MainWindow(const QString &filename) connect(this->editActionPreferences, SIGNAL(triggered()), this, SLOT(preferences())); // Design menu + connect(this->designActionAutoReload, SIGNAL(toggled(bool)), this, SLOT(autoReloadSet(bool))); connect(this->designActionReloadAndCompile, SIGNAL(triggered()), this, SLOT(actionReloadCompile())); connect(this->designActionCompile, SIGNAL(triggered()), this, SLOT(actionCompile())); #ifdef ENABLE_CGAL @@ -959,6 +969,28 @@ void MainWindow::pasteViewportRotation() cursor.insertText(txt); } +void MainWindow::checkAutoReload() +{ + QString new_stinfo; + struct stat st; + memset(&st, 0, sizeof(struct stat)); + stat(this->fileName.toAscii().data(), &st); + new_stinfo.sprintf("%x.%x", (int)st.st_mtime, (int)st.st_size); + if (new_stinfo != autoReloadInfo) + actionReloadCompile(); + autoReloadInfo = new_stinfo; +} + +void MainWindow::autoReloadSet(bool on) +{ + if (on) { + autoReloadInfo = QString(); + autoReloadTimer->start(200); + } else { + autoReloadTimer->stop(); + } +} + void MainWindow::actionReloadCompile() { if (editor->isContentModified()) { @@ -968,6 +1000,7 @@ void MainWindow::actionReloadCompile() "Do you really want to reload the file?", QMessageBox::Yes | QMessageBox::No); if (ret != QMessageBox::Yes) { + designActionAutoReload->setChecked(false); return; } } -- cgit v0.10.1 From 069dff81401ea8d549e576d18996a0571f5c669c Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 10 May 2010 17:42:27 +0000 Subject: Autorun sanity check before publising git-svn-id: http://svn.clifford.at/openscad/trunk@541 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-sanity-check.py b/scripts/macosx-sanity-check.py index a085bda..c9fcb5d 100755 --- a/scripts/macosx-sanity-check.py +++ b/scripts/macosx-sanity-check.py @@ -4,6 +4,8 @@ # This is be used to verify that all the dependant libraries of a Mac OS X executable # are present and that they are backwards compatible with at least 10.5. # Run with an executable as parameter +# Will return 0 if the executable an all libraries are OK +# Returns != 0 and prints some textural description on error # # Author: Marius Kintel # @@ -82,6 +84,7 @@ def validate_lib(lib): return True if __name__ == '__main__': + error = False if len(sys.argv) != 2: usage() executable = sys.argv[1] if DEBUG: print "Processing " + executable @@ -113,3 +116,6 @@ if __name__ == '__main__': # print " " + str(processed[dep]) if not validate_lib(dep): print "..required by " + str(processed[dep]) + error = True + if error: sys.exit(1) + else: sys.exit(0) diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index 51d890e..684a601 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -9,6 +9,10 @@ export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy if [[ $? != 0 ]]; then exit 1 fi +`dirname $0`/macosx-sanity-check.py OpenSCAD.app/Contents/MacOS/OpenSCAD +if [[ $? != 0 ]]; then + exit 1 +fi cp OpenSCAD-$VERSION.dmg ~/Documents/Dropbox/Public ln -sf OpenSCAD-$VERSION.dmg ~/Documents/Dropbox/Public/OpenSCAD-latest.dmg -- cgit v0.10.1 From d9b08b16595c9cb325874f0271e567e8a310eaf7 Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 10 May 2010 17:43:42 +0000 Subject: Use DEPLOYDIR independant of deploy config git-svn-id: http://svn.clifford.at/openscad/trunk@542 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/cgal.pri b/cgal.pri index 0c1fd30..23f0c8c 100644 --- a/cgal.pri +++ b/cgal.pri @@ -1,7 +1,7 @@ cgal { DEFINES += ENABLE_CGAL - !deploy { + isEmpty(DEPLOYDIR) { # Optionally specify location of CGAL using the # CGALDIR env. variable CGAL_DIR = $$(CGALDIR) diff --git a/glew.pri b/glew.pri index 67ed68f..189b953 100644 --- a/glew.pri +++ b/glew.pri @@ -1,5 +1,5 @@ glew { - !deploy { + isEmpty(DEPLOYDIR) { # Optionally specify location of GLEW using the # GLEWDIR env. variable GLEW_DIR = $$(GLEWDIR) diff --git a/opencsg.pri b/opencsg.pri index a3b70f7..8538f99 100644 --- a/opencsg.pri +++ b/opencsg.pri @@ -6,7 +6,7 @@ opencsg { HEADERS += src/render-opencsg.h SOURCES += src/render-opencsg.cc - !deploy { + isEmpty(DEPLOYDIR) { # Optionally specify location of OpenCSG using the # OPENCSGDIR env. variable OPENCSG_DIR = $$(OPENCSGDIR) diff --git a/openscad.pro b/openscad.pro index e5c740a..42a5d22 100644 --- a/openscad.pro +++ b/openscad.pro @@ -10,15 +10,15 @@ RCC_DIR = objects INCLUDEPATH += src macx { + DEPLOYDIR = $$(MACOSX_DEPLOY_DIR) + !isEmpty(DEPLOYDIR) { + INCLUDEPATH += $$DEPLOYDIR/include + LIBS += -L$$DEPLOYDIR/lib + } # add CONFIG+=deploy to the qmake command-line to make a deployment build deploy { message("Building deployment version") CONFIG += x86 x86_64 - DEPLOYDIR = $$(MACOSX_DEPLOY_DIR) - !isEmpty(DEPLOYDIR) { - INCLUDEPATH += $$DEPLOYDIR/include - LIBS += -L$$DEPLOYDIR/lib - } } TARGET = OpenSCAD -- cgit v0.10.1 From 677211b4c603866f848c8714d1dd4290760709fa Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 10 May 2010 17:43:45 +0000 Subject: use script-built libs for now git-svn-id: http://svn.clifford.at/openscad/trunk@543 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/setenv_mjau.sh b/setenv_mjau.sh index 5a1adb0..e00512a 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -1,7 +1,7 @@ export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy export DYLD_LIBRARY_PATH=$MACOSX_DEPLOY_DIR/lib -export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 -export CGALDIR=$PWD/../install/CGAL-3.6 -export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install -export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib +#export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 +#export CGALDIR=$PWD/../install/CGAL-3.6 +#export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install +#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib -- cgit v0.10.1 From 4a935570fc4cc929691293a44b2afcf6695c2654 Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 10 May 2010 18:14:09 +0000 Subject: sync git-svn-id: http://svn.clifford.at/openscad/trunk@544 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index b6643c4..7ec5a9e 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -20,6 +20,7 @@ o union() { USER INTERFACE -------------- o Preferences + - Remember settings done in menus between sessions (automatic reload, perspective, show*, hide*) - Beautify color schemes - Color schemes read from file - Color scheme editor -- cgit v0.10.1 From f715d7cbfa1c97aa2f8339c711e2ad27391ae1d1 Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 10 May 2010 18:14:12 +0000 Subject: bugfix: Don't normalize zero-length normals git-svn-id: http://svn.clifford.at/openscad/trunk@545 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/export.cc b/src/export.cc index d63188a..40573c5 100644 --- a/src/export.cc +++ b/src/export.cc @@ -120,9 +120,12 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * double nx = (y1-y2)*(z1-z3) - (z1-z2)*(y1-y3); double ny = (z1-z2)*(x1-x3) - (x1-x2)*(z1-z3); double nz = (x1-x2)*(y1-y3) - (y1-y2)*(x1-x3); - double n_scale = 1 / sqrt(nx*nx + ny*ny + nz*nz); + double nlength = sqrt(nx*nx + ny*ny + nz*nz); + // Avoid generating normals for polygons with zero area + double eps = 0.000001; + if (nlength < eps) nlength = 1.0; fprintf(f, " facet normal %f %f %f\n", - nx * n_scale, ny * n_scale, nz * n_scale); + nx / nlength, ny / nlength, nz / nlength); fprintf(f, " outer loop\n"); fprintf(f, " vertex %s\n", vs1.toAscii().data()); fprintf(f, " vertex %s\n", vs2.toAscii().data()); -- cgit v0.10.1 From 5e0a00c8d082abb0e7dde2a178ac4ab9a7a89a35 Mon Sep 17 00:00:00 2001 From: clifford Date: Thu, 27 May 2010 07:50:59 +0000 Subject: Clifford Wolf: Release prep git-svn-id: http://svn.clifford.at/openscad/trunk@546 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/RELEASE_NOTES b/RELEASE_NOTES index be07670..c33f7b8 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,8 +1,7 @@ -OpenSCAD 2010.03 +OpenSCAD 2010.05 ================ - .. ADD STUFF HERE .. o Added functions and statements - Added abs() function - Added exp(x), log(b, x), log(x) and ln(x) functions diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index 684a601..77e5ef5 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -1,7 +1,7 @@ #!/bin/sh -VERSION=`date "+%Y.%m.%d"` -#VERSION=2010.02 +#VERSION=`date "+%Y.%m.%d"` +VERSION=2010.05 export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy diff --git a/scripts/release-linux.sh b/scripts/release-linux.sh index 2de7b86..49c3880 100755 --- a/scripts/release-linux.sh +++ b/scripts/release-linux.sh @@ -1,7 +1,8 @@ #!/bin/bash # WARNING: This script might only work with the authors setup... -VERSION=2010.02 +#VERSION=`date "+%Y.%m.%d"` +VERSION=2010.05 set -ex -- cgit v0.10.1 From 5234cb9c31fc4fb83135c8d6953f667bf6c2e6df Mon Sep 17 00:00:00 2001 From: clifford Date: Thu, 27 May 2010 07:53:35 +0000 Subject: Clifford Wolf: Post release stuff git-svn-id: http://svn.clifford.at/openscad/trunk@548 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/RELEASE_NOTES b/RELEASE_NOTES index c33f7b8..51b20ee 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,4 +1,9 @@ +OpenSCAD 2010.06 +================ + +... add stuff here ... + OpenSCAD 2010.05 ================ diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index 77e5ef5..95062ac 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -1,7 +1,7 @@ #!/bin/sh -#VERSION=`date "+%Y.%m.%d"` -VERSION=2010.05 +VERSION=`date "+%Y.%m.%d"` +#VERSION=2010.05 export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy diff --git a/scripts/release-linux.sh b/scripts/release-linux.sh index 49c3880..8f532e0 100755 --- a/scripts/release-linux.sh +++ b/scripts/release-linux.sh @@ -1,8 +1,8 @@ #!/bin/bash # WARNING: This script might only work with the authors setup... -#VERSION=`date "+%Y.%m.%d"` -VERSION=2010.05 +VERSION=`date "+%Y.%m.%d"` +#VERSION=2010.05 set -ex -- cgit v0.10.1 From 438825a30869db8c18eef51ec1abf458d3121573 Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 27 May 2010 10:28:41 +0000 Subject: Added note about minkowski exception git-svn-id: http://svn.clifford.at/openscad/trunk@549 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index 7ec5a9e..337f5c5 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -16,6 +16,7 @@ o union() { linear_extrude(height=10, twist=90) circle(5); translate([7,-5,0]) linear_extrude(height=10, twist=180) polygon(points = [[0,0], [10,0], [5,10]]); } +o non-convex minkowski example from chrysn fails with an exception USER INTERFACE -------------- -- cgit v0.10.1 From f8a3ce8862ffa9c6a37c6ba95591962b926ef998 Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 27 May 2010 23:16:23 +0000 Subject: Added create-stl.sh git-svn-id: http://svn.clifford.at/openscad/trunk@550 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/batch-examples-stl.sh b/scripts/batch-examples-stl.sh index 9c9f5e2..c8c3659 100755 --- a/scripts/batch-examples-stl.sh +++ b/scripts/batch-examples-stl.sh @@ -1,12 +1,9 @@ #!/bin/sh -cmd="openscad" -[ -x "./openscad" ] && cmd="./openscad" -[ -x "./OpenSCAD.app/Contents/MacOS/OpenSCAD" ] && cmd="./OpenSCAD.app/Contents/MacOS/OpenSCAD" +SCRIPTDIR=`dirname $0` mkdir -p output for f in examples/*.scad; do echo `basename $f .scad` - "$cmd" -s output/`basename $f .scad`.stl $f + $SCRIPTDIR/create-stl.sh $f output/`basename $f .scad`.stl done - diff --git a/scripts/create-stl.sh b/scripts/create-stl.sh new file mode 100755 index 0000000..cd296bf --- /dev/null +++ b/scripts/create-stl.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ $# != 2 ]; then + echo "Usage: $0 scad-file stl-file" + exit 1 +fi +scadfile=$1 +stlfile=$2 + +cmd="openscad" +[ -x "./openscad" ] && cmd="./openscad" +[ -x "./OpenSCAD.app/Contents/MacOS/OpenSCAD" ] && cmd="./OpenSCAD.app/Contents/MacOS/OpenSCAD" + +"$cmd" -s $stlfile $scadfile -- cgit v0.10.1 From b82bf6b9cb00483dc2467a19a5e5ad41c6444906 Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 27 May 2010 23:16:49 +0000 Subject: Fail correctly on library not found git-svn-id: http://svn.clifford.at/openscad/trunk@551 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-sanity-check.py b/scripts/macosx-sanity-check.py index c9fcb5d..243020f 100755 --- a/scripts/macosx-sanity-check.py +++ b/scripts/macosx-sanity-check.py @@ -103,6 +103,7 @@ if __name__ == '__main__': if absfile == None: print "Not found: " + d print " ..required by " + str(processed[dep]) + error = True continue if absfile in processed: processed[absfile].append(dep) -- cgit v0.10.1 From 4821ea2f5b10e8cca89c261ee8061ec1decd0715 Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 27 May 2010 23:17:25 +0000 Subject: Fixed problems in fat binary build of libgmp and libmpfr git-svn-id: http://svn.clifford.at/openscad/trunk@552 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 4e33493..630b067 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -20,8 +20,14 @@ BASEDIR=/Users/kintel/code/metalab/checkout/OpenSCAD/libraries OPENSCADDIR=/Users/kintel/code/metalab/checkout/OpenSCAD/openscad-release SRCDIR=$BASEDIR/src -DEPLOYDIR=$BASEDIR/deploy +DEPLOYDIR=$BASEDIR/install +# Hack warning: gmplib is built separately in 32-bit and 64-bit mode +# and then merged afterwards. Somehow, gmplib's header files appear +# to be dependant on the CPU architecture on which configure was +# run. Not nice, but as long as we also build mpfr in two separate +# steps and nobody else uses these architecture-dependent macros, we +# should be fine. build_gmp() { version=$1 @@ -31,21 +37,32 @@ build_gmp() curl -O ftp://ftp.gmplib.org/pub/gmp-$version/gmp-$version.tar.bz2 tar xjf gmp-$version.tar.bz2 cd gmp-$version + # 32-bit version mkdir build-i386 cd build-i386 - ../configure --prefix=$DEPLOYDIR "CFLAGS=-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" ABI=32 --libdir=$DEPLOYDIR/lib-i386 + ../configure --prefix=$DEPLOYDIR/i386 "CFLAGS=-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" ABI=32 --enable-cxx make install cd .. + # 64-bit version mkdir build-x86_64 cd build-x86_64 - ../configure --prefix=$DEPLOYDIR "CFLAGS=-mmacosx-version-min=10.5" LDFLAGS="-mmacosx-version-min=10.5" --libdir=$DEPLOYDIR/lib-x86_64 + ../configure --prefix=$DEPLOYDIR/x86_64 "CFLAGS=-mmacosx-version-min=10.5" LDFLAGS="-mmacosx-version-min=10.5" --enable-cxx make install + + # merge cd $DEPLOYDIR mkdir -p lib - lipo -create lib-i386/libgmp.dylib lib-x86_64/libgmp.dylib -output lib/libgmp.dylib + lipo -create i386/lib/libgmp.dylib x86_64/lib/libgmp.dylib -output lib/libgmp.dylib install_name_tool -id $DEPLOYDIR/lib/libgmp.dylib lib/libgmp.dylib + cp lib/libgmp.dylib i386/lib/ + cp lib/libgmp.dylib x86_64/lib/ + mkdir -p include + cp x86_64/include/gmp.h include/ + cp x86_64/include/gmpxx.h include/ } +# As with gmplib, mpfr is built separately in 32-bit and 64-bit mode and then merged +# afterwards. build_mpfr() { version=$1 @@ -55,18 +72,27 @@ build_mpfr() curl -O http://www.mpfr.org/mpfr-current/mpfr-$version.tar.bz2 tar xjf mpfr-$version.tar.bz2 cd mpfr-$version + + # 32-bit version mkdir build-i386 cd build-i386 - ../configure --prefix=$DEPLOYDIR --with-gmp=$DEPLOYDIR CFLAGS="-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" --libdir=$DEPLOYDIR/lib-i386 + ../configure --prefix=$DEPLOYDIR/i386 --with-gmp=$DEPLOYDIR/i386 CFLAGS="-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" make install cd .. + + # 64-bit version mkdir build-x86_64 cd build-x86_64 - ../configure --prefix=$DEPLOYDIR --with-gmp=$DEPLOYDIR CFLAGS="-mmacosx-version-min=10.5 -arch x86_64" LDFLAGS="-mmacosx-version-min=10.5 -arch x86_64" --libdir=$DEPLOYDIR/lib-x86_64 + ../configure --prefix=$DEPLOYDIR/x86_64 --with-gmp=$DEPLOYDIR/x86_64 CFLAGS="-mmacosx-version-min=10.5 -arch x86_64" LDFLAGS="-mmacosx-version-min=10.5 -arch x86_64" make install + + # merge cd $DEPLOYDIR - lipo -create lib-i386/libmpfr.dylib lib-x86_64/libmpfr.dylib -output lib/libmpfr.dylib + lipo -create i386/lib/libmpfr.dylib x86_64/lib/libmpfr.dylib -output lib/libmpfr.dylib install_name_tool -id $DEPLOYDIR/lib/libmpfr.dylib lib/libmpfr.dylib + mkdir -p include + cp x86_64/include/mpfr.h include/ + cp x86_64/include/mpf2mpfr.h include/ } @@ -80,6 +106,7 @@ build_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 ./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 @@ -94,6 +121,7 @@ build_cgal() curl -O https://gforge.inria.fr/frs/download.php/26688/CGAL-$version.tar.gz tar xzf CGAL-$version.tar.gz cd CGAL-$version + # We build a static lib. Not really necessary, but it's well tested. cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" make -j4 make install -- cgit v0.10.1 From fa7f34ccdf953a2fc54b1eb9e6b702d652d7350b Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 27 May 2010 23:18:08 +0000 Subject: Minor adaptations and verbosity git-svn-id: http://svn.clifford.at/openscad/trunk@553 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index 95062ac..b01d7f0 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -3,12 +3,15 @@ VERSION=`date "+%Y.%m.%d"` #VERSION=2010.05 -export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy +# This is the same location as DEPLOYDIR in macosx-build-dependencies.sh +export MACOSX_DEPLOY_DIR=$PWD/../libraries/install `dirname $0`/release-common.sh -v $VERSION if [[ $? != 0 ]]; then exit 1 fi + +echo "Sanity check of the app bundle..." `dirname $0`/macosx-sanity-check.py OpenSCAD.app/Contents/MacOS/OpenSCAD if [[ $? != 0 ]]; then exit 1 -- cgit v0.10.1 From 4129061198b23197aaa263c53b9bafdad28c3d34 Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 27 May 2010 23:18:31 +0000 Subject: Use automatic build script for dependencied from now on git-svn-id: http://svn.clifford.at/openscad/trunk@554 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/checklist-macosx.txt b/doc/checklist-macosx.txt index 0f79e10..ff1c7ea 100644 --- a/doc/checklist-macosx.txt +++ b/doc/checklist-macosx.txt @@ -10,88 +10,11 @@ o Qt4 - Download and install the combined 32-bit and 64-bit build for 10.5-10.6 from here: http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x -o Build gmp +o Build dependencies from source - curl -O ftp://ftp.gmplib.org/pub/gmp-5.0.1/gmp-5.0.1.tar.bz2 - tar xjz gmp-5.0.1.tar.bz2 - cd gmp-5.0.1 - mkdir build-i386 - cd build-i386 - ../configure --prefix=$PWD/../../../deploy "CFLAGS=-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" ABI=32 --libdir=$PWD/../../../deploy/lib-i386 - make install - cd .. - mkdir build-x86_64 - cd build-x86_64 - ../configure --prefix=$PWD/../../../deploy "CFLAGS=-mmacosx-version-min=10.5" LDFLAGS="-mmacosx-version-min=10.5" --libdir=$PWD/../../../deploy/lib-x86_64 - make install - cd ../../../deploy - lipo -create lib-i386/libgmp.dylib lib-x86_64/libgmp.dylib -output lib/libgmp.dylib - install_name_tool -id $PWD/lib/libgmp.dylib lib/libgmp.dylib - cd ../src - -o Build mpfr - - curl -O http://www.mpfr.org/mpfr-current/mpfr-2.4.2.tar.bz2 - tar xjz mpfr-2.4.2.tar.bz2 - cd mpfr-2.4.2 - mkdir build-i386 - cd build-i386 - ../configure --prefix=$PWD/../../../deploy --with-gmp=$PWD/../../../deploy CFLAGS="-mmacosx-version-min=10.5 -arch i386" LDFLAGS="-mmacosx-version-min=10.5 -arch i386" --libdir=$PWD/../../../deploy/lib-i386 - make install - cd .. - mkdir build-x86_64 - cd build-x86_64 - ../configure --prefix=$PWD/../../../deploy --with-gmp=$PWD/../../../deploy CFLAGS="-mmacosx-version-min=10.5 -arch x86_64" LDFLAGS="-mmacosx-version-min=10.5 -arch x86_64" --libdir=$PWD/../../../deploy/lib-x86_64 - make install - cd ../../../deploy - lipo -create lib-i386/libmpfr.dylib lib-x86_64/libmpfr.dylib -output lib/libmpfr.dylib - install_name_tool -id $PWD/lib/libmpfr.dylib lib/libmpfr.dylib - cd ../src - -o Build boost::thread - - curl -O http://downloads.sourceforge.net/project/boost/boost/1.42.0/boost_1_42_0.tar.bz2 - tar xjz boost_1_42_0.tar.bz2 - cd boost_1_42_0 - ./bootstrap.sh --prefix=$PWD/../../deploy --with-libraries=thread - ./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 $PWD/../../deploy/lib/libboost_thread.dylib /Users/kintel/code/metalab/checkout/OpenSCAD/libraries/deploy/lib/libboost_thread.dylib - cd .. - -o Build CGAL >= 3.5 - - curl -O https://gforge.inria.fr/frs/download.php/26688/CGAL-3.6.tar.gz - tar xzf CGAL-3.6.tar.gz - cd CGAL-3.6 - cmake -DCMAKE_INSTALL_PREFIX=$PWD/../../deploy -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" - make -j4 - make install - cd .. - -o Patch & build GLEW - - curl -LO http://downloads.sourceforge.net/project/glew/glew/1.5.4/glew-1.5.4.tgz - tar xzf glew-1.5.3.tar.gz - cd glew-1.5.3 - patch -p1 < ../openscad/patches/glew-1.5.3-MacOSX.patch - mkdir ../../deploy/lib/pkgconfig - make GLEW_DEST=$PWD/../../deploy CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=10.5 -arch i386 -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" install - cd .. - -o Patch and build OpenCSG >= 1.3.0 - - curl -O http://www.opencsg.org/OpenCSG-1.3.0.tar.gz - FIXME: Update patch - tar xzf OpenCSG-1.3.0.tar.gz - cd OpenCSG-1.3.0 - patch -p1 < ../openscad/patches/OpenCSG-1.3.0-MacOSX-port.patch - MACOSX_DEPLOY_DIR=$PWD/../../deploy qmake -r CONFIG+="x86 x86_64" - make install - cd .. + scripts/macosx-build-dependencies.sh o Build and Deploy OpenSCAD # Update VERSION in publish-macosx.sh - cd openscad - ./scripts/publish-macosx.sh + scripts/publish-macosx.sh -- cgit v0.10.1 From bebe7eb348c1c6cfc6801651b113b8e86e0f9607 Mon Sep 17 00:00:00 2001 From: kintel Date: Thu, 27 May 2010 23:19:12 +0000 Subject: Added some blurb about for, intersection_for and child modules git-svn-id: http://svn.clifford.at/openscad/trunk@555 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index 337f5c5..ab26c10 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -107,6 +107,9 @@ o Language Frontend a module search path. - allow 0/1 f/t FALSE/TRUE as boolean values - allow any expression to be evaluated as boolean (e.g. 1 = 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()? o DXF Import - Support for POLYLINE entity - Support for SPLINE entity -- cgit v0.10.1 From 8ea31ee2ce37377263a2abbabc21bd79e8eac88a Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 12 Jun 2010 23:30:42 +0000 Subject: fixed check-before-reload, also for the Reload (F3) function git-svn-id: http://svn.clifford.at/openscad/trunk@556 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/MainWindow.h b/src/MainWindow.h index 6b15889..c0a9844 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -75,6 +75,7 @@ private: void compile(bool procevents); void compileCSG(bool procevents); bool maybeSave(); + bool checkModified(); static void consoleOutput(const QString &msg, void *userdata) { static_cast(userdata)->console->append(msg); } diff --git a/src/mainwin.cc b/src/mainwin.cc index cdd7c6f..f6b7a53 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -932,7 +932,7 @@ void MainWindow::actionSaveAs() void MainWindow::actionReload() { - load(); + if (checkModified()) load(); } void MainWindow::hideEditor() @@ -991,7 +991,7 @@ void MainWindow::autoReloadSet(bool on) } } -void MainWindow::actionReloadCompile() +bool MainWindow::checkModified() { if (editor->isContentModified()) { QMessageBox::StandardButton ret; @@ -1001,9 +1001,15 @@ void MainWindow::actionReloadCompile() QMessageBox::Yes | QMessageBox::No); if (ret != QMessageBox::Yes) { designActionAutoReload->setChecked(false); - return; + return false; } } + return true; +} + +void MainWindow::actionReloadCompile() +{ + if (!checkModified()) return; console->clear(); -- cgit v0.10.1 From 5244ea6a7670ea59b4ea351585d8196b3ae971a7 Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 14 Jun 2010 17:52:28 +0000 Subject: Added mesh and convex hull git-svn-id: http://svn.clifford.at/openscad/trunk@557 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index ab26c10..f6115ba 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -87,6 +87,7 @@ o Primitives - Springs, spirals (requested by Cathal Garvey) - (TTF) Text - Image-based height field like http://www.thingiverse.com/thing:2078 + - mesh (coordinates and indices) o 2D Subsystem - Performance: Is it necessary to union children before extrusion when compiling? Can this be postponed to CGAL evaluation time? @@ -94,6 +95,7 @@ o 2D Subsystem o Built-in modules - extrude*: Allow the base 2D primitive to have a Z value - rotate_extrude(): Allow for specification of start/stop/sweep angle? + - Convex hull of multiple 2D or 2D objects o Advanced Transformations - Add statement for refinement via surface subdivision - Add statement for intersections in cartesian product of childs -- cgit v0.10.1 From 0057a2992ab76b7f9caabc1c0e28ef3a26e927ba Mon Sep 17 00:00:00 2001 From: kintel Date: Mon, 14 Jun 2010 19:23:38 +0000 Subject: bugfix: Don't crash when giving 3D vectors or number to a parameter which expects 2d vectors git-svn-id: http://svn.clifford.at/openscad/trunk@558 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/primitives.cc b/src/primitives.cc index 0808261..1856cbc 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -30,6 +30,7 @@ #include "dxfdata.h" #include "dxftess.h" #include "builtin.h" +#include "printutils.h" enum primitive_type_e { CUBE, @@ -465,8 +466,12 @@ sphere_next_r2: DxfData dd; for (int i=0; ivec[0]->num; - double y = points.vec[i]->vec[1]->num; + double x,y; + if (!points.vec[i]->getv2(x, y)) { + PRINTF("ERROR: Unable to convert point at index %d to a vec2 of numbers", i); + // FIXME: Return NULL and make sure this is checked by all callers? + return p; + } dd.points.append(DxfData::Point(x, y)); } -- cgit v0.10.1 From 155ebf21a94738ec16af7c487fb9e57314645b37 Mon Sep 17 00:00:00 2001 From: kintel Date: Tue, 15 Jun 2010 22:46:12 +0000 Subject: Added crash testcase for crash reported by Dan Zuras git-svn-id: http://svn.clifford.at/openscad/trunk@559 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/testdata/scad/polyset-reduce-crash.scad b/testdata/scad/polyset-reduce-crash.scad new file mode 100644 index 0000000..ce9fae7 --- /dev/null +++ b/testdata/scad/polyset-reduce-crash.scad @@ -0,0 +1,38 @@ +N=20; + +rotate (a = [0, 0, 36]) { + union() { + translate ([1, 0]) { + polygon (points = [[(N - 1)*cos(180/N), -(N - 1)*sin(180/N)], + [(N - 3)*cos(270/N), -(N - 3)*sin(270/N)], + [(N - 1)*cos(270/N), -(N - 1)*sin(270/N)]]); + + polygon (points = [[(N - 1)*cos(180/N), -(N - 1)*sin(180/N)], + [(N - 3)*cos(180/N), -(N - 3)*sin(180/N)], + [(N - 3)*cos(270/N), -(N - 3)*sin(270/N)]]); + + polygon (points = [[N - 1, 0], [N - 3, 0], + [(N - 3)*cos(180/N), -(N - 3)*sin(180/N)]]); + + polygon (points = [[N - 1, 0], + [(N - 3)*cos(180/N), -(N - 3)*sin(180/N)], + [(N - 1)*cos(180/N), -(N - 1)*sin(180/N)]]); + + polygon (points = [[N - 1, 0], [N - 3, 0], + [(N - 3)*cos(180/N), (N - 3)*sin(180/N)]]); + + polygon (points = [[N - 1, 0], + [(N - 3)*cos(180/N), (N - 3)*sin(180/N)], + [(N - 1)*cos(180/N), (N - 1)*sin(180/N)]]); + + polygon (points = [[(N - 1)*cos(180/N), (N - 1)*sin(180/N)], + [(N - 3)*cos(180/N), (N - 3)*sin(180/N)], + [(N - 3)*cos(270/N), (N - 3)*sin(270/N)]]); + + polygon (points = [[(N - 1)*cos(180/N), (N - 1)*sin(180/N)], + [(N - 3)*cos(270/N), (N - 3)*sin(270/N)], + [(N - 1)*cos(270/N), (N - 1)*sin(270/N)]]); + } + circle (r = 20); + } +} diff --git a/testdata/scad/polyset-reduce-crash.txt b/testdata/scad/polyset-reduce-crash.txt new file mode 100644 index 0000000..bc9e8d5 --- /dev/null +++ b/testdata/scad/polyset-reduce-crash.txt @@ -0,0 +1,4 @@ +This testcase causes a crash in PolySet::PolyReducer::add_edges(). +It appears to be because we collapse two close vertices into the same +vertex. This is handled by just abort()'ing. + -- cgit v0.10.1 From da224436468673a63a5f1b3bb6d0c5814e9cc76c Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 26 Jun 2010 16:17:34 +0000 Subject: Applied comma radix bugfix by jmarsden git-svn-id: http://svn.clifford.at/openscad/trunk@560 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/export.cc b/src/export.cc index 40573c5..87916c4 100644 --- a/src/export.cc +++ b/src/export.cc @@ -83,6 +83,8 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * typedef CGAL_Polyhedron::Facet_const_iterator FCI; typedef CGAL_Polyhedron::Halfedge_around_facet_const_circulator HFCC; + setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output + FILE *f = fopen(filename.toUtf8().data(), "w"); if (!f) { PRINTA("Can't open STL file \"%1\" for STL export: %2", @@ -142,6 +144,7 @@ void export_stl(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * fprintf(f, "endsolid OpenSCAD_Model\n"); fclose(f); + setlocale(LC_NUMERIC, ""); // Set default locale } void export_off(CGAL_Nef_polyhedron*, QString, QProgressDialog*) -- cgit v0.10.1 From e4a29dfb21ba1f38367b20adec5527519f16c1d4 Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 26 Jun 2010 22:55:18 +0000 Subject: Added dxflib git-svn-id: http://svn.clifford.at/openscad/trunk@561 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index f6115ba..e64b6ed 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -112,12 +112,14 @@ o Language Frontend - 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()? -o DXF Import - - Support for POLYLINE entity - - Support for SPLINE entity - - Support for LEADER entity - - Support for MTEXT entity ? - - idea: DXF inline - convert from dxf to OpenSCAD syntax -> parametrize dxf content +o DXF Import/Export + - Use dxflib from RibbonSoft for import/export? -> investigate + - Import + - Support for POLYLINE entity + - Support for SPLINE entity + - Support for LEADER entity + - Support for MTEXT entity ? + - idea: DXF inline - convert from dxf to OpenSCAD syntax -> parametrize dxf content o Mesh optimization on STL export - Remove super small triangles (all sides are short) - Replace super thin triangles (one h is short) -- cgit v0.10.1 From f8012852e808c8111106cbdcc04710f1dd4f122b Mon Sep 17 00:00:00 2001 From: kintel Date: Sat, 26 Jun 2010 22:55:21 +0000 Subject: Fixed DXF export to include the necessary information to make Inkscape import our files git-svn-id: http://svn.clifford.at/openscad/trunk@562 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/export.cc b/src/export.cc index 87916c4..40b16d5 100644 --- a/src/export.cc +++ b/src/export.cc @@ -165,10 +165,19 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * return; } - fprintf(f, " 0\n"); - fprintf(f, "SECTION\n"); - fprintf(f, " 2\n"); - fprintf(f, "ENTITIES\n"); + setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output + // Some importers (e.g. Inkscape) needs a BLOCKS section to be present + fprintf(f, " 0\n" + "SECTION\n" + " 2\n" + "BLOCKS\n" + " 0\n" + "ENDSEC\n"); + + fprintf(f, " 0\n" + "SECTION\n" + " 2\n" + "ENTITIES\n"); DxfData dd(*root_N); for (int i=0; iy; fprintf(f, " 0\n"); fprintf(f, "LINE\n"); + // Some importers (e.g. Inkscape) needs a layer to be specified + fprintf(f, " 8\n"); + fprintf(f, "0\n"); fprintf(f, " 10\n"); fprintf(f, "%f\n", x1); fprintf(f, " 11\n"); @@ -195,10 +207,20 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * fprintf(f, " 0\n"); fprintf(f, "ENDSEC\n"); + // Some importers (e.g. Inkscape) needs an OBJECTS section with a DICTIONARY entry + fprintf(f, " 0\n" + "SECTION\n" + " 2\n" + "OBJECTS\n" + " 0\n" + "DICTIONARY\n" + " 0\n" + "ENDSEC\n"); fprintf(f, " 0\n"); fprintf(f, "EOF\n"); fclose(f); + setlocale(LC_NUMERIC, ""); // Set default locale } #endif -- cgit v0.10.1 From b83fc6ac6a97ed012dd90324b30645f2f9f6246c Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 27 Jun 2010 01:34:25 +0000 Subject: Added some info about STL import issues reported by Andrew Plumb git-svn-id: http://svn.clifford.at/openscad/trunk@563 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index e64b6ed..ceab45b 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -8,6 +8,35 @@ o It's now possible to start a new rendering while one is already running. -> turn off most (or all) interaction while rendering o Look into the polygon winding and rotate_extrude() problem reported by Britton +STL Import BUGS +--------------- + +Using STL-imported models is tricky and triggers multiple issues: +(these all fail with the usual "Illegal polygonal object" error) +1) null-faces causes F6 rendering to fail while F5 rendering succeeds. + (null-faces are exported by OpenSCAD). Example: adns2610_dev_circuit_inv.stl + by Andrew Plumb +2) Even very simple imported STL models don't render correctly with F5 when taking + a difference(), though F6 looks correct. Example: test_cube.stl by Andrew Plumb + with this scad file: + difference() { + import_stl("test_cube.stl"); + translate([2,2,2]) cylinder(h=10); + } +3) More complex STL models with something simple unioned or subtracted fails rendering + using F6 even though F5 works. Example: adns2610_dev_circuit_inv.stl + by Andrew Plumb with the three null-faces removed by MeshLab with this scad file: + union() { + import_stl("adns2610_dev_circuit_inv_4.stl"); + sphere(r=5); + } +4) More complex STL models cannot be projected (both F5 and F6). + Example: adns2610_dev_circuit_inv.stl by Andrew Plumb with the three + null-faces removed by MeshLab and this scad file: + projection(cut=true) { + import_stl("adns2610_dev_circuit_inv.stl"); + } + CRASH BUGS ---------- o Broken polyhedron() entities are not correctly detected and cause CGAL segfaults -- cgit v0.10.1 From 3df5b51145d1e8d6256b055eb68ed6e429c315c9 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 27 Jun 2010 01:34:46 +0000 Subject: Catch some more CGAL exceptions which were encountered git-svn-id: http://svn.clifford.at/openscad/trunk@564 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/csgops.cc b/src/csgops.cc index 508eecc..ae97085 100644 --- a/src/csgops.cc +++ b/src/csgops.cc @@ -30,6 +30,8 @@ #include "printutils.h" #ifdef ENABLE_CGAL # include "cgal.h" +# include +# include #endif enum csg_type_e { @@ -82,8 +84,10 @@ CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const print_messages_push(); + CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); bool first = true; CGAL_Nef_polyhedron N; + try { foreach (AbstractNode *v, children) { if (v->modinst->tag_background) continue; @@ -110,8 +114,13 @@ CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const } v->progress_report(); } - cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); + } + catch (CGAL::Assertion_exception e) { + PRINTF("ERROR: Illegal polygonal object - make sure all polygons are defined with the same winding order. Skipping affected object."); + } + CGAL::set_error_behaviour(old_behaviour); + print_messages_pop(); progress_report(); diff --git a/src/polyset.cc b/src/polyset.cc index b8e77f4..47d858c 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -667,6 +667,7 @@ CGAL_Nef_polyhedron PolySet::render_cgal_nef_polyhedron() const CGAL::set_error_behaviour(old_behaviour); return CGAL_Nef_polyhedron(); } + CGAL::set_error_behaviour(old_behaviour); } return CGAL_Nef_polyhedron(); } diff --git a/src/projection.cc b/src/projection.cc index 1fb036c..7a3f77a 100644 --- a/src/projection.cc +++ b/src/projection.cc @@ -34,6 +34,11 @@ #include "export.h" #include "progress.h" +#ifdef ENABLE_CGAL +# include +# include +#endif + #include #include #include @@ -106,17 +111,26 @@ PolySet *ProjectionNode::render_polyset(render_mode_e) const print_messages_push(); + PolySet *ps = new PolySet(); + ps->convexity = this->convexity; + ps->is2d = true; + CGAL_Nef_polyhedron N; N.dim = 3; + CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); + try { foreach(AbstractNode *v, this->children) { if (v->modinst->tag_background) continue; N.p3 += v->render_cgal_nef_polyhedron().p3; } - - PolySet *ps = new PolySet(); - ps->convexity = this->convexity; - ps->is2d = true; + } + catch (CGAL::Assertion_exception e) { + PRINTF("ERROR: Illegal polygonal object - make sure all polygons are defined with the same winding order. Skipping affected object."); + CGAL::set_error_behaviour(old_behaviour); + return ps; + } + CGAL::set_error_behaviour(old_behaviour); if (cut_mode) { -- cgit v0.10.1 From 6eff371329ddc79809494d3dbe688acb8c406374 Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 2 Jul 2010 20:59:10 +0000 Subject: Use release libs also when developing git-svn-id: http://svn.clifford.at/openscad/trunk@565 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/setenv_mjau.sh b/setenv_mjau.sh index e00512a..b8012f6 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -1,4 +1,4 @@ -export MACOSX_DEPLOY_DIR=$PWD/../libraries/deploy +export MACOSX_DEPLOY_DIR=$PWD/../libraries/install export DYLD_LIBRARY_PATH=$MACOSX_DEPLOY_DIR/lib #export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 -- cgit v0.10.1 From 3efd99e4af55bfb53101d6de3fd146044ee5cd3c Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 2 Jul 2010 20:59:16 +0000 Subject: Some fixes by Jestin Stoffel git-svn-id: http://svn.clifford.at/openscad/trunk@566 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/glview.cc b/src/glview.cc index 270aed6..d51714b 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -215,8 +215,8 @@ void GLView::resizeGL(int w, int h) void GLView::paintGL() { - const QColor &col = Preferences::inst()->color(Preferences::BACKGROUND_COLOR); - glClearColor(col.redF(), col.greenF(), col.blueF(), 0.0); + const QColor &bgcol = Preferences::inst()->color(Preferences::BACKGROUND_COLOR); + glClearColor(bgcol.redF(), bgcol.greenF(), bgcol.blueF(), 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -253,6 +253,8 @@ void GLView::paintGL() glRotated(object_rot_y, 0.0, 1.0, 0.0); glRotated(object_rot_z, 0.0, 0.0, 1.0); + // FIXME: Crosshairs and axes are lighted, this doesn't make sense and causes them + // to change color based on view orientation. if (showcrosshairs) { glLineWidth(3); @@ -271,6 +273,7 @@ void GLView::paintGL() glTranslated(object_trans_x, object_trans_y, object_trans_z); // Large gray axis cross inline with the model + // FIXME: This is always gray - adjust color to keep contrast with background if (showaxes) { glLineWidth(1); @@ -296,7 +299,6 @@ void GLView::paintGL() renderfunc(renderfunc_vp); // Small axis cross in the lower left corner - // FIXME: Adjust color to keep contrast with background if (showaxes) { glDepthFunc(GL_ALWAYS); @@ -354,8 +356,11 @@ void GLView::paintGL() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - // FIXME: Adjust color to keep contrast with background - glColor3d(0.0, 0.0, 0.0); + // FIXME: This was an attempt to keep contrast with background, but is suboptimal + // (e.g. nearly invisible against a gray background). + int r,g,b; + bgcol.getRgb(&r, &g, &b); + glColor3d((255.0-r)/255.0, (255.0-g)/255.0, (255.0-b)/255.0); glBegin(GL_LINES); // X Label glVertex3d(xlabel_x-3, xlabel_y-3, 0); glVertex3d(xlabel_x+3, xlabel_y+3, 0); diff --git a/src/mainwin.cc b/src/mainwin.cc index f6b7a53..ef738fc 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -812,6 +812,9 @@ void MainWindow::actionNew() #ifdef ENABLE_MDI new MainWindow(QString()); #else + if (!maybeSave()) + return; + setFileName(""); editor->setPlainText(""); #endif @@ -819,18 +822,35 @@ void MainWindow::actionNew() void MainWindow::actionOpen() { - setCurrentOutput(); QString new_filename = QFileDialog::getOpenFileName(this, "Open File", "", "OpenSCAD Designs (*.scad)"); - if (!new_filename.isEmpty()) openFile(new_filename); - clearCurrentOutput(); +#ifdef ENABLE_MDI + new MainWindow(new_filename); +#else + if (!new_filename.isEmpty()) { + if (!maybeSave()) + return; + + setCurrentOutput(); + openFile(new_filename); + clearCurrentOutput(); + } +#endif } void MainWindow::actionOpenRecent() { QAction *action = qobject_cast(sender()); + +#ifdef ENABLE_MDI + new MainWindow(action->data().toString()); +#else + if (!maybeSave()) + return; + if (action) { openFile(action->data().toString()); } +#endif } void MainWindow::clearRecentFiles() @@ -1800,8 +1820,7 @@ MainWindow::helpManual() } /*! - FIXME: In SDI mode, this should be called also on New and Open - In MDI mode; also call on both reload functions? + FIXME: In MDI mode, should this be called on both reload functions? */ bool MainWindow::maybeSave() -- cgit v0.10.1 From a4fc13fee72dd385b560f276183ce8d2301584f2 Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 9 Jul 2010 09:35:15 +0000 Subject: mpft -> 1.3.0, cgal -> 3.6.1 git-svn-id: http://svn.clifford.at/openscad/trunk@567 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 630b067..3fba062 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -118,7 +118,7 @@ build_cgal() version=$1 echo "Building CGAL" $version "..." cd $BASEDIR/src - curl -O https://gforge.inria.fr/frs/download.php/26688/CGAL-$version.tar.gz + curl -O https://gforge.inria.fr/frs/download.php/27222/CGAL-$version.tar.gz tar xzf CGAL-$version.tar.gz cd CGAL-$version # We build a static lib. Not really necessary, but it's well tested. @@ -156,9 +156,9 @@ build_opencsg() echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR -build_gmp 5.0.1 -build_mpfr 2.4.2 -build_boost 1.43.0 -build_cgal 3.6 -build_glew 1.5.4 +#build_gmp 5.0.1 +#build_mpfr 3.0.0 +#build_boost 1.43.0 +#build_cgal 3.6.1 +#build_glew 1.5.4 build_opencsg 1.3.0 -- cgit v0.10.1 From b36f7a58dc51186cea2f9cd14d5bfd751f8ab072 Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 9 Jul 2010 09:35:19 +0000 Subject: sign() function suggested by Dan Zuras and implemented by Giles Bathgate git-svn-id: http://svn.clifford.at/openscad/trunk@568 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/func.cc b/src/func.cc index 9f1b8e7..eb0afcd 100644 --- a/src/func.cc +++ b/src/func.cc @@ -117,6 +117,13 @@ Value builtin_abs(const Context *, const QVector&, const QVector return Value(); } +Value builtin_sign(const Context *, const QVector&, const QVector &args) +{ + if (args.size() == 1 && args[0].type == Value::NUMBER) + return Value((args[0].num<0) ? -1.0 : ((args[0].num>0) ? 1.0 : 0.0)); + return Value(); +} + Value builtin_min(const Context *, const QVector&, const QVector &args) { if (args.size() >= 1 && args[0].type == Value::NUMBER) { @@ -292,6 +299,7 @@ Value builtin_lookup(const Context *, const QVector&, const QVector Date: Sat, 30 Oct 2010 15:24:49 +0000 Subject: Compile fixes from Giles Bathgate git-svn-id: http://svn.clifford.at/openscad/trunk@569 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/dxftess-glu.cc b/src/dxftess-glu.cc index 73eae63..ca12ea9 100644 --- a/src/dxftess-glu.cc +++ b/src/dxftess-glu.cc @@ -2,6 +2,7 @@ #include "dxfdata.h" #include "polyset.h" #include "grid.h" +#include #ifdef ENABLE_OPENCSG // this must be included before the GL headers diff --git a/src/polyset.cc b/src/polyset.cc index 47d858c..d438769 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -26,9 +26,10 @@ #include "polyset.h" #include "printutils.h" #include "Preferences.h" +#ifdef ENABLE_CGAL #include #include - +#endif #include #include diff --git a/src/primitives.cc b/src/primitives.cc index 1856cbc..ac1f0a3 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -31,6 +31,7 @@ #include "dxftess.h" #include "builtin.h" #include "printutils.h" +#include enum primitive_type_e { CUBE, diff --git a/test-code/batch-cgal-tests.sh b/test-code/batch-cgal-tests.sh index 8b3a2b5..12b8fe1 100755 --- a/test-code/batch-cgal-tests.sh +++ b/test-code/batch-cgal-tests.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash cmd="./cgaltest" diff --git a/test-code/batch-cgal.sh b/test-code/batch-cgal.sh index ea587be..031020d 100755 --- a/test-code/batch-cgal.sh +++ b/test-code/batch-cgal.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash cmd="./cgaltest" diff --git a/test-code/batch-dump.sh b/test-code/batch-dump.sh index 9db4fb5..e8c9cd5 100755 --- a/test-code/batch-dump.sh +++ b/test-code/batch-dump.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash cmd="./dumptest" @@ -8,6 +8,8 @@ else dir=$1 fi +echo $dir; + for f in $dir/*.scad; do echo `basename $f` "$cmd" "$f" diff --git a/test-code/dumptest.pro b/test-code/dumptest.pro index 50d3a98..a6729f7 100644 --- a/test-code/dumptest.pro +++ b/test-code/dumptest.pro @@ -30,6 +30,9 @@ else { INCLUDEPATH += /usr/include/eigen2 } } +FORMS += ../src/Preferences.ui +HEADERS += ../src/Preferences.h +SOURCES += ../src/Preferences.cc LEXSOURCES += ../src/lexer.l YACCSOURCES += ../src/parser.y -- cgit v0.10.1 From c8a2578bcb71c8d3f258c03d24e209dd8c2fef1e Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 31 Oct 2010 00:30:27 +0000 Subject: Updated to latest versions git-svn-id: http://svn.clifford.at/openscad/trunk@570 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 3fba062..ef4653c 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -118,7 +118,7 @@ build_cgal() version=$1 echo "Building CGAL" $version "..." cd $BASEDIR/src - curl -O https://gforge.inria.fr/frs/download.php/27222/CGAL-$version.tar.gz + curl -O https://gforge.inria.fr/frs/download.php/27641/CGAL-$version.tar.gz tar xzf CGAL-$version.tar.gz cd CGAL-$version # We build a static lib. Not really necessary, but it's well tested. @@ -156,9 +156,9 @@ build_opencsg() echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR -#build_gmp 5.0.1 -#build_mpfr 3.0.0 -#build_boost 1.43.0 -#build_cgal 3.6.1 -#build_glew 1.5.4 +build_gmp 5.0.1 +build_mpfr 3.0.0 +build_boost 1.44.0 +build_cgal 3.7 +build_glew 1.5.6 build_opencsg 1.3.0 -- cgit v0.10.1 From 6ed27af1392953d44cf0c3f0f0bd0b82e3c69c4f Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 31 Oct 2010 01:19:06 +0000 Subject: Committed current version of visitor refactoring git-svn-id: http://svn.clifford.at/openscad/trunk@571 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/openscad.pro b/openscad.pro index 42a5d22..fec7a79 100644 --- a/openscad.pro +++ b/openscad.pro @@ -98,12 +98,22 @@ HEADERS += src/CGAL_renderer.h \ src/highlighter.h \ src/module.h \ src/node.h \ + src/csgnode.h \ + src/dxflinextrudenode.h \ + src/dxfrotextrudenode.h \ + src/projectionnode.h \ + src/importnode.h \ src/openscad.h \ src/polyset.h \ src/printutils.h \ src/value.h \ src/progress.h \ - src/editor.h + src/editor.h \ + src/visitor.h \ + src/state.h \ + src/traverser.h \ + src/nodecache.h \ + src/nodedumper.h SOURCES += src/openscad.cc \ src/mainwin.cc \ @@ -140,7 +150,9 @@ SOURCES += src/openscad.cc \ src/nef2dxf.cc \ src/Preferences.cc \ src/progress.cc \ - src/editor.cc + src/editor.cc \\ + src/traverser.cc \ + src/nodedumper.cc macx { HEADERS += src/AppleEvents.h \ diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 829bc84..e391ea8 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -29,6 +29,8 @@ #include "builtin.h" #include "printutils.h" #include "cgal.h" +#include "visitor.h" +#include #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); @@ -52,15 +54,21 @@ public: class CgaladvNode : public AbstractNode { public: + CgaladvNode(const ModuleInstantiation *mi, cgaladv_type_e type) : AbstractNode(mi), type(type) { + convexity = 1; + } + virtual ~CgaladvNode() { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + Value path; QString subdiv_type; int convexity, level; cgaladv_type_e type; - CgaladvNode(const ModuleInstantiation *mi, cgaladv_type_e type) : AbstractNode(mi), type(type) { - convexity = 1; - } #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + virtual CGAL_Nef_polyhedron renderCSGMesh() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -128,7 +136,7 @@ void register_builtin_cgaladv() #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron CgaladvNode::renderCSGMesh() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -147,11 +155,11 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const if (v->modinst->tag_background) continue; if (first) { - N = v->render_cgal_nef_polyhedron(); + N = v->renderCsgMesh(); if (N.dim != 0) first = false; } else { - CGAL_Nef_polyhedron tmp = v->render_cgal_nef_polyhedron(); + CGAL_Nef_polyhedron tmp = v->renderCsgMesh(); if (N.dim == 3 && tmp.dim == 3) { N.p3 = minkowski3(N.p3, tmp.p3); } @@ -224,3 +232,24 @@ QString CgaladvNode::dump(QString indent) const return dump_cache; } +std::string CgaladvNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + switch (type) { + case MINKOWSKI: + stream << "minkowski(convexity = " << this->convexity << ")"; + break; + case GLIDE: + stream << "glide(path = " << this->path.dump() << ", convexity = " << this->convexity << ")"; + break; + case SUBDIV: + stream << "subdiv(level = " << this->level << ", convexity = " << this->convexity << ")"; + break; + default: + assert(false); + } + + return stream.str(); +} diff --git a/src/csgnode.h b/src/csgnode.h new file mode 100644 index 0000000..405dd96 --- /dev/null +++ b/src/csgnode.h @@ -0,0 +1,33 @@ +#ifndef CSGNODE_H_ +#define CSGNODE_H_ + +#include "node.h" +#include "visitor.h" +#ifdef ENABLE_CGAL +# include "cgal.h" +#endif + +enum csg_type_e { + CSG_TYPE_UNION, + CSG_TYPE_DIFFERENCE, + CSG_TYPE_INTERSECTION +}; + +class CsgNode : public AbstractNode +{ +public: + csg_type_e type; + CsgNode(const ModuleInstantiation *mi, csg_type_e type) : AbstractNode(mi), type(type) { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + +#ifdef ENABLE_CGAL + virtual CGAL_Nef_polyhedron renderCSGMesh() const; +#endif + CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; + virtual QString dump(QString indent) const; +}; + +#endif diff --git a/src/csgops.cc b/src/csgops.cc index ae97085..5baa149 100644 --- a/src/csgops.cc +++ b/src/csgops.cc @@ -23,22 +23,13 @@ * */ +#include "csgnode.h" + #include "module.h" -#include "node.h" #include "csgterm.h" #include "builtin.h" #include "printutils.h" -#ifdef ENABLE_CGAL -# include "cgal.h" -# include -# include -#endif - -enum csg_type_e { - CSG_TYPE_UNION, - CSG_TYPE_DIFFERENCE, - CSG_TYPE_INTERSECTION -}; +#include class CsgModule : public AbstractModule { @@ -48,18 +39,6 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; -class CsgNode : public AbstractNode -{ -public: - csg_type_e type; - CsgNode(const ModuleInstantiation *mi, csg_type_e type) : AbstractNode(mi), type(type) { } -#ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; -#endif - CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; - virtual QString dump(QString indent) const; -}; - AbstractNode *CsgModule::evaluate(const Context*, const ModuleInstantiation *inst) const { CsgNode *node = new CsgNode(inst, type); @@ -73,7 +52,7 @@ AbstractNode *CsgModule::evaluate(const Context*, const ModuleInstantiation *ins #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron CsgNode::renderCSGMesh() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -92,24 +71,24 @@ CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const if (v->modinst->tag_background) continue; if (first) { - N = v->render_cgal_nef_polyhedron(); + N = v->renderCSGMesh(); if (N.dim != 0) first = false; } else if (N.dim == 2) { if (type == CSG_TYPE_UNION) { - N.p2 += v->render_cgal_nef_polyhedron().p2; + N.p2 += v->renderCSGMesh().p2; } else if (type == CSG_TYPE_DIFFERENCE) { - N.p2 -= v->render_cgal_nef_polyhedron().p2; + N.p2 -= v->renderCSGMesh().p2; } else if (type == CSG_TYPE_INTERSECTION) { - N.p2 *= v->render_cgal_nef_polyhedron().p2; + N.p2 *= v->renderCSGMesh().p2; } } else if (N.dim == 3) { if (type == CSG_TYPE_UNION) { - N.p3 += v->render_cgal_nef_polyhedron().p3; + N.p3 += v->renderCSGMesh().p3; } else if (type == CSG_TYPE_DIFFERENCE) { - N.p3 -= v->render_cgal_nef_polyhedron().p3; + N.p3 -= v->renderCSGMesh().p3; } else if (type == CSG_TYPE_INTERSECTION) { - N.p3 *= v->render_cgal_nef_polyhedron().p3; + N.p3 *= v->renderCSGMesh().p3; } } v->progress_report(); @@ -172,6 +151,28 @@ QString CsgNode::dump(QString indent) const return dump_cache; } +std::string CsgNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + switch (this->type) { + case CSG_TYPE_UNION: + stream << "union()"; + break; + case CSG_TYPE_DIFFERENCE: + stream << "difference()"; + break; + case CSG_TYPE_INTERSECTION: + stream << "intersection()"; + break; + default: + assert(false); + } + + return stream.str(); +} + void register_builtin_csgops() { builtin_modules["union"] = new CsgModule(CSG_TYPE_UNION); diff --git a/src/dxflinextrude.cc b/src/dxflinextrude.cc index 83c3d9c..1f6bc8c 100644 --- a/src/dxflinextrude.cc +++ b/src/dxflinextrude.cc @@ -23,8 +23,9 @@ * */ +#include "dxflinextrudenode.h" + #include "module.h" -#include "node.h" #include "context.h" #include "printutils.h" #include "builtin.h" @@ -32,11 +33,13 @@ #include "dxftess.h" #include "polyset.h" #include "progress.h" +#include "visitor.h" #include "openscad.h" // get_fragments_from_r() #include #include #include +#include #include #include @@ -49,24 +52,6 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; -class DxfLinearExtrudeNode : public AbstractPolyNode -{ -public: - int convexity, slices; - double fn, fs, fa, height, twist; - double origin_x, origin_y, scale; - bool center, has_twist; - QString filename, layername; - DxfLinearExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - convexity = slices = 0; - fn = fs = fa = height = twist = 0; - origin_x = origin_y = scale = 0; - center = has_twist = false; - } - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - AbstractNode *DxfLinearExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { DxfLinearExtrudeNode *node = new DxfLinearExtrudeNode(inst); @@ -91,10 +76,8 @@ AbstractNode *DxfLinearExtrudeModule::evaluate(const Context *ctx, const ModuleI Value twist = c.lookup_variable("twist", true); Value slices = c.lookup_variable("slices", true); - if(!file.text.isNull()) + if (!file.text.isNull()) node->filename = c.get_absolute_path(file.text); - else - node->filename = file.text; node->layername = layer.text; node->height = height.num; @@ -236,7 +219,7 @@ PolySet *DxfLinearExtrudeNode::render_polyset(render_mode_e) const foreach(AbstractNode * v, children) { if (v->modinst->tag_background) continue; - N.p2 += v->render_cgal_nef_polyhedron().p2; + N.p2 += v->renderCSGMesh().p2; } dxf = new DxfData(N); @@ -344,3 +327,30 @@ QString DxfLinearExtrudeNode::dump(QString indent) const return dump_cache; } +std::string DxfLinearExtrudeNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + QString text; + struct stat st; + memset(&st, 0, sizeof(struct stat)); + stat(this->filename.toAscii().data(), &st); + + stream << "linear_extrude(" + "file = \"" << this->filename << "\", " + "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " + "layer = \"" << this->layername << "\", " + "height = " << std::dec << this->height << ", " + "origin = [ " << this->origin_x << " " << this->origin_y << " ], " + "scale = " << this->scale << ", " + "center = " << (this->center?"true":"false") << ", " + "convexity = " << this->convexity; + + if (this->has_twist) { + stream << ", twist = " << this->twist << ", slices = " << this->slices; + } + stream << ", $fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; + + return stream.str(); +} diff --git a/src/dxflinextrudenode.h b/src/dxflinextrudenode.h new file mode 100644 index 0000000..2df52c8 --- /dev/null +++ b/src/dxflinextrudenode.h @@ -0,0 +1,30 @@ +#ifndef DXFLINEXTRUDENODE_H_ +#define DXFLINEXTRUDENODE_H_ + +#include "node.h" +#include "visitor.h" + +class DxfLinearExtrudeNode : public AbstractPolyNode +{ +public: + DxfLinearExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + convexity = slices = 0; + fn = fs = fa = height = twist = 0; + origin_x = origin_y = scale = 0; + center = has_twist = false; + } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + + int convexity, slices; + double fn, fs, fa, height, twist; + double origin_x, origin_y, scale; + bool center, has_twist; + QString filename, layername; + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + +#endif diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc index ea603f0..98f91f3 100644 --- a/src/dxfrotextrude.cc +++ b/src/dxfrotextrude.cc @@ -23,19 +23,21 @@ * */ +#include "dxfrotextrudenode.h" #include "module.h" -#include "node.h" #include "context.h" #include "printutils.h" #include "builtin.h" #include "polyset.h" #include "dxfdata.h" #include "progress.h" +#include "visitor.h" #include "openscad.h" // get_fragments_from_r() #include #include #include +#include #include #include @@ -48,22 +50,6 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; -class DxfRotateExtrudeNode : public AbstractPolyNode -{ -public: - int convexity; - double fn, fs, fa; - double origin_x, origin_y, scale; - QString filename, layername; - DxfRotateExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - convexity = 0; - fn = fs = fa = 0; - origin_x = origin_y = scale = 0; - } - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - AbstractNode *DxfRotateExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { DxfRotateExtrudeNode *node = new DxfRotateExtrudeNode(inst); @@ -84,10 +70,8 @@ AbstractNode *DxfRotateExtrudeModule::evaluate(const Context *ctx, const ModuleI Value origin = c.lookup_variable("origin", true); Value scale = c.lookup_variable("scale", true); - if(!file.text.isNull()) + if (!file.text.isNull()) node->filename = c.get_absolute_path(file.text); - else - node->filename = file.text; node->layername = layer.text; node->convexity = (int)convexity.num; @@ -136,7 +120,7 @@ PolySet *DxfRotateExtrudeNode::render_polyset(render_mode_e) const foreach(AbstractNode * v, children) { if (v->modinst->tag_background) continue; - N.p2 += v->render_cgal_nef_polyhedron().p2; + N.p2 += v->renderCSGMesh().p2; } dxf = new DxfData(N); @@ -234,3 +218,22 @@ QString DxfRotateExtrudeNode::dump(QString indent) const return dump_cache; } +std::string DxfRotateExtrudeNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + struct stat st; + memset(&st, 0, sizeof(struct stat)); + stat(filename.toAscii().data(), &st); + stream << "rotate_extrude(" + "file = \"" << this->filename << "\", " + "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " + "layer = \"" << this->layername << "\", " + "origin = [ " << std::dec << this->origin_x << " " << this->origin_y << " ], " + "scale = " << this->scale << ", " + "convexity = " << this->convexity << ", " + "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; + + return stream.str(); +} diff --git a/src/dxfrotextrudenode.h b/src/dxfrotextrudenode.h new file mode 100644 index 0000000..fbe2b85 --- /dev/null +++ b/src/dxfrotextrudenode.h @@ -0,0 +1,28 @@ +#ifndef DXFROTEXTRUDENODE_H_ +#define DXFROTEXTRUDENODE_H_ + +#include "node.h" +#include "visitor.h" + +class DxfRotateExtrudeNode : public AbstractPolyNode +{ +public: + DxfRotateExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + convexity = 0; + fn = fs = fa = 0; + origin_x = origin_y = scale = 0; + } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + + int convexity; + double fn, fs, fa; + double origin_x, origin_y, scale; + QString filename, layername; + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + +#endif diff --git a/src/import.cc b/src/import.cc index bab13ae..5d0a497 100644 --- a/src/import.cc +++ b/src/import.cc @@ -23,8 +23,9 @@ * */ +#include "importnode.h" + #include "module.h" -#include "node.h" #include "polyset.h" #include "context.h" #include "builtin.h" @@ -36,12 +37,7 @@ #include #include #include - -enum import_type_e { - TYPE_STL, - TYPE_OFF, - TYPE_DXF -}; +#include class ImportModule : public AbstractModule { @@ -51,20 +47,6 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; -class ImportNode : public AbstractPolyNode -{ -public: - import_type_e type; - QString filename; - QString layername; - int convexity; - double fn, fs, fa; - double origin_x, origin_y, scale; - ImportNode(const ModuleInstantiation *mi, import_type_e type) : AbstractPolyNode(mi), type(type) { } - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { ImportNode *node = new ImportNode(inst, type); @@ -231,3 +213,39 @@ QString ImportNode::dump(QString indent) const return dump_cache; } +std::string ImportNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + QString text; + struct stat st; + memset(&st, 0, sizeof(struct stat)); + stat(this->filename.toAscii().data(), &st); + + switch (this->type) { + case TYPE_STL: + stream << "import_stl(file = \"" << this->filename << "\", " + "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " + "convexity = " << std::dec << this->convexity << ")"; + break; + case TYPE_OFF: + stream << "import_off(file = \"" << this->filename << "\", " + "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " + "convexity = " << std::dec << this->convexity << ")"; + break; + case TYPE_DXF: + stream << "import_dxf(file = \"" << this->filename << "\", " + "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " + "layer = \"" << this->layername << "\", " + "origin = [ " << std::dec << this->origin_x << " " << this->origin_y << " ], " + "scale = " << this->scale << ", " + "convexity = " << this->convexity << ", " + "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; + break; + default: + assert(false); + } + + return stream.str(); +} diff --git a/src/importnode.h b/src/importnode.h new file mode 100644 index 0000000..b226569 --- /dev/null +++ b/src/importnode.h @@ -0,0 +1,32 @@ +#ifndef IMPORTNODE_H_ +#define IMPORTNODE_H_ + +#include "node.h" +#include "visitor.h" + +enum import_type_e { + TYPE_STL, + TYPE_OFF, + TYPE_DXF +}; + +class ImportNode : public AbstractPolyNode +{ +public: + ImportNode(const ModuleInstantiation *mi, import_type_e type) : AbstractPolyNode(mi), type(type) { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + + import_type_e type; + QString filename; + QString layername; + int convexity; + double fn, fs, fa; + double origin_x, origin_y, scale; + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + +#endif diff --git a/src/mainwin.cc b/src/mainwin.cc index ef738fc..1bf2695 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1126,7 +1126,7 @@ void MainWindow::actionRenderCGAL() progress_report_prep(root_node, report_func, pd); try { - this->root_N = new CGAL_Nef_polyhedron(root_node->render_cgal_nef_polyhedron()); + this->root_N = new CGAL_Nef_polyhedron(root_node->renderCSGMesh()); } catch (ProgressCancelException e) { PRINT("Rendering cancelled."); diff --git a/src/node.cc b/src/node.cc index 87a7051..437fdfa 100644 --- a/src/node.cc +++ b/src/node.cc @@ -29,7 +29,9 @@ #include "csgterm.h" #include "progress.h" #include "polyset.h" +#include "visitor.h" #include +#include int AbstractNode::idx_counter; @@ -45,6 +47,21 @@ AbstractNode::~AbstractNode() delete v; } +Response AbstractNode::accept(const class State &state, Visitor &visitor) const +{ + return visitor.visit(state, *this); +} + +Response AbstractIntersectionNode::accept(const class State &state, Visitor &visitor) const +{ + return visitor.visit(state, *this); +} + +Response AbstractPolyNode::accept(const class State &state, Visitor &visitor) const +{ + return visitor.visit(state, *this); +} + QString AbstractNode::mk_cache_id() const { QString cache_id = dump(""); @@ -79,19 +96,19 @@ static CGAL_Nef_polyhedron render_cgal_nef_polyhedron_backend(const AbstractNode if (v->modinst->tag_background) continue; if (first) { - N = v->render_cgal_nef_polyhedron(); + N = v->renderCSGMesh(); if (N.dim != 0) first = false; } else if (N.dim == 2) { if (intersect) - N.p2 *= v->render_cgal_nef_polyhedron().p2; + N.p2 *= v->renderCSGMesh().p2; else - N.p2 += v->render_cgal_nef_polyhedron().p2; + N.p2 += v->renderCSGMesh().p2; } else { if (intersect) - N.p3 *= v->render_cgal_nef_polyhedron().p3; + N.p3 *= v->renderCSGMesh().p3; else - N.p3 += v->render_cgal_nef_polyhedron().p3; + N.p3 += v->renderCSGMesh().p3; } v->progress_report(); } @@ -103,12 +120,12 @@ static CGAL_Nef_polyhedron render_cgal_nef_polyhedron_backend(const AbstractNode return N; } -CGAL_Nef_polyhedron AbstractNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron AbstractNode::renderCSGMesh() const { return render_cgal_nef_polyhedron_backend(this, false); } -CGAL_Nef_polyhedron AbstractIntersectionNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron AbstractIntersectionNode::renderCSGMesh() const { return render_cgal_nef_polyhedron_backend(this, true); } @@ -159,10 +176,17 @@ QString AbstractNode::dump(QString indent) const return dump_cache; } +std::string AbstractNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": group()"; + return stream.str(); +} + QString AbstractIntersectionNode::dump(QString indent) const { if (dump_cache.isEmpty()) { - QString text = indent + QString("n%1: intersection() {\n").arg(idx); + QString text = indent + QString::fromStdString(this->toString()) + " {\n"; foreach (AbstractNode *v, children) text += v->dump(indent + QString("\t")); ((AbstractNode*)this)->dump_cache = text + indent + "}\n"; @@ -170,6 +194,13 @@ QString AbstractIntersectionNode::dump(QString indent) const return dump_cache; } +std::string AbstractIntersectionNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": intersection()"; + return stream.str(); +} + void AbstractNode::progress_prepare() { foreach (AbstractNode *v, children) @@ -184,7 +215,7 @@ void AbstractNode::progress_report() const #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron AbstractPolyNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron AbstractPolyNode::renderCSGMesh() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -197,7 +228,7 @@ CGAL_Nef_polyhedron AbstractPolyNode::render_cgal_nef_polyhedron() const PolySet *ps = render_polyset(RENDER_CGAL); try { - CGAL_Nef_polyhedron N = ps->render_cgal_nef_polyhedron(); + CGAL_Nef_polyhedron N = ps->renderCSGMesh(); cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); print_messages_pop(); progress_report(); @@ -231,3 +262,15 @@ CSGTerm *AbstractPolyNode::render_csg_term_from_ps(double m[20], QVector getChildren() const { + return this->children.toList().toStdList(); + } + int index() const { return this->idx; } + static void resetIndexCounter() { idx_counter = 1; } QVector children; - const class ModuleInstantiation *modinst; - + const ModuleInstantiation *modinst; + int progress_mark; void progress_prepare(); void progress_report() const; - int idx; + int idx; // Node index (unique per tree) QString dump_cache; - AbstractNode(const ModuleInstantiation *mi); - virtual ~AbstractNode(); + + virtual QString mk_cache_id() const; #ifdef ENABLE_CGAL struct cgal_nef_cache_entry { @@ -41,7 +54,7 @@ public: cgal_nef_cache_entry(const CGAL_Nef_polyhedron &N); }; static QCache cgal_nef_cache; - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + virtual CGAL_Nef_polyhedron renderCSGMesh() const; class CSGTerm *render_csg_term_from_nef(double m[20], QVector *highlights, QVector *background, const char *statement, int convexity) const; #endif virtual class CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; @@ -52,8 +65,12 @@ class AbstractIntersectionNode : public AbstractNode { public: AbstractIntersectionNode(const ModuleInstantiation *mi) : AbstractNode(mi) { }; + virtual ~AbstractIntersectionNode() { }; + virtual Response accept(const class State &state, class Visitor &visitor) const; + virtual std::string toString() const; + #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + virtual CGAL_Nef_polyhedron renderCSGMesh() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -62,17 +79,24 @@ public: class AbstractPolyNode : public AbstractNode { public: + AbstractPolyNode(const ModuleInstantiation *mi) : AbstractNode(mi) { }; + virtual ~AbstractPolyNode() { }; + virtual Response accept(const class State &state, class Visitor &visitor) const; + enum render_mode_e { RENDER_CGAL, RENDER_OPENCSG }; - AbstractPolyNode(const ModuleInstantiation *mi) : AbstractNode(mi) { }; virtual class PolySet *render_polyset(render_mode_e mode) const = 0; #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + virtual CGAL_Nef_polyhedron renderCSGMesh() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; static CSGTerm *render_csg_term_from_ps(double m[20], QVector *highlights, QVector *background, PolySet *ps, const ModuleInstantiation *modinst, int idx); }; +std::ostream &operator<<(std::ostream &stream, const AbstractNode &node); +// FIXME: Doesn't belong here.. +std::ostream &operator<<(std::ostream &stream, const QString &str); + #endif diff --git a/src/nodecache.h b/src/nodecache.h new file mode 100644 index 0000000..c5a5524 --- /dev/null +++ b/src/nodecache.h @@ -0,0 +1,33 @@ +#ifndef NODECACHE_H_ +#define NODECACHE_H_ + +#include +#include "node.h" + +template +class NodeCache +{ +public: + NodeCache() { } + virtual ~NodeCache() { } + + const T & operator[](const AbstractNode &node) const { + if (this->cache.size() > node.index()) return this->cache[node.index()]; + else return nullvalue; + } + + void insert(const class AbstractNode &node, const T & value) { + this->cache.resize(node.index() + 1); + this->cache[node.index()] = value; + } + + void remove(const class AbstractNode &node) { + if (this->cache.size() > node.index()) this->cache[node.index()] = nullvalue; + } + +private: + std::vector cache; + T nullvalue; +}; + +#endif diff --git a/src/nodedumper.cc b/src/nodedumper.cc new file mode 100644 index 0000000..1956a89 --- /dev/null +++ b/src/nodedumper.cc @@ -0,0 +1,98 @@ +#include "nodedumper.h" +#include +#include +#include +#include "visitor.h" +#include "state.h" +#include "nodecache.h" + +#include +#include + +// For compatibility with old dump() output +#define NODEDUMPER_COMPAT_MODE +#ifdef NODEDUMPER_COMPAT_MODE +#include "dxflinextrudenode.h" +#include "dxfrotextrudenode.h" +#include "projectionnode.h" +#endif + + +bool NodeDumper::isCached(const AbstractNode &node) +{ + return !this->cache[node].empty(); +} + +void NodeDumper::handleIndent(const State &state) +{ + if (state.isPrefix()) { + this->currindent += "\t"; + } + else if (state.isPostfix()) { + this->currindent.erase((this->currindent.length() >= 1) ? + this->currindent.length() - 1 : 0); + } +} + +string NodeDumper::dumpChildren(const AbstractNode &node) +{ + std::stringstream dump; + if (!this->visitedchildren[node.index()].empty()) { + dump << " {\n"; + + for (ChildList::const_iterator iter = this->visitedchildren[node.index()].begin(); + iter != this->visitedchildren[node.index()].end(); + iter++) { + dump << this->cache[**iter] << "\n"; + } + + dump << this->currindent << "}"; + } + else { +#ifndef NODEDUMPER_COMPAT_MODE + dump << ";"; +#else + if (dynamic_cast(&node) && + !dynamic_cast(&node) && + !dynamic_cast(&node) && + !dynamic_cast(&node)) dump << ";"; + else dump << " {\n" << this->currindent << "}"; +#endif + } + return dump.str(); +} + + +Response NodeDumper::visit(const State &state, const AbstractNode &node) +{ + if (isCached(node)) return PruneTraversal; + else handleIndent(state); + if (state.isPostfix()) { + std::stringstream dump; + dump << this->currindent << node; + dump << dumpChildren(node); + this->cache.insert(node, dump.str()); + } + + handleVisitedChildren(state, node); + return ContinueTraversal; +} + +const string &NodeDumper::getDump() const +{ + assert(this->root); + return this->cache[*this->root]; +} + +void NodeDumper::handleVisitedChildren(const State &state, const AbstractNode &node) +{ + if (state.isPostfix()) { + this->visitedchildren.erase(node.index()); + if (!state.parent()) { + this->root = &node; + } + else { + this->visitedchildren[state.parent()->index()].push_back(&node); + } + } +} diff --git a/src/nodedumper.h b/src/nodedumper.h new file mode 100644 index 0000000..568d578 --- /dev/null +++ b/src/nodedumper.h @@ -0,0 +1,37 @@ +#ifndef NODEDUMPER_H_ +#define NODEDUMPER_H_ + +#include +#include +#include +#include "visitor.h" +#include "nodecache.h" + +using std::string; +using std::map; +using std::list; + +class NodeDumper : public Visitor +{ +public: + NodeDumper() : root(NULL) {} + virtual ~NodeDumper() {} + + virtual Response visit(const State &state, const AbstractNode &node); + + const string &getDump() const; +private: + void handleVisitedChildren(const State &state, const AbstractNode &node); + bool isCached(const AbstractNode &node); + void handleIndent(const State &state); + string dumpChildren(const AbstractNode &node); + + string currindent; + const AbstractNode *root; + typedef list ChildList; + map visitedchildren; + NodeCache cache; +}; + + +#endif diff --git a/src/openscad.cc b/src/openscad.cc index bf24c9f..fdd2502 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -31,6 +31,7 @@ #include "value.h" #include "export.h" #include "builtin.h" +#include "nodedumper.h" #ifdef ENABLE_CGAL #include "cgal.h" @@ -284,8 +285,20 @@ int main(int argc, char **argv) AbstractNode::resetIndexCounter(); root_node = root_module->evaluate(&root_ctx, &root_inst); + NodeDumper dumper; + Traverser trav(dumper, *root_node, Traverser::PRE_AND_POSTFIX); + trav.execute(); +// std::cout << dumper.getDump(); +// std::cout << std::endl; +// trav.execute(); +// std::cout << dumper.getDump(); +// std::cout << std::endl; + printf(dumper.getDump().c_str()); + exit(1); + + CGAL_Nef_polyhedron *root_N; - root_N = new CGAL_Nef_polyhedron(root_node->render_cgal_nef_polyhedron()); + root_N = new CGAL_Nef_polyhedron(root_node->renderCSGMesh()); QDir::setCurrent(original_path.absolutePath()); diff --git a/src/polyset.cc b/src/polyset.cc index d438769..4548f8a 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -144,7 +144,9 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m bool mirrored = m3f.determinant() < 0; if (colormode == COLORMODE_MATERIAL) { - const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_FRONT_COLOR); +// FIXME: Reenable/rewrite - don't be dependant on GUI +// const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_FRONT_COLOR); + const QColor &col = QColor(0xf9, 0xd7, 0x2c); glColor3f(col.redF(), col.greenF(), col.blueF()); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -154,7 +156,9 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m #endif /* ENABLE_OPENCSG */ } if (colormode == COLORMODE_CUTOUT) { - const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_BACK_COLOR); +// FIXME: Reenable/rewrite - don't be dependant on GUI +// const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_BACK_COLOR); + const QColor &col = QColor(0x9d, 0xcb, 0x51); glColor3f(col.redF(), col.greenF(), col.blueF()); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -407,7 +411,7 @@ public: } }; -CGAL_Nef_polyhedron PolySet::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron PolySet::renderCSGMesh() const { if (this->is2d) { diff --git a/src/polyset.h b/src/polyset.h index 0914e91..074f82e 100644 --- a/src/polyset.h +++ b/src/polyset.h @@ -78,7 +78,7 @@ public: void render_edges(colormode_e colormode, csgmode_e csgmode) const; #ifdef ENABLE_CGAL - CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + CGAL_Nef_polyhedron renderCSGMesh() const; #endif int refcount; diff --git a/src/primitives.cc b/src/primitives.cc index ac1f0a3..8838547 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -32,6 +32,8 @@ #include "builtin.h" #include "printutils.h" #include +#include "visitor.h" +#include enum primitive_type_e { CUBE, @@ -54,13 +56,18 @@ public: class PrimitiveNode : public AbstractPolyNode { public: + PrimitiveNode(const ModuleInstantiation *mi, primitive_type_e type) : AbstractPolyNode(mi), type(type) { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + bool center; double x, y, z, h, r1, r2; double fn, fs, fa; primitive_type_e type; int convexity; Value points, paths, triangles; - PrimitiveNode(const ModuleInstantiation *mi, primitive_type_e type) : AbstractPolyNode(mi), type(type) { } virtual PolySet *render_polyset(render_mode_e mode) const; virtual QString dump(QString indent) const; }; @@ -542,3 +549,44 @@ QString PrimitiveNode::dump(QString indent) const return dump_cache; } +std::string PrimitiveNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + switch (this->type) { + case CUBE: + stream << "cube(size = [" << this->x << ", " << this->y << ", " << this->z << "], " + << "center = " << (center ? "true" : "false") << ")"; + break; + case SPHERE: + stream << "sphere($fn = " << this->fn << ", $fa = " << this->fa + << ", $fs = " << this->fs << ", r = " << this->r1 << ")"; + break; + case CYLINDER: + stream << "cylinder($fn = " << this->fn << ", $fa = " << this->fa + << ", $fs = " << this->fs << ", h = " << this->h << ", r1 = " << this->r1 + << ", r2 = " << this->r2 << ", center = " << (center ? "true" : "false") << ")"; + break; + case POLYHEDRON: + stream << "polyhedron(points = " << this->points.dump() + << ", triangles = " << this->triangles.dump() + << ", convexity = " << this->convexity << ")"; + break; + case SQUARE: + stream << "square(size = [" << this->x << ", " << this->y << "], " + << "center = " << (center ? "true" : "false") << ")"; + break; + case CIRCLE: + stream << "circle($fn = " << this->fn << ", $fa = " << this->fa + << ", $fs = " << this->fs << ", r = " << this->r1 << ")"; + break; + case POLYGON: + stream << "polygon(points = " << this->points.dump() << ", paths = " << this->paths.dump() << ", convexity = " << this->convexity << ")"; + break; + default: + assert(false); + } + + return stream.str(); +} diff --git a/src/printutils.cc b/src/printutils.cc index 8830a8c..0f4c67d 100644 --- a/src/printutils.cc +++ b/src/printutils.cc @@ -18,8 +18,7 @@ void print_messages_push() void print_messages_pop() { - QString msg = print_messages_stack.last(); - print_messages_stack.removeLast(); + QString msg = print_messages_stack.takeLast(); if (print_messages_stack.size() > 0 && !msg.isNull()) { if (!print_messages_stack.last().isEmpty()) print_messages_stack.last() += "\n"; diff --git a/src/projection.cc b/src/projection.cc index 7a3f77a..985ed20 100644 --- a/src/projection.cc +++ b/src/projection.cc @@ -23,8 +23,8 @@ * */ +#include "projectionnode.h" #include "module.h" -#include "node.h" #include "context.h" #include "printutils.h" #include "builtin.h" @@ -33,6 +33,7 @@ #include "polyset.h" #include "export.h" #include "progress.h" +#include "visitor.h" #ifdef ENABLE_CGAL # include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include @@ -55,18 +57,6 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; -class ProjectionNode : public AbstractPolyNode -{ -public: - int convexity; - bool cut_mode; - ProjectionNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - cut_mode = false; - } - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - AbstractNode *ProjectionModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { ProjectionNode *node = new ProjectionNode(inst); @@ -122,7 +112,7 @@ PolySet *ProjectionNode::render_polyset(render_mode_e) const foreach(AbstractNode *v, this->children) { if (v->modinst->tag_background) continue; - N.p3 += v->render_cgal_nef_polyhedron().p3; + N.p3 += v->renderCSGMesh().p3; } } catch (CGAL::Assertion_exception e) { @@ -173,7 +163,7 @@ PolySet *ProjectionNode::render_polyset(render_mode_e) const cube->append_vertex(x1, y1, z1); cube->append_vertex(x1, y1, z2); cube->append_vertex(x1, y2, z2); - CGAL_Nef_polyhedron Ncube = cube->render_cgal_nef_polyhedron(); + CGAL_Nef_polyhedron Ncube = cube->renderCSGMesh(); cube->unlink(); // N.p3 *= CGAL_Nef_polyhedron3(CGAL_Plane(0, 0, 1, 0), CGAL_Nef_polyhedron3::INCLUDED); @@ -298,3 +288,13 @@ QString ProjectionNode::dump(QString indent) const return dump_cache; } +std::string ProjectionNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + stream << "projection(cut = " << (this->cut_mode ? "true" : "false") + << ", convexity = " << this->convexity << ")"; + + return stream.str(); +} diff --git a/src/projectionnode.h b/src/projectionnode.h new file mode 100644 index 0000000..d5ba6da --- /dev/null +++ b/src/projectionnode.h @@ -0,0 +1,24 @@ +#ifndef PROJECTIONNODE_H_ +#define PROJECTIONNODE_H_ + +#include "node.h" +#include "visitor.h" + +class ProjectionNode : public AbstractPolyNode +{ +public: + ProjectionNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + cut_mode = false; + } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + + int convexity; + bool cut_mode; + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + +#endif diff --git a/src/render.cc b/src/render.cc index d851fc8..5bd57fc 100644 --- a/src/render.cc +++ b/src/render.cc @@ -33,13 +33,14 @@ #include "builtin.h" #include "printutils.h" #include "progress.h" +#include "visitor.h" #ifdef ENABLE_CGAL # include "cgal.h" #endif -#include #include #include +#include class RenderModule : public AbstractModule { @@ -51,10 +52,15 @@ public: class RenderNode : public AbstractNode { public: - int convexity; RenderNode(const ModuleInstantiation *mi) : AbstractNode(mi), convexity(1) { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + + int convexity; #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + virtual CGAL_Nef_polyhedron renderCSGMesh() const; #endif CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -90,7 +96,7 @@ void register_builtin_render() #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron RenderNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron RenderNode::renderCSGMesh() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -108,13 +114,13 @@ CGAL_Nef_polyhedron RenderNode::render_cgal_nef_polyhedron() const if (v->modinst->tag_background) continue; if (first) { - N = v->render_cgal_nef_polyhedron(); + N = v->renderCSGMesh(); if (N.dim != 0) first = false; } else if (N.dim == 2) { - N.p2 += v->render_cgal_nef_polyhedron().p2; + N.p2 += v->renderCSGMesh().p2; } else if (N.dim == 3) { - N.p3 += v->render_cgal_nef_polyhedron().p3; + N.p3 += v->renderCSGMesh().p3; } v->progress_report(); } @@ -153,7 +159,7 @@ CSGTerm *AbstractNode::render_csg_term_from_nef(double m[20], QVector QTime t; t.start(); - N = this->render_cgal_nef_polyhedron(); + N = this->renderCSGMesh(); int s = t.elapsed() / 1000; PRINTF_NOCACHE("..rendering time: %d hours, %d minutes, %d seconds", s / (60*60), (s / 60) % 60, s % 60); @@ -261,3 +267,12 @@ QString RenderNode::dump(QString indent) const return dump_cache; } +std::string RenderNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + stream << "render(convexity = " << convexity << ")"; + + return stream.str(); +} diff --git a/src/state.h b/src/state.h new file mode 100644 index 0000000..7ac8e9f --- /dev/null +++ b/src/state.h @@ -0,0 +1,28 @@ +#ifndef STATE_H_ +#define STATE_H_ + +class State +{ +public: + State(const class AbstractNode *parent) + : parentnode(parent), isprefix(false), ispostfix(false), numchildren(0) { } + virtual ~State() {} + + void setPrefix(bool on) { this->isprefix = on; } + void setPostfix(bool on) { this->ispostfix = on; } + void setNumChildren(unsigned int numc) { this->numchildren = numc; } + void setParent(const AbstractNode *parent) { this->parentnode = parent; } + + bool isPrefix() const { return this->isprefix; } + bool isPostfix() const { return this->ispostfix; } + unsigned int numChildren() const { return this->numchildren; } + const AbstractNode *parent() const { return this->parentnode; } + +private: + const AbstractNode * parentnode; + bool isprefix; + bool ispostfix; + unsigned int numchildren; +}; + +#endif diff --git a/src/surface.cc b/src/surface.cc index ddcd3a6..57b3f59 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -31,8 +31,10 @@ #include "dxftess.h" #include "printutils.h" #include "openscad.h" // handle_dep() +#include "visitor.h" #include +#include class SurfaceModule : public AbstractModule { @@ -44,10 +46,15 @@ public: class SurfaceNode : public AbstractPolyNode { public: + SurfaceNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + QString filename; bool center; int convexity; - SurfaceNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { } virtual PolySet *render_polyset(render_mode_e mode) const; virtual QString dump(QString indent) const; }; @@ -208,3 +215,13 @@ QString SurfaceNode::dump(QString indent) const return dump_cache; } +std::string SurfaceNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + stream << "surface(file = \"" << this->filename + << "\", center = " << (this->center ? "true" : "false") << ")"; + + return stream.str(); +} diff --git a/src/transform.cc b/src/transform.cc index 746283e..8f61c26 100644 --- a/src/transform.cc +++ b/src/transform.cc @@ -32,6 +32,8 @@ #include "dxftess.h" #include "builtin.h" #include "printutils.h" +#include "visitor.h" +#include enum transform_type_e { SCALE, @@ -53,10 +55,15 @@ public: class TransformNode : public AbstractNode { public: - double m[20]; TransformNode(const ModuleInstantiation *mi) : AbstractNode(mi) { } + virtual Response accept(const class State &state, Visitor &visitor) const { + return visitor.visit(state, *this); + } + virtual std::string toString() const; + + double m[20]; #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; + virtual CGAL_Nef_polyhedron renderCSGMesh() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -240,7 +247,7 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron TransformNode::render_cgal_nef_polyhedron() const +CGAL_Nef_polyhedron TransformNode::renderCSGMesh() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -258,13 +265,13 @@ CGAL_Nef_polyhedron TransformNode::render_cgal_nef_polyhedron() const if (v->modinst->tag_background) continue; if (first) { - N = v->render_cgal_nef_polyhedron(); + N = v->renderCSGMesh(); if (N.dim != 0) first = false; } else if (N.dim == 2) { - N.p2 += v->render_cgal_nef_polyhedron().p2; + N.p2 += v->renderCSGMesh().p2; } else if (N.dim == 3) { - N.p3 += v->render_cgal_nef_polyhedron().p3; + N.p3 += v->renderCSGMesh().p3; } v->progress_report(); } @@ -291,7 +298,7 @@ CGAL_Nef_polyhedron TransformNode::render_cgal_nef_polyhedron() const ps.is2d = true; dxf_tesselate(&ps, &dd, 0, true, false, 0); - N = ps.render_cgal_nef_polyhedron(); + N = ps.renderCSGMesh(); ps.refcount = 0; } if (N.dim == 3) { @@ -368,6 +375,32 @@ QString TransformNode::dump(QString indent) const return dump_cache; } +std::string TransformNode::toString() const +{ + std::stringstream stream; + stream << "n" << this->index() << ": "; + + if (m[16] >= 0 || m[17] >= 0 || m[18] >= 0 || m[19] >= 0) { + stream << "color([" << m[16] << ", " << m[17] << ", " << m[18] << ", " << m[19] << "])"; + } + else { + stream << "multmatrix(["; + for (int j=0;j<4;j++) { + stream << "["; + for (int i=0;i<4;i++) { + // FIXME: The 0 test is to avoid a leading minus before a single 0 (cosmetics) + stream << ((m[i*4+j]==0)?0:m[i*4+j]); + if (i != 3) stream << ", "; + } + stream << "]"; + if (j != 3) stream << ", "; + } + stream << "])"; + } + + return stream.str(); +} + void register_builtin_transform() { builtin_modules["scale"] = new TransformModule(SCALE); @@ -377,4 +410,3 @@ void register_builtin_transform() builtin_modules["multmatrix"] = new TransformModule(MULTMATRIX); builtin_modules["color"] = new TransformModule(COLOR); } - diff --git a/src/traverser.cc b/src/traverser.cc new file mode 100644 index 0000000..af29132 --- /dev/null +++ b/src/traverser.cc @@ -0,0 +1,40 @@ +#include "traverser.h" +#include "visitor.h" +#include "node.h" +#include "state.h" + +void Traverser::execute() +{ + State state(NULL); + traverse(state, this->root); +} + +void Traverser::traverse(const State &state, const AbstractNode &node) +{ + // FIXME: Handle abort + + State newstate = state; + newstate.setNumChildren(node.getChildren().size()); + + if (traversaltype == PREFIX || traversaltype == PRE_AND_POSTFIX) { + newstate.setPrefix(true); + newstate.setParent(state.parent()); + node.accept(newstate, this->visitor); + } + + newstate.setParent(&node); + const std::list &children = node.getChildren(); + for (std::list::const_iterator iter = children.begin(); + iter != children.end(); + iter++) { + + traverse(newstate, **iter); + } + + if (traversaltype == POSTFIX || traversaltype == PRE_AND_POSTFIX) { + newstate.setParent(state.parent()); + newstate.setPrefix(false); + newstate.setPostfix(true); + node.accept(newstate, this->visitor); + } +} diff --git a/src/traverser.h b/src/traverser.h new file mode 100644 index 0000000..80913e3 --- /dev/null +++ b/src/traverser.h @@ -0,0 +1,26 @@ +#ifndef TRAVERSER_H_ +#define TRAVERSER_H_ + +enum Response {ContinueTraversal, AbortTraversal, PruneTraversal}; + +class Traverser +{ +public: + enum TraversalType {PREFIX, POSTFIX, PRE_AND_POSTFIX}; + + Traverser(class Visitor &visitor, const class AbstractNode &root, TraversalType travtype) + : visitor(visitor), root(root), traversaltype(travtype) { + } + virtual ~Traverser() { } + + void execute(); +private: + // FIXME: reverse parameters + void traverse(const class State &state, const AbstractNode &node); + + Visitor &visitor; + const AbstractNode &root; + TraversalType traversaltype; +}; + +#endif diff --git a/src/value.h b/src/value.h index 3491cbb..982d5d8 100644 --- a/src/value.h +++ b/src/value.h @@ -59,6 +59,7 @@ public: bool getv2(double &x, double &y) const; bool getv3(double &x, double &y, double &z) const; + // FIXME: stream support QString dump() const; private: diff --git a/src/visitor.h b/src/visitor.h new file mode 100644 index 0000000..7867446 --- /dev/null +++ b/src/visitor.h @@ -0,0 +1,52 @@ +#ifndef VISITOR_H_ +#define VISITOR_H_ + +#include "traverser.h" + +class Visitor +{ +public: + Visitor() {} + virtual ~Visitor() {} + + virtual Response visit(const class State &state, const class AbstractNode &node) = 0; + virtual Response visit(const class State &state, const class AbstractIntersectionNode &node) { + return visit(state, (const class AbstractNode &)node); + } + virtual Response visit(const class State &state, const class AbstractPolyNode &node) { + return visit(state, (const class AbstractNode &)node); + } + virtual Response visit(const class State &state, const class CgaladvNode &node) { + return visit(state, (const class AbstractNode &)node); + } + virtual Response visit(const class State &state, const class CsgNode &node) { + return visit(state, (const class AbstractNode &)node); + } + virtual Response visit(const class State &state, const class DxfLinearExtrudeNode &node) { + return visit(state, (const class AbstractPolyNode &)node); + } + virtual Response visit(const class State &state, const class DxfRotateExtrudeNode &node) { + return visit(state, (const class AbstractPolyNode &)node); + } + virtual Response visit(const class State &state, const class ImportNode &node) { + return visit(state, (const class AbstractPolyNode &)node); + } + virtual Response visit(const class State &state, const class PrimitiveNode &node) { + return visit(state, (const class AbstractPolyNode &)node); + } + virtual Response visit(const class State &state, const class ProjectionNode &node) { + return visit(state, (const class AbstractPolyNode &)node); + } + virtual Response visit(const class State &state, const class RenderNode &node) { + return visit(state, (const class AbstractNode &)node); + } + virtual Response visit(const class State &state, const class SurfaceNode &node) { + return visit(state, (const class AbstractPolyNode &)node); + } + virtual Response visit(const class State &state, const class TransformNode &node) { + return visit(state, (const class AbstractNode &)node); + } + // Add visit() methods for new visitable subtypes of AbstractNode here +}; + +#endif diff --git a/test-code/dumptest.cc b/test-code/dumptest.cc index 45d19ff..cb2b13c 100644 --- a/test-code/dumptest.cc +++ b/test-code/dumptest.cc @@ -30,7 +30,7 @@ #include "value.h" #include "export.h" #include "builtin.h" -//#include "nodedumper.h" +#include "nodedumper.h" #include #include @@ -148,17 +148,19 @@ int main(int argc, char **argv) QString dumpstr_cached = root_node->dump(""); if (dumpstr != dumpstr_cached) rc = 1; - printf(dumpstr.toUtf8()); - -#if 0 NodeDumper dumper; Traverser trav(dumper, *root_node, Traverser::PRE_AND_POSTFIX); trav.execute(); - std::string dumpstdstr = dumper.getDump(); + std::string dumpstdstr = dumper.getDump() + "\n"; trav.execute(); - std::string dumpstdstr_cached = dumper.getDump(); + std::string dumpstdstr_cached = dumper.getDump() + "\n"; if (dumpstdstr != dumpstdstr_cached) rc = 1; -#endif + + if (QString::fromStdString(dumpstdstr) != dumpstr) { + printf(dumpstr.toUtf8()); + printf(dumpstdstr.c_str()); + rc = 1; + } destroy_builtin_functions(); destroy_builtin_modules(); diff --git a/test-code/dumptest.pro b/test-code/dumptest.pro index a6729f7..d196cda 100644 --- a/test-code/dumptest.pro +++ b/test-code/dumptest.pro @@ -50,11 +50,23 @@ HEADERS += ../src/builtin.h \ ../src/grid.h \ ../src/module.h \ ../src/node.h \ + ../src/dxflinextrudenode.h \ + ../src/dxfrotextrudenode.h \ + ../src/projectionnode.h \ + ../src/importnode.h \ + ../src/csgnode.h \ ../src/openscad.h \ ../src/polyset.h \ ../src/printutils.h \ ../src/value.h \ - ../src/progress.h + ../src/progress.h \ + ../src/traverser.h \ + ../src/csgnode.h \ + ../src/visitor.h \ + ../src/nodedumper.h \ + ../src/nodecache.h \ + ../src/importnode.h \ + ../src/state.h SOURCES += dumptest.cc \ ../src/export.cc \ @@ -83,4 +95,6 @@ SOURCES += dumptest.cc \ ../src/dxflinextrude.cc \ ../src/dxfrotextrude.cc \ ../src/printutils.cc \ - ../src/progress.cc + ../src/progress.cc \ + ../src/nodedumper.cc \ + ../src/traverser.cc -- cgit v0.10.1 From a41eda3afe73bd29d5fd8f2801a0ad153e264e7a Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 31 Oct 2010 01:19:28 +0000 Subject: FIXME's added to AbstractNode git-svn-id: http://svn.clifford.at/openscad/trunk@572 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/node.h b/src/node.h index 08a5cb1..f3a5b0b 100644 --- a/src/node.h +++ b/src/node.h @@ -19,6 +19,10 @@ void progress_report_fin(); class AbstractNode { + // FIXME: the idx_counter/idx is mostly (only?) for debugging. + // We can hash on pointer value or smth. else. + // -> remove and + // use smth. else to display node identifier in CSG tree output? static int idx_counter; // Node instantiation index public: AbstractNode(const class ModuleInstantiation *mi); @@ -34,19 +38,28 @@ public: static void resetIndexCounter() { idx_counter = 1; } + // FIXME: Rewrite to STL container? + // FIXME: Make protected QVector children; const ModuleInstantiation *modinst; - + + // progress_mark is a running number used for progress indication + // FIXME: Make all progress handling external, put it in the traverser class? int progress_mark; void progress_prepare(); void progress_report() const; int idx; // Node index (unique per tree) - QString dump_cache; + // FIXME: Remove these three with dump() method + QString dump_cache; + virtual QString mk_cache_id() const; + virtual QString dump(QString indent) const; + // FIXME: Rewrite to visitor + virtual class CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; - virtual QString mk_cache_id() const; + // FIXME: Rewrite to visitor #ifdef ENABLE_CGAL struct cgal_nef_cache_entry { CGAL_Nef_polyhedron N; @@ -57,8 +70,6 @@ public: virtual CGAL_Nef_polyhedron renderCSGMesh() const; class CSGTerm *render_csg_term_from_nef(double m[20], QVector *highlights, QVector *background, const char *statement, int convexity) const; #endif - virtual class CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; - virtual QString dump(QString indent) const; }; class AbstractIntersectionNode : public AbstractNode -- cgit v0.10.1 From 1611f6230ed0d887d1480751089cd596b7216727 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 31 Oct 2010 01:58:50 +0000 Subject: Reverted accidental commits git-svn-id: http://svn.clifford.at/openscad/trunk@573 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/openscad.pro b/openscad.pro index fec7a79..42a5d22 100644 --- a/openscad.pro +++ b/openscad.pro @@ -98,22 +98,12 @@ HEADERS += src/CGAL_renderer.h \ src/highlighter.h \ src/module.h \ src/node.h \ - src/csgnode.h \ - src/dxflinextrudenode.h \ - src/dxfrotextrudenode.h \ - src/projectionnode.h \ - src/importnode.h \ src/openscad.h \ src/polyset.h \ src/printutils.h \ src/value.h \ src/progress.h \ - src/editor.h \ - src/visitor.h \ - src/state.h \ - src/traverser.h \ - src/nodecache.h \ - src/nodedumper.h + src/editor.h SOURCES += src/openscad.cc \ src/mainwin.cc \ @@ -150,9 +140,7 @@ SOURCES += src/openscad.cc \ src/nef2dxf.cc \ src/Preferences.cc \ src/progress.cc \ - src/editor.cc \\ - src/traverser.cc \ - src/nodedumper.cc + src/editor.cc macx { HEADERS += src/AppleEvents.h \ diff --git a/src/cgaladv.cc b/src/cgaladv.cc index e391ea8..829bc84 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -29,8 +29,6 @@ #include "builtin.h" #include "printutils.h" #include "cgal.h" -#include "visitor.h" -#include #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); @@ -54,21 +52,15 @@ public: class CgaladvNode : public AbstractNode { public: - CgaladvNode(const ModuleInstantiation *mi, cgaladv_type_e type) : AbstractNode(mi), type(type) { - convexity = 1; - } - virtual ~CgaladvNode() { } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - Value path; QString subdiv_type; int convexity, level; cgaladv_type_e type; + CgaladvNode(const ModuleInstantiation *mi, cgaladv_type_e type) : AbstractNode(mi), type(type) { + convexity = 1; + } #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron renderCSGMesh() const; + virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -136,7 +128,7 @@ void register_builtin_cgaladv() #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron CgaladvNode::renderCSGMesh() const +CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -155,11 +147,11 @@ CGAL_Nef_polyhedron CgaladvNode::renderCSGMesh() const if (v->modinst->tag_background) continue; if (first) { - N = v->renderCsgMesh(); + N = v->render_cgal_nef_polyhedron(); if (N.dim != 0) first = false; } else { - CGAL_Nef_polyhedron tmp = v->renderCsgMesh(); + CGAL_Nef_polyhedron tmp = v->render_cgal_nef_polyhedron(); if (N.dim == 3 && tmp.dim == 3) { N.p3 = minkowski3(N.p3, tmp.p3); } @@ -232,24 +224,3 @@ QString CgaladvNode::dump(QString indent) const return dump_cache; } -std::string CgaladvNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - switch (type) { - case MINKOWSKI: - stream << "minkowski(convexity = " << this->convexity << ")"; - break; - case GLIDE: - stream << "glide(path = " << this->path.dump() << ", convexity = " << this->convexity << ")"; - break; - case SUBDIV: - stream << "subdiv(level = " << this->level << ", convexity = " << this->convexity << ")"; - break; - default: - assert(false); - } - - return stream.str(); -} diff --git a/src/csgnode.h b/src/csgnode.h deleted file mode 100644 index 405dd96..0000000 --- a/src/csgnode.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CSGNODE_H_ -#define CSGNODE_H_ - -#include "node.h" -#include "visitor.h" -#ifdef ENABLE_CGAL -# include "cgal.h" -#endif - -enum csg_type_e { - CSG_TYPE_UNION, - CSG_TYPE_DIFFERENCE, - CSG_TYPE_INTERSECTION -}; - -class CsgNode : public AbstractNode -{ -public: - csg_type_e type; - CsgNode(const ModuleInstantiation *mi, csg_type_e type) : AbstractNode(mi), type(type) { } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - -#ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron renderCSGMesh() const; -#endif - CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; - virtual QString dump(QString indent) const; -}; - -#endif diff --git a/src/csgops.cc b/src/csgops.cc index 5baa149..ae97085 100644 --- a/src/csgops.cc +++ b/src/csgops.cc @@ -23,13 +23,22 @@ * */ -#include "csgnode.h" - #include "module.h" +#include "node.h" #include "csgterm.h" #include "builtin.h" #include "printutils.h" -#include +#ifdef ENABLE_CGAL +# include "cgal.h" +# include +# include +#endif + +enum csg_type_e { + CSG_TYPE_UNION, + CSG_TYPE_DIFFERENCE, + CSG_TYPE_INTERSECTION +}; class CsgModule : public AbstractModule { @@ -39,6 +48,18 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; +class CsgNode : public AbstractNode +{ +public: + csg_type_e type; + CsgNode(const ModuleInstantiation *mi, csg_type_e type) : AbstractNode(mi), type(type) { } +#ifdef ENABLE_CGAL + virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; +#endif + CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; + virtual QString dump(QString indent) const; +}; + AbstractNode *CsgModule::evaluate(const Context*, const ModuleInstantiation *inst) const { CsgNode *node = new CsgNode(inst, type); @@ -52,7 +73,7 @@ AbstractNode *CsgModule::evaluate(const Context*, const ModuleInstantiation *ins #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron CsgNode::renderCSGMesh() const +CGAL_Nef_polyhedron CsgNode::render_cgal_nef_polyhedron() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -71,24 +92,24 @@ CGAL_Nef_polyhedron CsgNode::renderCSGMesh() const if (v->modinst->tag_background) continue; if (first) { - N = v->renderCSGMesh(); + N = v->render_cgal_nef_polyhedron(); if (N.dim != 0) first = false; } else if (N.dim == 2) { if (type == CSG_TYPE_UNION) { - N.p2 += v->renderCSGMesh().p2; + N.p2 += v->render_cgal_nef_polyhedron().p2; } else if (type == CSG_TYPE_DIFFERENCE) { - N.p2 -= v->renderCSGMesh().p2; + N.p2 -= v->render_cgal_nef_polyhedron().p2; } else if (type == CSG_TYPE_INTERSECTION) { - N.p2 *= v->renderCSGMesh().p2; + N.p2 *= v->render_cgal_nef_polyhedron().p2; } } else if (N.dim == 3) { if (type == CSG_TYPE_UNION) { - N.p3 += v->renderCSGMesh().p3; + N.p3 += v->render_cgal_nef_polyhedron().p3; } else if (type == CSG_TYPE_DIFFERENCE) { - N.p3 -= v->renderCSGMesh().p3; + N.p3 -= v->render_cgal_nef_polyhedron().p3; } else if (type == CSG_TYPE_INTERSECTION) { - N.p3 *= v->renderCSGMesh().p3; + N.p3 *= v->render_cgal_nef_polyhedron().p3; } } v->progress_report(); @@ -151,28 +172,6 @@ QString CsgNode::dump(QString indent) const return dump_cache; } -std::string CsgNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - switch (this->type) { - case CSG_TYPE_UNION: - stream << "union()"; - break; - case CSG_TYPE_DIFFERENCE: - stream << "difference()"; - break; - case CSG_TYPE_INTERSECTION: - stream << "intersection()"; - break; - default: - assert(false); - } - - return stream.str(); -} - void register_builtin_csgops() { builtin_modules["union"] = new CsgModule(CSG_TYPE_UNION); diff --git a/src/dxflinextrude.cc b/src/dxflinextrude.cc index 1f6bc8c..83c3d9c 100644 --- a/src/dxflinextrude.cc +++ b/src/dxflinextrude.cc @@ -23,9 +23,8 @@ * */ -#include "dxflinextrudenode.h" - #include "module.h" +#include "node.h" #include "context.h" #include "printutils.h" #include "builtin.h" @@ -33,13 +32,11 @@ #include "dxftess.h" #include "polyset.h" #include "progress.h" -#include "visitor.h" #include "openscad.h" // get_fragments_from_r() #include #include #include -#include #include #include @@ -52,6 +49,24 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; +class DxfLinearExtrudeNode : public AbstractPolyNode +{ +public: + int convexity, slices; + double fn, fs, fa, height, twist; + double origin_x, origin_y, scale; + bool center, has_twist; + QString filename, layername; + DxfLinearExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + convexity = slices = 0; + fn = fs = fa = height = twist = 0; + origin_x = origin_y = scale = 0; + center = has_twist = false; + } + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + AbstractNode *DxfLinearExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { DxfLinearExtrudeNode *node = new DxfLinearExtrudeNode(inst); @@ -76,8 +91,10 @@ AbstractNode *DxfLinearExtrudeModule::evaluate(const Context *ctx, const ModuleI Value twist = c.lookup_variable("twist", true); Value slices = c.lookup_variable("slices", true); - if (!file.text.isNull()) + if(!file.text.isNull()) node->filename = c.get_absolute_path(file.text); + else + node->filename = file.text; node->layername = layer.text; node->height = height.num; @@ -219,7 +236,7 @@ PolySet *DxfLinearExtrudeNode::render_polyset(render_mode_e) const foreach(AbstractNode * v, children) { if (v->modinst->tag_background) continue; - N.p2 += v->renderCSGMesh().p2; + N.p2 += v->render_cgal_nef_polyhedron().p2; } dxf = new DxfData(N); @@ -327,30 +344,3 @@ QString DxfLinearExtrudeNode::dump(QString indent) const return dump_cache; } -std::string DxfLinearExtrudeNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - QString text; - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(this->filename.toAscii().data(), &st); - - stream << "linear_extrude(" - "file = \"" << this->filename << "\", " - "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " - "layer = \"" << this->layername << "\", " - "height = " << std::dec << this->height << ", " - "origin = [ " << this->origin_x << " " << this->origin_y << " ], " - "scale = " << this->scale << ", " - "center = " << (this->center?"true":"false") << ", " - "convexity = " << this->convexity; - - if (this->has_twist) { - stream << ", twist = " << this->twist << ", slices = " << this->slices; - } - stream << ", $fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; - - return stream.str(); -} diff --git a/src/dxflinextrudenode.h b/src/dxflinextrudenode.h deleted file mode 100644 index 2df52c8..0000000 --- a/src/dxflinextrudenode.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DXFLINEXTRUDENODE_H_ -#define DXFLINEXTRUDENODE_H_ - -#include "node.h" -#include "visitor.h" - -class DxfLinearExtrudeNode : public AbstractPolyNode -{ -public: - DxfLinearExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - convexity = slices = 0; - fn = fs = fa = height = twist = 0; - origin_x = origin_y = scale = 0; - center = has_twist = false; - } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - - int convexity, slices; - double fn, fs, fa, height, twist; - double origin_x, origin_y, scale; - bool center, has_twist; - QString filename, layername; - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - -#endif diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc index 98f91f3..ea603f0 100644 --- a/src/dxfrotextrude.cc +++ b/src/dxfrotextrude.cc @@ -23,21 +23,19 @@ * */ -#include "dxfrotextrudenode.h" #include "module.h" +#include "node.h" #include "context.h" #include "printutils.h" #include "builtin.h" #include "polyset.h" #include "dxfdata.h" #include "progress.h" -#include "visitor.h" #include "openscad.h" // get_fragments_from_r() #include #include #include -#include #include #include @@ -50,6 +48,22 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; +class DxfRotateExtrudeNode : public AbstractPolyNode +{ +public: + int convexity; + double fn, fs, fa; + double origin_x, origin_y, scale; + QString filename, layername; + DxfRotateExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + convexity = 0; + fn = fs = fa = 0; + origin_x = origin_y = scale = 0; + } + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + AbstractNode *DxfRotateExtrudeModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { DxfRotateExtrudeNode *node = new DxfRotateExtrudeNode(inst); @@ -70,8 +84,10 @@ AbstractNode *DxfRotateExtrudeModule::evaluate(const Context *ctx, const ModuleI Value origin = c.lookup_variable("origin", true); Value scale = c.lookup_variable("scale", true); - if (!file.text.isNull()) + if(!file.text.isNull()) node->filename = c.get_absolute_path(file.text); + else + node->filename = file.text; node->layername = layer.text; node->convexity = (int)convexity.num; @@ -120,7 +136,7 @@ PolySet *DxfRotateExtrudeNode::render_polyset(render_mode_e) const foreach(AbstractNode * v, children) { if (v->modinst->tag_background) continue; - N.p2 += v->renderCSGMesh().p2; + N.p2 += v->render_cgal_nef_polyhedron().p2; } dxf = new DxfData(N); @@ -218,22 +234,3 @@ QString DxfRotateExtrudeNode::dump(QString indent) const return dump_cache; } -std::string DxfRotateExtrudeNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(filename.toAscii().data(), &st); - stream << "rotate_extrude(" - "file = \"" << this->filename << "\", " - "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " - "layer = \"" << this->layername << "\", " - "origin = [ " << std::dec << this->origin_x << " " << this->origin_y << " ], " - "scale = " << this->scale << ", " - "convexity = " << this->convexity << ", " - "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; - - return stream.str(); -} diff --git a/src/dxfrotextrudenode.h b/src/dxfrotextrudenode.h deleted file mode 100644 index fbe2b85..0000000 --- a/src/dxfrotextrudenode.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DXFROTEXTRUDENODE_H_ -#define DXFROTEXTRUDENODE_H_ - -#include "node.h" -#include "visitor.h" - -class DxfRotateExtrudeNode : public AbstractPolyNode -{ -public: - DxfRotateExtrudeNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - convexity = 0; - fn = fs = fa = 0; - origin_x = origin_y = scale = 0; - } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - - int convexity; - double fn, fs, fa; - double origin_x, origin_y, scale; - QString filename, layername; - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - -#endif diff --git a/src/import.cc b/src/import.cc index 5d0a497..bab13ae 100644 --- a/src/import.cc +++ b/src/import.cc @@ -23,9 +23,8 @@ * */ -#include "importnode.h" - #include "module.h" +#include "node.h" #include "polyset.h" #include "context.h" #include "builtin.h" @@ -37,7 +36,12 @@ #include #include #include -#include + +enum import_type_e { + TYPE_STL, + TYPE_OFF, + TYPE_DXF +}; class ImportModule : public AbstractModule { @@ -47,6 +51,20 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; +class ImportNode : public AbstractPolyNode +{ +public: + import_type_e type; + QString filename; + QString layername; + int convexity; + double fn, fs, fa; + double origin_x, origin_y, scale; + ImportNode(const ModuleInstantiation *mi, import_type_e type) : AbstractPolyNode(mi), type(type) { } + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { ImportNode *node = new ImportNode(inst, type); @@ -213,39 +231,3 @@ QString ImportNode::dump(QString indent) const return dump_cache; } -std::string ImportNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - QString text; - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(this->filename.toAscii().data(), &st); - - switch (this->type) { - case TYPE_STL: - stream << "import_stl(file = \"" << this->filename << "\", " - "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " - "convexity = " << std::dec << this->convexity << ")"; - break; - case TYPE_OFF: - stream << "import_off(file = \"" << this->filename << "\", " - "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " - "convexity = " << std::dec << this->convexity << ")"; - break; - case TYPE_DXF: - stream << "import_dxf(file = \"" << this->filename << "\", " - "cache = \"" << std::hex << (int)st.st_mtime << "." << (int)st.st_size << "\", " - "layer = \"" << this->layername << "\", " - "origin = [ " << std::dec << this->origin_x << " " << this->origin_y << " ], " - "scale = " << this->scale << ", " - "convexity = " << this->convexity << ", " - "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; - break; - default: - assert(false); - } - - return stream.str(); -} diff --git a/src/importnode.h b/src/importnode.h deleted file mode 100644 index b226569..0000000 --- a/src/importnode.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef IMPORTNODE_H_ -#define IMPORTNODE_H_ - -#include "node.h" -#include "visitor.h" - -enum import_type_e { - TYPE_STL, - TYPE_OFF, - TYPE_DXF -}; - -class ImportNode : public AbstractPolyNode -{ -public: - ImportNode(const ModuleInstantiation *mi, import_type_e type) : AbstractPolyNode(mi), type(type) { } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - - import_type_e type; - QString filename; - QString layername; - int convexity; - double fn, fs, fa; - double origin_x, origin_y, scale; - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - -#endif diff --git a/src/mainwin.cc b/src/mainwin.cc index 1bf2695..ef738fc 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1126,7 +1126,7 @@ void MainWindow::actionRenderCGAL() progress_report_prep(root_node, report_func, pd); try { - this->root_N = new CGAL_Nef_polyhedron(root_node->renderCSGMesh()); + this->root_N = new CGAL_Nef_polyhedron(root_node->render_cgal_nef_polyhedron()); } catch (ProgressCancelException e) { PRINT("Rendering cancelled."); diff --git a/src/node.cc b/src/node.cc index 437fdfa..87a7051 100644 --- a/src/node.cc +++ b/src/node.cc @@ -29,9 +29,7 @@ #include "csgterm.h" #include "progress.h" #include "polyset.h" -#include "visitor.h" #include -#include int AbstractNode::idx_counter; @@ -47,21 +45,6 @@ AbstractNode::~AbstractNode() delete v; } -Response AbstractNode::accept(const class State &state, Visitor &visitor) const -{ - return visitor.visit(state, *this); -} - -Response AbstractIntersectionNode::accept(const class State &state, Visitor &visitor) const -{ - return visitor.visit(state, *this); -} - -Response AbstractPolyNode::accept(const class State &state, Visitor &visitor) const -{ - return visitor.visit(state, *this); -} - QString AbstractNode::mk_cache_id() const { QString cache_id = dump(""); @@ -96,19 +79,19 @@ static CGAL_Nef_polyhedron render_cgal_nef_polyhedron_backend(const AbstractNode if (v->modinst->tag_background) continue; if (first) { - N = v->renderCSGMesh(); + N = v->render_cgal_nef_polyhedron(); if (N.dim != 0) first = false; } else if (N.dim == 2) { if (intersect) - N.p2 *= v->renderCSGMesh().p2; + N.p2 *= v->render_cgal_nef_polyhedron().p2; else - N.p2 += v->renderCSGMesh().p2; + N.p2 += v->render_cgal_nef_polyhedron().p2; } else { if (intersect) - N.p3 *= v->renderCSGMesh().p3; + N.p3 *= v->render_cgal_nef_polyhedron().p3; else - N.p3 += v->renderCSGMesh().p3; + N.p3 += v->render_cgal_nef_polyhedron().p3; } v->progress_report(); } @@ -120,12 +103,12 @@ static CGAL_Nef_polyhedron render_cgal_nef_polyhedron_backend(const AbstractNode return N; } -CGAL_Nef_polyhedron AbstractNode::renderCSGMesh() const +CGAL_Nef_polyhedron AbstractNode::render_cgal_nef_polyhedron() const { return render_cgal_nef_polyhedron_backend(this, false); } -CGAL_Nef_polyhedron AbstractIntersectionNode::renderCSGMesh() const +CGAL_Nef_polyhedron AbstractIntersectionNode::render_cgal_nef_polyhedron() const { return render_cgal_nef_polyhedron_backend(this, true); } @@ -176,17 +159,10 @@ QString AbstractNode::dump(QString indent) const return dump_cache; } -std::string AbstractNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": group()"; - return stream.str(); -} - QString AbstractIntersectionNode::dump(QString indent) const { if (dump_cache.isEmpty()) { - QString text = indent + QString::fromStdString(this->toString()) + " {\n"; + QString text = indent + QString("n%1: intersection() {\n").arg(idx); foreach (AbstractNode *v, children) text += v->dump(indent + QString("\t")); ((AbstractNode*)this)->dump_cache = text + indent + "}\n"; @@ -194,13 +170,6 @@ QString AbstractIntersectionNode::dump(QString indent) const return dump_cache; } -std::string AbstractIntersectionNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": intersection()"; - return stream.str(); -} - void AbstractNode::progress_prepare() { foreach (AbstractNode *v, children) @@ -215,7 +184,7 @@ void AbstractNode::progress_report() const #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron AbstractPolyNode::renderCSGMesh() const +CGAL_Nef_polyhedron AbstractPolyNode::render_cgal_nef_polyhedron() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -228,7 +197,7 @@ CGAL_Nef_polyhedron AbstractPolyNode::renderCSGMesh() const PolySet *ps = render_polyset(RENDER_CGAL); try { - CGAL_Nef_polyhedron N = ps->renderCSGMesh(); + CGAL_Nef_polyhedron N = ps->render_cgal_nef_polyhedron(); cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); print_messages_pop(); progress_report(); @@ -262,15 +231,3 @@ CSGTerm *AbstractPolyNode::render_csg_term_from_ps(double m[20], QVector remove and - // use smth. else to display node identifier in CSG tree output? static int idx_counter; // Node instantiation index public: - AbstractNode(const class ModuleInstantiation *mi); - virtual ~AbstractNode(); - virtual Response accept(const class State &state, class Visitor &visitor) const; - virtual std::string toString() const; - - // FIXME: Make return value a reference - const std::list getChildren() const { - return this->children.toList().toStdList(); - } - int index() const { return this->idx; } - static void resetIndexCounter() { idx_counter = 1; } - // FIXME: Rewrite to STL container? - // FIXME: Make protected QVector children; - const ModuleInstantiation *modinst; + const class ModuleInstantiation *modinst; - // progress_mark is a running number used for progress indication - // FIXME: Make all progress handling external, put it in the traverser class? int progress_mark; void progress_prepare(); void progress_report() const; - int idx; // Node index (unique per tree) - - // FIXME: Remove these three with dump() method + int idx; QString dump_cache; - virtual QString mk_cache_id() const; - virtual QString dump(QString indent) const; - - // FIXME: Rewrite to visitor - virtual class CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; - // FIXME: Rewrite to visitor + AbstractNode(const ModuleInstantiation *mi); + virtual ~AbstractNode(); + virtual QString mk_cache_id() const; #ifdef ENABLE_CGAL struct cgal_nef_cache_entry { CGAL_Nef_polyhedron N; @@ -67,21 +41,19 @@ public: cgal_nef_cache_entry(const CGAL_Nef_polyhedron &N); }; static QCache cgal_nef_cache; - virtual CGAL_Nef_polyhedron renderCSGMesh() const; + virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; class CSGTerm *render_csg_term_from_nef(double m[20], QVector *highlights, QVector *background, const char *statement, int convexity) const; #endif + virtual class CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; + virtual QString dump(QString indent) const; }; class AbstractIntersectionNode : public AbstractNode { public: AbstractIntersectionNode(const ModuleInstantiation *mi) : AbstractNode(mi) { }; - virtual ~AbstractIntersectionNode() { }; - virtual Response accept(const class State &state, class Visitor &visitor) const; - virtual std::string toString() const; - #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron renderCSGMesh() const; + virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -90,24 +62,17 @@ public: class AbstractPolyNode : public AbstractNode { public: - AbstractPolyNode(const ModuleInstantiation *mi) : AbstractNode(mi) { }; - virtual ~AbstractPolyNode() { }; - virtual Response accept(const class State &state, class Visitor &visitor) const; - enum render_mode_e { RENDER_CGAL, RENDER_OPENCSG }; + AbstractPolyNode(const ModuleInstantiation *mi) : AbstractNode(mi) { }; virtual class PolySet *render_polyset(render_mode_e mode) const = 0; #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron renderCSGMesh() const; + virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; static CSGTerm *render_csg_term_from_ps(double m[20], QVector *highlights, QVector *background, PolySet *ps, const ModuleInstantiation *modinst, int idx); }; -std::ostream &operator<<(std::ostream &stream, const AbstractNode &node); -// FIXME: Doesn't belong here.. -std::ostream &operator<<(std::ostream &stream, const QString &str); - #endif diff --git a/src/nodecache.h b/src/nodecache.h deleted file mode 100644 index c5a5524..0000000 --- a/src/nodecache.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef NODECACHE_H_ -#define NODECACHE_H_ - -#include -#include "node.h" - -template -class NodeCache -{ -public: - NodeCache() { } - virtual ~NodeCache() { } - - const T & operator[](const AbstractNode &node) const { - if (this->cache.size() > node.index()) return this->cache[node.index()]; - else return nullvalue; - } - - void insert(const class AbstractNode &node, const T & value) { - this->cache.resize(node.index() + 1); - this->cache[node.index()] = value; - } - - void remove(const class AbstractNode &node) { - if (this->cache.size() > node.index()) this->cache[node.index()] = nullvalue; - } - -private: - std::vector cache; - T nullvalue; -}; - -#endif diff --git a/src/nodedumper.cc b/src/nodedumper.cc deleted file mode 100644 index 1956a89..0000000 --- a/src/nodedumper.cc +++ /dev/null @@ -1,98 +0,0 @@ -#include "nodedumper.h" -#include -#include -#include -#include "visitor.h" -#include "state.h" -#include "nodecache.h" - -#include -#include - -// For compatibility with old dump() output -#define NODEDUMPER_COMPAT_MODE -#ifdef NODEDUMPER_COMPAT_MODE -#include "dxflinextrudenode.h" -#include "dxfrotextrudenode.h" -#include "projectionnode.h" -#endif - - -bool NodeDumper::isCached(const AbstractNode &node) -{ - return !this->cache[node].empty(); -} - -void NodeDumper::handleIndent(const State &state) -{ - if (state.isPrefix()) { - this->currindent += "\t"; - } - else if (state.isPostfix()) { - this->currindent.erase((this->currindent.length() >= 1) ? - this->currindent.length() - 1 : 0); - } -} - -string NodeDumper::dumpChildren(const AbstractNode &node) -{ - std::stringstream dump; - if (!this->visitedchildren[node.index()].empty()) { - dump << " {\n"; - - for (ChildList::const_iterator iter = this->visitedchildren[node.index()].begin(); - iter != this->visitedchildren[node.index()].end(); - iter++) { - dump << this->cache[**iter] << "\n"; - } - - dump << this->currindent << "}"; - } - else { -#ifndef NODEDUMPER_COMPAT_MODE - dump << ";"; -#else - if (dynamic_cast(&node) && - !dynamic_cast(&node) && - !dynamic_cast(&node) && - !dynamic_cast(&node)) dump << ";"; - else dump << " {\n" << this->currindent << "}"; -#endif - } - return dump.str(); -} - - -Response NodeDumper::visit(const State &state, const AbstractNode &node) -{ - if (isCached(node)) return PruneTraversal; - else handleIndent(state); - if (state.isPostfix()) { - std::stringstream dump; - dump << this->currindent << node; - dump << dumpChildren(node); - this->cache.insert(node, dump.str()); - } - - handleVisitedChildren(state, node); - return ContinueTraversal; -} - -const string &NodeDumper::getDump() const -{ - assert(this->root); - return this->cache[*this->root]; -} - -void NodeDumper::handleVisitedChildren(const State &state, const AbstractNode &node) -{ - if (state.isPostfix()) { - this->visitedchildren.erase(node.index()); - if (!state.parent()) { - this->root = &node; - } - else { - this->visitedchildren[state.parent()->index()].push_back(&node); - } - } -} diff --git a/src/nodedumper.h b/src/nodedumper.h deleted file mode 100644 index 568d578..0000000 --- a/src/nodedumper.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef NODEDUMPER_H_ -#define NODEDUMPER_H_ - -#include -#include -#include -#include "visitor.h" -#include "nodecache.h" - -using std::string; -using std::map; -using std::list; - -class NodeDumper : public Visitor -{ -public: - NodeDumper() : root(NULL) {} - virtual ~NodeDumper() {} - - virtual Response visit(const State &state, const AbstractNode &node); - - const string &getDump() const; -private: - void handleVisitedChildren(const State &state, const AbstractNode &node); - bool isCached(const AbstractNode &node); - void handleIndent(const State &state); - string dumpChildren(const AbstractNode &node); - - string currindent; - const AbstractNode *root; - typedef list ChildList; - map visitedchildren; - NodeCache cache; -}; - - -#endif diff --git a/src/openscad.cc b/src/openscad.cc index fdd2502..bf24c9f 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -31,7 +31,6 @@ #include "value.h" #include "export.h" #include "builtin.h" -#include "nodedumper.h" #ifdef ENABLE_CGAL #include "cgal.h" @@ -285,20 +284,8 @@ int main(int argc, char **argv) AbstractNode::resetIndexCounter(); root_node = root_module->evaluate(&root_ctx, &root_inst); - NodeDumper dumper; - Traverser trav(dumper, *root_node, Traverser::PRE_AND_POSTFIX); - trav.execute(); -// std::cout << dumper.getDump(); -// std::cout << std::endl; -// trav.execute(); -// std::cout << dumper.getDump(); -// std::cout << std::endl; - printf(dumper.getDump().c_str()); - exit(1); - - CGAL_Nef_polyhedron *root_N; - root_N = new CGAL_Nef_polyhedron(root_node->renderCSGMesh()); + root_N = new CGAL_Nef_polyhedron(root_node->render_cgal_nef_polyhedron()); QDir::setCurrent(original_path.absolutePath()); diff --git a/src/polyset.cc b/src/polyset.cc index 4548f8a..d438769 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -144,9 +144,7 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m bool mirrored = m3f.determinant() < 0; if (colormode == COLORMODE_MATERIAL) { -// FIXME: Reenable/rewrite - don't be dependant on GUI -// const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_FRONT_COLOR); - const QColor &col = QColor(0xf9, 0xd7, 0x2c); + const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_FRONT_COLOR); glColor3f(col.redF(), col.greenF(), col.blueF()); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -156,9 +154,7 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m #endif /* ENABLE_OPENCSG */ } if (colormode == COLORMODE_CUTOUT) { -// FIXME: Reenable/rewrite - don't be dependant on GUI -// const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_BACK_COLOR); - const QColor &col = QColor(0x9d, 0xcb, 0x51); + const QColor &col = Preferences::inst()->color(Preferences::OPENCSG_FACE_BACK_COLOR); glColor3f(col.redF(), col.greenF(), col.blueF()); #ifdef ENABLE_OPENCSG if (shaderinfo) { @@ -411,7 +407,7 @@ public: } }; -CGAL_Nef_polyhedron PolySet::renderCSGMesh() const +CGAL_Nef_polyhedron PolySet::render_cgal_nef_polyhedron() const { if (this->is2d) { diff --git a/src/polyset.h b/src/polyset.h index 074f82e..0914e91 100644 --- a/src/polyset.h +++ b/src/polyset.h @@ -78,7 +78,7 @@ public: void render_edges(colormode_e colormode, csgmode_e csgmode) const; #ifdef ENABLE_CGAL - CGAL_Nef_polyhedron renderCSGMesh() const; + CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; #endif int refcount; diff --git a/src/primitives.cc b/src/primitives.cc index 8838547..ac1f0a3 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -32,8 +32,6 @@ #include "builtin.h" #include "printutils.h" #include -#include "visitor.h" -#include enum primitive_type_e { CUBE, @@ -56,18 +54,13 @@ public: class PrimitiveNode : public AbstractPolyNode { public: - PrimitiveNode(const ModuleInstantiation *mi, primitive_type_e type) : AbstractPolyNode(mi), type(type) { } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - bool center; double x, y, z, h, r1, r2; double fn, fs, fa; primitive_type_e type; int convexity; Value points, paths, triangles; + PrimitiveNode(const ModuleInstantiation *mi, primitive_type_e type) : AbstractPolyNode(mi), type(type) { } virtual PolySet *render_polyset(render_mode_e mode) const; virtual QString dump(QString indent) const; }; @@ -549,44 +542,3 @@ QString PrimitiveNode::dump(QString indent) const return dump_cache; } -std::string PrimitiveNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - switch (this->type) { - case CUBE: - stream << "cube(size = [" << this->x << ", " << this->y << ", " << this->z << "], " - << "center = " << (center ? "true" : "false") << ")"; - break; - case SPHERE: - stream << "sphere($fn = " << this->fn << ", $fa = " << this->fa - << ", $fs = " << this->fs << ", r = " << this->r1 << ")"; - break; - case CYLINDER: - stream << "cylinder($fn = " << this->fn << ", $fa = " << this->fa - << ", $fs = " << this->fs << ", h = " << this->h << ", r1 = " << this->r1 - << ", r2 = " << this->r2 << ", center = " << (center ? "true" : "false") << ")"; - break; - case POLYHEDRON: - stream << "polyhedron(points = " << this->points.dump() - << ", triangles = " << this->triangles.dump() - << ", convexity = " << this->convexity << ")"; - break; - case SQUARE: - stream << "square(size = [" << this->x << ", " << this->y << "], " - << "center = " << (center ? "true" : "false") << ")"; - break; - case CIRCLE: - stream << "circle($fn = " << this->fn << ", $fa = " << this->fa - << ", $fs = " << this->fs << ", r = " << this->r1 << ")"; - break; - case POLYGON: - stream << "polygon(points = " << this->points.dump() << ", paths = " << this->paths.dump() << ", convexity = " << this->convexity << ")"; - break; - default: - assert(false); - } - - return stream.str(); -} diff --git a/src/printutils.cc b/src/printutils.cc index 0f4c67d..8830a8c 100644 --- a/src/printutils.cc +++ b/src/printutils.cc @@ -18,7 +18,8 @@ void print_messages_push() void print_messages_pop() { - QString msg = print_messages_stack.takeLast(); + QString msg = print_messages_stack.last(); + print_messages_stack.removeLast(); if (print_messages_stack.size() > 0 && !msg.isNull()) { if (!print_messages_stack.last().isEmpty()) print_messages_stack.last() += "\n"; diff --git a/src/projection.cc b/src/projection.cc index 985ed20..7a3f77a 100644 --- a/src/projection.cc +++ b/src/projection.cc @@ -23,8 +23,8 @@ * */ -#include "projectionnode.h" #include "module.h" +#include "node.h" #include "context.h" #include "printutils.h" #include "builtin.h" @@ -33,7 +33,6 @@ #include "polyset.h" #include "export.h" #include "progress.h" -#include "visitor.h" #ifdef ENABLE_CGAL # include @@ -44,7 +43,6 @@ #include #include #include -#include #include #include @@ -57,6 +55,18 @@ public: virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const; }; +class ProjectionNode : public AbstractPolyNode +{ +public: + int convexity; + bool cut_mode; + ProjectionNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { + cut_mode = false; + } + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + AbstractNode *ProjectionModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const { ProjectionNode *node = new ProjectionNode(inst); @@ -112,7 +122,7 @@ PolySet *ProjectionNode::render_polyset(render_mode_e) const foreach(AbstractNode *v, this->children) { if (v->modinst->tag_background) continue; - N.p3 += v->renderCSGMesh().p3; + N.p3 += v->render_cgal_nef_polyhedron().p3; } } catch (CGAL::Assertion_exception e) { @@ -163,7 +173,7 @@ PolySet *ProjectionNode::render_polyset(render_mode_e) const cube->append_vertex(x1, y1, z1); cube->append_vertex(x1, y1, z2); cube->append_vertex(x1, y2, z2); - CGAL_Nef_polyhedron Ncube = cube->renderCSGMesh(); + CGAL_Nef_polyhedron Ncube = cube->render_cgal_nef_polyhedron(); cube->unlink(); // N.p3 *= CGAL_Nef_polyhedron3(CGAL_Plane(0, 0, 1, 0), CGAL_Nef_polyhedron3::INCLUDED); @@ -288,13 +298,3 @@ QString ProjectionNode::dump(QString indent) const return dump_cache; } -std::string ProjectionNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - stream << "projection(cut = " << (this->cut_mode ? "true" : "false") - << ", convexity = " << this->convexity << ")"; - - return stream.str(); -} diff --git a/src/projectionnode.h b/src/projectionnode.h deleted file mode 100644 index d5ba6da..0000000 --- a/src/projectionnode.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef PROJECTIONNODE_H_ -#define PROJECTIONNODE_H_ - -#include "node.h" -#include "visitor.h" - -class ProjectionNode : public AbstractPolyNode -{ -public: - ProjectionNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { - cut_mode = false; - } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - - int convexity; - bool cut_mode; - virtual PolySet *render_polyset(render_mode_e mode) const; - virtual QString dump(QString indent) const; -}; - -#endif diff --git a/src/render.cc b/src/render.cc index 5bd57fc..d851fc8 100644 --- a/src/render.cc +++ b/src/render.cc @@ -33,14 +33,13 @@ #include "builtin.h" #include "printutils.h" #include "progress.h" -#include "visitor.h" #ifdef ENABLE_CGAL # include "cgal.h" #endif +#include #include #include -#include class RenderModule : public AbstractModule { @@ -52,15 +51,10 @@ public: class RenderNode : public AbstractNode { public: - RenderNode(const ModuleInstantiation *mi) : AbstractNode(mi), convexity(1) { } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - int convexity; + RenderNode(const ModuleInstantiation *mi) : AbstractNode(mi), convexity(1) { } #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron renderCSGMesh() const; + virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; #endif CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -96,7 +90,7 @@ void register_builtin_render() #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron RenderNode::renderCSGMesh() const +CGAL_Nef_polyhedron RenderNode::render_cgal_nef_polyhedron() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -114,13 +108,13 @@ CGAL_Nef_polyhedron RenderNode::renderCSGMesh() const if (v->modinst->tag_background) continue; if (first) { - N = v->renderCSGMesh(); + N = v->render_cgal_nef_polyhedron(); if (N.dim != 0) first = false; } else if (N.dim == 2) { - N.p2 += v->renderCSGMesh().p2; + N.p2 += v->render_cgal_nef_polyhedron().p2; } else if (N.dim == 3) { - N.p3 += v->renderCSGMesh().p3; + N.p3 += v->render_cgal_nef_polyhedron().p3; } v->progress_report(); } @@ -159,7 +153,7 @@ CSGTerm *AbstractNode::render_csg_term_from_nef(double m[20], QVector QTime t; t.start(); - N = this->renderCSGMesh(); + N = this->render_cgal_nef_polyhedron(); int s = t.elapsed() / 1000; PRINTF_NOCACHE("..rendering time: %d hours, %d minutes, %d seconds", s / (60*60), (s / 60) % 60, s % 60); @@ -267,12 +261,3 @@ QString RenderNode::dump(QString indent) const return dump_cache; } -std::string RenderNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - stream << "render(convexity = " << convexity << ")"; - - return stream.str(); -} diff --git a/src/state.h b/src/state.h deleted file mode 100644 index 7ac8e9f..0000000 --- a/src/state.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef STATE_H_ -#define STATE_H_ - -class State -{ -public: - State(const class AbstractNode *parent) - : parentnode(parent), isprefix(false), ispostfix(false), numchildren(0) { } - virtual ~State() {} - - void setPrefix(bool on) { this->isprefix = on; } - void setPostfix(bool on) { this->ispostfix = on; } - void setNumChildren(unsigned int numc) { this->numchildren = numc; } - void setParent(const AbstractNode *parent) { this->parentnode = parent; } - - bool isPrefix() const { return this->isprefix; } - bool isPostfix() const { return this->ispostfix; } - unsigned int numChildren() const { return this->numchildren; } - const AbstractNode *parent() const { return this->parentnode; } - -private: - const AbstractNode * parentnode; - bool isprefix; - bool ispostfix; - unsigned int numchildren; -}; - -#endif diff --git a/src/surface.cc b/src/surface.cc index 57b3f59..ddcd3a6 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -31,10 +31,8 @@ #include "dxftess.h" #include "printutils.h" #include "openscad.h" // handle_dep() -#include "visitor.h" #include -#include class SurfaceModule : public AbstractModule { @@ -46,15 +44,10 @@ public: class SurfaceNode : public AbstractPolyNode { public: - SurfaceNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - QString filename; bool center; int convexity; + SurfaceNode(const ModuleInstantiation *mi) : AbstractPolyNode(mi) { } virtual PolySet *render_polyset(render_mode_e mode) const; virtual QString dump(QString indent) const; }; @@ -215,13 +208,3 @@ QString SurfaceNode::dump(QString indent) const return dump_cache; } -std::string SurfaceNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - stream << "surface(file = \"" << this->filename - << "\", center = " << (this->center ? "true" : "false") << ")"; - - return stream.str(); -} diff --git a/src/transform.cc b/src/transform.cc index 8f61c26..746283e 100644 --- a/src/transform.cc +++ b/src/transform.cc @@ -32,8 +32,6 @@ #include "dxftess.h" #include "builtin.h" #include "printutils.h" -#include "visitor.h" -#include enum transform_type_e { SCALE, @@ -55,15 +53,10 @@ public: class TransformNode : public AbstractNode { public: - TransformNode(const ModuleInstantiation *mi) : AbstractNode(mi) { } - virtual Response accept(const class State &state, Visitor &visitor) const { - return visitor.visit(state, *this); - } - virtual std::string toString() const; - double m[20]; + TransformNode(const ModuleInstantiation *mi) : AbstractNode(mi) { } #ifdef ENABLE_CGAL - virtual CGAL_Nef_polyhedron renderCSGMesh() const; + virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const; #endif virtual CSGTerm *render_csg_term(double m[20], QVector *highlights, QVector *background) const; virtual QString dump(QString indent) const; @@ -247,7 +240,7 @@ AbstractNode *TransformModule::evaluate(const Context *ctx, const ModuleInstanti #ifdef ENABLE_CGAL -CGAL_Nef_polyhedron TransformNode::renderCSGMesh() const +CGAL_Nef_polyhedron TransformNode::render_cgal_nef_polyhedron() const { QString cache_id = mk_cache_id(); if (cgal_nef_cache.contains(cache_id)) { @@ -265,13 +258,13 @@ CGAL_Nef_polyhedron TransformNode::renderCSGMesh() const if (v->modinst->tag_background) continue; if (first) { - N = v->renderCSGMesh(); + N = v->render_cgal_nef_polyhedron(); if (N.dim != 0) first = false; } else if (N.dim == 2) { - N.p2 += v->renderCSGMesh().p2; + N.p2 += v->render_cgal_nef_polyhedron().p2; } else if (N.dim == 3) { - N.p3 += v->renderCSGMesh().p3; + N.p3 += v->render_cgal_nef_polyhedron().p3; } v->progress_report(); } @@ -298,7 +291,7 @@ CGAL_Nef_polyhedron TransformNode::renderCSGMesh() const ps.is2d = true; dxf_tesselate(&ps, &dd, 0, true, false, 0); - N = ps.renderCSGMesh(); + N = ps.render_cgal_nef_polyhedron(); ps.refcount = 0; } if (N.dim == 3) { @@ -375,32 +368,6 @@ QString TransformNode::dump(QString indent) const return dump_cache; } -std::string TransformNode::toString() const -{ - std::stringstream stream; - stream << "n" << this->index() << ": "; - - if (m[16] >= 0 || m[17] >= 0 || m[18] >= 0 || m[19] >= 0) { - stream << "color([" << m[16] << ", " << m[17] << ", " << m[18] << ", " << m[19] << "])"; - } - else { - stream << "multmatrix(["; - for (int j=0;j<4;j++) { - stream << "["; - for (int i=0;i<4;i++) { - // FIXME: The 0 test is to avoid a leading minus before a single 0 (cosmetics) - stream << ((m[i*4+j]==0)?0:m[i*4+j]); - if (i != 3) stream << ", "; - } - stream << "]"; - if (j != 3) stream << ", "; - } - stream << "])"; - } - - return stream.str(); -} - void register_builtin_transform() { builtin_modules["scale"] = new TransformModule(SCALE); @@ -410,3 +377,4 @@ void register_builtin_transform() builtin_modules["multmatrix"] = new TransformModule(MULTMATRIX); builtin_modules["color"] = new TransformModule(COLOR); } + diff --git a/src/traverser.cc b/src/traverser.cc deleted file mode 100644 index af29132..0000000 --- a/src/traverser.cc +++ /dev/null @@ -1,40 +0,0 @@ -#include "traverser.h" -#include "visitor.h" -#include "node.h" -#include "state.h" - -void Traverser::execute() -{ - State state(NULL); - traverse(state, this->root); -} - -void Traverser::traverse(const State &state, const AbstractNode &node) -{ - // FIXME: Handle abort - - State newstate = state; - newstate.setNumChildren(node.getChildren().size()); - - if (traversaltype == PREFIX || traversaltype == PRE_AND_POSTFIX) { - newstate.setPrefix(true); - newstate.setParent(state.parent()); - node.accept(newstate, this->visitor); - } - - newstate.setParent(&node); - const std::list &children = node.getChildren(); - for (std::list::const_iterator iter = children.begin(); - iter != children.end(); - iter++) { - - traverse(newstate, **iter); - } - - if (traversaltype == POSTFIX || traversaltype == PRE_AND_POSTFIX) { - newstate.setParent(state.parent()); - newstate.setPrefix(false); - newstate.setPostfix(true); - node.accept(newstate, this->visitor); - } -} diff --git a/src/traverser.h b/src/traverser.h deleted file mode 100644 index 80913e3..0000000 --- a/src/traverser.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TRAVERSER_H_ -#define TRAVERSER_H_ - -enum Response {ContinueTraversal, AbortTraversal, PruneTraversal}; - -class Traverser -{ -public: - enum TraversalType {PREFIX, POSTFIX, PRE_AND_POSTFIX}; - - Traverser(class Visitor &visitor, const class AbstractNode &root, TraversalType travtype) - : visitor(visitor), root(root), traversaltype(travtype) { - } - virtual ~Traverser() { } - - void execute(); -private: - // FIXME: reverse parameters - void traverse(const class State &state, const AbstractNode &node); - - Visitor &visitor; - const AbstractNode &root; - TraversalType traversaltype; -}; - -#endif diff --git a/src/value.h b/src/value.h index 982d5d8..3491cbb 100644 --- a/src/value.h +++ b/src/value.h @@ -59,7 +59,6 @@ public: bool getv2(double &x, double &y) const; bool getv3(double &x, double &y, double &z) const; - // FIXME: stream support QString dump() const; private: diff --git a/src/visitor.h b/src/visitor.h deleted file mode 100644 index 7867446..0000000 --- a/src/visitor.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef VISITOR_H_ -#define VISITOR_H_ - -#include "traverser.h" - -class Visitor -{ -public: - Visitor() {} - virtual ~Visitor() {} - - virtual Response visit(const class State &state, const class AbstractNode &node) = 0; - virtual Response visit(const class State &state, const class AbstractIntersectionNode &node) { - return visit(state, (const class AbstractNode &)node); - } - virtual Response visit(const class State &state, const class AbstractPolyNode &node) { - return visit(state, (const class AbstractNode &)node); - } - virtual Response visit(const class State &state, const class CgaladvNode &node) { - return visit(state, (const class AbstractNode &)node); - } - virtual Response visit(const class State &state, const class CsgNode &node) { - return visit(state, (const class AbstractNode &)node); - } - virtual Response visit(const class State &state, const class DxfLinearExtrudeNode &node) { - return visit(state, (const class AbstractPolyNode &)node); - } - virtual Response visit(const class State &state, const class DxfRotateExtrudeNode &node) { - return visit(state, (const class AbstractPolyNode &)node); - } - virtual Response visit(const class State &state, const class ImportNode &node) { - return visit(state, (const class AbstractPolyNode &)node); - } - virtual Response visit(const class State &state, const class PrimitiveNode &node) { - return visit(state, (const class AbstractPolyNode &)node); - } - virtual Response visit(const class State &state, const class ProjectionNode &node) { - return visit(state, (const class AbstractPolyNode &)node); - } - virtual Response visit(const class State &state, const class RenderNode &node) { - return visit(state, (const class AbstractNode &)node); - } - virtual Response visit(const class State &state, const class SurfaceNode &node) { - return visit(state, (const class AbstractPolyNode &)node); - } - virtual Response visit(const class State &state, const class TransformNode &node) { - return visit(state, (const class AbstractNode &)node); - } - // Add visit() methods for new visitable subtypes of AbstractNode here -}; - -#endif diff --git a/test-code/dumptest.cc b/test-code/dumptest.cc index cb2b13c..45d19ff 100644 --- a/test-code/dumptest.cc +++ b/test-code/dumptest.cc @@ -30,7 +30,7 @@ #include "value.h" #include "export.h" #include "builtin.h" -#include "nodedumper.h" +//#include "nodedumper.h" #include #include @@ -148,19 +148,17 @@ int main(int argc, char **argv) QString dumpstr_cached = root_node->dump(""); if (dumpstr != dumpstr_cached) rc = 1; + printf(dumpstr.toUtf8()); + +#if 0 NodeDumper dumper; Traverser trav(dumper, *root_node, Traverser::PRE_AND_POSTFIX); trav.execute(); - std::string dumpstdstr = dumper.getDump() + "\n"; + std::string dumpstdstr = dumper.getDump(); trav.execute(); - std::string dumpstdstr_cached = dumper.getDump() + "\n"; + std::string dumpstdstr_cached = dumper.getDump(); if (dumpstdstr != dumpstdstr_cached) rc = 1; - - if (QString::fromStdString(dumpstdstr) != dumpstr) { - printf(dumpstr.toUtf8()); - printf(dumpstdstr.c_str()); - rc = 1; - } +#endif destroy_builtin_functions(); destroy_builtin_modules(); diff --git a/test-code/dumptest.pro b/test-code/dumptest.pro index d196cda..a6729f7 100644 --- a/test-code/dumptest.pro +++ b/test-code/dumptest.pro @@ -50,23 +50,11 @@ HEADERS += ../src/builtin.h \ ../src/grid.h \ ../src/module.h \ ../src/node.h \ - ../src/dxflinextrudenode.h \ - ../src/dxfrotextrudenode.h \ - ../src/projectionnode.h \ - ../src/importnode.h \ - ../src/csgnode.h \ ../src/openscad.h \ ../src/polyset.h \ ../src/printutils.h \ ../src/value.h \ - ../src/progress.h \ - ../src/traverser.h \ - ../src/csgnode.h \ - ../src/visitor.h \ - ../src/nodedumper.h \ - ../src/nodecache.h \ - ../src/importnode.h \ - ../src/state.h + ../src/progress.h SOURCES += dumptest.cc \ ../src/export.cc \ @@ -95,6 +83,4 @@ SOURCES += dumptest.cc \ ../src/dxflinextrude.cc \ ../src/dxfrotextrude.cc \ ../src/printutils.cc \ - ../src/progress.cc \ - ../src/nodedumper.cc \ - ../src/traverser.cc + ../src/progress.cc -- cgit v0.10.1 From fb7ed8cf01bd359dd86acd007615980613ede07b Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 31 Oct 2010 02:51:11 +0000 Subject: Added a rands() function that returns a vector of random numbers. the function takes either 3 arguments or 4 rands(min,max,num) or rands(min,max,num,seed) git-svn-id: http://svn.clifford.at/openscad/trunk@574 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/func.cc b/src/func.cc index eb0afcd..6f7ff1c 100644 --- a/src/func.cc +++ b/src/func.cc @@ -124,6 +124,44 @@ Value builtin_sign(const Context *, const QVector&, const QVectormax) ? frand()*(min-max)+max : frand()*(max-min)+min; +} + +Value builtin_rands(const Context *, const QVector&, const QVector &args) +{ + if (args.size() == 3 && args[0].type == Value::NUMBER && args[1].type == Value::NUMBER && args[2].type == Value::NUMBER) + { + srand((unsigned int)time(0)); + } + else if (args.size() == 4 && args[0].type == Value::NUMBER && args[1].type == Value::NUMBER && args[2].type == Value::NUMBER && args[3].type == Value::NUMBER) + { + srand((unsigned int)args[3].num); + } + else + { + return Value(); + } + + Value v; + v.type = Value::VECTOR; + + for(int i=0; i&, const QVector &args) { if (args.size() >= 1 && args[0].type == Value::NUMBER) { @@ -300,6 +338,7 @@ void initialize_builtin_functions() { builtin_functions["abs"] = new BuiltinFunction(&builtin_abs); builtin_functions["sign"] = new BuiltinFunction(&builtin_sign); + builtin_functions["rands"] = new BuiltinFunction(&builtin_rands); builtin_functions["min"] = new BuiltinFunction(&builtin_min); builtin_functions["max"] = new BuiltinFunction(&builtin_max); builtin_functions["sin"] = new BuiltinFunction(&builtin_sin); -- cgit v0.10.1 From d011ae46c6f7e52b8e3bbe3e96dcdc7d6a6e0924 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 31 Oct 2010 02:51:27 +0000 Subject: coding style git-svn-id: http://svn.clifford.at/openscad/trunk@575 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/func.cc b/src/func.cc index 6f7ff1c..e8ff54a 100644 --- a/src/func.cc +++ b/src/func.cc @@ -136,11 +136,18 @@ double frand(double min, double max) Value builtin_rands(const Context *, const QVector&, const QVector &args) { - if (args.size() == 3 && args[0].type == Value::NUMBER && args[1].type == Value::NUMBER && args[2].type == Value::NUMBER) + if (args.size() == 3 && + args[0].type == Value::NUMBER && + args[1].type == Value::NUMBER && + args[2].type == Value::NUMBER) { srand((unsigned int)time(0)); } - else if (args.size() == 4 && args[0].type == Value::NUMBER && args[1].type == Value::NUMBER && args[2].type == Value::NUMBER && args[3].type == Value::NUMBER) + else if (args.size() == 4 && + args[0].type == Value::NUMBER && + args[1].type == Value::NUMBER && + args[2].type == Value::NUMBER && + args[3].type == Value::NUMBER) { srand((unsigned int)args[3].num); } @@ -148,16 +155,16 @@ Value builtin_rands(const Context *, const QVector&, const QVector Date: Tue, 2 Nov 2010 11:13:36 +0000 Subject: use is implemented, added note about include limitation git-svn-id: http://svn.clifford.at/openscad/trunk@576 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index ceab45b..c01b13a 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -132,10 +132,11 @@ o Function-Module-Interface - Pass a module instanciation to a function (e.g. for a volume() function) - Pass a function to a module instanciation (e.g. for dynamic extrusion paths) o Language Frontend + - include statement doesn't support nesting. This can be fixed by + keeping a nested stack of current input files in the lexer. See + 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) - - Add "use" statement to load modules. Like include but read a module only once, - ignore all top level objects (they are used as module testcase) and search in - a module search path. - allow 0/1 f/t FALSE/TRUE as boolean values - allow any expression to be evaluated as boolean (e.g. 1 = true, 0 = false) - Rethink for vs. intersection_for vs. group. Should for loops -- cgit v0.10.1 From ab293cc99068a636f65b9192b9ada68a9f036462 Mon Sep 17 00:00:00 2001 From: kintel Date: Tue, 2 Nov 2010 11:13:41 +0000 Subject: Recently added features git-svn-id: http://svn.clifford.at/openscad/trunk@577 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 51b20ee..69fe747 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,8 +1,10 @@ -OpenSCAD 2010.06 +OpenSCAD 2010.XX ================ -... add stuff here ... +o Added rands() function +o Added sign() function +o Bugfixes: More robust DXF export OpenSCAD 2010.05 ================ -- cgit v0.10.1 From 6e4d2cb885500da9a06990fa1d26117996d9449d Mon Sep 17 00:00:00 2001 From: kintel Date: Tue, 2 Nov 2010 11:13:44 +0000 Subject: Tag deprecation as such git-svn-id: http://svn.clifford.at/openscad/trunk@578 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 48729c8..e0e70eb 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -106,7 +106,7 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { finfo = QFileInfo(QDir(librarydir), filename); } - PRINTF("WARNING: Support for implicit include will be removed in future releases. Use `include ' instead."); + PRINTF("DEPRECATED: Support for implicit include will be removed in future releases. Use `include ' instead."); handle_dep(finfo.absoluteFilePath()); yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); if (!yyin) { -- cgit v0.10.1 From 02d017aed1845bb41e82b8cdc69a783f81470bcd Mon Sep 17 00:00:00 2001 From: kintel Date: Tue, 2 Nov 2010 14:17:03 +0000 Subject: TOK_NUMBER lexer improvement by Steven Dick git-svn-id: http://svn.clifford.at/openscad/trunk@579 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index e0e70eb..49243fd 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -65,6 +65,8 @@ extern const char *parser_source_path; %x comment +DIGIT [0-9] + %% include[ \t\r\n>]*"<"[^ \t\r\n>]+">" { @@ -135,7 +137,7 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { "false" return TOK_FALSE; "undef" return TOK_UNDEF; -[0-9][0-9.]* { parserlval.number = QString(yytext).toDouble(); return TOK_NUMBER; } +{DIGIT}+|{DIGIT}*\.{DIGIT}+|{DIGIT}+\.{DIGIT}* { parserlval.number = QString(yytext).toDouble(); return TOK_NUMBER; } "$"?[a-zA-Z0-9_]+ { parserlval.text = strdup(yytext); return TOK_ID; } \"[^"]*\" { -- cgit v0.10.1 From d96fedc5295922a717635a4f296a4d226b8c2431 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:08 +0000 Subject: added notes about byacc and boost, removed fixed macos x build issues git-svn-id: http://svn.clifford.at/openscad/trunk@580 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index c01b13a..feed2b9 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -185,6 +185,11 @@ o Consider decoupling DXF-specific functionality from the 2D subsystem o Visitation refactoring - Make AbstractNode members private/protected? +BUILD SYSTEM +------------ +o Fedora is reported to ship with byacc, which doesn't support bison extensions (e.g. %debuig). Look into this, either be yacc-compatible or force the build system to use bison. +o We currently link in -lboost_thread. Should we always use -lboost_thread-mt under Linux or can we pick this up using qmake? + TESTING ------- o Caching and MDI looks suspicious when the code relies on external resources @@ -208,9 +213,6 @@ MISC ---- o Streamline the cmd-line interface a bit - Implicit output file format -o Mac OS X: - - 32-bit compatibility - o Build everything including i386 arch o Write checklists for typical extension work (add new module, add new function) -> make sure new test files are added -- cgit v0.10.1 From 7f10e40c4d06922b877fa40bab9e333f231b0862 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:08 +0000 Subject: added notes about byacc and boost, removed fixed macos x build issues git-svn-id: http://svn.clifford.at/openscad/trunk@580 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index c01b13a..feed2b9 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -185,6 +185,11 @@ o Consider decoupling DXF-specific functionality from the 2D subsystem o Visitation refactoring - Make AbstractNode members private/protected? +BUILD SYSTEM +------------ +o Fedora is reported to ship with byacc, which doesn't support bison extensions (e.g. %debuig). Look into this, either be yacc-compatible or force the build system to use bison. +o We currently link in -lboost_thread. Should we always use -lboost_thread-mt under Linux or can we pick this up using qmake? + TESTING ------- o Caching and MDI looks suspicious when the code relies on external resources @@ -208,9 +213,6 @@ MISC ---- o Streamline the cmd-line interface a bit - Implicit output file format -o Mac OS X: - - 32-bit compatibility - o Build everything including i386 arch o Write checklists for typical extension work (add new module, add new function) -> make sure new test files are added -- cgit v0.10.1 From 8bf2099ca0eeea4f94a1b75a66035cd28cd3fa7f Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:11 +0000 Subject: This adds support for escape sequences in strings e.g \t \n \r \" \\ git-svn-id: http://svn.clifford.at/openscad/trunk@581 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 49243fd..b949169 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -140,11 +140,15 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { {DIGIT}+|{DIGIT}*\.{DIGIT}+|{DIGIT}+\.{DIGIT}* { parserlval.number = QString(yytext).toDouble(); return TOK_NUMBER; } "$"?[a-zA-Z0-9_]+ { parserlval.text = strdup(yytext); return TOK_ID; } -\"[^"]*\" { - parserlval.text = strdup(yytext+1); - parserlval.text[strlen(parserlval.text)-1] = 0; - return TOK_STRING; -} +\"(\\[tnr\"\\]|[^\\"])*\" { QString str(yytext+1); + str.chop(1); + str=str.replace("\\\\","\\"); + str=str.replace("\\\"","\""); + str=str.replace("\\t","\t"); + str=str.replace("\\n","\n"); + str=str.replace("\\r","\r"); + parserlval.text = strdup(str.toAscii().data()); + return TOK_STRING; } [\n\r\t ] \/\/[^\n]*\n? -- cgit v0.10.1 From ff92ba6cc46180bbdfe81c37427c56962e2280fe Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:11 +0000 Subject: This adds support for escape sequences in strings e.g \t \n \r \" \\ git-svn-id: http://svn.clifford.at/openscad/trunk@581 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 49243fd..b949169 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -140,11 +140,15 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { {DIGIT}+|{DIGIT}*\.{DIGIT}+|{DIGIT}+\.{DIGIT}* { parserlval.number = QString(yytext).toDouble(); return TOK_NUMBER; } "$"?[a-zA-Z0-9_]+ { parserlval.text = strdup(yytext); return TOK_ID; } -\"[^"]*\" { - parserlval.text = strdup(yytext+1); - parserlval.text[strlen(parserlval.text)-1] = 0; - return TOK_STRING; -} +\"(\\[tnr\"\\]|[^\\"])*\" { QString str(yytext+1); + str.chop(1); + str=str.replace("\\\\","\\"); + str=str.replace("\\\"","\""); + str=str.replace("\\t","\t"); + str=str.replace("\\n","\n"); + str=str.replace("\\r","\r"); + parserlval.text = strdup(str.toAscii().data()); + return TOK_STRING; } [\n\r\t ] \/\/[^\n]*\n? -- cgit v0.10.1 From ba8d663de2f8fa2a0c8ebb69ece99131bff01bee Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:14 +0000 Subject: Improvement to lexing of strings don't use QString.replace, use the power of flex instead. git-svn-id: http://svn.clifford.at/openscad/trunk@582 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index b949169..86006d0 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -30,7 +30,7 @@ #include "parser_yacc.h" #include #include - +QString* stringcontents; int lexerget_lineno(void); #ifdef __GNUC__ static void yyunput(int, char*) __attribute__((unused)); @@ -63,7 +63,7 @@ extern const char *parser_source_path; %option yylineno %option noyywrap -%x comment +%x comment string DIGIT [0-9] @@ -140,15 +140,19 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { {DIGIT}+|{DIGIT}*\.{DIGIT}+|{DIGIT}+\.{DIGIT}* { parserlval.number = QString(yytext).toDouble(); return TOK_NUMBER; } "$"?[a-zA-Z0-9_]+ { parserlval.text = strdup(yytext); return TOK_ID; } -\"(\\[tnr\"\\]|[^\\"])*\" { QString str(yytext+1); - str.chop(1); - str=str.replace("\\\\","\\"); - str=str.replace("\\\"","\""); - str=str.replace("\\t","\t"); - str=str.replace("\\n","\n"); - str=str.replace("\\r","\r"); - parserlval.text = strdup(str.toAscii().data()); - return TOK_STRING; } +\" { BEGIN(string); stringcontents = new QString(); } +{ +\\n { stringcontents->append('\n'); } +\\t { stringcontents->append('\t'); } +\\r { stringcontents->append('\r'); } +\\\\ { stringcontents->append('\\'); } +\\\" { stringcontents->append('"'); } +[^\\\n\"]+ { stringcontents->append(lexertext); } +\" { BEGIN(INITIAL); + parserlval.text = strdup(stringcontents->toLocal8Bit()); + delete stringcontents; + return TOK_STRING; } +} [\n\r\t ] \/\/[^\n]*\n? -- cgit v0.10.1 From 3db181cca700f760d27893423bfbe2e2a9de082d Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:14 +0000 Subject: Improvement to lexing of strings don't use QString.replace, use the power of flex instead. git-svn-id: http://svn.clifford.at/openscad/trunk@582 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index b949169..86006d0 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -30,7 +30,7 @@ #include "parser_yacc.h" #include #include - +QString* stringcontents; int lexerget_lineno(void); #ifdef __GNUC__ static void yyunput(int, char*) __attribute__((unused)); @@ -63,7 +63,7 @@ extern const char *parser_source_path; %option yylineno %option noyywrap -%x comment +%x comment string DIGIT [0-9] @@ -140,15 +140,19 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { {DIGIT}+|{DIGIT}*\.{DIGIT}+|{DIGIT}+\.{DIGIT}* { parserlval.number = QString(yytext).toDouble(); return TOK_NUMBER; } "$"?[a-zA-Z0-9_]+ { parserlval.text = strdup(yytext); return TOK_ID; } -\"(\\[tnr\"\\]|[^\\"])*\" { QString str(yytext+1); - str.chop(1); - str=str.replace("\\\\","\\"); - str=str.replace("\\\"","\""); - str=str.replace("\\t","\t"); - str=str.replace("\\n","\n"); - str=str.replace("\\r","\r"); - parserlval.text = strdup(str.toAscii().data()); - return TOK_STRING; } +\" { BEGIN(string); stringcontents = new QString(); } +{ +\\n { stringcontents->append('\n'); } +\\t { stringcontents->append('\t'); } +\\r { stringcontents->append('\r'); } +\\\\ { stringcontents->append('\\'); } +\\\" { stringcontents->append('"'); } +[^\\\n\"]+ { stringcontents->append(lexertext); } +\" { BEGIN(INITIAL); + parserlval.text = strdup(stringcontents->toLocal8Bit()); + delete stringcontents; + return TOK_STRING; } +} [\n\r\t ] \/\/[^\n]*\n? -- cgit v0.10.1 From f889ec36f7272bd06b34d36e63fa2e68b8f7fa30 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:17 +0000 Subject: Added support for nested includes. git-svn-id: http://svn.clifford.at/openscad/trunk@583 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 86006d0..91606c6 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -28,6 +28,7 @@ #include "openscad.h" #include "printutils.h" #include "parser_yacc.h" +#include #include #include QString* stringcontents; @@ -58,35 +59,33 @@ extern const char *parser_source_path; } \ } +void includefile(); +QDir sourcepath(); +QStack path_stack; + +QString filename; +QString filepath; + %} %option yylineno %option noyywrap %x comment string +%x include path DIGIT [0-9] %% -include[ \t\r\n>]*"<"[^ \t\r\n>]+">" { - QString filename(yytext); - filename.remove(QRegExp("^include[ \t\r\n>]*<")); - filename.remove(QRegExp(">$")); - QFileInfo finfo(QDir(parser_source_path), filename); - if (!finfo.exists()) { - finfo = QFileInfo(QDir(librarydir), filename); - } - handle_dep(finfo.absoluteFilePath()); - yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); - if (!yyin) { - PRINTA("WARNING: Can't open input file `%1'.", filename); - } else { - yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); - BEGIN(INITIAL); - } +include[ \t\r\n>]*"<" { BEGIN(include); } +{ +[^\t\r\n>]+"/" { filepath = yytext; } +[^\t\r\n>/]+ { filename = yytext; } +">" { BEGIN(INITIAL); includefile(); } } + use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { QString filename(yytext); filename.remove(QRegExp("^use[ \t\r\n>]*<")); @@ -121,6 +120,8 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { } <> { + if(!path_stack.isEmpty()) + path_stack.pop(); if (yyin && yyin != stdin) fclose(yyin); yypop_buffer_state(); @@ -169,3 +170,42 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { . { return yytext[0]; } +%% + +QDir sourcepath() +{ + if(!path_stack.isEmpty()) + return path_stack.top(); + + return QDir(parser_source_path); +} + +void includefile() +{ + if(filename.isEmpty()) + return; + + if(filepath.isEmpty()) { + path_stack.push(sourcepath()); + } else { + QFileInfo dirinfo(sourcepath(),filepath); + path_stack.push(dirinfo.dir()); + filepath.clear(); + } + + QFileInfo finfo(sourcepath(), filename); + if (!finfo.exists()) { + finfo = QFileInfo(QDir(librarydir), filename); + } + + handle_dep(finfo.absoluteFilePath()); + yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); + if (!yyin) { + PRINTA("WARNING: Can't open input file `%1'.", filename); + return; + } + filename.clear(); + + yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); +} + -- cgit v0.10.1 From 4cbc08de85989e754c8717e04b39aff0d1c11a40 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:17 +0000 Subject: Added support for nested includes. git-svn-id: http://svn.clifford.at/openscad/trunk@583 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 86006d0..91606c6 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -28,6 +28,7 @@ #include "openscad.h" #include "printutils.h" #include "parser_yacc.h" +#include #include #include QString* stringcontents; @@ -58,35 +59,33 @@ extern const char *parser_source_path; } \ } +void includefile(); +QDir sourcepath(); +QStack path_stack; + +QString filename; +QString filepath; + %} %option yylineno %option noyywrap %x comment string +%x include path DIGIT [0-9] %% -include[ \t\r\n>]*"<"[^ \t\r\n>]+">" { - QString filename(yytext); - filename.remove(QRegExp("^include[ \t\r\n>]*<")); - filename.remove(QRegExp(">$")); - QFileInfo finfo(QDir(parser_source_path), filename); - if (!finfo.exists()) { - finfo = QFileInfo(QDir(librarydir), filename); - } - handle_dep(finfo.absoluteFilePath()); - yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); - if (!yyin) { - PRINTA("WARNING: Can't open input file `%1'.", filename); - } else { - yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); - BEGIN(INITIAL); - } +include[ \t\r\n>]*"<" { BEGIN(include); } +{ +[^\t\r\n>]+"/" { filepath = yytext; } +[^\t\r\n>/]+ { filename = yytext; } +">" { BEGIN(INITIAL); includefile(); } } + use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { QString filename(yytext); filename.remove(QRegExp("^use[ \t\r\n>]*<")); @@ -121,6 +120,8 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { } <> { + if(!path_stack.isEmpty()) + path_stack.pop(); if (yyin && yyin != stdin) fclose(yyin); yypop_buffer_state(); @@ -169,3 +170,42 @@ use[ \t\r\n>]*"<"[^ \t\r\n>]+">" { . { return yytext[0]; } +%% + +QDir sourcepath() +{ + if(!path_stack.isEmpty()) + return path_stack.top(); + + return QDir(parser_source_path); +} + +void includefile() +{ + if(filename.isEmpty()) + return; + + if(filepath.isEmpty()) { + path_stack.push(sourcepath()); + } else { + QFileInfo dirinfo(sourcepath(),filepath); + path_stack.push(dirinfo.dir()); + filepath.clear(); + } + + QFileInfo finfo(sourcepath(), filename); + if (!finfo.exists()) { + finfo = QFileInfo(QDir(librarydir), filename); + } + + handle_dep(finfo.absoluteFilePath()); + yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); + if (!yyin) { + PRINTA("WARNING: Can't open input file `%1'.", filename); + return; + } + filename.clear(); + + yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); +} + -- cgit v0.10.1 From 62dc1a48ef8f062af517fb6b0b0c140bf9e3ac28 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:20 +0000 Subject: Removed some unneeded cruft. git-svn-id: http://svn.clifford.at/openscad/trunk@584 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 91606c6..9e8aaf8 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -72,7 +72,7 @@ QString filepath; %option noyywrap %x comment string -%x include path +%x include DIGIT [0-9] @@ -80,9 +80,9 @@ DIGIT [0-9] include[ \t\r\n>]*"<" { BEGIN(include); } { -[^\t\r\n>]+"/" { filepath = yytext; } -[^\t\r\n>/]+ { filename = yytext; } -">" { BEGIN(INITIAL); includefile(); } +[^\t\r\n>]+"/" { filepath = yytext; } +[^\t\r\n>/]+ { filename = yytext; } +">" { BEGIN(INITIAL); includefile(); } } -- cgit v0.10.1 From ee0c2d3ae5d37ddec1f61ea7212cff6edd4fc403 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:20 +0000 Subject: Removed some unneeded cruft. git-svn-id: http://svn.clifford.at/openscad/trunk@584 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 91606c6..9e8aaf8 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -72,7 +72,7 @@ QString filepath; %option noyywrap %x comment string -%x include path +%x include DIGIT [0-9] @@ -80,9 +80,9 @@ DIGIT [0-9] include[ \t\r\n>]*"<" { BEGIN(include); } { -[^\t\r\n>]+"/" { filepath = yytext; } -[^\t\r\n>/]+ { filename = yytext; } -">" { BEGIN(INITIAL); includefile(); } +[^\t\r\n>]+"/" { filepath = yytext; } +[^\t\r\n>/]+ { filename = yytext; } +">" { BEGIN(INITIAL); includefile(); } } -- cgit v0.10.1 From a6880af2753fa3623e29ce9e7b9e0d6512eec82d Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:23 +0000 Subject: sync git-svn-id: http://svn.clifford.at/openscad/trunk@585 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index feed2b9..63afb03 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -4,8 +4,9 @@ BUGS o Some invalid DXF data gets pass the import checks and breaks the tessing code o Tesselation via GLU sometimes produces strange results o Export STL: Exports existing CGAL model even though the current model is changed, but not CGAL rendered -o It's now possible to start a new rendering while one is already running. +o It's now possible to start a new rendering while one is already running (which call processEvents()) -> turn off most (or all) interaction while rendering + -> Lock all or only one MainWindow (MDI)? o Look into the polygon winding and rotate_extrude() problem reported by Britton STL Import BUGS -- cgit v0.10.1 From b3ee9a9da22bdbec7f209e3c2dc30069de601995 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:23 +0000 Subject: sync git-svn-id: http://svn.clifford.at/openscad/trunk@585 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index feed2b9..63afb03 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -4,8 +4,9 @@ BUGS o Some invalid DXF data gets pass the import checks and breaks the tessing code o Tesselation via GLU sometimes produces strange results o Export STL: Exports existing CGAL model even though the current model is changed, but not CGAL rendered -o It's now possible to start a new rendering while one is already running. +o It's now possible to start a new rendering while one is already running (which call processEvents()) -> turn off most (or all) interaction while rendering + -> Lock all or only one MainWindow (MDI)? o Look into the polygon winding and rotate_extrude() problem reported by Britton STL Import BUGS -- cgit v0.10.1 From 729b2516b6701249fa81a6d661486a1bfc0fcd98 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:28 +0000 Subject: Merge branch 'experiments' of git://gitorious.org/openscad/openscad into giles git-svn-id: http://svn.clifford.at/openscad/trunk@586 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/lexer.l b/src/lexer.l index 9e8aaf8..932711b 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -202,6 +202,7 @@ void includefile() yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); if (!yyin) { PRINTA("WARNING: Can't open input file `%1'.", filename); + path_stack.pop(); return; } filename.clear(); diff --git a/testdata/scad/include test6.scad b/testdata/scad/include test6.scad new file mode 100644 index 0000000..7a79456 --- /dev/null +++ b/testdata/scad/include test6.scad @@ -0,0 +1,4 @@ +module test6() +{ + echo("included from include test6.scad"); +} diff --git a/testdata/scad/include-test.scad b/testdata/scad/include-test.scad new file mode 100644 index 0000000..5db02d7 --- /dev/null +++ b/testdata/scad/include-test.scad @@ -0,0 +1,40 @@ +//Test that the entire path is pushed onto the stack upto the last '/' +include + +//Test that a non existent path/file doesn't screw things up +include + +//Test with empty path +include + +//Test without preceeding space +include + +//Test with other strange character that is allowed +include>>>>> + +//Test that filenames with spaces work +include + +//Test with empty file +include + +//Test with empty path and file +include + +//Test with empty +include <> + +module test1() +{ + test2(); + test3(); + test4(); + test5(); + test6(); + + //Just to give a top level object + sphere(1); +} + +test1(); diff --git a/testdata/scad/include-test5.scad b/testdata/scad/include-test5.scad new file mode 100644 index 0000000..4f6e656 --- /dev/null +++ b/testdata/scad/include-test5.scad @@ -0,0 +1,4 @@ +module test5() +{ + echo("included from include-test5.scad"); +} diff --git a/testdata/scad/string-test.scad b/testdata/scad/string-test.scad new file mode 100644 index 0000000..5ec4cfb --- /dev/null +++ b/testdata/scad/string-test.scad @@ -0,0 +1 @@ +echo("The quick brown fox \tjumps \"over\" the lazy dog.\rThe quick brown fox.\nThe \\lazy\\ dog."); diff --git a/testdata/scad/sub1/sub2/sub3/include-test4.scad b/testdata/scad/sub1/sub2/sub3/include-test4.scad new file mode 100644 index 0000000..1cb7eab --- /dev/null +++ b/testdata/scad/sub1/sub2/sub3/include-test4.scad @@ -0,0 +1,4 @@ +module test4() +{ + echo("included from include-test4.scad"); +} diff --git a/testdata/scad/sub1/sub2/sub3/sub4/include-test2.scad b/testdata/scad/sub1/sub2/sub3/sub4/include-test2.scad new file mode 100644 index 0000000..9f4c963 --- /dev/null +++ b/testdata/scad/sub1/sub2/sub3/sub4/include-test2.scad @@ -0,0 +1,10 @@ +//Test nested include +include + +//Test relative file location +include <../include-test4.scad> + +module test2 () +{ + echo("included from include-test2.scad"); +} diff --git a/testdata/scad/sub1/sub2/sub3/sub4/include-test3.scad b/testdata/scad/sub1/sub2/sub3/sub4/include-test3.scad new file mode 100644 index 0000000..2f67e93 --- /dev/null +++ b/testdata/scad/sub1/sub2/sub3/sub4/include-test3.scad @@ -0,0 +1,4 @@ +module test3() +{ + echo("included from include-test3.scad"); +} -- cgit v0.10.1 From baf19cfdda3454fcc1446f046d8765c8377c6cd7 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:31 +0000 Subject: Added section for proposed language changes for 'V2.0' git-svn-id: http://svn.clifford.at/openscad/trunk@587 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index 63afb03..a053b58 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -169,6 +169,11 @@ o Grammar - import_*() -> *_import() (consistent prefix vs. postfix) - linear_extrude()/rotate_extrude(): Cumbersome names? -> (extrude, revolve, lathe, sweep ?) +IDEAS FOR LANGUAGE CHANGES +-------------------------- +o More strict checking of module parameters to make e.g. this fail: + module test(a,b) { a=1; b=2; echo(a,b,c); } test(c=3); + CODE ---- -- cgit v0.10.1 From a09e855e4c9f3e852e15c48e8900ebb9f8d25b9d Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:31 +0000 Subject: Added section for proposed language changes for 'V2.0' git-svn-id: http://svn.clifford.at/openscad/trunk@587 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/doc/TODO.txt b/doc/TODO.txt index 63afb03..a053b58 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -169,6 +169,11 @@ o Grammar - import_*() -> *_import() (consistent prefix vs. postfix) - linear_extrude()/rotate_extrude(): Cumbersome names? -> (extrude, revolve, lathe, sweep ?) +IDEAS FOR LANGUAGE CHANGES +-------------------------- +o More strict checking of module parameters to make e.g. this fail: + module test(a,b) { a=1; b=2; echo(a,b,c); } test(c=3); + CODE ---- -- cgit v0.10.1 From 060a6c654de5ebd14ccb889881fa6c4d3fb9d763 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:34 +0000 Subject: Output LWPOLYLINE objects instead of LINE for DXF export. Patch submitted by Lars Kruse git-svn-id: http://svn.clifford.at/openscad/trunk@588 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/export.cc b/src/export.cc index 40b16d5..2b474f6 100644 --- a/src/export.cc +++ b/src/export.cc @@ -166,6 +166,20 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * } setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output + + // Some importers (e.g. QCAD) needs a HEADER section specifying AutoCAD 2000 as + // the file format for LWPOLYLINE entities to work + fprintf(f, " 0\n" + "SECTION\n" + " 2\n" + "HEADER\n" + " 9\n" + "$ACADVER\n" + " 1\n" + "AC1015\n" + " 0\n" + "ENDSEC\n"); + // Some importers (e.g. Inkscape) needs a BLOCKS section to be present fprintf(f, " 0\n" "SECTION\n" @@ -182,26 +196,29 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * DxfData dd(*root_N); for (int i=0; ix; - double y1 = p1->y; - double x2 = p2->x; - double y2 = p2->y; - fprintf(f, " 0\n"); - fprintf(f, "LINE\n"); - // Some importers (e.g. Inkscape) needs a layer to be specified - fprintf(f, " 8\n"); - fprintf(f, "0\n"); + if (dd.paths[i].points.size() < 2) + // not a valid polygon + continue; + // Use the LWPOLYLINE class - this makes it easier to handle complete + // objects (as paths) in Inkscape. + fprintf(f, " 0\n"); + fprintf(f, "LWPOLYLINE\n"); + // Some importers (e.g. Inkscape) need a layer to be specified + fprintf(f, " 8\n"); + fprintf(f, "0\n"); + // number of vertices + fprintf(f, " 90\n"); + fprintf(f, "%d\n", dd.paths[i].points.size()); + // polygon flag (closed, ...) + fprintf(f, " 70\n"); + fprintf(f, "%d\n", dd.paths[i].is_closed ? 1 : 0); + // add all points + for (int j=0; jx); fprintf(f, " 20\n"); - fprintf(f, "%f\n", y1); - fprintf(f, " 21\n"); - fprintf(f, "%f\n", y2); + fprintf(f, "%f\n", p->y); } } -- cgit v0.10.1 From fafd73cd2e5d5bf786f44b28dc1a887a10031b34 Mon Sep 17 00:00:00 2001 From: kintel Date: Sun, 9 Jan 2011 16:08:34 +0000 Subject: Output LWPOLYLINE objects instead of LINE for DXF export. Patch submitted by Lars Kruse git-svn-id: http://svn.clifford.at/openscad/trunk@588 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/src/export.cc b/src/export.cc index 40b16d5..2b474f6 100644 --- a/src/export.cc +++ b/src/export.cc @@ -166,6 +166,20 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * } setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output + + // Some importers (e.g. QCAD) needs a HEADER section specifying AutoCAD 2000 as + // the file format for LWPOLYLINE entities to work + fprintf(f, " 0\n" + "SECTION\n" + " 2\n" + "HEADER\n" + " 9\n" + "$ACADVER\n" + " 1\n" + "AC1015\n" + " 0\n" + "ENDSEC\n"); + // Some importers (e.g. Inkscape) needs a BLOCKS section to be present fprintf(f, " 0\n" "SECTION\n" @@ -182,26 +196,29 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * DxfData dd(*root_N); for (int i=0; ix; - double y1 = p1->y; - double x2 = p2->x; - double y2 = p2->y; - fprintf(f, " 0\n"); - fprintf(f, "LINE\n"); - // Some importers (e.g. Inkscape) needs a layer to be specified - fprintf(f, " 8\n"); - fprintf(f, "0\n"); + if (dd.paths[i].points.size() < 2) + // not a valid polygon + continue; + // Use the LWPOLYLINE class - this makes it easier to handle complete + // objects (as paths) in Inkscape. + fprintf(f, " 0\n"); + fprintf(f, "LWPOLYLINE\n"); + // Some importers (e.g. Inkscape) need a layer to be specified + fprintf(f, " 8\n"); + fprintf(f, "0\n"); + // number of vertices + fprintf(f, " 90\n"); + fprintf(f, "%d\n", dd.paths[i].points.size()); + // polygon flag (closed, ...) + fprintf(f, " 70\n"); + fprintf(f, "%d\n", dd.paths[i].is_closed ? 1 : 0); + // add all points + for (int j=0; jx); fprintf(f, " 20\n"); - fprintf(f, "%f\n", y1); - fprintf(f, " 21\n"); - fprintf(f, "%f\n", y2); + fprintf(f, "%f\n", p->y); } } -- cgit v0.10.1 From aed41cec255c76663aded493f7459224cab3de41 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 11 Jan 2011 13:42:44 +0100 Subject: Default dropbox installation has changed diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index b01d7f0..11820df 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -16,7 +16,7 @@ echo "Sanity check of the app bundle..." if [[ $? != 0 ]]; then exit 1 fi -cp OpenSCAD-$VERSION.dmg ~/Documents/Dropbox/Public -ln -sf OpenSCAD-$VERSION.dmg ~/Documents/Dropbox/Public/OpenSCAD-latest.dmg +cp OpenSCAD-$VERSION.dmg ~/Dropbox/Public +ln -sf OpenSCAD-$VERSION.dmg ~/Dropbox/Public/OpenSCAD-latest.dmg echo "Upload in progress..." -- cgit v0.10.1 From 91e33a87c4e0c07e1f423e09cfa74909e4d87fe2 Mon Sep 17 00:00:00 2001 From: meta Date: Sun, 16 Jan 2011 05:33:44 +0000 Subject: make the default VERSION initialization work on windows git-svn-id: http://svn.clifford.at/openscad/trunk@589 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/openscad.pro b/openscad.pro index 42a5d22..b329e4c 100644 --- a/openscad.pro +++ b/openscad.pro @@ -1,4 +1,9 @@ +win32 { +isEmpty(VERSION) VERSION = $$system(date /t) +} else { isEmpty(VERSION) VERSION = $$system(date "+%Y.%m.%d") +} + DEFINES += OPENSCAD_VERSION=$$VERSION TEMPLATE = app RESOURCES = openscad.qrc -- cgit v0.10.1 From 5f740ff14db3497234d2cde4798f40f166402c2f Mon Sep 17 00:00:00 2001 From: meta Date: Sun, 16 Jan 2011 05:34:33 +0000 Subject: indent properly git-svn-id: http://svn.clifford.at/openscad/trunk@590 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/openscad.pro b/openscad.pro index b329e4c..0e94eb0 100644 --- a/openscad.pro +++ b/openscad.pro @@ -1,7 +1,7 @@ win32 { -isEmpty(VERSION) VERSION = $$system(date /t) + isEmpty(VERSION) VERSION = $$system(date /t) } else { -isEmpty(VERSION) VERSION = $$system(date "+%Y.%m.%d") + isEmpty(VERSION) VERSION = $$system(date "+%Y.%m.%d") } DEFINES += OPENSCAD_VERSION=$$VERSION -- cgit v0.10.1 From e63576ce1aa85b7149f37a1f896a84f17ae58a7d Mon Sep 17 00:00:00 2001 From: meta Date: Mon, 17 Jan 2011 22:34:46 +0100 Subject: replace stat() with QFileInfo diff --git a/src/mainwin.cc b/src/mainwin.cc index ef738fc..7645860 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -75,10 +75,6 @@ //for chdir #include -// for stat() -#include -#include - #ifdef ENABLE_CGAL #if 1 @@ -992,10 +988,8 @@ void MainWindow::pasteViewportRotation() void MainWindow::checkAutoReload() { QString new_stinfo; - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(this->fileName.toAscii().data(), &st); - new_stinfo.sprintf("%x.%x", (int)st.st_mtime, (int)st.st_size); + QFileInfo finfo(this->fileName); + new_stinfo = QString::number(finfo.size()) + QString::number(finfo.lastModified().toTime_t()); if (new_stinfo != autoReloadInfo) actionReloadCompile(); autoReloadInfo = new_stinfo; -- cgit v0.10.1 From 1b44be5a635859ca7dd8bbfd8b19b4e9403faa6c Mon Sep 17 00:00:00 2001 From: meta Date: Mon, 17 Jan 2011 22:38:18 +0100 Subject: rename to fix a name clash with inner scope diff --git a/src/mainwin.cc b/src/mainwin.cc index 7645860..3373122 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1467,7 +1467,7 @@ static void renderGLviaCGAL(void *vp) glColor3f(col2.redF(), col2.greenF(), col2.blueF()); // Extract the boundary, including inner boundaries of the polygons - for (fci_t fit = E.faces_begin(), fend = E.faces_end(); fit != fend; ++fit) + for (fci_t fit = E.faces_begin(), facesend = E.faces_end(); fit != facesend; ++fit) { bool fset = false; double fx = 0.0, fy = 0.0; -- cgit v0.10.1 From 163461f47cdfb9de4b6b79268537fbe432a2522d Mon Sep 17 00:00:00 2001 From: meta Date: Mon, 17 Jan 2011 23:50:33 +0100 Subject: rename to fix a name clash with inner scope diff --git a/src/nef2dxf.cc b/src/nef2dxf.cc index 44d7561..6191e5e 100644 --- a/src/nef2dxf.cc +++ b/src/nef2dxf.cc @@ -38,7 +38,7 @@ DxfData::DxfData(const struct CGAL_Nef_polyhedron &N) typedef Explorer::Halfedge_around_face_const_circulator heafcc_t; Explorer E = N.p2.explorer(); - for (fci_t fit = E.faces_begin(), fend = E.faces_end(); fit != fend; ++fit) + for (fci_t fit = E.faces_begin(), facesend = E.faces_end(); fit != facesend; ++fit) { heafcc_t fcirc(E.halfedge(fit)), fend(fcirc); int first_point = -1, last_point = -1; -- cgit v0.10.1 From 8160212499c40c74f1c1c396f02332336ec4e8ae Mon Sep 17 00:00:00 2001 From: meta Date: Tue, 18 Jan 2011 00:02:56 +0100 Subject: add C99 math for win32 diff --git a/src/dxfdata.cc b/src/dxfdata.cc index dc3e8a1..0579389 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -32,7 +32,7 @@ #include #include #include -#include +#include "mathc99.h" #include struct Line { diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 02a1274..a45768d 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -31,7 +31,7 @@ #include "printutils.h" #include "context.h" -#include +#include "mathc99.h" #include #include #include diff --git a/src/dxftess-glu.cc b/src/dxftess-glu.cc index ca12ea9..63fa2e5 100644 --- a/src/dxftess-glu.cc +++ b/src/dxftess-glu.cc @@ -9,7 +9,7 @@ # include #endif #include -#include +#include "mathc99.h" #ifdef WIN32 # define STDCALL __stdcall diff --git a/src/func.cc b/src/func.cc index e8ff54a..46b29a8 100644 --- a/src/func.cc +++ b/src/func.cc @@ -28,7 +28,7 @@ #include "context.h" #include "dxfdim.h" #include "builtin.h" -#include +#include "mathc99.h" AbstractFunction::~AbstractFunction() { diff --git a/src/glview.cc b/src/glview.cc index d51714b..0b161c8 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -31,7 +31,7 @@ #include #include #include -#include +#include "mathc99.h" #include #define FAR_FAR_AWAY 100000.0 diff --git a/src/grid.h b/src/grid.h index 572bc66..306751f 100644 --- a/src/grid.h +++ b/src/grid.h @@ -1,7 +1,7 @@ #ifndef GRID_H_ #define GRID_H_ -#include +#include "mathc99.h" #include #include #include diff --git a/src/mathc99.cc b/src/mathc99.cc new file mode 100644 index 0000000..db71059 --- /dev/null +++ b/src/mathc99.cc @@ -0,0 +1,5 @@ +#include "mathc99.h" + +double found(double a) { + return a > 0 ? floor(a+0.5) : ceil(a-0.5); +} diff --git a/src/mathc99.h b/src/mathc99.h new file mode 100644 index 0000000..4d5d3be --- /dev/null +++ b/src/mathc99.h @@ -0,0 +1,16 @@ +#ifndef MATHC99_H_ +#define MATHC99_H_ + +#ifdef WIN32 + +#include +//for native win32 builds we need to provide C99 math functions by ourselves +double round(double a); + +#else + +#include + +#endif + +#endif diff --git a/src/value.cc b/src/value.cc index a237c5a..3931755 100644 --- a/src/value.cc +++ b/src/value.cc @@ -24,7 +24,7 @@ */ #include "value.h" -#include +#include "mathc99.h" Value::Value() { -- cgit v0.10.1 From e01934a24da408ac28076cc151e00c17ad6172ee Mon Sep 17 00:00:00 2001 From: meta Date: Tue, 18 Jan 2011 00:20:12 +0100 Subject: use QFileInfo instead of stat() diff --git a/src/dxfdim.cc b/src/dxfdim.cc index a45768d..5311209 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -32,10 +32,9 @@ #include "context.h" #include "mathc99.h" -#include -#include -#include #include +#include +#include QHash dxf_dim_cache; QHash dxf_cross_cache; @@ -62,12 +61,10 @@ Value builtin_dxf_dim(const Context *ctx, const QVector &argnames, cons name = args[i].text; } - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(filename.toAscii().data(), &st); + QFileInfo fileInfo(filename); QString key = filename + "|" + layername + "|" + name + "|" + QString::number(xorigin) + "|" + QString::number(yorigin) + - "|" + QString::number(scale) + "|" + QString::number(st.st_mtime) + "|" + QString::number(st.st_size); + "|" + QString::number(scale) + "|" + QString::number(fileInfo.lastModified().toTime_t()) + "|" + QString::number(fileInfo.size()); if (dxf_dim_cache.contains(key)) return dxf_dim_cache[key]; @@ -144,12 +141,10 @@ Value builtin_dxf_cross(const Context *ctx, const QVector &argnames, co args[i].getnum(scale); } - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(filename.toAscii().data(), &st); + QFileInfo fileInfo(filename); QString key = filename + "|" + layername + "|" + QString::number(xorigin) + "|" + QString::number(yorigin) + - "|" + QString::number(scale) + "|" + QString::number(st.st_mtime) + "|" + QString::number(st.st_size); + "|" + QString::number(scale) + "|" + QString::number(fileInfo.lastModified().toTime_t()) + "|" + QString::number(fileInfo.size()); if (dxf_cross_cache.contains(key)) return dxf_cross_cache[key]; diff --git a/src/dxflinextrude.cc b/src/dxflinextrude.cc index 83c3d9c..df364e5 100644 --- a/src/dxflinextrude.cc +++ b/src/dxflinextrude.cc @@ -34,13 +34,11 @@ #include "progress.h" #include "openscad.h" // get_fragments_from_r() -#include -#include -#include - #include #include #include +#include +#include class DxfLinearExtrudeModule : public AbstractModule { @@ -320,14 +318,12 @@ QString DxfLinearExtrudeNode::dump(QString indent) const { if (dump_cache.isEmpty()) { QString text; - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(filename.toAscii().data(), &st); + QFileInfo fileInfo(filename); text.sprintf("linear_extrude(file = \"%s\", cache = \"%x.%x\", layer = \"%s\", " "height = %g, origin = [ %g %g ], scale = %g, center = %s, convexity = %d", - filename.toAscii().data(), (int)st.st_mtime, (int)st.st_size, - layername.toAscii().data(), height, origin_x, origin_y, scale, - center ? "true" : "false", convexity); + filename.toAscii().data(), (int)fileInfo.lastModified().toTime_t(), + (int)fileInfo.size(), layername.toAscii().data(), height, origin_x, + origin_y, scale, center ? "true" : "false", convexity); if (has_twist) { QString t2; t2.sprintf(", twist = %g, slices = %d", twist, slices); diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc index ea603f0..6344d2a 100644 --- a/src/dxfrotextrude.cc +++ b/src/dxfrotextrude.cc @@ -33,13 +33,11 @@ #include "progress.h" #include "openscad.h" // get_fragments_from_r() -#include -#include -#include - #include #include #include +#include +#include class DxfRotateExtrudeModule : public AbstractModule { @@ -217,15 +215,13 @@ QString DxfRotateExtrudeNode::dump(QString indent) const { if (dump_cache.isEmpty()) { QString text; - struct stat st; - memset(&st, 0, sizeof(struct stat)); - stat(filename.toAscii().data(), &st); + QFileInfo fileInfo(filename); text.sprintf("rotate_extrude(file = \"%s\", cache = \"%x.%x\", layer = \"%s\", " "origin = [ %g %g ], scale = %g, convexity = %d, " "$fn = %g, $fa = %g, $fs = %g) {\n", - filename.toAscii().data(), (int)st.st_mtime, (int)st.st_size, - layername.toAscii().data(), origin_x, origin_y, scale, convexity, - fn, fa, fs); + filename.toAscii().data(), (int)fileInfo.lastModified().toTime_t(), + (int)fileInfo.size(),layername.toAscii().data(), origin_x, origin_y, + scale, convexity, fn, fa, fs); foreach (AbstractNode *v, children) text += v->dump(indent + QString("\t")); text += indent + "}\n"; -- cgit v0.10.1 From 5c9ca91c2ce39f23246c95d23a982ac0f5721e28 Mon Sep 17 00:00:00 2001 From: meta Date: Tue, 18 Jan 2011 00:36:05 +0100 Subject: fix truncation warning diff --git a/src/polyset.cc b/src/polyset.cc index d438769..022e6cc 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -149,7 +149,7 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m #ifdef ENABLE_OPENCSG if (shaderinfo) { glUniform4f(shaderinfo[1], col.redF(), col.greenF(), col.blueF(), 1.0f); - glUniform4f(shaderinfo[2], 255 / 255.0, 236 / 255.0, 94 / 255.0, 1.0); + glUniform4f(shaderinfo[2], 255 / 255.0f, 236 / 255.0f, 94 / 255.0f, 1.0f); } #endif /* ENABLE_OPENCSG */ } @@ -158,8 +158,8 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m glColor3f(col.redF(), col.greenF(), col.blueF()); #ifdef ENABLE_OPENCSG if (shaderinfo) { - glUniform4f(shaderinfo[1], 157 / 255.0, 203 / 255.0, 81 / 255.0, 1.0); - glUniform4f(shaderinfo[2], 171 / 255.0, 216 / 255.0, 86 / 255.0, 1.0); + glUniform4f(shaderinfo[1], 157 / 255.0f, 203 / 255.0f, 81 / 255.0f, 1.0f); + glUniform4f(shaderinfo[2], 171 / 255.0f, 216 / 255.0f, 86 / 255.0f, 1.0f); } #endif /* ENABLE_OPENCSG */ } @@ -167,8 +167,8 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m glColor4ub(255, 157, 81, 128); #ifdef ENABLE_OPENCSG if (shaderinfo) { - glUniform4f(shaderinfo[1], 255 / 255.0, 157 / 255.0, 81 / 255.0, 0.5); - glUniform4f(shaderinfo[2], 255 / 255.0, 171 / 255.0, 86 / 255.0, 0.5); + glUniform4f(shaderinfo[1], 255 / 255.0f, 157 / 255.0f, 81 / 255.0f, 0.5f); + glUniform4f(shaderinfo[2], 255 / 255.0f, 171 / 255.0f, 86 / 255.0f, 0.5f); } #endif /* ENABLE_OPENCSG */ } @@ -176,8 +176,8 @@ void PolySet::render_surface(colormode_e colormode, csgmode_e csgmode, double *m glColor4ub(180, 180, 180, 128); #ifdef ENABLE_OPENCSG if (shaderinfo) { - glUniform4f(shaderinfo[1], 180 / 255.0, 180 / 255.0, 180 / 255.0, 0.5); - glUniform4f(shaderinfo[2], 150 / 255.0, 150 / 255.0, 150 / 255.0, 0.5); + glUniform4f(shaderinfo[1], 180 / 255.0f, 180 / 255.0f, 180 / 255.0f, 0.5f); + glUniform4f(shaderinfo[2], 150 / 255.0f, 150 / 255.0f, 150 / 255.0f, 0.5f); } #endif /* ENABLE_OPENCSG */ } -- cgit v0.10.1 From 438d5cfbc80b128f49c31e57749f937fecfe01b2 Mon Sep 17 00:00:00 2001 From: meta Date: Tue, 18 Jan 2011 00:52:45 +0100 Subject: add some more missing C99 math.h functions diff --git a/src/mathc99.cc b/src/mathc99.cc index db71059..335446e 100644 --- a/src/mathc99.cc +++ b/src/mathc99.cc @@ -1,5 +1,18 @@ #include "mathc99.h" -double found(double a) { - return a > 0 ? floor(a+0.5) : ceil(a-0.5); +#ifdef WIN32 +#include + +double round(double a) { + return a > 0 ? floor(a+0.5) : ceil(a-0.5); +} + +float fmin(float a, float b) { + return std::min(a,b); } + +float fmax(float a, float b) { + return std::max(a,b); +} + +#endif diff --git a/src/mathc99.h b/src/mathc99.h index 4d5d3be..ebc2d66 100644 --- a/src/mathc99.h +++ b/src/mathc99.h @@ -6,6 +6,8 @@ #include //for native win32 builds we need to provide C99 math functions by ourselves double round(double a); +float fmin(float a, float b); +float fmax(float a, float b); #else -- cgit v0.10.1 From a7bf88a9cbb78feb6bd2c9e34ce64cc428d6b708 Mon Sep 17 00:00:00 2001 From: meta Date: Tue, 18 Jan 2011 00:53:52 +0100 Subject: removed unused unistd.h diff --git a/src/mainwin.cc b/src/mainwin.cc index 3373122..7e0a2f6 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -72,9 +72,6 @@ #include "qlanguagefactory.h" #endif -//for chdir -#include - #ifdef ENABLE_CGAL #if 1 -- cgit v0.10.1 From a117735f7631a86d15075a6c1ca404b24e0a1bee Mon Sep 17 00:00:00 2001 From: meta Date: Wed, 19 Jan 2011 00:17:31 +0100 Subject: don't use C99 variable length arrays diff --git a/src/primitives.cc b/src/primitives.cc index ac1f0a3..901d035 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -278,7 +278,7 @@ PolySet *PrimitiveNode::render_polyset(render_mode_e) const }; int rings = get_fragments_from_r(r1, fn, fs, fa); - ring_s ring[rings]; + ring_s *ring = new ring_s[rings]; for (int i = 0; i < rings; i++) { double phi = (M_PI * (i + 0.5)) / rings; @@ -332,6 +332,8 @@ sphere_next_r2: p->append_poly(); for (int i = 0; i < ring[rings-1].fragments; i++) p->insert_vertex(ring[rings-1].points[i].x, ring[rings-1].points[i].y, ring[rings-1].z); + + delete[] ring; } if (type == CYLINDER && h > 0 && r1 >=0 && r2 >= 0 && (r1 > 0 || r2 > 0)) @@ -351,8 +353,8 @@ sphere_next_r2: double x, y; }; - point2d circle1[fragments]; - point2d circle2[fragments]; + point2d *circle1 = new point2d[fragments]; + point2d *circle2 = new point2d[fragments]; for (int i=0; iappend_vertex(circle2[i].x, circle2[i].y, z2); } + + delete[] circle1; + delete[] circle2; } if (type == POLYHEDRON) @@ -444,22 +449,13 @@ sphere_next_r2: { int fragments = get_fragments_from_r(r1, fn, fs, fa); - struct point2d { - double x, y; - }; - - point2d circle[fragments]; + p->is2d = true; + p->append_poly(); - for (int i=0; iappend_vertex(r1*cos(phi), r1*sin(phi)); } - - p->is2d = true; - p->append_poly(); - for (int i=0; iappend_vertex(circle[i].x, circle[i].y); } if (type == POLYGON) -- cgit v0.10.1 From 74faea5ff71ba426aacc83f08f355a8d9d90fd01 Mon Sep 17 00:00:00 2001 From: meta Date: Wed, 19 Jan 2011 00:20:52 +0100 Subject: add missing include diff --git a/src/func.cc b/src/func.cc index 46b29a8..9640321 100644 --- a/src/func.cc +++ b/src/func.cc @@ -29,6 +29,7 @@ #include "dxfdim.h" #include "builtin.h" #include "mathc99.h" +#include AbstractFunction::~AbstractFunction() { -- cgit v0.10.1 From d76a63c022f5ac493e369cbe1641c617e1b4781d Mon Sep 17 00:00:00 2001 From: meta Date: Wed, 19 Jan 2011 00:24:54 +0100 Subject: change literal to help choose a proper overload diff --git a/src/func.cc b/src/func.cc index 9640321..0c0d93f 100644 --- a/src/func.cc +++ b/src/func.cc @@ -290,7 +290,7 @@ Value builtin_log(const Context *, const QVector&, const QVector if (args.size() == 2 && args[0].type == Value::NUMBER && args[1].type == Value::NUMBER) return Value(log(args[1].num) / log(args[0].num)); if (args.size() == 1 && args[0].type == Value::NUMBER) - return Value(log(args[0].num) / log(10)); + return Value(log(args[0].num) / log(10.0)); return Value(); } -- cgit v0.10.1 From ae6517492ed9e54190bde3daefe13c794fea9325 Mon Sep 17 00:00:00 2001 From: meta Date: Wed, 19 Jan 2011 00:32:02 +0100 Subject: remove unused includes diff --git a/src/projection.cc b/src/projection.cc index 7a3f77a..2dd2696 100644 --- a/src/projection.cc +++ b/src/projection.cc @@ -39,9 +39,6 @@ # include #endif -#include -#include -#include #include #include -- cgit v0.10.1 From 929e4340e2307620d56980a45d480a12eb60876d Mon Sep 17 00:00:00 2001 From: meta Date: Wed, 19 Jan 2011 19:37:42 +0100 Subject: __attribute__ ((packed)) equivalent for MSVC diff --git a/src/import.cc b/src/import.cc index bab13ae..7581228 100644 --- a/src/import.cc +++ b/src/import.cc @@ -173,13 +173,24 @@ PolySet *ImportNode::render_polyset(render_mode_e) const { f.read(80-5+4); while (1) { +#ifdef _MSC_VER +#pragma pack(push,1) +#endif struct { float i, j, k; float x1, y1, z1; float x2, y2, z2; float x3, y3, z3; unsigned short acount; - } __attribute__ ((packed)) data; + } +#ifdef __GNUC__ + __attribute__ ((packed)) +#endif + data; +#ifdef _MSC_VER +#pragma pack(pop) +#endif + if (f.read((char*)&data, sizeof(data)) != sizeof(data)) break; p->append_poly(); -- cgit v0.10.1 From 91c640fb5e15383822716ddd8ef9b1650d07d2c1 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 21 Jan 2011 02:21:09 +0100 Subject: Copyright updates diff --git a/openscad_win32.rc b/openscad_win32.rc index 2f9783a..ffdc7e2 100644 --- a/openscad_win32.rc +++ b/openscad_win32.rc @@ -24,7 +24,7 @@ VS_VERSION_INFO VERSIONINFO VALUE "CompanyName", "\0" VALUE "FileDescription", "OpenSCAD Executable\0" VALUE "FileVersion", "development build\0" - VALUE "LegalCopyright", "Copyright (C) 2009 Clifford Wolf\0" + VALUE "LegalCopyright", "Copyright (C) 2009-2011 Clifford Wolf and Marius Kintel\0" VALUE "OriginalFilename", "openscad.exe\0" VALUE "ProductName", "OpenSCAD\0" END diff --git a/src/Preferences.cc b/src/Preferences.cc index 236a73c..6419944 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 829bc84..bf2e85a 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cgaladv_minkowski2.cc b/src/cgaladv_minkowski2.cc index 85a0b2b..6a4b31c 100644 --- a/src/cgaladv_minkowski2.cc +++ b/src/cgaladv_minkowski2.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/cgaladv_minkowski3.cc b/src/cgaladv_minkowski3.cc index cc9ef00..f270de2 100644 --- a/src/cgaladv_minkowski3.cc +++ b/src/cgaladv_minkowski3.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/context.cc b/src/context.cc index 5aec712b..bfe9eb6 100644 --- a/src/context.cc +++ b/src/context.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/control.cc b/src/control.cc index 5b7e1b1..ae1d654 100644 --- a/src/control.cc +++ b/src/control.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/csgops.cc b/src/csgops.cc index ae97085..55d91d2 100644 --- a/src/csgops.cc +++ b/src/csgops.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/csgterm.cc b/src/csgterm.cc index 942aba6..6dd3bd5 100644 --- a/src/csgterm.cc +++ b/src/csgterm.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/dxfdata.cc b/src/dxfdata.cc index dc3e8a1..e896229 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 02a1274..c951868 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/dxflinextrude.cc b/src/dxflinextrude.cc index 83c3d9c..2f3fcb1 100644 --- a/src/dxflinextrude.cc +++ b/src/dxflinextrude.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc index ea603f0..2df66be 100644 --- a/src/dxfrotextrude.cc +++ b/src/dxfrotextrude.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/dxftess.cc b/src/dxftess.cc index e145391..03ed244 100644 --- a/src/dxftess.cc +++ b/src/dxftess.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/export.cc b/src/export.cc index 2b474f6..884e139 100644 --- a/src/export.cc +++ b/src/export.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/expr.cc b/src/expr.cc index 23bcc32..50950d0 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/func.cc b/src/func.cc index e8ff54a..59821e3 100644 --- a/src/func.cc +++ b/src/func.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/glview.cc b/src/glview.cc index d51714b..081c172 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/highlighter.cc b/src/highlighter.cc index aa21e38..759826c 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/import.cc b/src/import.cc index bab13ae..bd9d387 100644 --- a/src/import.cc +++ b/src/import.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/lexer.l b/src/lexer.l index 932711b..985dbbe 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/mainwin.cc b/src/mainwin.cc index ef738fc..a5c49f0 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -117,7 +118,7 @@ static char helptitle[] = QUOTED(OPENSCAD_VERSION) " (www.openscad.org)\n"; static char copyrighttext[] = - "Copyright (C) 2009 Clifford Wolf \n" + "Copyright (C) 2009-2011 Marius Kintel and Clifford Wolf \n" "\n" "This program is free software; you can redistribute it and/or modify" "it under the terms of the GNU General Public License as published by" diff --git a/src/module.cc b/src/module.cc index 1a1e30e..54b151c 100644 --- a/src/module.cc +++ b/src/module.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/nef2dxf.cc b/src/nef2dxf.cc index 44d7561..1f65637 100644 --- a/src/nef2dxf.cc +++ b/src/nef2dxf.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/node.cc b/src/node.cc index 87a7051..87b3c2b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/openscad.cc b/src/openscad.cc index bf24c9f..7bae683 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/openscad.h b/src/openscad.h index 5a1e793..e022668 100644 --- a/src/openscad.h +++ b/src/openscad.h @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/parser.y b/src/parser.y index 0cace25..26cd118 100644 --- a/src/parser.y +++ b/src/parser.y @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/polyset.cc b/src/polyset.cc index d438769..77ae26e 100644 --- a/src/polyset.cc +++ b/src/polyset.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/primitives.cc b/src/primitives.cc index ac1f0a3..1fb1011 100644 --- a/src/primitives.cc +++ b/src/primitives.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/projection.cc b/src/projection.cc index 7a3f77a..c709e95 100644 --- a/src/projection.cc +++ b/src/projection.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/render.cc b/src/render.cc index d851fc8..9fa7ab6 100644 --- a/src/render.cc +++ b/src/render.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/surface.cc b/src/surface.cc index ddcd3a6..92b661f 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/transform.cc b/src/transform.cc index 746283e..e841ef0 100644 --- a/src/transform.cc +++ b/src/transform.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/value.cc b/src/value.cc index a237c5a..bf912ac 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/test-code/dumptest.cc b/test-code/dumptest.cc index 45d19ff..2cb8f12 100644 --- a/test-code/dumptest.cc +++ b/test-code/dumptest.cc @@ -1,6 +1,7 @@ /* - * OpenSCAD (www.openscad.at) - * Copyright (C) 2009 Clifford Wolf + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit v0.10.1 From 1794a11b93284b7a1e3dbf100092be14a9bcd65f Mon Sep 17 00:00:00 2001 From: clifford Date: Fri, 21 Jan 2011 18:34:36 +0000 Subject: Clifford Wolf: Tiny fix in chrpath_linux for 64 bit (but it still does only work on 32 bit binaries) git-svn-id: http://svn.clifford.at/openscad/trunk@592 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/scripts/chrpath_linux.c b/scripts/chrpath_linux.c index 000244a..685913c 100644 --- a/scripts/chrpath_linux.c +++ b/scripts/chrpath_linux.c @@ -476,7 +476,7 @@ elf_open(const char *filename, int flags, Elf_Ehdr *ehdr) if (ehdr->e_phentsize != sizeof(Elf_Phdr)) { fprintf(stderr, "section size was read as %d, not %d!\n", - ehdr->e_phentsize, sizeof(Elf_Phdr)); + ehdr->e_phentsize, (int)sizeof(Elf_Phdr)); close(fd); return -1; } -- cgit v0.10.1 From 1b62870ca283f6f08969c9cc150cacf943c25dc5 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 21 Jan 2011 20:27:20 +0100 Subject: Update for 2011.01 diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 69fe747..972da0a 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,10 +1,18 @@ +OpenSCAD 20XX.YY +================ + -OpenSCAD 2010.XX +OpenSCAD 2011.01 ================ o Added rands() function o Added sign() function +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 Some bugs fixed, maybe some new bugs added OpenSCAD 2010.05 ================ -- cgit v0.10.1 From 64707cb326fbd8ba7e414d856e9279327066b2b7 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 21 Jan 2011 21:33:44 +0100 Subject: Upload script for binaries diff --git a/scripts/googlecode_upload.py b/scripts/googlecode_upload.py new file mode 100755 index 0000000..d2d5f97 --- /dev/null +++ b/scripts/googlecode_upload.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python +# +# Copyright 2006, 2007 Google Inc. All Rights Reserved. +# Author: danderson@google.com (David Anderson) +# +# Script for uploading files to a Google Code project. +# +# This is intended to be both a useful script for people who want to +# streamline project uploads and a reference implementation for +# uploading files to Google Code projects. +# +# To upload a file to Google Code, you need to provide a path to the +# file on your local machine, a small summary of what the file is, a +# project name, and a valid account that is a member or owner of that +# project. You can optionally provide a list of labels that apply to +# the file. The file will be uploaded under the same name that it has +# in your local filesystem (that is, the "basename" or last path +# component). Run the script with '--help' to get the exact syntax +# and available options. +# +# Note that the upload script requests that you enter your +# googlecode.com password. This is NOT your Gmail account password! +# This is the password you use on googlecode.com for committing to +# Subversion and uploading files. You can find your password by going +# to http://code.google.com/hosting/settings when logged in with your +# Gmail account. If you have already committed to your project's +# Subversion repository, the script will automatically retrieve your +# credentials from there (unless disabled, see the output of '--help' +# for details). +# +# If you are looking at this script as a reference for implementing +# your own Google Code file uploader, then you should take a look at +# the upload() function, which is the meat of the uploader. You +# basically need to build a multipart/form-data POST request with the +# right fields and send it to https://PROJECT.googlecode.com/files . +# Authenticate the request using HTTP Basic authentication, as is +# shown below. +# +# Licensed under the terms of the Apache Software License 2.0: +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Questions, comments, feature requests and patches are most welcome. +# Please direct all of these to the Google Code users group: +# http://groups.google.com/group/google-code-hosting + +"""Google Code file uploader script. +""" + +__author__ = 'danderson@google.com (David Anderson)' + +import httplib +import os.path +import optparse +import getpass +import base64 +import sys + + +def upload(file, project_name, user_name, password, summary, labels=None): + """Upload a file to a Google Code project's file server. + + Args: + file: The local path to the file. + project_name: The name of your project on Google Code. + user_name: Your Google account name. + password: The googlecode.com password for your account. + Note that this is NOT your global Google Account password! + summary: A small description for the file. + labels: an optional list of label strings with which to tag the file. + + Returns: a tuple: + http_status: 201 if the upload succeeded, something else if an + error occured. + http_reason: The human-readable string associated with http_status + file_url: If the upload succeeded, the URL of the file on Google + Code, None otherwise. + """ + # The login is the user part of user@gmail.com. If the login provided + # is in the full user@domain form, strip it down. + if user_name.endswith('@gmail.com'): + user_name = user_name[:user_name.index('@gmail.com')] + + form_fields = [('summary', summary)] + if labels is not None: + form_fields.extend([('label', l.strip()) for l in labels]) + + content_type, body = encode_upload_request(form_fields, file) + + upload_host = '%s.googlecode.com' % project_name + upload_uri = '/files' + auth_token = base64.b64encode('%s:%s'% (user_name, password)) + headers = { + 'Authorization': 'Basic %s' % auth_token, + 'User-Agent': 'Googlecode.com uploader v0.9.4', + 'Content-Type': content_type, + } + + server = httplib.HTTPSConnection(upload_host) + server.request('POST', upload_uri, body, headers) + resp = server.getresponse() + server.close() + + if resp.status == 201: + location = resp.getheader('Location', None) + else: + location = None + return resp.status, resp.reason, location + + +def encode_upload_request(fields, file_path): + """Encode the given fields and file into a multipart form body. + + fields is a sequence of (name, value) pairs. file is the path of + the file to upload. The file will be uploaded to Google Code with + the same file name. + + Returns: (content_type, body) ready for httplib.HTTP instance + """ + BOUNDARY = '----------Googlecode_boundary_reindeer_flotilla' + CRLF = '\r\n' + + body = [] + + # Add the metadata about the upload first + for key, value in fields: + body.extend( + ['--' + BOUNDARY, + 'Content-Disposition: form-data; name="%s"' % key, + '', + value, + ]) + + # Now add the file itself + file_name = os.path.basename(file_path) + f = open(file_path, 'rb') + file_content = f.read() + f.close() + + body.extend( + ['--' + BOUNDARY, + 'Content-Disposition: form-data; name="filename"; filename="%s"' + % file_name, + # The upload server determines the mime-type, no need to set it. + 'Content-Type: application/octet-stream', + '', + file_content, + ]) + + # Finalize the form body + body.extend(['--' + BOUNDARY + '--', '']) + + return 'multipart/form-data; boundary=%s' % BOUNDARY, CRLF.join(body) + + +def upload_find_auth(file_path, project_name, summary, labels=None, + user_name=None, password=None, tries=3): + """Find credentials and upload a file to a Google Code project's file server. + + file_path, project_name, summary, and labels are passed as-is to upload. + + Args: + file_path: The local path to the file. + project_name: The name of your project on Google Code. + summary: A small description for the file. + labels: an optional list of label strings with which to tag the file. + config_dir: Path to Subversion configuration directory, 'none', or None. + user_name: Your Google account name. + tries: How many attempts to make. + """ + + while tries > 0: + if user_name is None: + # Read username if not specified or loaded from svn config, or on + # subsequent tries. + sys.stdout.write('Please enter your googlecode.com username: ') + sys.stdout.flush() + user_name = sys.stdin.readline().rstrip() + if password is None: + # Read password if not loaded from svn config, or on subsequent tries. + print 'Please enter your googlecode.com password.' + print '** Note that this is NOT your Gmail account password! **' + print 'It is the password you use to access Subversion repositories,' + print 'and can be found here: http://code.google.com/hosting/settings' + password = getpass.getpass() + + status, reason, url = upload(file_path, project_name, user_name, password, + summary, labels) + # Returns 403 Forbidden instead of 401 Unauthorized for bad + # credentials as of 2007-07-17. + if status in [httplib.FORBIDDEN, httplib.UNAUTHORIZED]: + # Rest for another try. + user_name = password = None + tries = tries - 1 + else: + # We're done. + break + + return status, reason, url + + +def main(): + parser = optparse.OptionParser(usage='googlecode-upload.py -s SUMMARY ' + '-p PROJECT [options] FILE') + parser.add_option('-s', '--summary', dest='summary', + help='Short description of the file') + parser.add_option('-p', '--project', dest='project', + help='Google Code project name') + parser.add_option('-u', '--user', dest='user', + help='Your Google Code username') + parser.add_option('-w', '--password', dest='password', + help='Your Google Code password') + parser.add_option('-l', '--labels', dest='labels', + help='An optional list of comma-separated labels to attach ' + 'to the file') + + options, args = parser.parse_args() + + if not options.summary: + parser.error('File summary is missing.') + elif not options.project: + parser.error('Project name is missing.') + elif len(args) < 1: + parser.error('File to upload not provided.') + elif len(args) > 1: + parser.error('Only one file may be specified.') + + file_path = args[0] + + if options.labels: + labels = options.labels.split(',') + else: + labels = None + + status, reason, url = upload_find_auth(file_path, options.project, + options.summary, labels, + options.user, options.password) + if url: + print 'The file was uploaded successfully.' + print 'URL: %s' % url + return 0 + else: + print 'An error occurred. Your file was not uploaded.' + print 'Google Code upload server said: %s (%s)' % (reason, status) + return 1 + + +if __name__ == '__main__': + sys.exit(main()) -- cgit v0.10.1 From 397294fbec1de5c3b02f7315509fffc919105392 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 21 Jan 2011 21:36:33 +0100 Subject: Removed obsolete file diff --git a/doc/build-macosx.txt b/doc/build-macosx.txt deleted file mode 100644 index 71750b8..0000000 --- a/doc/build-macosx.txt +++ /dev/null @@ -1,41 +0,0 @@ -o Prerequisites (MacPorts): - - NB! CGAL requires gcc >= 4.2 (This is default in 10.6 Snow Leopard) - - eigen - - boost - - gmp - - mpfr - - cmake - - qt4-mac-devel - - glew - -o An important note about paths: - You can choose where to put the libs you build yourself as long as - this is reflected in the environment variables as specified under - 'Build OpenSCAD'. - -o Build CGAL >= 3.5 - - tar xzf CGAL-3.6.tar.gz - cd CGAL-3.6 - cmake -DCMAKE_INSTALL_PREFIX=$PWD/../install/CGAL-3.6 -DBUILD_SHARED_LIBS=FALSE - make -j4 - make install - -o Patch OpenCSG >= 1.3.0 - - tar xzf OpenCSG-1.3.0.tar.gz - cd OpenCSG-1.3.0 - patch -p1 < ../openscad/patches/OpenCSG-1.3.0-MacOSX-port.patch - -o Build OpenCSG - - qmake -recursive - make - -o Build OpenSCAD - - cd openscad - export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 - export CGALDIR=$PWD/../install/CGAL-3.6 - qmake - make -- cgit v0.10.1 From 46fde22b32c5fa1625c41e00983853d238153242 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 21 Jan 2011 21:43:35 +0100 Subject: Update to actually used library versions diff --git a/README b/README index b9cb493..0351ff6 100644 --- a/README +++ b/README @@ -34,13 +34,19 @@ To build OpenSCAD, you need some libraries and tools. The version numbers in brackets specify the versions which have been used for development. Other versions may or may not work as well.. -* Qt4 (4.4 - 4.6): +* Qt4 (4.4 - 4.7): http://www.qtsoftware.com/ -* CGAL (3.5.x): +* CGAL (3.6 - 3.7): http://www.cgal.org/ -* boost (1.35 - 1.41, required by CGAL) +* GMP (5.0.x): + http://www.gmplib.org/ + +* MPFR (3.0.x): + http://www.mpfr.org/ + +* boost (1.35 - 1.44, required by CGAL) http://www.boost.org/ * cmake (2.6.x, required by CGAL) @@ -49,13 +55,13 @@ development. Other versions may or may not work as well.. * OpenCSG (1.3.0): http://www.opencsg.org/ -* GLEW (bundled with OpenCSG) +* GLEW (1.5.x, also bundled with OpenCSG) http://glew.sourceforge.net/ * Eigen2 (2.0.11) http://eigen.tuxfamily.org/ -* GCC C++ Compiler (4.0, 4.2, 4.3.1): +* GCC C++ Compiler (4.2, 4.3.1): http://gcc.gnu.org/ * Bison (2.4): -- cgit v0.10.1 From 94748bb8d2cb9943f2cfb0accb71fd64f73584fc Mon Sep 17 00:00:00 2001 From: meta Date: Fri, 21 Jan 2011 22:06:50 +0100 Subject: update qmake file for visual C++ builds diff --git a/bison.pri b/bison.pri new file mode 100644 index 0000000..cf67768 --- /dev/null +++ b/bison.pri @@ -0,0 +1,15 @@ +#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.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.CONFIG += target_predeps no_link +silent:bison_header.commands = @echo Bison ${QMAKE_FILE_IN} && $$bison.commands +QMAKE_EXTRA_COMPILERS += bison_header diff --git a/boost.pri b/boost.pri new file mode 100644 index 0000000..8907b2d --- /dev/null +++ b/boost.pri @@ -0,0 +1,11 @@ +boost { + isEmpty(DEPLOYDIR) { + # Optionally specify location of boost using the + # BOOSTDIR env. variable + BOOST_DIR = $$(BOOSTDIR) + !isEmpty(BOOST_DIR) { + INCLUDEPATH += $$BOOST_DIR + message("boost location: $$BOOST_DIR") + } + } +} diff --git a/cgal.pri b/cgal.pri index 23f0c8c..ed01a44 100644 --- a/cgal.pri +++ b/cgal.pri @@ -12,6 +12,11 @@ cgal { } } - LIBS += -lCGAL -lmpfr -lgmp -lboost_thread + LIBS += -lCGAL -lmpfr -lboost_thread + win32 { + LIBS += -lmpir + } else { + LIBS += -lgmp + } QMAKE_CXXFLAGS += -frounding-math } diff --git a/flex.pri b/flex.pri new file mode 100644 index 0000000..11f6878 --- /dev/null +++ b/flex.pri @@ -0,0 +1,10 @@ +#setup flex for qmake + +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.CONFIG += target_predeps +flex.variable_out = GENERATED_SOURCES +silent:flex.commands = @echo Lex ${QMAKE_FILE_IN} && $$flex.commands +QMAKE_EXTRA_COMPILERS += flex diff --git a/openscad.pro b/openscad.pro index 42a5d22..355a129 100644 --- a/openscad.pro +++ b/openscad.pro @@ -1,5 +1,34 @@ -isEmpty(VERSION) VERSION = $$system(date "+%Y.%m.%d") +win32 { + isEmpty(VERSION) VERSION = $$system(date /t) +} else { + isEmpty(VERSION) VERSION = $$system(date "+%Y.%m.%d") +} + + +#configure lex / yacc +win32 { + include(flex.pri) + include(bison.pri) + FLEXSOURCES = src/lexer.l + BISONSOURCES = src/parser.y +} else { + LEXSOURCES += src/lexer.l + YACCSOURCES += src/parser.y +} + +#configure additional directories +win32 { + INCLUDEPATH += $$(MPIRDIR) + INCLUDEPATH += $$(MPFRDIR) +} + DEFINES += OPENSCAD_VERSION=$$VERSION +win32:DEFINES += _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS + +#disable warning about too long decorated names +win32:QMAKE_CXXFLAGS += -wd4503 + + TEMPLATE = app RESOURCES = openscad.qrc @@ -45,6 +74,7 @@ macx:CONFIG += mdi CONFIG += cgal CONFIG += opencsg CONFIG += progresswidget +CONFIG += boost #Uncomment the following line to enable QCodeEdit #CONFIG += qcodeedit @@ -64,6 +94,7 @@ progresswidget { include(cgal.pri) include(opencsg.pri) include(eigen2.pri) +include(boost.pri) # Standard include path for misc external libs #macx { @@ -74,8 +105,6 @@ include(eigen2.pri) # QMAKE_CXXFLAGS += -pg # QMAKE_LFLAGS += -pg -LEXSOURCES += src/lexer.l -YACCSOURCES += src/parser.y FORMS += src/MainWindow.ui \ src/Preferences.ui @@ -103,7 +132,8 @@ HEADERS += src/CGAL_renderer.h \ src/printutils.h \ src/value.h \ src/progress.h \ - src/editor.h + src/editor.h \ + src/mathc99.h SOURCES += src/openscad.cc \ src/mainwin.cc \ @@ -140,7 +170,8 @@ SOURCES += src/openscad.cc \ src/nef2dxf.cc \ src/Preferences.cc \ src/progress.cc \ - src/editor.cc + src/editor.cc \ + src/mathc99.cc macx { HEADERS += src/AppleEvents.h \ -- cgit v0.10.1 From 5a1fc30fc6cecd8620d32c514cc69292d0da95e5 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 21 Jan 2011 22:39:34 +0100 Subject: Added support for specifying a VARIANT variable diff --git a/openscad.pro b/openscad.pro index 0e94eb0..ee237c5 100644 --- a/openscad.pro +++ b/openscad.pro @@ -1,3 +1,13 @@ +# Auto-include config_.pri if the VARIANT variable is give on the +# command-line, e.g. qmake VARIANT=mybuild +!isEmpty(VARIANT) { + message("Variant: $${VARIANT}") + exists(config_$${VARIANT}.pri) { + message("Including config_$${VARIANT}.pri") + include(config_$${VARIANT}.pri) + } +} + win32 { isEmpty(VERSION) VERSION = $$system(date /t) } else { -- cgit v0.10.1 From 76af8c45ef719f662b7688c53d506cd28c24682e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 22 Jan 2011 01:28:01 +0100 Subject: Initial version of release checklist diff --git a/doc/release-checklist.txt b/doc/release-checklist.txt new file mode 100644 index 0000000..d0e1174 --- /dev/null +++ b/doc/release-checklist.txt @@ -0,0 +1,36 @@ +OpenSCAD Release Checklist +-------------------------- + +o Update version + release-linux.sh + publish-macosx.sh + FIXME: Windows + +o Update RELEASE_NOTES + +o Tag release + git tag "openscad-2011.01" + +o build source package + git archive --format=tar openscad-2011.01 --prefix=openscad-2011.01/ | gzip > openscad-2011.01.tar.gz + +o build binaries + Mac OS X + - publish-macosx.sh -> OpenSCAD-2011.01.dmg + Linux: FIXME 32 vs. 64 bit + - release-linux.sh + Windows: FIXME 32 vs. 64 bit + +o Set back version: release-linux.sh, publish-macosx.sh, FIXME: Windows + +o Upload + - Github + Upload manually here: https://github.com/openscad/openscad/downloads + FIXME: Write a script + + - Google code + - Get password from https://code.google.com/hosting/settings + ./scripts/googlecode_upload.py -u kintel -w -s "OpenSCAD 2011.11 Windows" -p openscad openscad-2011.01.win32.zip + ./scripts/googlecode_upload.py -u kintel -w -s "OpenSCAD 2011.11 Linux x86" -p openscad openscad-2011.01.linux-x86.tar.gz + ./scripts/googlecode_upload.py -u kintel -w -s "OpenSCAD 2011.11 Mac OS X" -p openscad openscad-2011.01.dmg + ./scripts/googlecode_upload.py -u kintel -w -s "OpenSCAD 2011.11 Source code" -p openscad openscad-2011.01.src.tar.gz -- cgit v0.10.1 From 46f8a1508c4de736b0d90bbeff58cfe3c4ef8913 Mon Sep 17 00:00:00 2001 From: meta Date: Sat, 22 Jan 2011 02:02:45 +0100 Subject: convert from getopt to boost::program_options diff --git a/src/openscad.cc b/src/openscad.cc index 7bae683..08beae1 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -33,6 +33,9 @@ #include "export.h" #include "builtin.h" +#include +#include + #ifdef ENABLE_CGAL #include "cgal.h" #include @@ -43,12 +46,19 @@ #include #include #include -#include +#include #ifdef Q_WS_MAC #include "EventFilter.h" #include "AppleEvents.h" #endif +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + +using namespace boost; +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" @@ -123,75 +133,70 @@ 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(), "stl-file") + ("o", po::value(), "off-file") + ("x", po::value(), "dxf-file") + ("d", po::value(), "deps-file") + ("m", po::value(), "make file") + ("D", po::value>(), "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().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().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().c_str(); + } + if (vm.count("d")) { + if (deps_output_file) + help(argv[0]); + deps_output_file = vm["d"].as().c_str(); + } + if (vm.count("m")) { + if (make_command) + help(argv[0]); + make_command = vm["m"].as().c_str(); + } + + if (vm.count("D")) { + const std::vector &commands = vm["D"].as >(); + + for (std::vector::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 >().begin()->c_str(); #ifndef ENABLE_MDI - if (optind != argc) + if (vm["input-file"].as >().size() > 1) help(argv[0]); #endif @@ -338,8 +343,9 @@ int main(int argc, char **argv) #endif #ifdef ENABLE_MDI new MainWindow(qfilename); - while (optind < argc) - new MainWindow(QFileInfo(original_path, argv[optind++]).absoluteFilePath()); + std::vector inputFiles = vm["input-files"].as>(); + for (std::vector::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); -- cgit v0.10.1 From 18a303ac5b335792591a0c007d74f21dc457363a Mon Sep 17 00:00:00 2001 From: meta Date: Sat, 22 Jan 2011 02:22:17 +0100 Subject: change C99 vla to heap allocated array 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())); -- cgit v0.10.1 From 26879007ae3e5de82e09512c4f18541063f949cf Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 22 Jan 2011 18:14:30 +0100 Subject: filenames are case sensitive on some filesystems diff --git a/src/dxfdim.cc b/src/dxfdim.cc index 060691b..4c53d86 100644 --- a/src/dxfdim.cc +++ b/src/dxfdim.cc @@ -34,7 +34,7 @@ #include "mathc99.h" #include -#include +#include #include QHash dxf_dim_cache; -- cgit v0.10.1 From 4ac3af2f92843401f3f2204efd72d0596516f538 Mon Sep 17 00:00:00 2001 From: meta Date: Mon, 24 Jan 2011 23:58:19 +0100 Subject: compile fixes for parser and lexer under MSVC 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 #include #include + +//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/parser.y b/src/parser.y index 26cd118..aad5ba0 100644 --- a/src/parser.y +++ b/src/parser.y @@ -35,7 +35,9 @@ #include #include +#ifndef _MSC_VER #include +#endif #include "module.h" #include "expression.h" -- cgit v0.10.1 From 9f1c837e1566fc23c76e4bb07cf47f4b0048f94f Mon Sep 17 00:00:00 2001 From: meta Date: Tue, 25 Jan 2011 00:21:36 +0100 Subject: update build files diff --git a/bison.pri b/bison.pri index cf67768..003e09b 100644 --- a/bison.pri +++ b/bison.pri @@ -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 diff --git a/boost.pri b/boost.pri index 8907b2d..165f071 100644 --- a/boost.pri +++ b/boost.pri @@ -6,6 +6,14 @@ boost { !isEmpty(BOOST_DIR) { INCLUDEPATH += $$BOOST_DIR message("boost location: $$BOOST_DIR") + win32:LIBS += -L$$BOOST_DIR/libs/program_options/build/msvc-10.0/release/link-static/threading-multi + win32:LIBS += -L$$BOOST_DIR/libs/thread/build/msvc-10.0/release/link-static/threading-multi } } + + win32 { + LIBS += -llibboost_thread-vc100-mt-1_45 -llibboost_program_options-vc100-mt-1_45 + } else { + LIBS += -lboost_thread -lboost_program_options + } } diff --git a/cgal.pri b/cgal.pri index ed01a44..bdd236a 100644 --- a/cgal.pri +++ b/cgal.pri @@ -7,16 +7,20 @@ cgal { CGAL_DIR = $$(CGALDIR) !isEmpty(CGAL_DIR) { INCLUDEPATH += $$CGAL_DIR/include - LIBS += -L$$CGAL_DIR/lib + win32 { + LIBS += -L$$CGAL_DIR/build/lib -L$$(MPFRDIR)/build.vc10/lib/Win32/Release -L$$(MPIRDIR) + } else { + LIBS += -L$$CGAL_DIR/lib + } message("CGAL location: $$CGAL_DIR") } } - LIBS += -lCGAL -lmpfr -lboost_thread + LIBS += -lmpfr win32 { - LIBS += -lmpir + LIBS += -lmpir -lCGAL-vc100-mt } else { - LIBS += -lgmp + LIBS += -lgmp -lCGAL } QMAKE_CXXFLAGS += -frounding-math } diff --git a/flex.pri b/flex.pri index 11f6878..15fccd0 100644 --- a/flex.pri +++ b/flex.pri @@ -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 diff --git a/glew.pri b/glew.pri index 189b953..f2aca4e 100644 --- a/glew.pri +++ b/glew.pri @@ -15,5 +15,5 @@ glew { } unix:LIBS += -lGLEW - win32:LIBS += -lglew32 + win32:LIBS += -lglew32s } diff --git a/openscad.pro b/openscad.pro index 95c860b..e81cb36 100644 --- a/openscad.pro +++ b/openscad.pro @@ -22,7 +22,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 -- cgit v0.10.1 From 420c36603b8ba8e7fcf2988ccef4774130d39511 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 4 Feb 2011 14:07:22 +0100 Subject: suggestions for constants diff --git a/doc/TODO.txt b/doc/TODO.txt index a053b58..29c4d87 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -143,6 +143,7 @@ o Language Frontend - 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 o DXF Import/Export - Use dxflib from RibbonSoft for import/export? -> investigate - Import -- cgit v0.10.1 From 07ec4e43b8bc1328e1815b3e259d0cbb62e17087 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 5 Feb 2011 17:06:34 +0100 Subject: clarify boolean wishes diff --git a/doc/TODO.txt b/doc/TODO.txt index 29c4d87..31e569f 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -138,12 +138,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 -- cgit v0.10.1 From 32abad175da311264993a49c9f312a6eed191d35 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Apr 2011 15:01:49 +0200 Subject: Windows compile fix diff --git a/src/grid.h b/src/grid.h index 306751f..703e006 100644 --- a/src/grid.h +++ b/src/grid.h @@ -2,7 +2,11 @@ #define GRID_H_ #include "mathc99.h" +#ifdef WIN32 +typedef __int64 int64_t; +#else #include +#endif #include #include @@ -33,8 +37,9 @@ public: for (int64_t jy = iy - 1; jy <= iy + 1; jy++) { if (!db.contains(QPair(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,int64_t>(QPair(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; -- cgit v0.10.1 From 3c77e2a8b6fe76d57375ab4fadc5fb1c88c4b269 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 15:04:08 +0200 Subject: Small steps towards making this buildable on VS2008 diff --git a/boost.pri b/boost.pri index 165f071..b9f47d0 100644 --- a/boost.pri +++ b/boost.pri @@ -6,13 +6,12 @@ boost { !isEmpty(BOOST_DIR) { INCLUDEPATH += $$BOOST_DIR message("boost location: $$BOOST_DIR") - win32:LIBS += -L$$BOOST_DIR/libs/program_options/build/msvc-10.0/release/link-static/threading-multi - win32:LIBS += -L$$BOOST_DIR/libs/thread/build/msvc-10.0/release/link-static/threading-multi + win32:LIBS += -L$$BOOST_DIR/lib } } win32 { - LIBS += -llibboost_thread-vc100-mt-1_45 -llibboost_program_options-vc100-mt-1_45 + 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 } diff --git a/cgal.pri b/cgal.pri index bdd236a..040ace2 100644 --- a/cgal.pri +++ b/cgal.pri @@ -7,18 +7,14 @@ cgal { CGAL_DIR = $$(CGALDIR) !isEmpty(CGAL_DIR) { INCLUDEPATH += $$CGAL_DIR/include - win32 { - LIBS += -L$$CGAL_DIR/build/lib -L$$(MPFRDIR)/build.vc10/lib/Win32/Release -L$$(MPIRDIR) - } else { - LIBS += -L$$CGAL_DIR/lib - } + win32: INCLUDEPATH += $$CGAL_DIR/auxiliary/gmp/include + LIBS += -L$$CGAL_DIR/lib message("CGAL location: $$CGAL_DIR") } } - LIBS += -lmpfr win32 { - LIBS += -lmpir -lCGAL-vc100-mt + LIBS += $$CGAL_DIR/auxiliary/gmp/lib/libmpfr-4.lib -lCGAL-vc90-mt-gd } else { LIBS += -lgmp -lCGAL } -- cgit v0.10.1 From 4ebf146769b27afac33bcfdee9ee50d1f0d54b63 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 15:16:06 +0200 Subject: Some wishes from Adrian diff --git a/doc/TODO.txt b/doc/TODO.txt index 31e569f..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 -- cgit v0.10.1 From 4ed0748e3a32f42c4a1e4c626ee93dc7b90e324f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 15:16:35 +0200 Subject: Update from upstream 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 # +# 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 -- cgit v0.10.1 From 9103d2235cada5b54d5968cc82f881159f3fb92c Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 15:16:59 +0200 Subject: Updated to latest version of 3rd party libs diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index ef4653c..e06a8ac 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -158,7 +158,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 -- cgit v0.10.1 From b59ec0cbacc9a198ccd8b2ea71cc7b45a78a193e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 15:27:51 +0200 Subject: gcc compile fix diff --git a/src/openscad.cc b/src/openscad.cc index 08beae1..e10f607 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -143,7 +143,7 @@ int main(int argc, char **argv) ("x", po::value(), "dxf-file") ("d", po::value(), "deps-file") ("m", po::value(), "make file") - ("D", po::value>(), "var=val") + ("D", po::value >(), "var=val") ; po::positional_options_description p; @@ -343,7 +343,7 @@ int main(int argc, char **argv) #endif #ifdef ENABLE_MDI new MainWindow(qfilename); - std::vector inputFiles = vm["input-files"].as>(); + std::vector inputFiles = vm["input-files"].as >(); for (std::vector::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())); -- cgit v0.10.1 From 69a9311faff7429eb29c1db2333f5a140e233961 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 17:17:12 +0200 Subject: Readded -lmpfr for Unix diff --git a/cgal.pri b/cgal.pri index 040ace2..3a30b22 100644 --- a/cgal.pri +++ b/cgal.pri @@ -16,7 +16,7 @@ cgal { win32 { LIBS += $$CGAL_DIR/auxiliary/gmp/lib/libmpfr-4.lib -lCGAL-vc90-mt-gd } else { - LIBS += -lgmp -lCGAL + LIBS += -lgmp -lmpfr -lCGAL } QMAKE_CXXFLAGS += -frounding-math } -- cgit v0.10.1 From 4a00f2ddb2b1f5e29e239553ae7db74795286a85 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 17:18:09 +0200 Subject: bugfix: check size of program options before indexing diff --git a/src/openscad.cc b/src/openscad.cc index e10f607..54e80ae 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -56,14 +56,13 @@ #define snprintf _snprintf #endif -using namespace boost; 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); } @@ -82,6 +81,9 @@ QString currentdir; QString examplesdir; QString librarydir; +using std::string; +using std::vector; + void handle_dep(QString filename) { if (filename.startsWith("/")) @@ -138,21 +140,20 @@ int main(int argc, char **argv) desc.add_options() ("help,h", "help message") ("version,v", "print the version") - ("s", po::value(), "stl-file") - ("o", po::value(), "off-file") - ("x", po::value(), "dxf-file") - ("d", po::value(), "deps-file") - ("m", po::value(), "make file") - ("D", po::value >(), "var=val") + ("s", po::value(), "stl-file") + ("o", po::value(), "off-file") + ("x", po::value(), "dxf-file") + ("d", po::value(), "deps-file") + ("m", po::value(), "make file") + ("D", po::value >(), "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); + po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm); +// po::notify(vm); if (vm.count("help")) help(argv[0]); if (vm.count("version")) version(); @@ -160,43 +161,44 @@ int main(int argc, char **argv) if (vm.count("s")) { if (stl_output_file || off_output_file || dxf_output_file) help(argv[0]); - stl_output_file = vm["s"].as().c_str(); + stl_output_file = vm["s"].as().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().c_str(); + off_output_file = vm["o"].as().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().c_str(); + dxf_output_file = vm["x"].as().c_str(); } if (vm.count("d")) { if (deps_output_file) help(argv[0]); - deps_output_file = vm["d"].as().c_str(); + deps_output_file = vm["d"].as().c_str(); } if (vm.count("m")) { if (make_command) help(argv[0]); - make_command = vm["m"].as().c_str(); + make_command = vm["m"].as().c_str(); } if (vm.count("D")) { - const std::vector &commands = vm["D"].as >(); + const vector &commands = vm["D"].as >(); - for (std::vector::const_iterator i = commands.begin(); i != commands.end(); i++) { + for (vector::const_iterator i = commands.begin(); i != commands.end(); i++) { commandline_commands.append(i->c_str()); commandline_commands.append(";\n"); } } - if (vm.count("input-file")) - filename = vm["input-file"].as >().begin()->c_str(); + if (vm.count("input-file")) { + filename = vm["input-file"].as< vector >().begin()->c_str(); + } #ifndef ENABLE_MDI - if (vm["input-file"].as >().size() > 1) + if (vm["input-file"].as >().size() > 1) help(argv[0]); #endif @@ -210,16 +212,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 @@ -229,16 +231,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) { @@ -343,9 +345,13 @@ int main(int argc, char **argv) #endif #ifdef ENABLE_MDI new MainWindow(qfilename); - std::vector inputFiles = vm["input-files"].as >(); - for (std::vector::const_iterator i = inputFiles.begin()+1; i != inputFiles.end(); i++) - new MainWindow(QFileInfo(original_path, i->c_str()).absoluteFilePath()); + vector inputFiles; + if (vm.count("input-file")) { + inputFiles = vm["input-files"].as >(); + for (vector::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); -- cgit v0.10.1 From d0f2d5ead95ec7430974b45191296ec26cc19ddc Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 17:18:34 +0200 Subject: gdb: use our own libraries diff --git a/mjau.gdb b/mjau.gdb index 6d749f1..7e420bb 100644 --- a/mjau.gdb +++ b/mjau.gdb @@ -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 -- cgit v0.10.1 From 36e970bc799888d9e5dbdfc55d5eca1375a617cc Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 6 Apr 2011 18:05:42 +0200 Subject: forgot install name of boost_program_options diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index e06a8ac..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() -- cgit v0.10.1 From 53d0b594700cbdcf43f7f5e2706680dc0bf85b97 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Thu, 7 Apr 2011 00:51:29 +0200 Subject: bugfix: no bounds checking on program_options in non-MDI mode diff --git a/src/openscad.cc b/src/openscad.cc index 54e80ae..bc1d845 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -198,8 +198,9 @@ int main(int argc, char **argv) } #ifndef ENABLE_MDI - if (vm["input-file"].as >().size() > 1) + if (vm.count("input-file") > 1) { help(argv[0]); + } #endif currentdir = QDir::currentPath(); -- cgit v0.10.1 From 496cc66cf253b805db73c4ce39fc477591f2c60e Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 8 Apr 2011 00:36:13 +0200 Subject: Bugfix: Clamp and to 0.01 to fix a crash diff --git a/src/primitives.cc b/src/primitives.cc index d0cd1b5..5ba32fe 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"); -- cgit v0.10.1 From 7b3a8a990f09265929fb5d463fa042dbb298ba30 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 8 Apr 2011 00:40:15 +0200 Subject: sync 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 -- cgit v0.10.1 From 9aa7b944590eadd6bd05ad2a8e5331f06ec17079 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Fri, 8 Apr 2011 22:19:06 +0100 Subject: WIP adding support for convex hull operations. diff --git a/src/cgaladv.cc b/src/cgaladv.cc index bf2e85a..3e53569 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -30,6 +30,7 @@ #include "builtin.h" #include "printutils.h" #include "cgal.h" +#include #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); @@ -39,7 +40,8 @@ extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedr enum cgaladv_type_e { MINKOWSKI, GLIDE, - SUBDIV + SUBDIV, + HULL }; class CgaladvModule : public AbstractModule @@ -103,6 +105,10 @@ AbstractNode *CgaladvModule::evaluate(const Context *ctx, const ModuleInstantiat level = c.lookup_variable("level", true); } + if (type == HULL) { + convexity = c.lookup_variable("convexity", true); + } + node->convexity = (int)convexity.num; node->path = path; node->subdiv_type = subdiv_type.text; @@ -125,6 +131,7 @@ void register_builtin_cgaladv() builtin_modules["minkowski"] = new CgaladvModule(MINKOWSKI); builtin_modules["glide"] = new CgaladvModule(GLIDE); builtin_modules["subdiv"] = new CgaladvModule(SUBDIV); + builtin_modules["hull"] = new CgaladvModule(HULL); } #ifdef ENABLE_CGAL @@ -174,6 +181,29 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const PRINT("WARNING: subdiv() is not implemented yet!"); } + if (type == HULL) + { + bool first = true; + foreach(AbstractNode * v, children) { + if (v->modinst->tag_background) + continue; + if (first) { + N = v->render_cgal_nef_polyhedron(); + if (N.dim != 0) + first = false; + } else { + CGAL_Nef_polyhedron tmp = v->render_cgal_nef_polyhedron(); + if (N.dim == 3 && tmp.dim == 3) { + + } + if (N.dim == 2 && tmp.dim == 2) { + + } + } + v->progress_report(); + } + } + cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); print_messages_pop(); progress_report(); -- cgit v0.10.1 From fe5d7359644ca26098a1cb070f0deba416b60598 Mon Sep 17 00:00:00 2001 From: Len Trigg Date: Sat, 9 Apr 2011 07:39:14 +0100 Subject: 2d Minkowski mostly working When the 2d minkowski was enabled the nef2p2 was bailing out too early. I added a simple p2nef2 based on what projection.cc was doing, and applied it to the outer_boundary of the polygon_with_holes_2. It now seems to work for simple scad code such as: minkowski() { translate([25,0,0]) square(20); circle(r=3); } diff --git a/src/cgaladv_minkowski2.cc b/src/cgaladv_minkowski2.cc index 6a4b31c..d03943c 100644 --- a/src/cgaladv_minkowski2.cc +++ b/src/cgaladv_minkowski2.cc @@ -31,7 +31,7 @@ #include "grid.h" #include "cgal.h" -#if 0 +#if 1 #include #include @@ -42,6 +42,44 @@ struct K2 : public CGAL::Exact_predicates_exact_constructions_kernel {}; typedef CGAL::Polygon_2 Poly2; typedef CGAL::Polygon_with_holes_2 Poly2h; +//----------------------------------------------------------------------------- +// Pretty-print a CGAL polygon. +// +template +void print_polygon (const CGAL::Polygon_2& P) +{ + typename CGAL::Polygon_2::Vertex_const_iterator vit; + + std::cout << "[ " << P.size() << " vertices:"; + for (vit = P.vertices_begin(); vit != P.vertices_end(); ++vit) + std::cout << " (" << *vit << ')'; + std::cout << " ]" << std::endl; +} + +//----------------------------------------------------------------------------- +// Pretty-print a polygon with holes. +// +template +void print_polygon_with_holes (const CGAL::Polygon_with_holes_2& pwh) { + if (! pwh.is_unbounded()) { + std::cout << "{ Outer boundary = "; + print_polygon (pwh.outer_boundary()); + } else + std::cout << "{ Unbounded polygon." << std::endl; + + typename CGAL::Polygon_with_holes_2::Hole_const_iterator hit; + unsigned int k = 1; + + std::cout << " " << pwh.number_of_holes() << " holes:" << std::endl; + for (hit = pwh.holes_begin(); hit != pwh.holes_end(); ++hit, ++k) { + std::cout << " Hole #" << k << " = "; + print_polygon (*hit); + } + std::cout << " }" << std::endl; + + return; +} + static Poly2 nef2p2(CGAL_Nef_polyhedron2 p) { std::list points; @@ -54,16 +92,23 @@ static Poly2 nef2p2(CGAL_Nef_polyhedron2 p) for (fci_t fit = E.faces_begin(), fend = E.faces_end(); fit != fend; ++fit) { - if (fit != E.faces_begin()) { + std::cout << "face " << ((E.mark(fit))? "is part of polygon" : "is not part of polygon") << std::endl; + if (!E.mark(fit)) { + continue; + } + //if (fit != E.faces_begin()) { + if (points.size() != 0) { PRINT("WARNING: minkowski() is not implemented for 2d objects with holes!"); - break; + break; } heafcc_t fcirc(E.halfedge(fit)), fend(fcirc); CGAL_For_all(fcirc, fend) { + //std::cout << "fcirc,fend " << std::endl; if (E.is_standard(E.target(fcirc))) { Explorer::Point ep = E.point(E.target(fcirc)); double x = to_double(ep.x()), y = to_double(ep.y()); + std::cout << "point " << ep << std::endl; grid.align(x, y); points.push_back(K2::Point_2(x, y)); } @@ -72,15 +117,36 @@ static Poly2 nef2p2(CGAL_Nef_polyhedron2 p) return Poly2(points.begin(), points.end()); } +static CGAL_Nef_polyhedron2 p2nef2(Poly2 p2) { + std::list points; + for (int j = 0; j < p2.size(); j++) { + double x = to_double(p2[j].x()); + double y = to_double(p2[j].y()); + CGAL_Nef_polyhedron2::Point p = CGAL_Nef_polyhedron2::Point(x, y); + points.push_back(p); + } + return CGAL_Nef_polyhedron2(points.begin(), points.end(), CGAL_Nef_polyhedron2::INCLUDED); +} CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) { Poly2 ap = nef2p2(a), bp = nef2p2(b); - Poly2h x = minkowski_sum_2(ap, bp); - /** FIXME **/ - - PRINT("WARNING: minkowski() is not implemented yet for 2d objects!"); - return CGAL_Nef_polyhedron2(); + std::cout << "ap = "; print_polygon(ap); + std::cout << "bp = "; print_polygon(bp); + + if (ap.size() == 0) { + PRINT("WARNING: minkowski() could not get any points from object 1!"); + return CGAL_Nef_polyhedron2(); + } else if (bp.size() == 0) { + PRINT("WARNING: minkowski() could not get any points from object 2!"); + return CGAL_Nef_polyhedron2(); + } else { + Poly2h x = minkowski_sum_2(ap, bp); + std::cout << "result = "; print_polygon_with_holes(x); + + // Make a CGAL_Nef_polyhedron2 out of just the boundary for starters + return p2nef2(x.outer_boundary()); + } } #else -- cgit v0.10.1 From 9cc441025cda17a494259b1ae2cafc5b48c14a12 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 9 Apr 2011 10:27:50 +0100 Subject: Basic implementation of convex hull for 2d polyhedra. The code was provided to me by Len Trigg via email. diff --git a/openscad.pro b/openscad.pro index 5b3a398..eecae9a 100644 --- a/openscad.pro +++ b/openscad.pro @@ -161,6 +161,7 @@ SOURCES += src/openscad.cc \ src/primitives.cc \ src/projection.cc \ src/cgaladv.cc \ + src/cgaladv_convexhull2.cc \ src/cgaladv_minkowski3.cc \ src/cgaladv_minkowski2.cc \ src/surface.cc \ @@ -180,7 +181,7 @@ SOURCES += src/openscad.cc \ src/Preferences.cc \ src/progress.cc \ src/editor.cc \ - src/mathc99.cc + src/mathc99.cc macx { HEADERS += src/AppleEvents.h \ @@ -198,4 +199,3 @@ INSTALLS += examples libraries.path = /usr/local/share/openscad/libraries/ libraries.files = libraries/* INSTALLS += libraries - diff --git a/src/cgal.h b/src/cgal.h index 6cbb251..f9161cc 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include typedef CGAL::Extended_cartesian CGAL_Kernel2; typedef CGAL::Nef_polyhedron_2 CGAL_Nef_polyhedron2; @@ -24,6 +27,9 @@ typedef CGAL_Nef_polyhedron3::Aff_transformation_3 CGAL_Aff_transformation; typedef CGAL_Nef_polyhedron3::Vector_3 CGAL_Vector; typedef CGAL_Nef_polyhedron3::Plane_3 CGAL_Plane; typedef CGAL_Nef_polyhedron3::Point_3 CGAL_Point; +typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_ExactKernel2; +typedef CGAL::Polygon_2 CGAL_Poly2; +typedef CGAL::Polygon_with_holes_2 CGAL_Poly2h; struct CGAL_Nef_polyhedron { diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 3e53569..48f14c7 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -30,11 +30,11 @@ #include "builtin.h" #include "printutils.h" #include "cgal.h" -#include #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); #endif enum cgaladv_type_e { @@ -197,7 +197,7 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const } if (N.dim == 2 && tmp.dim == 2) { - + N.p2 = convexhull2(N.p2, tmp.p2); } } v->progress_report(); diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc new file mode 100644 index 0000000..9505e44 --- /dev/null +++ b/src/cgaladv_convexhull2.cc @@ -0,0 +1,59 @@ +/* + * OpenSCAD (www.openscad.org) + * Copyright (C) 2009-2011 Clifford Wolf and + * Marius Kintel + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * As a special exception, you have permission to link this program + * with the CGAL library and distribute executables, as long as you + * follow the requirements of the GNU GPL in regard to all of the + * software in the executable aside from CGAL. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifdef ENABLE_CGAL + +#include "cgal.h" +#include + +extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); + +static std::list p2points(CGAL_Poly2 p2) +{ + std::list points; + for (int j = 0; j < p2.size(); j++) { + double x = to_double(p2[j].x()), y = to_double(p2[j].y()); + CGAL_Nef_polyhedron2::Point p = + CGAL_Nef_polyhedron2::Point(x, y); + points.push_back(p); + } + return points; +} + +CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) +{ + CGAL_Poly2 ap = nef2p2(a); + std::list points = p2points(ap), result; + + CGAL::convex_hull_2(points.begin(), points.end(), + std::back_inserter(result)); + std::cout << result.size() << " points on the convex hull" << std::endl; + return CGAL_Nef_polyhedron2(result.begin(), + result.end(), CGAL_Nef_polyhedron2::INCLUDED); +} + +#endif diff --git a/src/cgaladv_minkowski2.cc b/src/cgaladv_minkowski2.cc index d03943c..116139f 100644 --- a/src/cgaladv_minkowski2.cc +++ b/src/cgaladv_minkowski2.cc @@ -33,14 +33,10 @@ #if 1 -#include #include extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); - -struct K2 : public CGAL::Exact_predicates_exact_constructions_kernel {}; -typedef CGAL::Polygon_2 Poly2; -typedef CGAL::Polygon_with_holes_2 Poly2h; +extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); //----------------------------------------------------------------------------- // Pretty-print a CGAL polygon. @@ -80,9 +76,9 @@ void print_polygon_with_holes (const CGAL::Polygon_with_holes_2 points; + std::list points; Grid2d grid(GRID_COARSE); typedef CGAL_Nef_polyhedron2::Explorer Explorer; @@ -110,14 +106,14 @@ static Poly2 nef2p2(CGAL_Nef_polyhedron2 p) double x = to_double(ep.x()), y = to_double(ep.y()); std::cout << "point " << ep << std::endl; grid.align(x, y); - points.push_back(K2::Point_2(x, y)); + points.push_back(CGAL_ExactKernel2::Point_2(x, y)); } } } - return Poly2(points.begin(), points.end()); + return CGAL_Poly2(points.begin(), points.end()); } -static CGAL_Nef_polyhedron2 p2nef2(Poly2 p2) { +static CGAL_Nef_polyhedron2 p2nef2(CGAL_Poly2 p2) { std::list points; for (int j = 0; j < p2.size(); j++) { double x = to_double(p2[j].x()); @@ -130,7 +126,7 @@ static CGAL_Nef_polyhedron2 p2nef2(Poly2 p2) { CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) { - Poly2 ap = nef2p2(a), bp = nef2p2(b); + CGAL_Poly2 ap = nef2p2(a), bp = nef2p2(b); std::cout << "ap = "; print_polygon(ap); std::cout << "bp = "; print_polygon(bp); @@ -141,7 +137,7 @@ CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) PRINT("WARNING: minkowski() could not get any points from object 2!"); return CGAL_Nef_polyhedron2(); } else { - Poly2h x = minkowski_sum_2(ap, bp); + CGAL_Poly2h x = minkowski_sum_2(ap, bp); std::cout << "result = "; print_polygon_with_holes(x); // Make a CGAL_Nef_polyhedron2 out of just the boundary for starters -- cgit v0.10.1 From 5ef540054cc4a548a78eb78318e527f0e283ece8 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 9 Apr 2011 17:52:12 +0100 Subject: Added test script for convex hull. diff --git a/testdata/scad/convex_hull.scad b/testdata/scad/convex_hull.scad new file mode 100644 index 0000000..7db6817 --- /dev/null +++ b/testdata/scad/convex_hull.scad @@ -0,0 +1,8 @@ +hull() { + union() { + translate([15,10,0]) + circle(10); + circle(10); + } + square(2); +} -- cgit v0.10.1 From 5d5c745fdecd2580b5254cc1fd758bdc31ff88ba Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 9 Apr 2011 17:53:19 +0100 Subject: Slight improvement. You no longer need an arbitary shape in the script for it to work. See changes in testdata/scad/convex_hull.scad The square(2) was never rendered it was just there because the hull is calculated when it itterates onto the second child. I also removed the unneeded parameter. diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 48f14c7..45a3bdd 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -34,7 +34,7 @@ #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); -extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); #endif enum cgaladv_type_e { @@ -183,24 +183,19 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const if (type == HULL) { - bool first = true; + foreach(AbstractNode * v, children) { - if (v->modinst->tag_background) - continue; - if (first) { - N = v->render_cgal_nef_polyhedron(); - if (N.dim != 0) - first = false; - } else { - CGAL_Nef_polyhedron tmp = v->render_cgal_nef_polyhedron(); - if (N.dim == 3 && tmp.dim == 3) { - - } - if (N.dim == 2 && tmp.dim == 2) { - N.p2 = convexhull2(N.p2, tmp.p2); - } - } - v->progress_report(); + if (v->modinst->tag_background) + continue; + N = v->render_cgal_nef_polyhedron(); + if (N.dim == 3) { + + } + if (N.dim == 2) { + N.p2 = convexhull2(N.p2); + } + v->progress_report(); + break; } } diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc index 9505e44..1914954 100644 --- a/src/cgaladv_convexhull2.cc +++ b/src/cgaladv_convexhull2.cc @@ -29,7 +29,7 @@ #include "cgal.h" #include -extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); +extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); static std::list p2points(CGAL_Poly2 p2) @@ -44,7 +44,7 @@ static std::list p2points(CGAL_Poly2 p2) return points; } -CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) +CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a) { CGAL_Poly2 ap = nef2p2(a); std::list points = p2points(ap), result; diff --git a/testdata/scad/convex_hull.scad b/testdata/scad/convex_hull.scad index 7db6817..0f6c073 100644 --- a/testdata/scad/convex_hull.scad +++ b/testdata/scad/convex_hull.scad @@ -4,5 +4,4 @@ hull() { circle(10); circle(10); } - square(2); } -- cgit v0.10.1 From ded6d3b1b45c965ec5da81befe1b0d2c7ae31209 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sat, 9 Apr 2011 20:27:08 +0100 Subject: Convex hull now works properly with multiple children that do not neccecerily need to be touching. diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 45a3bdd..6301cd3 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -34,7 +34,7 @@ #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); -extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); +extern CGAL_Nef_polyhedron2 convexhull2(std::list a); #endif enum cgaladv_type_e { @@ -184,19 +184,24 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const if (type == HULL) { + std::list polys; + bool all2d = true; foreach(AbstractNode * v, children) { if (v->modinst->tag_background) continue; N = v->render_cgal_nef_polyhedron(); if (N.dim == 3) { - + //polys.push_back(tmp.p3); + all2d=false; } if (N.dim == 2) { - N.p2 = convexhull2(N.p2); + polys.push_back(N.p2); } v->progress_report(); - break; } + + if(all2d) + N.p2 = convexhull2(polys); } cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc index 1914954..e1e466d 100644 --- a/src/cgaladv_convexhull2.cc +++ b/src/cgaladv_convexhull2.cc @@ -29,31 +29,27 @@ #include "cgal.h" #include -extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); +extern CGAL_Nef_polyhedron2 convexhull2(std::list a); extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); -static std::list p2points(CGAL_Poly2 p2) +CGAL_Nef_polyhedron2 convexhull2(std::list a) { - std::list points; - for (int j = 0; j < p2.size(); j++) { - double x = to_double(p2[j].x()), y = to_double(p2[j].y()); - CGAL_Nef_polyhedron2::Point p = - CGAL_Nef_polyhedron2::Point(x, y); - points.push_back(p); + std::list points; + + std::list::iterator i; + for(i=a.begin(); i!=a.end(); i++) { + CGAL_Poly2 ap=nef2p2(*i); + for (int j=0;j points = p2points(ap), result; - - CGAL::convex_hull_2(points.begin(), points.end(), - std::back_inserter(result)); - std::cout << result.size() << " points on the convex hull" << std::endl; - return CGAL_Nef_polyhedron2(result.begin(), - result.end(), CGAL_Nef_polyhedron2::INCLUDED); + std::list result; + CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result)); + + return CGAL_Nef_polyhedron2(result.begin(),result.end(),CGAL_Nef_polyhedron2::INCLUDED); } #endif -- cgit v0.10.1 From cdc4574a9c1d6be012eab8e49b55e4472a71d563 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 10 Apr 2011 10:10:42 +0100 Subject: Updated test, you no longer need to union the ojects passed to hull. diff --git a/testdata/scad/convex_hull.scad b/testdata/scad/convex_hull.scad index 0f6c073..8255417 100644 --- a/testdata/scad/convex_hull.scad +++ b/testdata/scad/convex_hull.scad @@ -1,7 +1,5 @@ hull() { - union() { translate([15,10,0]) circle(10); circle(10); - } } -- cgit v0.10.1 From 5739d33cd5c801d47b6d6e4b753811b13639bfbd Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 10 Apr 2011 17:41:32 +0200 Subject: Bugfix: Handling of input-file was not working diff --git a/src/openscad.cc b/src/openscad.cc index bc1d845..aa0188c 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -144,15 +144,21 @@ int main(int argc, char **argv) ("o", po::value(), "off-file") ("x", po::value(), "dxf-file") ("d", po::value(), "deps-file") - ("m", po::value(), "make file") - ("D", po::value >(), "var=val") - ; + ("m", po::value(), "makefile") + ("D", po::value >(), "var=val"); + + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value< vector >(), "input file"); po::positional_options_description p; p.add("input-file", -1); + po::options_description all_options; + all_options.add(desc).add(hidden); + po::variables_map vm; - po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm); + po::store(po::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm); // po::notify(vm); if (vm.count("help")) help(argv[0]); @@ -348,7 +354,7 @@ int main(int argc, char **argv) new MainWindow(qfilename); vector inputFiles; if (vm.count("input-file")) { - inputFiles = vm["input-files"].as >(); + inputFiles = vm["input-file"].as >(); for (vector::const_iterator i = inputFiles.begin()+1; i != inputFiles.end(); i++) { new MainWindow(QFileInfo(original_path, i->c_str()).absoluteFilePath()); } -- cgit v0.10.1 From 0c1b1f4e2243696cbec0427c41182c5529a6c55f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 10 Apr 2011 17:41:54 +0200 Subject: Removed excessive debug output diff --git a/src/cgaladv_minkowski2.cc b/src/cgaladv_minkowski2.cc index d03943c..fb8dd4b 100644 --- a/src/cgaladv_minkowski2.cc +++ b/src/cgaladv_minkowski2.cc @@ -31,8 +31,6 @@ #include "grid.h" #include "cgal.h" -#if 1 - #include #include @@ -62,9 +60,9 @@ void print_polygon (const CGAL::Polygon_2& P) template void print_polygon_with_holes (const CGAL::Polygon_with_holes_2& pwh) { if (! pwh.is_unbounded()) { - std::cout << "{ Outer boundary = "; - print_polygon (pwh.outer_boundary()); - } else + std::cout << "{ Outer boundary = "; + print_polygon (pwh.outer_boundary()); + } else std::cout << "{ Unbounded polygon." << std::endl; typename CGAL::Polygon_with_holes_2::Hole_const_iterator hit; @@ -92,23 +90,20 @@ static Poly2 nef2p2(CGAL_Nef_polyhedron2 p) for (fci_t fit = E.faces_begin(), fend = E.faces_end(); fit != fend; ++fit) { - std::cout << "face " << ((E.mark(fit))? "is part of polygon" : "is not part of polygon") << std::endl; - if (!E.mark(fit)) { - continue; - } + if (!E.mark(fit)) { + continue; + } //if (fit != E.faces_begin()) { if (points.size() != 0) { PRINT("WARNING: minkowski() is not implemented for 2d objects with holes!"); - break; + break; } heafcc_t fcirc(E.halfedge(fit)), fend(fcirc); CGAL_For_all(fcirc, fend) { - //std::cout << "fcirc,fend " << std::endl; if (E.is_standard(E.target(fcirc))) { Explorer::Point ep = E.point(E.target(fcirc)); double x = to_double(ep.x()), y = to_double(ep.y()); - std::cout << "point " << ep << std::endl; grid.align(x, y); points.push_back(K2::Point_2(x, y)); } @@ -117,9 +112,10 @@ static Poly2 nef2p2(CGAL_Nef_polyhedron2 p) return Poly2(points.begin(), points.end()); } + static CGAL_Nef_polyhedron2 p2nef2(Poly2 p2) { std::list points; - for (int j = 0; j < p2.size(); j++) { + for (size_t j = 0; j < p2.size(); j++) { double x = to_double(p2[j].x()); double y = to_double(p2[j].y()); CGAL_Nef_polyhedron2::Point p = CGAL_Nef_polyhedron2::Point(x, y); @@ -131,33 +127,20 @@ static CGAL_Nef_polyhedron2 p2nef2(Poly2 p2) { CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) { Poly2 ap = nef2p2(a), bp = nef2p2(b); - std::cout << "ap = "; print_polygon(ap); - std::cout << "bp = "; print_polygon(bp); - - if (ap.size() == 0) { - PRINT("WARNING: minkowski() could not get any points from object 1!"); - return CGAL_Nef_polyhedron2(); - } else if (bp.size() == 0) { - PRINT("WARNING: minkowski() could not get any points from object 2!"); - return CGAL_Nef_polyhedron2(); - } else { - Poly2h x = minkowski_sum_2(ap, bp); - std::cout << "result = "; print_polygon_with_holes(x); - - // Make a CGAL_Nef_polyhedron2 out of just the boundary for starters - return p2nef2(x.outer_boundary()); - } -} -#else - -CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2, CGAL_Nef_polyhedron2) -{ - PRINT("WARNING: minkowski() is not implemented yet for 2d objects!"); - return CGAL_Nef_polyhedron2(); + if (ap.size() == 0) { + PRINT("WARNING: minkowski() could not get any points from object 1!"); + return CGAL_Nef_polyhedron2(); + } else if (bp.size() == 0) { + PRINT("WARNING: minkowski() could not get any points from object 2!"); + return CGAL_Nef_polyhedron2(); + } else { + Poly2h x = minkowski_sum_2(ap, bp); + + // Make a CGAL_Nef_polyhedron2 out of just the boundary for starters + return p2nef2(x.outer_boundary()); + } } #endif -#endif - -- cgit v0.10.1 From 06cc8b1d585e03d47dfb20014c5281c43d806f1b Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 11 Apr 2011 01:47:06 +0200 Subject: indentation diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 6301cd3..0dc70ad 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -183,25 +183,24 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const if (type == HULL) { - - std::list polys; - bool all2d = true; - foreach(AbstractNode * v, children) { - if (v->modinst->tag_background) + std::list polys; + bool all2d = true; + foreach(AbstractNode * v, children) { + if (v->modinst->tag_background) continue; - N = v->render_cgal_nef_polyhedron(); - if (N.dim == 3) { + N = v->render_cgal_nef_polyhedron(); + if (N.dim == 3) { //polys.push_back(tmp.p3); all2d=false; - } - if (N.dim == 2) { + } + if (N.dim == 2) { polys.push_back(N.p2); + } + v->progress_report(); } - v->progress_report(); - } - if(all2d) - N.p2 = convexhull2(polys); + if (all2d) + N.p2 = convexhull2(polys); } cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc index e1e466d..448dd4b 100644 --- a/src/cgaladv_convexhull2.cc +++ b/src/cgaladv_convexhull2.cc @@ -34,22 +34,22 @@ extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); CGAL_Nef_polyhedron2 convexhull2(std::list a) { - std::list points; + std::list points; - std::list::iterator i; - for(i=a.begin(); i!=a.end(); i++) { - CGAL_Poly2 ap=nef2p2(*i); - for (int j=0;j::iterator i; + for (i=a.begin(); i!=a.end(); i++) { + CGAL_Poly2 ap=nef2p2(*i); + for (size_t j=0;j result; - CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result)); + std::list result; + CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result)); - return CGAL_Nef_polyhedron2(result.begin(),result.end(),CGAL_Nef_polyhedron2::INCLUDED); + return CGAL_Nef_polyhedron2(result.begin(),result.end(),CGAL_Nef_polyhedron2::INCLUDED); } #endif -- cgit v0.10.1 From 3fbadddeacdf708875df0fe4a2c5d410a263ca51 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 11 Apr 2011 01:48:09 +0200 Subject: Added warning about missing 3D version of hull() diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 0dc70ad..66cefa9 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -191,6 +191,7 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const N = v->render_cgal_nef_polyhedron(); if (N.dim == 3) { //polys.push_back(tmp.p3); + PRINT("WARNING: hull() is not implemented yet for 3D objects!"); all2d=false; } if (N.dim == 2) { -- cgit v0.10.1 From b6e9179e4888bd52b2881275011e071b59fe1df9 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 11 Apr 2011 01:51:16 +0200 Subject: misc. fixes: Now supports hull() in OpenCSG mode, dump supports hull(), convexity not needed for hull() diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 66cefa9..dd797fd 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -105,10 +105,6 @@ AbstractNode *CgaladvModule::evaluate(const Context *ctx, const ModuleInstantiat level = c.lookup_variable("level", true); } - if (type == HULL) { - convexity = c.lookup_variable("convexity", true); - } - node->convexity = (int)convexity.num; node->path = path; node->subdiv_type = subdiv_type.text; @@ -222,6 +218,9 @@ CSGTerm *CgaladvNode::render_csg_term(double m[20], QVector *highlight if (type == SUBDIV) return render_csg_term_from_nef(m, highlights, background, "subdiv", this->convexity); + if (type == HULL) + return render_csg_term_from_nef(m, highlights, background, "hull", this->convexity); + return NULL; } @@ -229,7 +228,7 @@ CSGTerm *CgaladvNode::render_csg_term(double m[20], QVector *highlight CSGTerm *CgaladvNode::render_csg_term(double m[20], QVector *highlights, QVector *background) const { - PRINT("WARNING: Found minkowski(), glide() or subdiv() statement but compiled without CGAL support!"); + PRINT("WARNING: Found minkowski(), glide(), subdiv() or hull() statement but compiled without CGAL support!"); return NULL; } @@ -247,6 +246,8 @@ QString CgaladvNode::dump(QString indent) const } if (type == SUBDIV) text.sprintf("subdiv(level = %d, convexity = %d) {\n", this->level, this->convexity); + if (type == HULL) + text.sprintf("hull() {\n"); foreach (AbstractNode *v, this->children) text += v->dump(indent + QString("\t")); text += indent + "}\n"; -- cgit v0.10.1 From 46c3ef4ed427ec2b4dcbd089936ff0f30c9b7d30 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 11 Apr 2011 01:52:26 +0200 Subject: Added hull() and 2D minkowski diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 3cfb955..9995180 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,8 +1,9 @@ OpenSCAD 2011.XX ================ -o Added rands() function -o Added sign() function +o Added hull() for convex hulls +o minkowski() now supports 2D objects +o Added functions: rands(), sign() o Now supports escaping of the following characters in strings: \n, \t, \r, \\, \" o Support nested includes o Improved parsing of numbers -- cgit v0.10.1 From a3cfe9e6d76f41cbd13711d1bc3843afe3d14f2d Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 12 Apr 2011 17:48:57 +0200 Subject: Added note about 2D only for hull() diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 9995180..352fa67 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,7 +1,7 @@ OpenSCAD 2011.XX ================ -o Added hull() for convex hulls +o Added hull() for convex hulls (2D object only) o minkowski() now supports 2D objects o Added functions: rands(), sign() o Now supports escaping of the following characters in strings: \n, \t, \r, \\, \" -- cgit v0.10.1