diff options
| author | Marius Kintel <marius@kintel.net> | 2013-04-24 06:00:04 (GMT) | 
|---|---|---|
| committer | Marius Kintel <marius@kintel.net> | 2013-04-24 06:00:04 (GMT) | 
| commit | 5f10c9f9c0a9805567ea8f9b560c6e0b50126119 (patch) | |
| tree | 8869b03872b42ce1ffb1755958d05925f9f0bcb4 | |
| parent | 3307deee9361883a5297fbcac7f5a1cb428ed40c (diff) | |
| parent | f0ee85e17d474ab9119f82ee6f802d4634743b12 (diff) | |
Merge branch 'master' into issue217
30 files changed, 431 insertions, 173 deletions
| @@ -108,8 +108,7 @@ This will download the latest sources into a directory named 'openscad'.  To pull the MCAD library (http://reprap.org/wiki/MCAD), do the following:      cd openscad -    git submodule init -    git submodule update +    git submodule update --init  ### Building for Mac OS X diff --git a/RELEASE_NOTES b/RELEASE_NOTES index d912be4..252b38b 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -21,7 +21,6 @@ o Changed multmatrix floating-point output to improve dumptest portability  o Regression test auto-starts & stops Xvfb / Xvnc if on headless unix machine  o CGAL triangulation more lenient- enables partial rendering of 'bad' DXF data  o Fixes problem where local changes are overwritten on automatic reload when included files has changed. -o Non-ascii filenames are now allowed  OpenSCAD 2013.01  ================ diff --git a/openscad.pro b/openscad.pro index d9442d4..42b8ef0 100644 --- a/openscad.pro +++ b/openscad.pro @@ -247,6 +247,7 @@ HEADERS += src/version_check.h \             src/Camera.h \             src/system-gl.h \             src/stl-utils.h \ +           src/boost-utils.h \             src/svg.h \             \             src/lodepng.h \ @@ -291,6 +292,7 @@ SOURCES += src/version_check.cc \             src/progress.cc \             src/parsersettings.cc \             src/stl-utils.cc \ +           src/boost-utils.cc \             \             src/nodedumper.cc \             src/traverser.cc \ diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 3687041..f3fbc2b 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -28,7 +28,7 @@ OPTION_32BIT=true  OPTION_LLVM=false  OPTION_CLANG=false  OPTION_GCC=false -DETECTED_LION=false +OPTION_DEPLOY=false  export QMAKESPEC=macx-g++  printUsage() @@ -370,12 +370,13 @@ do    esac  done -OSVERSION=`sw_vers -productVersion | cut -d. -f2` -if [[ $OSVERSION -ge 7 ]]; then -  echo "Detected Lion or later" -  DETECTED_LION=true +OSX_VERSION=`sw_vers -productVersion | cut -d. -f2` +if (( $OSX_VERSION >= 8 )); then +  echo "Detected Mountain Lion (10.8) or later" +elif (( $OSX_VERSION >= 7 )); then +  echo "Detected Lion (10.7) or later"  else -  echo "Detected Snow Leopard or earlier" +  echo "Detected Snow Leopard (10.6) or earlier"  fi  USING_LLVM=false @@ -387,7 +388,7 @@ elif $OPTION_GCC; then    USING_GCC=true  elif $OPTION_CLANG; then    USING_CLANG=true -elif $DETECTED_LION; then +elif (( $OSX_VERSION >= 7 )); then    USING_GCC=true  fi @@ -411,6 +412,26 @@ elif $USING_CLANG; then    export QMAKESPEC=unsupported/macx-clang  fi +if (( $OSX_VERSION >= 8 )); then +  echo "Setting build target to 10.6 or later" +  MAC_OSX_VERSION_MIN=10.6 +else +  echo "Setting build target to 10.5 or later" +  MAC_OSX_VERSION_MIN=10.5 +fi + +if $OPTION_DEPLOY; then +  echo "Building deployment version of libraries" +else +  OPTION_32BIT=false +fi + +if $OPTION_32BIT; then +  echo "Building combined 32/64-bit binaries" +else +  echo "Building 64-bit binaries" +fi +  echo "Using basedir:" $BASEDIR  mkdir -p $SRCDIR $DEPLOYDIR  build_qt 4.8.4 diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index dc61f74..bfc830f 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -264,6 +264,12 @@ build_boost()      echo boost build failed      exit 1    fi +  if [ "`ls $DEPLOYDIR/include/ | grep boost.[0-9]`" ]; then +    if [ ! -e $DEPLOYDIR/include/boost ]; then +      echo "boost is old, make a symlink to $DEPLOYDIR/include/boost & rerun" +      exit 1 +    fi +  fi  }  build_cgal() @@ -276,17 +282,26 @@ build_cgal()    echo "Building CGAL" $version "..."    cd $BASEDIR/src    rm -rf CGAL-$version -  if [ ! -f CGAL-$version.tar.* ]; then -    # 4.1 -    curl --insecure -O https://gforge.inria.fr/frs/download.php/31640/CGAL-$version.tar.bz2 -    # 4.0.2 curl --insecure -O https://gforge.inria.fr/frs/download.php/31174/CGAL-$version.tar.bz2 -    # 4.0 curl --insecure -O https://gforge.inria.fr/frs/download.php/30387/CGAL-$version.tar.gz #4.0 -    # 3.9 curl --insecure -O https://gforge.inria.fr/frs/download.php/29125/CGAL-$version.tar.gz #3.9 -    # 3.8 curl --insecure -O https://gforge.inria.fr/frs/download.php/28500/CGAL-$version.tar.gz -    # 3.7 curl --insecure -O https://gforge.inria.fr/frs/download.php/27641/CGAL-$version.tar.gz -  fi -  tar xf CGAL-$version.tar.bz2 +  ver4_1="curl --insecure -O https://gforge.inria.fr/frs/download.php/31640/CGAL-4.1.tar.bz2" +  ver4_0_2="curl --insecure -O https://gforge.inria.fr/frs/download.php/31174/CGAL-4.0.2.tar.bz2" +  ver4_0="curl --insecure -O https://gforge.inria.fr/frs/download.php/30387/CGAL-4.0.tar.gz" +  ver3_9="curl --insecure -O https://gforge.inria.fr/frs/download.php/29125/CGAL-3.9.tar.gz" +  ver3_8="curl --insecure -O https://gforge.inria.fr/frs/download.php/28500/CGAL-3.8.tar.gz" +  ver3_7="curl --insecure -O https://gforge.inria.fr/frs/download.php/27641/CGAL-3.7.tar.gz" +  vernull="echo already downloaded..skipping" +  download_cmd=ver`echo $version | sed s/"\."/"_"/` +  if [ -e CGAL-$version.tar.gz ]; then download_cmd=vernull; fi +  if [ -e CGAL-$version.tar.bz2 ]; then download_cmd=vernull; fi +  `eval echo "$"$download_cmd` +  if [ -e CGAL-$version.tar.gz ]; then tar xf CGAL-$version.tar.gz; fi +  if [ -e CGAL-$version.tar.bz2 ]; then tar xf CGAL-$version.tar.bz2; fi    cd CGAL-$version + +  # older cmakes have buggy FindBoost that can result in +  # finding the system libraries but OPENSCAD_LIBRARIES include paths +  FINDBOOST_CMAKE=$OPENSCAD_SCRIPTDIR/../tests/FindBoost.cmake +  cp $FINDBOOST_CMAKE ./cmake/modules/ +    mkdir bin    cd bin    rm -rf ./* @@ -295,10 +310,13 @@ build_cgal()    else      CGAL_BUILDTYPE="Debug"    fi + +  DEBUGBOOSTFIND=0 # for debugging FindBoost.cmake (not for debugging boost) +  Boost_NO_SYSTEM_PATHS=1    if [ "`echo $2 | grep use-sys-libs`" ]; then -    cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DCMAKE_BUILD_TYPE=$CGAL_BUILDTYPE .. +    cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DCMAKE_BUILD_TYPE=$CGAL_BUILDTYPE -DBoost_DEBUG=$DEBUGBOOSTFIND ..    else -    cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.so -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.so -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.so -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBOOST_ROOT=$DEPLOYDIR -DBoost_USE_MULTITHREADED=false -DCMAKE_BUILD_TYPE=$CGAL_BUILD_TYPE .. +    cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DGMP_INCLUDE_DIR=$DEPLOYDIR/include -DGMP_LIBRARIES=$DEPLOYDIR/lib/libgmp.so -DGMPXX_LIBRARIES=$DEPLOYDIR/lib/libgmpxx.so -DGMPXX_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_INCLUDE_DIR=$DEPLOYDIR/include -DMPFR_LIBRARIES=$DEPLOYDIR/lib/libmpfr.so -DWITH_CGAL_Qt3=OFF -DWITH_CGAL_Qt4=OFF -DWITH_CGAL_ImageIO=OFF -DBOOST_LIBRARYDIR=$DEPLOYDIR/lib -DBOOST_INCLUDEDIR=$DEPLOYDIR/include -DCMAKE_BUILD_TYPE=$CGAL_BUILD_TYPE -DBoost_DEBUG=$DEBUGBOOSTFIND -DBoost_NO_SYSTEM_PATHS=1 ..    fi    make -j$NUMCPU    make install @@ -459,7 +477,11 @@ build_eigen()  # the 'dirname' command installed  if [ "`command -v dirname`" ]; then +  RUNDIR=$PWD    OPENSCAD_SCRIPTDIR=`dirname $0` +  cd $OPENSCAD_SCRIPTDIR +  OPENSCAD_SCRIPTDIR=$PWD +  cd $RUNDIR  else    if [ ! -f openscad.pro ]; then      echo "Must be run from the OpenSCAD source root directory (dont have 'dirname')" @@ -513,7 +535,7 @@ if [ $1 ]; then      exit $?    fi    if [ $1 = "cgal" ]; then -    build_cgal 4.0.2 use-sys-libs +    build_cgal 4.1 use-sys-libs      exit $?    fi    if [ $1 = "opencsg" ]; then diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index 98170de..e2fdaa7 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -7,7 +7,8 @@  get_fedora_deps()  {   sudo yum install qt-devel bison flex eigen2-devel python-paramiko \ -  boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git libXmu-devel +  boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig \ +  git libXmu-devel curl imagemagick  }  get_qomo_deps() @@ -19,7 +20,7 @@ get_altlinux_deps()  {   for i in boost-devel boost-filesystem-devel gcc4.5 gcc4.5-c++ boost-program_options-devel \    boost-thread-devel boost-system-devel boost-regex-devel eigen2 libmpfr libgmp libgmp_cxx-devel qt4-devel libcgal-devel git-core \ -  libglew-devel flex bison; do sudo apt-get install $i; done +  libglew-devel flex bison curl imagemagick; do sudo apt-get install $i; done  }  get_freebsd_deps() @@ -27,19 +28,19 @@ get_freebsd_deps()   pkg_add -r bison boost-libs cmake git bash eigen2 flex gmake gmp mpfr \    xorg libGLU libXmu libXi xorg-vfbserver glew \    qt4-corelib qt4-gui qt4-moc qt4-opengl qt4-qmake qt4-rcc qt4-uic \ -  opencsg cgal +  opencsg cgal curl imagemagick  }  get_netbsd_deps()  {   sudo pkgin install bison boost cmake git bash eigen flex gmake gmp mpfr \ -  qt4 glew cgal opencsg modular-xorg python27 py27-paramiko +  qt4 glew cgal opencsg modular-xorg python27 py27-paramiko curl imagemagick  }  get_opensuse_deps()  {   sudo zypper install libeigen2-devel mpfr-devel gmp-devel boost-devel \ -  libqt4-devel glew-devel cmake git bison flex cgal-devel opencsg-devel +  libqt4-devel glew-devel cmake git bison flex cgal-devel opencsg-devel curl  }  get_mageia_deps() @@ -56,7 +57,7 @@ get_debian_deps()    libxmu-dev cmake bison flex git-core libboost-all-dev \    libXi-dev libmpfr-dev libboost-dev libglew-dev libeigen2-dev \    libeigen3-dev libcgal-dev libopencsg-dev libgmp3-dev libgmp-dev \ -  python-paramiko ; do +  python-paramiko curl imagemagick; do     sudo apt-get -y install $pkg;   done  } diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 7c483cb..6ad9e4d 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -206,9 +206,11 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node)  		bb = bounding_box( *N.p3 );  	} -	Eigen::Matrix<NT,3,1> scale, bbox_size; -	scale << 1,1,1; -	bbox_size << bb.xmax()-bb.xmin(), bb.ymax()-bb.ymin(), bb.zmax()-bb.zmin(); +	std::vector<NT> scale, bbox_size; +	for (int i=0;i<3;i++) scale.push_back( NT(1) ); +	bbox_size.push_back( bb.xmax()-bb.xmin() ); +	bbox_size.push_back( bb.ymax()-bb.ymin() ); +	bbox_size.push_back( bb.zmax()-bb.zmin() );  	for (int i=0;i<3;i++) {  		if (node.newsize[i]) {  			if (bbox_size[i]==NT(0)) { @@ -220,7 +222,7 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node)  			}  		}  	} -	NT autoscale = scale.maxCoeff(); +	NT autoscale = std::max( scale[0], std::max( scale[1], scale[2] ));  	for (int i=0;i<3;i++) {  		if (node.autosize[i]) scale[i] = autoscale;  	} diff --git a/src/boost-utils.cc b/src/boost-utils.cc new file mode 100644 index 0000000..534cbaa --- /dev/null +++ b/src/boost-utils.cc @@ -0,0 +1,168 @@ +#include "boosty.h" +#include "boost-utils.h" +#include <stdio.h> +#include <iostream> + +// If the given (absolute) path is relative to the relative_to path, return a new +// relative path. Will normalize the given path first +fs::path boostfs_relative_path(const fs::path &path, const fs::path &relative_to) +{ +	// create absolute paths +	fs::path p = boosty::absolute(boostfs_normalize(path)); +	fs::path r = boosty::absolute(relative_to); +	 +	// if root paths are different, return absolute path +	if (p.root_path() != r.root_path()) +		return p; +	 +	// initialize relative path +	fs::path result; +	 +	// find out where the two paths diverge +	fs::path::const_iterator itr_path = p.begin(); +	fs::path::const_iterator itr_relative_to = r.begin(); +	while (*itr_path == *itr_relative_to && itr_path != p.end() && itr_relative_to != r.end()) { +		++itr_path; +		++itr_relative_to; +	} +	 +	// add "../" for each remaining token in relative_to +	if (itr_relative_to != r.end()) { +		++itr_relative_to; +		while (itr_relative_to != r.end()) { +			result /= ".."; +			++itr_relative_to; +		} +	} +	 +	// add remaining path +	while (itr_path != p.end()) { +		result /= *itr_path; +		++itr_path; +	} +	 +	return result; +} + +// Will normalize the given path, i.e. remove any redundant ".." path elements. +fs::path boostfs_normalize(const fs::path &path) +{ +	fs::path absPath = boosty::absolute(path); +	fs::path::iterator it = absPath.begin(); +	fs::path result = *it; +	if (it!=absPath.end()) it++; + +	// Get canonical version of the existing part +	for(;exists(result) && it != absPath.end(); ++it) { +		result /= *it; +	} +	result = boosty::canonical(result.parent_path()); +	if (it!=absPath.begin()) it--; + +	// For the rest remove ".." and "." in a path with no symlinks +	for (; it != absPath.end(); ++it) { +		// Just move back on ../ +		if (*it == "..") { +			result = result.parent_path(); +		} +		// Ignore "." +		else if (*it != ".") { +			// Just cat other path entries +			result /= *it; +		} +	} + +	return result; +} + +/** + * https://svn.boost.org/trac/boost/ticket/1976#comment:2 + *  + * "The idea: uncomplete(/foo/new, /foo/bar) => ../new + *  The use case for this is any time you get a full path (from an open dialog, perhaps) + *  and want to store a relative path so that the group of files can be moved to a different + *  directory without breaking the paths. An IDE would be a simple example, so that the + *  project file could be safely checked out of subversion." + *  + * ALGORITHM: + *  iterate path and base + * compare all elements so far of path and base + * whilst they are the same, no write to output +x2 * when they change, or one runs out: + *   write to output, ../ times the number of remaining elements in base + *   write to output, the remaining elements in path + */ +fs::path +boostfs_uncomplete(fs::path const p, fs::path const base) +{ +	if (p == base) return "./"; +	/*!! this breaks stuff if path is a filename rather than a directory, +		which it most likely is... but then base shouldn't be a filename so... */ + +	// create absolute paths +	fs::path abs_p = boosty::absolute(boostfs_normalize(p)); +	fs::path abs_base = boosty::absolute(base); + +	fs::path from_path, from_base, output; + +	fs::path::iterator path_it = abs_p.begin(),    path_end = abs_p.end(); +	fs::path::iterator base_it = abs_base.begin(), base_end = abs_base.end(); + +	// check for emptiness +	if ((path_it == path_end) || (base_it == base_end)) { +		throw std::runtime_error("path or base was empty; couldn't generate relative path"); +	} + +#ifdef WIN32 +	// drive letters are different; don't generate a relative path +	if (*path_it != *base_it) return p; + +	// now advance past drive letters; relative paths should only go up +	// to the root of the drive and not past it +	++path_it, ++base_it; +#endif + +	// Cache system-dependent dot, double-dot and slash strings +	const std::string _dot  = "."; +	const std::string _dots = ".."; +	const std::string _sep = "/"; + +	// iterate over path and base +	while (true) { + +		// compare all elements so far of path and base to find greatest common root; +		// when elements of path and base differ, or run out: +		if ((path_it == path_end) || (base_it == base_end) || (*path_it != *base_it)) { + +			// write to output, ../ times the number of remaining elements in base; +			// this is how far we've had to come down the tree from base to get to the common root +			for (; base_it != base_end; ++base_it) { +				if (*base_it == _dot) +					continue; +				else if (*base_it == _sep) +					continue; + +				output /= "../"; +			} + +			// write to output, the remaining elements in path; +			// this is the path relative from the common root +			fs::path::iterator path_it_start = path_it; +			for (; path_it != path_end; ++path_it) { +				if (path_it != path_it_start) output /= "/"; +				if (*path_it == _dot) continue; +				if (*path_it == _sep) continue; +				output /= *path_it; +			} +			break; +		} + +		// add directory level to both paths and continue iteration +		from_path /= fs::path(*path_it); +		from_base /= fs::path(*base_it); + +		++path_it, ++base_it; +	} + +	return output; +} diff --git a/src/boost-utils.h b/src/boost-utils.h new file mode 100644 index 0000000..3678ecc --- /dev/null +++ b/src/boost-utils.h @@ -0,0 +1,13 @@ +#ifndef BOOST_UTILS_H_ +#define BOOST_UTILS_H_ + +#include <boost/filesystem.hpp> +namespace fs = boost::filesystem; + +// FIXME: boostfs_relative_path() has been replaced by  +// boostfs_uncomplete(), but kept around for now. +fs::path boostfs_relative_path(const fs::path &path, const fs::path &relative_to); +fs::path boostfs_normalize(const fs::path &path); +fs::path boostfs_uncomplete(fs::path const p, fs::path const base); + +#endif diff --git a/src/boosty.h b/src/boosty.h index 6ec417a..82c765b 100644 --- a/src/boosty.h +++ b/src/boosty.h @@ -10,9 +10,8 @@   versions of boost found on popular versions of linux, circa early 2012.   design -  hope that the user is compiling with boost>1.46 + filesystem v3 -  if not, fall back to older deprecated functions, and rely on -  testing to find bugs. implement the minimum needed by OpenSCAD and no more. +  the boost filsystem changed around 1.46-1.48. we do a large #ifdef +  based on boost version that wraps various functions appropriately.    in a few years, this file should be deleted as unnecessary.   see also @@ -27,7 +26,9 @@  #include <string>  #include <boost/version.hpp>  #include <boost/filesystem.hpp> +#include <boost/algorithm/string.hpp>  namespace fs = boost::filesystem; +#include "printutils.h"  namespace boosty { @@ -77,6 +78,67 @@ inline std::string extension_str( fs::path p)  #endif + + + + +#if BOOST_VERSION >= 104800 + +inline fs::path canonical( fs::path p, fs::path p2 ) +{ +	return fs::canonical( p, p2 ); +} + +inline fs::path canonical( fs::path p ) +{ +	return fs::canonical( p ); +} + +#else + +inline fs::path canonical( fs::path p, fs::path p2 ) +{ +#if defined (__WIN32__) || defined(__APPLE__) +#error you should be using a newer version of boost on win/mac +#endif +	// based on the code in boost +	fs::path result; +	if (p=="") p=p2; +	std::string result_s; +	std::vector<std::string> resultv, pieces; +	std::vector<std::string>::iterator pi; +	std::string tmps = boosty::stringy( p ); +	boost::split( pieces, tmps, boost::is_any_of("/") ); +	for ( pi = pieces.begin(); pi != pieces.end(); ++pi ) +	{ +		if (*pi == "..") +			resultv.erase( resultv.end() ); +		else +			resultv.push_back( *pi ); +	} +	for ( pi = resultv.begin(); pi != resultv.end(); ++pi ) +	{ +		if ((*pi).length()>0) result_s = result_s + "/" + *pi; +	} +	result = fs::path( result_s ); +	if (fs::is_symlink(result)) +	{ +		PRINT("WARNING: canonical() wrapper can't do symlinks. rebuild openscad with boost >=1.48"); +		PRINT("WARNING: or don't use symbolic links"); +	} +	return result; +} + +inline fs::path canonical( fs::path p ) +{ +	return canonical( p, fs::current_path() ); +} + +#endif + + + +  } // namespace  #endif diff --git a/src/dxfdata.cc b/src/dxfdata.cc index f34af51..8415228 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -41,8 +41,9 @@  #include <sstream>  #include <map> -#include <QDir>  #include "value.h" +#include "boost-utils.h" +#include "boosty.h"  /*! \class DxfData @@ -389,10 +390,10 @@ DxfData::DxfData(double fn, double fs, double fa,  	BOOST_FOREACH(const EntityList::value_type &i, unsupported_entities_list) {  		if (layername.empty()) {  			PRINTB("WARNING: Unsupported DXF Entity '%s' (%x) in %s.", -						 i.first % i.second % QuotedString(QDir::current().relativeFilePath(QString::fromLocal8Bit(filename.c_str())).toLocal8Bit().constData())); +						 i.first % i.second % QuotedString(boosty::stringy(boostfs_uncomplete(filename, fs::current_path()))));  		} else {  			PRINTB("WARNING: Unsupported DXF Entity '%s' (%x) in layer '%s' of %s.", -						 i.first % i.second % layername % QuotedString(QDir::current().relativeFilePath(QString::fromLocal8Bit(filename.c_str())).toLocal8Bit().constData())); +						 i.first % i.second % layername % QuotedString(boosty::stringy(boostfs_uncomplete(filename, fs::current_path()))));  		}  	} diff --git a/src/dxftess-glu.cc b/src/dxftess-glu.cc index 1a8bfa5..3f87729 100644 --- a/src/dxftess-glu.cc +++ b/src/dxftess-glu.cc @@ -3,14 +3,11 @@  #include "polyset.h"  #include "grid.h"  #include <stdio.h> +#include <boost/foreach.hpp>  #include "system-gl.h"  #include "mathc99.h" -#include <QVector> -#include <QPair> -#include <QHash> -  #ifdef WIN32  #  define STDCALL __stdcall  #else @@ -31,7 +28,7 @@ struct tess_triangle {  static GLenum tess_type;  static int tess_count; -static QVector<tess_triangle> tess_tri; +static std::vector<tess_triangle> tess_tri;  static GLdouble *tess_p1, *tess_p2;  static void STDCALL tess_vertex(void *vertex_data) @@ -48,7 +45,7 @@ static void STDCALL tess_vertex(void *vertex_data)  			tess_p2 = p;  		}  		if (tess_count > 1) { -			tess_tri.append(tess_triangle(tess_p1, tess_p2, p)); +			tess_tri.push_back(tess_triangle(tess_p1, tess_p2, p));  			tess_p2 = p;  		}  	} @@ -61,9 +58,9 @@ static void STDCALL tess_vertex(void *vertex_data)  		}  		if (tess_count > 1) {  			if (tess_count % 2 == 1) { -				tess_tri.append(tess_triangle(tess_p2, tess_p1, p)); +				tess_tri.push_back(tess_triangle(tess_p2, tess_p1, p));  			} else { -				tess_tri.append(tess_triangle(tess_p1, tess_p2, p)); +				tess_tri.push_back(tess_triangle(tess_p1, tess_p2, p));  			}  			tess_p1 = tess_p2;  			tess_p2 = p; @@ -77,7 +74,7 @@ static void STDCALL tess_vertex(void *vertex_data)  			tess_p2 = p;  		}  		if (tess_count == 2) { -			tess_tri.append(tess_triangle(tess_p1, tess_p2, p)); +			tess_tri.push_back(tess_triangle(tess_p1, tess_p2, p));  			tess_count = -1;  		}  	} @@ -188,6 +185,17 @@ static bool point_on_line(double *p1, double *p2, double *p3)  	return true;  } +typedef std::pair<int,int> pair_ii; +inline void do_emplace( boost::unordered_multimap<int, pair_ii> &tri_by_atan2, int ai, const pair_ii &indexes) +{ +#if BOOST_VERSION >= 104800 +			tri_by_atan2.emplace(ai, indexes); +#else +			std::pair< int, pair_ii > tmp( ai, indexes ); +			tri_by_atan2.insert( tmp ); +#endif +} +  /*!  	up: true if the polygon is facing in the normal direction (i.e. normal = [0,0,1])  	rot: CLOCKWISE rotation around positive Z axis @@ -214,7 +222,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian  	tess_tri.clear(); -	QList<tess_vdata> vl; +	std::list<tess_vdata> vl;  	gluTessBeginPolygon(tobj, NULL); @@ -225,7 +233,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian  		gluTessNormal(tobj, 0, 0, +1);  	} -	Grid3d< QPair<int,int> > point_to_path(GRID_COARSE); +	Grid3d< std::pair<int,int> > point_to_path(GRID_COARSE);  	for (int i = 0; i < dxf.paths.size(); i++) {  		if (!dxf.paths[i].is_closed) @@ -234,12 +242,12 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian  		for (int j = 1; j < dxf.paths[i].indices.size(); j++) {  			point_to_path.data(dxf.points[dxf.paths[i].indices[j]][0],  												 dxf.points[dxf.paths[i].indices[j]][1], -												 h) = QPair<int,int>(i, j); -			vl.append(tess_vdata()); -			vl.last().v[0] = dxf.points[dxf.paths[i].indices[j]][0]; -			vl.last().v[1] = dxf.points[dxf.paths[i].indices[j]][1]; -			vl.last().v[2] = h; -			gluTessVertex(tobj, vl.last().v, vl.last().v); +												 h) = std::pair<int,int>(i, j); +			vl.push_back(tess_vdata()); +			vl.back().v[0] = dxf.points[dxf.paths[i].indices[j]][0]; +			vl.back().v[1] = dxf.points[dxf.paths[i].indices[j]][1]; +			vl.back().v[2] = h; +			gluTessVertex(tobj, vl.back().v, vl.back().v);  		}  		gluTessEndContour(tobj);  	} @@ -263,7 +271,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian  				point_on_line(tess_tri[i].p[1], tess_tri[i].p[2], tess_tri[i].p[0]) ||  				point_on_line(tess_tri[i].p[2], tess_tri[i].p[0], tess_tri[i].p[1])) {  			// printf("DEBUG: Removed triangle\n"); -			tess_tri.remove(i--); +			tess_tri.erase(tess_tri.begin() + i--);  		}  	} @@ -277,13 +285,13 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian  	if (do_triangle_splitting)  	{  		bool added_triangles = true; -		typedef QPair<int,int> QPair_ii; -		QHash<int, QPair_ii> tri_by_atan2; +		typedef std::pair<int,int> pair_ii; +		boost::unordered_multimap<int, pair_ii> tri_by_atan2;  		for (int i = 0; i < tess_tri.size(); i++)  		for (int j = 0; j < 3; j++) {  			int ai = (int)round(atan2(fabs(tess_tri[i].p[(j+1)%3][0] - tess_tri[i].p[j][0]),  					fabs(tess_tri[i].p[(j+1)%3][1] - tess_tri[i].p[j][1])) / 0.001); -			tri_by_atan2.insertMulti(ai, QPair<int,int>(i, j)); +			do_emplace( tri_by_atan2, ai, std::pair<int,int>(i, j) );  		}  		while (added_triangles)  		{ @@ -294,20 +302,23 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian  			for (int i = 0; i < tess_tri.size(); i++)  			for (int k = 0; k < 3; k++)  			{ -				QHash<QPair_ii, QPair_ii> possible_neigh; +				boost::unordered_map<pair_ii, pair_ii> possible_neigh;  				int ai = (int)floor(atan2(fabs(tess_tri[i].p[(k+1)%3][0] - tess_tri[i].p[k][0]),  						fabs(tess_tri[i].p[(k+1)%3][1] - tess_tri[i].p[k][1])) / 0.001 - 0.5);  				for (int j = 0; j < 2; j++) { -					foreach (const QPair_ii &jl, tri_by_atan2.values(ai+j)) -						if (i != jl.first) -							possible_neigh[jl] = jl; +					for (boost::unordered_multimap<int, pair_ii>::iterator it = tri_by_atan2.find(ai+j); +							 it != tri_by_atan2.end(); +							 it++) { +						if (i != it->first) possible_neigh[it->second] = it->second; +					}  				}  #ifdef DEBUG_TRIANGLE_SPLITTING  				printf("%d/%d: %d\n", i, k, possible_neigh.size());  #endif -				foreach (const QPair_ii &jl, possible_neigh) { -					int j = jl.first; -					for (int l = jl.second; l != (jl.second + 2) % 3; l = (l + 1) % 3) +				typedef std::pair<pair_ii,pair_ii> ElemPair; +				BOOST_FOREACH (const ElemPair &elem, possible_neigh) { +					int j = elem.first.first; +					for (int l = elem.first.second; l != (elem.first.second + 2) % 3; l = (l + 1) % 3)  					if (point_on_line(tess_tri[i].p[k], tess_tri[j].p[l], tess_tri[i].p[(k+1)%3])) {  #ifdef DEBUG_TRIANGLE_SPLITTING  						printf("%% %f %f %f %f %f %f [%d %d]\n", @@ -316,18 +327,18 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian  								tess_tri[i].p[(k+1)%3][0], tess_tri[i].p[(k+1)%3][1],  								i, j);  #endif -						tess_tri.append(tess_triangle(tess_tri[j].p[l], +						tess_tri.push_back(tess_triangle(tess_tri[j].p[l],  								tess_tri[i].p[(k+1)%3], tess_tri[i].p[(k+2)%3]));  						for (int m = 0; m < 2; m++) { -							int ai = (int)round(atan2(fabs(tess_tri.last().p[(m+1)%3][0] - tess_tri.last().p[m][0]), -									fabs(tess_tri.last().p[(m+1)%3][1] - tess_tri.last().p[m][1])) / 0.001 ); -							tri_by_atan2.insertMulti(ai, QPair<int,int>(tess_tri.size()-1, m)); +							int ai = (int)round(atan2(fabs(tess_tri.back().p[(m+1)%3][0] - tess_tri.back().p[m][0]), +									fabs(tess_tri.back().p[(m+1)%3][1] - tess_tri.back().p[m][1])) / 0.001 ); +							do_emplace(tri_by_atan2, ai, std::pair<int,int>(tess_tri.size()-1, m));  						}  						tess_tri[i].p[(k+1)%3] = tess_tri[j].p[l];  						for (int m = 0; m < 2; m++) {  							int ai = (int)round(atan2(fabs(tess_tri[i].p[(m+1)%3][0] - tess_tri[i].p[m][0]),  									fabs(tess_tri[i].p[(m+1)%3][1] - tess_tri[i].p[m][1])) / 0.001 ); -							tri_by_atan2.insertMulti(ai, QPair<int,int>(i, m)); +							do_emplace(tri_by_atan2, ai, std::pair<int,int>(i, m));  						}  						added_triangles = true;  					} diff --git a/src/func.cc b/src/func.cc index 791e957..26d7e69 100644 --- a/src/func.cc +++ b/src/func.cc @@ -449,7 +449,7 @@ Value builtin_search(const Context *, const std::vector<std::string>&, const std  		      if (num_returns_per_match > 1 && matchCount >= num_returns_per_match) break;  		    }  		  } -		  if (matchCount == 0) PRINTB("  search term not found: \"%s\"", findThis.toString()[i]); +		  if (matchCount == 0) PRINTB("  WARNING: search term not found: \"%s\"", findThis.toString()[i]);  		  if (num_returns_per_match == 0 || num_returns_per_match > 1) {  				returnvec.push_back(Value(resultvec));  			} @@ -478,10 +478,10 @@ Value builtin_search(const Context *, const std::vector<std::string>&, const std  		  }  		  if (num_returns_per_match == 1 && matchCount == 0) {  		    if (findThis.toVector()[i].type() == Value::NUMBER) { -					PRINTB("  search term not found: %s",findThis.toVector()[i].toDouble()); +					PRINTB("  WARNING: search term not found: %s",findThis.toVector()[i].toDouble());  				}  		    else if (findThis.toVector()[i].type() == Value::STRING) { -					PRINTB("  search term not found: \"%s\"",findThis.toVector()[i].toString()); +					PRINTB("  WARNING: search term not found: \"%s\"",findThis.toVector()[i].toString());  				}  		    returnvec.push_back(Value(resultvec));  		  } @@ -490,7 +490,7 @@ Value builtin_search(const Context *, const std::vector<std::string>&, const std  			}  		}  	} else { -		PRINTB("  search: none performed on input %s", findThis); +		PRINTB("  WARNING: search: none performed on input %s", findThis);  		return Value();  	}  	return Value(returnvec); diff --git a/src/highlighter.cc b/src/highlighter.cc index 391e3a5..bf80bb4 100644 --- a/src/highlighter.cc +++ b/src/highlighter.cc @@ -151,7 +151,7 @@ Highlighter::Highlighter(QTextDocument *parent)  	tokentypes["import"] << "include" << "use" << "import_stl" << "import" << "import_dxf" << "dxf_dim" << "dxf_cross";  	typeformats["import"].setForeground(Qt::darkYellow); -	tokentypes["special"] << "$children" << "child" << "$fn" << "$fa" << "$fb"; +	tokentypes["special"] << "$children" << "child" << "$fn" << "$fa" << "$fs" << "$t" << "$vpt" << "$vpr";  	typeformats["special"].setForeground(Qt::darkGreen);  	tokentypes["extrude"] << "linear_extrude" << "rotate_extrude"; diff --git a/src/import.cc b/src/import.cc index bbf5a6e..627fb56 100644 --- a/src/import.cc +++ b/src/import.cc @@ -251,10 +251,15 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const  #ifdef ENABLE_CGAL  		CGAL_Polyhedron poly;  		std::ifstream file(this->filename.c_str(), std::ios::in | std::ios::binary); -		file >> poly; -		file.close(); -		 -		p = createPolySetFromPolyhedron(poly); +		if (!file.good()) { +			PRINTB("WARNING: Can't open import file '%s'.", this->filename); +		} +		else { +			file >> poly; +			file.close(); +			 +			p = createPolySetFromPolyhedron(poly); +		}  #else    PRINT("WARNING: OFF import requires CGAL.");  #endif diff --git a/src/parsersettings.cc b/src/parsersettings.cc index a757ba1..8d82744 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -3,8 +3,9 @@  #include <boost/foreach.hpp>  #include "boosty.h"  #include <boost/algorithm/string.hpp> -#include <qglobal.h> // Needed for Q_ defines - move the offending code somewhere else +#ifdef __APPLE__  #include "CocoaUtils.h" +#endif  namespace fs = boost::filesystem; diff --git a/src/value.cc b/src/value.cc index f14f826..ebb825d 100644 --- a/src/value.cc +++ b/src/value.cc @@ -34,12 +34,14 @@  #include <boost/variant/apply_visitor.hpp>  #include <boost/variant/static_visitor.hpp>  #include <boost/format.hpp> - -#include <QtCore/QDir> +#include "boost-utils.h" +#include "boosty.h"  std::ostream &operator<<(std::ostream &stream, const Filename &filename)  { -  stream << QuotedString(QDir::current().relativeFilePath(QString::fromLocal8Bit(filename.c_str())).toLocal8Bit().constData()); +  fs::path fnpath = fs::path( (std::string)filename ); +  fs::path fpath = boostfs_uncomplete(fnpath, fs::current_path()); +  stream << QuotedString(boosty::stringy( fpath ));    return stream;  } diff --git a/testdata/scad/templates/import_dxf-tests-template.scad b/testdata/scad/templates/import_dxf-tests-template.scad index f10dd06..91eca7a 100644 --- a/testdata/scad/templates/import_dxf-tests-template.scad +++ b/testdata/scad/templates/import_dxf-tests-template.scad @@ -4,7 +4,7 @@ translate([-210,0,0]) import(file="../../dxf/polygons.dxf", origin=[0,110]);  translate([-210,0,0]) import(file="../../dxf/polygons.dxf", origin=[110,110], scale=0.5);  import(file="../../dxf/multiple-layers.dxf");  translate([-200,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="0"); -translate([0,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="0"); +translate([0,200,0]) import(filename="../../dxf/multiple-layers.dxf", layername="0");  translate([200,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="noname");  translate([0,200,0]) import(file="../../dxf/multiple-layers.dxf", layer="Layer with a pretty long name including \\ \"special\" /'\\\\ characters");  translate([200,0,0]) import(file="@CMAKE_SOURCE_DIR@/../testdata/dxf/polygons.dxf"); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a0d8f6b..34432d3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -97,7 +97,7 @@ endif()  # Clang compiler -if(CMAKE_CXX_COMPILER MATCHES ".*clang.*") +if(${CMAKE_CXX_COMPILER} MATCHES ".*clang.*")    # disable enormous amount of warnings about CGAL    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") @@ -179,28 +179,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")    FIND_LIBRARY(COCOA_LIBRARY Cocoa REQUIRED)  endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") -# Qt4 - -set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) -find_package(OpenGL REQUIRED) -if ( "${OPENGL_glu_LIBRARY}" MATCHES "NOTFOUND" ) -  # GLU and Mesa split in late 2012 so some systems dont have GLU -  find_library(OPENGL_glu_LIBRARY GLU HINTS "$ENV{OPENSCAD_LIBRARIES}/lib" REQUIRED) -  set( OPENGL_LIBRARY ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARY} ) -endif() - -if (MINGW_CROSS_ENV_DIR)  -  mingw_cross_env_find_qt() -  mingw_cross_env_info() -  include_directories( ${QT_INCLUDE_DIRS} ) -  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QT_CFLAGS_OTHER}") -else() -  find_package(Qt4 COMPONENTS QtCore REQUIRED) -  include(${QT_USE_FILE}) -endif() - -set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF) -  # Eigen @@ -268,6 +246,8 @@ else()    inclusion(EIGEN_DIR EIGEN_INCLUDE_DIR)  endif() +# OpenGL +find_package(OpenGL REQUIRED)  # OpenCSG  if (NOT $ENV{OPENCSGDIR} STREQUAL "") @@ -374,7 +354,7 @@ if("${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}" VERSION_LESS 3.6)  endif()  inclusion(CGAL_DIR CGAL_INCLUDE_DIRS) -if(CMAKE_CXX_COMPILER MATCHES ".*clang.*") +if(${CMAKE_CXX_COMPILER} MATCHES ".*clang.*" AND NOT ${CGAL_CXX_FLAGS_INIT} STREQUAL "" )  	string(REPLACE "-frounding-math" "" CGAL_CXX_FLAGS_INIT ${CGAL_CXX_FLAGS_INIT})  	string(REPLACE "--param=ssp-buffer-size=4" "" CGAL_CXX_FLAGS_INIT ${CGAL_CXX_FLAGS_INIT})  endif() @@ -444,6 +424,7 @@ set(CORE_SOURCES    ../src/rotateextrude.cc     ../src/printutils.cc     ../src/progress.cc  +  ../src/boost-utils.cc     ${FLEX_OpenSCADlexer_OUTPUTS}    ${BISON_OpenSCADparser_OUTPUTS}) @@ -604,6 +585,10 @@ else()    set(GUI_BINPATH "${CMAKE_CURRENT_SOURCE_DIR}/../openscad")  endif() +if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/openscad") +  set(GUI_BINPATH "${CMAKE_CURRENT_BINARY_DIR}/openscad") +endif() +  if(EXISTS "${GUI_BINPATH}")    message(STATUS "Found OpenSCAD GUI binary: ${GUI_BINPATH}")  else() diff --git a/tests/cgalcachetest.cc b/tests/cgalcachetest.cc index 3a0a855..b7e51b5 100644 --- a/tests/cgalcachetest.cc +++ b/tests/cgalcachetest.cc @@ -40,7 +40,6 @@  #include "PolySetCGALEvaluator.h"  #include "CGALCache.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -57,7 +56,6 @@ namespace po = boost::program_options;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::string; @@ -124,13 +122,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path(); -	currentdir = boosty::stringy( fs::current_path() ); +	currentdir = boosty::stringy(fs::current_path()); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc index 52205fd..947a231 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -43,7 +43,6 @@  #include "cgal.h"  #include "OffscreenView.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -57,7 +56,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::string; @@ -97,13 +95,12 @@ int main(int argc, char **argv)  #endif  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/cgalstlsanitytest.cc b/tests/cgalstlsanitytest.cc index 2815463..228bfde 100644 --- a/tests/cgalstlsanitytest.cc +++ b/tests/cgalstlsanitytest.cc @@ -38,11 +38,6 @@  #include "CGALEvaluator.h"  #include "PolySetCGALEvaluator.h" -#include <QCoreApplication> -#include <QFile> -#include <QDir> -#include <QSet> -#include <QTextStream>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -56,7 +51,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::string; @@ -83,13 +77,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc index 4a15050..9c8c090 100644 --- a/tests/cgaltest.cc +++ b/tests/cgaltest.cc @@ -38,7 +38,6 @@  #include "CGALEvaluator.h"  #include "PolySetCGALEvaluator.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -52,7 +51,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::string; @@ -76,13 +74,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/csgtermtest.cc b/tests/csgtermtest.cc index e793c4a..864ba5d 100644 --- a/tests/csgtermtest.cc +++ b/tests/csgtermtest.cc @@ -38,7 +38,6 @@  #include "Tree.h"  #include "csgterm.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -53,7 +52,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::cout; @@ -71,13 +69,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 7583a41..1e518e2 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -23,9 +23,6 @@  #include "csgtermnormalizer.h"  #include "OffscreenView.h" -#include <QCoreApplication> -#include <QTimer> -  #include <sstream>  #include <vector> @@ -128,14 +125,12 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv); -  	fs::path original_path = fs::current_path();  	std::string currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/csgtexttest.cc b/tests/csgtexttest.cc index e050232..6a72dff 100644 --- a/tests/csgtexttest.cc +++ b/tests/csgtexttest.cc @@ -37,7 +37,6 @@  #include "builtin.h"  #include "Tree.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -52,7 +51,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  void csgTree(CSGTextCache &cache, const AbstractNode &root)  { @@ -75,13 +73,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/dumptest.cc b/tests/dumptest.cc index 3627608..32c9842 100644 --- a/tests/dumptest.cc +++ b/tests/dumptest.cc @@ -35,7 +35,6 @@  #include "builtin.h"  #include "Tree.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -50,7 +49,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::string; @@ -81,13 +79,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy(fs::current_path()); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/echotest.cc b/tests/echotest.cc index bf2f4a4..af4942b 100644 --- a/tests/echotest.cc +++ b/tests/echotest.cc @@ -34,7 +34,6 @@  #include "builtin.h"  #include "printutils.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -49,7 +48,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::string; @@ -83,13 +81,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/modulecachetest.cc b/tests/modulecachetest.cc index 0028114..1103720 100644 --- a/tests/modulecachetest.cc +++ b/tests/modulecachetest.cc @@ -35,7 +35,6 @@  #include "builtin.h"  #include "Tree.h" -#include <QCoreApplication>  #ifndef _MSC_VER  #include <getopt.h>  #endif @@ -50,7 +49,6 @@ namespace fs = boost::filesystem;  std::string commandline_commands;  std::string currentdir; -QString examplesdir;  using std::string; @@ -71,13 +69,12 @@ int main(int argc, char **argv)  	Builtins::instance()->initialize(); -	QCoreApplication app(argc, argv);  	fs::path original_path = fs::current_path();  	currentdir = boosty::stringy( fs::current_path() ); -	parser_init(QCoreApplication::instance()->applicationDirPath().toStdString()); -	add_librarydir(boosty::stringy(fs::path(QCoreApplication::instance()->applicationDirPath().toStdString()) / "../libraries")); +	parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); +	add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries"));  	Context root_ctx;  	register_builtin(root_ctx); diff --git a/tests/regression/echotest/search-tests-expected.txt b/tests/regression/echotest/search-tests-expected.txt index 64df0b6..0269f43 100644 --- a/tests/regression/echotest/search-tests-expected.txt +++ b/tests/regression/echotest/search-tests-expected.txt @@ -1,9 +1,9 @@ -  search term not found: "q" -  search term not found: 1000 -  search term not found: "zzz" -  search term not found: "zzz" -  search term not found: 500 -  search term not found: "" +  WARNING: search term not found: "q" +  WARNING: search term not found: 1000 +  WARNING: search term not found: "zzz" +  WARNING: search term not found: "zzz" +  WARNING: search term not found: 500 +  WARNING: search term not found: ""  ECHO: "Characters in string (\"a\"): [0]"  ECHO: "Characters in string (\"adeq\"): [[0, 5], [3, 8], [4], []]"  ECHO: "Default string search (\"abe\"): [0, 1, 8]" | 
