Merge branch 'master' into issue116

felipesanches-svg
Marius Kintel 2013-04-18 18:42:51 -04:00
commit b06b4f32f8
7 changed files with 82 additions and 43 deletions

View File

@ -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')"

View File

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

View File

@ -26,6 +26,7 @@
#include <string>
#include <boost/version.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
namespace fs = boost::filesystem;
#include "printutils.h"
@ -97,29 +98,33 @@ inline fs::path canonical( fs::path p )
inline fs::path canonical( fs::path p, fs::path p2 )
{
// dotpath: win32/mac builds will be using newer versions of boost
// so we can treat this as though it is unix only
const fs::path dot_path(".");
const fs::path dot_dot_path("..");
#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=="")
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 )
{
p=p2;
if (*pi == "..")
resultv.erase( resultv.end() );
else
resultv.push_back( *pi );
}
for (fs::path::iterator itr = p.begin(); itr != p.end(); itr++)
for ( pi = resultv.begin(); pi != resultv.end(); ++pi )
{
if (*itr == dot_path) continue;
if (*itr == dot_dot_path)
{
result.remove_filename();
continue;
}
result /= *itr;
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");
}
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;
}

View File

@ -185,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
@ -280,7 +291,7 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian
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.emplace(ai, std::pair<int,int>(i, j));
do_emplace( tri_by_atan2, ai, std::pair<int,int>(i, j) );
}
while (added_triangles)
{
@ -321,13 +332,13 @@ void dxf_tesselate(PolySet *ps, DxfData &dxf, double rot, bool up, bool do_trian
for (int m = 0; m < 2; 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 );
tri_by_atan2.emplace(ai, std::pair<int,int>(tess_tri.size()-1, m));
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.emplace(ai, std::pair<int,int>(i, m));
do_emplace(tri_by_atan2, ai, std::pair<int,int>(i, m));
}
added_triangles = true;
}

View File

@ -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";

View File

@ -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");

View File

@ -354,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 STREQUAL ${CGAL_CXX_FLAGS_INIT} "" )
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()