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 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 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 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 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 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 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 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 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 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