Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Eigen3 #183

Closed
wants to merge 45 commits into
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+222 −106
Split
View
@@ -92,7 +92,7 @@ Follow the instructions for the platform you're compiling on below.
* [boost (1.35 - 1.47)](http://www.boost.org/)
* [OpenCSG (1.3.2)](http://www.opencsg.org/)
* [GLEW (1.6 ->)](http://glew.sourceforge.net/)
-* [Eigen2 (2.0.13->)](http://eigen.tuxfamily.org/)
+* [Eigen (2.0.13->3.1.1)](http://eigen.tuxfamily.org/)
* [GCC C++ Compiler (4.2 ->)](http://gcc.gnu.org/)
* [Bison (2.4)](http://www.gnu.org/software/bison/)
* [Flex (2.5.35)](http://flex.sourceforge.net/)
View
@@ -9,5 +9,5 @@ include(bison.pri)
include(cgal.pri)
include(opencsg.pri)
include(glew.pri)
-include(eigen2.pri)
+include(eigen.pri)
include(boost.pri)
View
@@ -85,15 +85,15 @@ Some versions of Xvfb may fail, however.
1. Trouble finding libraries on unix
- To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use
+ To help CMAKE find eigen, OpenCSG, CGAL, Boost, and GLEW, you can use
environment variables, just like for the main qmake & openscad.pro. Examples:
OPENSCAD_LIBRARIES=$HOME cmake .
CGALDIR=$HOME/CGAL-3.9 BOOSTDIR=$HOME/boost-1.47.0 cmake .
Valid variables are as follows:
- BOOSTDIR, CGALDIR, EIGEN2DIR, GLEWDIR, OPENCSGDIR, OPENSCAD_LIBRARIES
+ BOOSTDIR, CGALDIR, EIGENDIR, GLEWDIR, OPENCSGDIR, OPENSCAD_LIBRARIES
When running, this might help find your locally built libraries (assuming
you installed into $HOME)
View
@@ -0,0 +1,72 @@
+# Detect eigen3 + eigen2, then use this priority list to determine
+# which eigen to use:
+#
+# Priority
+# 0. EIGENDIR if set (also EIGEN2DIR for backwards compatability)
+# 1. OPENSCAD_LIBRARIES eigen3
+# 2. OPENSCAD_LIBRARIES eigen2
+# 3. system's standard include paths for eigen3
+# 4. system's standard include paths for eigen2
+
+eigen {
+
+# read environment variables
+OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
+EIGEN2_DIR = $$(EIGEN2DIR)
+EIGEN_DIR = $$(EIGENDIR)
+
+CONFIG(mingw-cross-env) {
+ EIGEN_INCLUDEPATH = mingw-cross-env/include/eigen2
+}
+
+# Optionally specify location of Eigen3 using the
+# OPENSCAD_LIBRARIES env. variable
+!isEmpty(OPENSCAD_LIBRARIES_DIR) {
+ isEmpty(EIGEN_INCLUDEPATH) {
+ exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) {
+ EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3
+ }
+ }
+ isEmpty(EIGEN_INCLUDEPATH) {
+ exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) {
+ EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2
+ }
+ }
+}
+
+
+# Optionally specify location of Eigen using the
+# EIGENDIR env. variable (EIGEN2 for backwards compatability)
+!isEmpty(EIGEN2_DIR) {
+ EIGEN_INCLUDEPATH = $$EIGEN2_DIR
+ message("User set EIGEN location: $$EIGEN_INCLUDEPATH")
+}
+!isEmpty(EIGEN_DIR) {
+ EIGEN_INCLUDEPATH = $$EIGEN_DIR
+ message("User set EIGEN location: $$EIGEN_INCLUDEPATH")
+}
+
+isEmpty(EIGEN_INCLUDEPATH) {
+ freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen3
+ macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3
+ linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen3
+ netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3
+ !exists($$EIGEN_INCLUDEPATH) {
+ freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2
+ macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2
+ linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen2
+ netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2
+ }
+}
+
+# disable Eigen SIMD optimizations for platforms where it breaks compilation
+!macx {
+ !freebsd-g++ {
+ QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
+ }
+}
+
+# EIGEN being under 'include/eigen[2-3]' needs special prepending
+QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT
+
+} # eigen
View
@@ -1,44 +0,0 @@
-eigen2 {
-
- CONFIG(mingw-cross-env) {
- EIGEN2_INCLUDEPATH = mingw-cross-env/include/eigen2
- }
-
- # Optionally specify location of Eigen2 using the
- # OPENSCAD_LIBRARIES env. variable
- isEmpty(EIGEN2_INCLUDEPATH) {
- OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
- !isEmpty(OPENSCAD_LIBRARIES_DIR) {
- exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) {
- EIGEN2_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2
- }
- }
- }
-
- # Optionally specify location of Eigen2 using the
- # EIGEN2DIR env. variable
- isEmpty(EIGEN2_INCLUDEPATH) {
- EIGEN2_DIR = $$(EIGEN2DIR)
- !isEmpty(EIGEN2_DIR) {
- EIGEN2_INCLUDEPATH = $$EIGEN2_DIR
- message("EIGEN2 location: $$EIGEN2_INCLUDEPATH")
- }
- }
-
- isEmpty(EIGEN2_INCLUDEPATH) {
- freebsd-g++: EIGEN2_INCLUDEPATH = /usr/local/include/eigen2
- macx: EIGEN2_INCLUDEPATH = /opt/local/include/eigen2
- linux*|hurd*: EIGEN2_INCLUDEPATH = /usr/include/eigen2
- netbsd*: EIGEN2_INCLUDEPATH = /usr/pkg/include/eigen2
- }
-
- # eigen2 being under 'include/eigen2' needs special prepending
- QMAKE_INCDIR_QT = $$EIGEN2_INCLUDEPATH $$QMAKE_INCDIR_QT
-
- # disable Eigen SIMD optimizations for platforms where it breaks compilation
- !macx {
- !freebsd-g++ {
- QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
- }
- }
-}
View
@@ -3,7 +3,7 @@
# MPFRDIR
# BOOSTDIR
# CGALDIR
-# EIGEN2DIR
+# EIGENDIR
# GLEWDIR
# OPENCSGDIR
# OPENSCAD_LIBRARIES
@@ -123,7 +123,7 @@ macx:CONFIG += mdi
CONFIG += cgal
CONFIG += opencsg
CONFIG += boost
-CONFIG += eigen2
+CONFIG += eigen
#Uncomment the following line to enable QCodeEdit
#CONFIG += qcodeedit
@@ -124,7 +124,7 @@ build_boost()
# We only need certain portions of boost
./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex
if [ $CXX ]; then
- if [ $CXX = "clang" ]; then
+ if [ $CXX = "clang++" ]; then
./b2 -j$NUMCPU toolset=clang install
# ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install
fi
@@ -246,17 +246,24 @@ build_eigen()
echo "Building eigen" $version "..."
cd $BASEDIR/src
rm -rf eigen-$version
- ## Directory name for v2.0.17
- rm -rf eigen-eigen-b23437e61a07
+ EIGENDIR="none"
+ if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi
+ if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi
+ if [ $EIGENDIR = "none" ]; then
+ echo Unknown eigen version. Please edit script.
+ exit 1
+ fi
+ rm -rf ./$EIGENDIR
if [ ! -f eigen-$version.tar.bz2 ]; then
curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2
mv $version.tar.bz2 eigen-$version.tar.bz2
fi
tar xjf eigen-$version.tar.bz2
- ## File name for v2.0.17
- ln -s eigen-eigen-b23437e61a07 eigen-$version
+ ln -s ./$EIGENDIR eigen-$version
cd eigen-$version
- cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR
+ mkdir build
+ cd build
+ cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR ..
make -j$NUMCPU
make install
}
@@ -320,7 +327,7 @@ fi
# edit version numbers here as needed.
#
-build_eigen 2.0.17
+build_eigen 3.1.1
build_gmp 5.0.5
build_mpfr 3.1.1
build_boost 1.47.0
@@ -174,9 +174,9 @@ build_boost()
echo "Building boost" $version "..."
cd $BASEDIR/src
rm -rf boost_$bversion
- if [ ! -f boost_$bversion.tar.bz2 ]; then
- curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2
- fi
+# if [ ! -f boost_$bversion.tar.bz2 ]; then
+# curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2
+# fi
tar xjf boost_$bversion.tar.bz2
cd boost_$bversion
# We only need the thread and program_options libraries
@@ -271,20 +271,29 @@ build_eigen()
echo "Building eigen" $version "..."
cd $BASEDIR/src
rm -rf eigen-$version
- ## Directory name for v2.0.17
- rm -rf eigen-eigen-b23437e61a07
+
+ EIGENDIR="none"
+ if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi
+ if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi
+ if [ $EIGENDIR = "none" ]; then
+ echo Unknown eigen version. Please edit script.
+ exit 1
+ fi
+ rm -rf ./$EIGENDIR
+
if [ ! -f eigen-$version.tar.bz2 ]; then
curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2
mv $version.tar.bz2 eigen-$version.tar.bz2
fi
tar xjf eigen-$version.tar.bz2
- ## File name for v2.0.17
- ln -s eigen-eigen-b23437e61a07 eigen-$version
+ ln -s ./$EIGENDIR eigen-$version
cd eigen-$version
+ mkdir build
+ cd build
if $OPTION_32BIT; then
EIGEN_EXTRA_FLAGS=";i386"
fi
- cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DEIGEN_BUILD_LIB=ON -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$EIGEN_EXTRA_FLAGS"
+ cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR -DEIGEN_BUILD_LIB=ON -DBUILD_SHARED_LIBS=FALSE -DCMAKE_OSX_DEPLOYMENT_TARGET="$MAC_OSX_VERSION_MIN" -DCMAKE_OSX_ARCHITECTURES="x86_64$EIGEN_EXTRA_FLAGS" ..
make -j4
make install
}
@@ -325,7 +334,7 @@ fi
echo "Using basedir:" $BASEDIR
mkdir -p $SRCDIR $DEPLOYDIR
-build_eigen 2.0.17
+build_eigen 3.1.1
build_gmp 5.0.5
build_mpfr 3.1.0
build_boost 1.47.0
View
@@ -66,16 +66,29 @@ shared_ptr<CSGTerm> CSGTerm::createCSGTerm(type_e type, shared_ptr<CSGTerm> left
// http://www.cc.gatech.edu/~turk/my_papers/pxpl_csg.pdf
const BoundingBox &leftbox = left->getBoundingBox();
const BoundingBox &rightbox = right->getBoundingBox();
+ Vector3d newmin, newmax;
if (type == TYPE_INTERSECTION) {
- BoundingBox newbox(leftbox.min().cwise().max(rightbox.min()),
- leftbox.max().cwise().min(rightbox.max()));
+#if EIGEN_WORLD_VERSION == 2
+ newmin = leftbox.min().cwise().max( rightbox.min() );
+ newmax = leftbox.max().cwise().min( rightbox.max() );
+#else
+ newmin = leftbox.min().array().cwiseMax( rightbox.min().array() );
+ newmax = leftbox.max().array().cwiseMin( rightbox.max().array() );
+#endif
+ BoundingBox newbox( newmin, newmax );
if (newbox.isNull()) {
return shared_ptr<CSGTerm>(); // Prune entire product
}
}
else if (type == TYPE_DIFFERENCE) {
- BoundingBox newbox(leftbox.min().cwise().max(rightbox.min()),
- leftbox.max().cwise().min(rightbox.max()));
+#if EIGEN_WORLD_VERSION == 2
+ newmin = leftbox.min().cwise().max( rightbox.min() );
+ newmax = leftbox.max().cwise().min( rightbox.max() );
+#else
+ newmin = leftbox.min().array().cwiseMax( rightbox.min().array() );
+ newmax = leftbox.max().array().cwiseMin( rightbox.max().array() );
+#endif
+ BoundingBox newbox( newmin, newmax );
if (newbox.isNull()) {
return left; // Prune the negative component
}
@@ -119,14 +132,27 @@ void CSGTerm::initBoundingBox()
else {
const BoundingBox &leftbox = this->left->getBoundingBox();
const BoundingBox &rightbox = this->right->getBoundingBox();
+ Vector3d newmin, newmax;
switch (this->type) {
case TYPE_UNION:
- this->bbox = this->m * BoundingBox(leftbox.min().cwise().min(rightbox.min()),
- leftbox.max().cwise().max(rightbox.max()));
+#if EIGEN_WORLD_VERSION == 2
+ newmin = leftbox.min().cwise().min( rightbox.min() );
+ newmax = leftbox.max().cwise().max( rightbox.max() );
+#else
+ newmin = leftbox.min().array().cwiseMin( rightbox.min().array() );
+ newmax = leftbox.max().array().cwiseMax( rightbox.max().array() );
+#endif
+ this->bbox = this->m * BoundingBox( newmin, newmax );
break;
case TYPE_INTERSECTION:
- this->bbox = this->m * BoundingBox(leftbox.min().cwise().max(rightbox.min()),
- leftbox.max().cwise().min(rightbox.max()));
+#if EIGEN_WORLD_VERSION == 2
+ newmin = leftbox.min().cwise().max( rightbox.min() );
+ newmax = leftbox.max().cwise().min( rightbox.max() );
+#else
+ newmin = leftbox.min().array().cwiseMax( rightbox.min().array() );
+ newmax = leftbox.max().array().cwiseMin( rightbox.max().array() );
+#endif
+ this->bbox = this->m * BoundingBox( newmin, newmax );
break;
case TYPE_DIFFERENCE:
this->bbox = this->m * leftbox;
View
@@ -36,10 +36,9 @@
#include <sstream>
#include <boost/filesystem.hpp>
-using namespace boost::filesystem;
-
boost::unordered_map<std::string,Value> dxf_dim_cache;
boost::unordered_map<std::string,Value> dxf_cross_cache;
+namespace fs = boost::filesystem;
Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnames, const std::vector<Value> &args)
{
@@ -65,8 +64,8 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam
std::stringstream keystream;
keystream << filename << "|" << layername << "|" << name << "|" << xorigin
- << "|" << yorigin <<"|" << scale << "|" << last_write_time(filename)
- << "|" << file_size(filename);
+ << "|" << yorigin <<"|" << scale << "|" << fs::last_write_time(filename)
+ << "|" << fs::file_size(filename);
std::string key = keystream.str();
if (dxf_dim_cache.find(key) != dxf_dim_cache.end())
return dxf_dim_cache.find(key)->second;
@@ -147,8 +146,8 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector<std::string> &argn
std::stringstream keystream;
keystream << filename << "|" << layername << "|" << xorigin << "|" << yorigin
- << "|" << scale << "|" << last_write_time(filename)
- << "|" << file_size(filename);
+ << "|" << scale << "|" << fs::last_write_time(filename)
+ << "|" << fs::file_size(filename);
std::string key = keystream.str();
if (dxf_cross_cache.find(key) != dxf_cross_cache.end())
Oops, something went wrong.