Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Eigen3 #183

Closed
wants to merge 45 commits into from

2 participants

@donbright
Collaborator

This allows OpenSCAD to build against Eigen3 or Eigen2, whichever is available.

The point is to maybe have a way to build with clang on Mac OSX (see issue #174)

  1. EIGEN2DIR environment variable has been replaced with EIGENDIR (although EIGEN2DIR is still read, for backwards compatability with any old scripts/websites)
  2. #ifdefs detect which eigen version and use appropriate code
  3. eigen::Transform3d -> eigen::Affine3d
  4. "Using namespace boost::filesystem" appears to conflict with eigen3 in some cases. Switched to using 'namespace fs = boost::filesystem' and prepending fs:: to all relevant functions.
  5. cwise() moved to array()
  6. qmake and cmake build rewritten to detect both eigen3 / eigen2
  7. dependency scripts rewritten to favor eigen3, but also allow eigen2 if needed.

see also http://eigen.tuxfamily.org/dox/Eigen2ToEigen3.html

tests pass with %100 on gcc 4.6 / linux 64bit / software renderer
1 test fails under clang / linux 32 bit, but im not sure if its related to eigen3 directly (see issue #182 )

kintel and others added some commits
@kintel kintel Enable running the test in a non-accelerated environment 2f446ce
@kintel kintel No need to link OpenCSG with Qt f7a6742
@kintel kintel Goldfeather fix for Mac OS X Lion, also for tests fa7dfe2
@kintel kintel Support for building under Lion a8f5a8f
@kintel kintel Force gcc under Lion fa872b9
@kintel kintel Merge branch 'value' into lion 4a16b03
@kintel kintel Support building using the LLVM compiler also on Snow Leopard, for te…
…sting
6efd183
@kintel kintel Support building using the LLVM compiler also on Snow Leopard, for te…
…sting
3a0cb88
@kintel kintel Merged with master dfa7d80
@kintel kintel Merge branch 'master' into lion
Conflicts:
	README.md
	scripts/macosx-build-dependencies.sh
	src/linearextrude.cc
	src/parsersettings.cc
ebc382d
@kintel kintel Merge branch 'master' into lion
Conflicts:
	README.md
	src/linearextrude.cc
	src/parsersettings.cc
	src/value.cc
7375d72
@kintel kintel fixed conflict ff10729
@kintel kintel Upgraded CGAL to 4.0.2 8fbda9b
@kintel kintel Updated Macports dependencies bbb0538
@kintel kintel Merge branch 'master' into lion 548a568
@kintel kintel Merge remote-tracking branch 'origin/issue148' into lion 1026be9
@kintel kintel Merge branch 'master' into lion
Conflicts:
	src/dxfdata.cc
43acfe5
@kintel kintel Merge branch 'master' into lion 6960d58
@kintel kintel Merge branch 'master' into lion 2291995
@kintel kintel Merge branch 'master' into lion f07e298
@kintel kintel Merge branch 'master' into lion e059146
@kintel kintel Merge branch 'master' into lion f3dcc20
@kintel kintel Merge branch 'master' into lion 11ffcd2
@donbright donbright initial rework to enable eigen3 per issue #174.
1. enable eigen3 in qmake build system
2. convert Transform3d and cwise() per the eigen2->eigen3 porting faq online
3. get rid of 'using namespace boost::filesystem' as it conflicts with eigen3
9f6819e
@donbright donbright more eigen3 fixes.
1. finish converting 'using namespace boost::filsystem' to 'namespace fs = boost::filesystem'.

2. initial version of changes to CMakelists.txt for the regression test
10c7607
@donbright donbright modify build system to auto-detect eigen3, and fallback to eigen2 c4d6858
@donbright donbright alter Mac OSX dependencies build script to get eigen version 3.1.1
This still allows the building of eigen, 2.0.17 just change the version
number at the bottom of the file.

Eigen3 requires an 'out of source' build.
1e0ce9e
@donbright donbright restore commented-out build commands 526ed73
@donbright donbright fix bug in build script for boost e7ebf47
@donbright donbright update eigen version in README. dont use alignment in dxfdata vector. 7a2f91e
@donbright donbright make EIGEN_DONT_ALIGN flag work. also remove warnings when using clang. aa2c67d
@donbright donbright debugging failed test: throwntogethertest polygons d656f55
@donbright donbright more debug 8f17a48
@donbright donbright Revert "more debug"
This reverts commit 8f17a48.
4ef470b
@donbright donbright Revert "Revert "more debug""
This reverts commit 4ef470b.
94de600
@donbright donbright Revert "Revert "Revert "more debug"""
This reverts commit 94de600.
5bba950
@donbright donbright cleaning up for pull request 17e9fe2
@donbright donbright Merge branch 'master' of github.com:openscad/openscad into eigen3 ca03eec
@donbright donbright cleanup for pull request 702525f
@donbright donbright rewrite Eigen detection in CMakelists. cleanup files for pull request. a904531
@donbright donbright look for EIGENDIR env var. (also look for EIGEN2DIR for backwards com…
…patability)
5d31f56
@donbright donbright fix small bugs in eigen build scripts fc945bf
@donbright donbright cleanup 765f1a9
@donbright donbright commented on the diff
tests/CMakeLists.txt
@@ -157,7 +168,8 @@ endif()
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
-# Eigen2
+
+# Eigen
@donbright Collaborator

it would be possible to just set all the 'HINTS' and do one 'find_path' but i have seen find_path be very buggy in various situations and perferred to keep the calls to find_path extremely simple and straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@donbright
Collaborator

can confirm this has nothing to do with eigen3, because it happens also on eigen2 (boost 1.50 linux 64 bit, gcc 4.6 compiler)

@kintel
Owner

I'm doing some tests under Mac OS X Lion, so I'm pushing a few related changes to this branch..

@kintel kintel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 27, 2012
  1. @kintel
  2. @kintel

    No need to link OpenCSG with Qt

    kintel authored
  3. @kintel
  4. @kintel

    Support for building under Lion

    kintel authored
  5. @kintel

    Force gcc under Lion

    kintel authored
  6. @kintel

    Merge branch 'value' into lion

    kintel authored
Commits on May 28, 2012
  1. @kintel
  2. @kintel
Commits on Jul 4, 2012
  1. @kintel

    Merged with master

    kintel authored
Commits on Jul 9, 2012
  1. @kintel

    Merge branch 'master' into lion

    kintel authored
    Conflicts:
    	README.md
    	scripts/macosx-build-dependencies.sh
    	src/linearextrude.cc
    	src/parsersettings.cc
Commits on Jul 17, 2012
  1. @kintel

    Merge branch 'master' into lion

    kintel authored
    Conflicts:
    	README.md
    	src/linearextrude.cc
    	src/parsersettings.cc
    	src/value.cc
  2. @kintel

    fixed conflict

    kintel authored
Commits on Jul 26, 2012
  1. @kintel

    Upgraded CGAL to 4.0.2

    kintel authored
  2. @kintel

    Updated Macports dependencies

    kintel authored
  3. @kintel

    Merge branch 'master' into lion

    kintel authored
  4. @kintel
  5. @kintel

    Merge branch 'master' into lion

    kintel authored
    Conflicts:
    	src/dxfdata.cc
Commits on Jul 29, 2012
  1. @kintel

    Merge branch 'master' into lion

    kintel authored
Commits on Aug 2, 2012
  1. @kintel
  2. @kintel
Commits on Aug 16, 2012
  1. @kintel

    Merge branch 'master' into lion

    kintel authored
Commits on Aug 18, 2012
  1. @kintel

    Merge branch 'master' into lion

    kintel authored
  2. @kintel

    Merge branch 'master' into lion

    kintel authored
  3. @donbright

    initial rework to enable eigen3 per issue #174.

    donbright authored
    1. enable eigen3 in qmake build system
    2. convert Transform3d and cwise() per the eigen2->eigen3 porting faq online
    3. get rid of 'using namespace boost::filesystem' as it conflicts with eigen3
  4. @donbright

    more eigen3 fixes.

    donbright authored
    1. finish converting 'using namespace boost::filsystem' to 'namespace fs = boost::filesystem'.
    
    2. initial version of changes to CMakelists.txt for the regression test
  5. @donbright
  6. @donbright

    alter Mac OSX dependencies build script to get eigen version 3.1.1

    donbright authored
    This still allows the building of eigen, 2.0.17 just change the version
    number at the bottom of the file.
    
    Eigen3 requires an 'out of source' build.
  7. @donbright
  8. @donbright
Commits on Aug 19, 2012
  1. @donbright
  2. @donbright
  3. @donbright
  4. @donbright

    more debug

    donbright authored
  5. @donbright

    Revert "more debug"

    donbright authored
    This reverts commit 8f17a48.
  6. @donbright

    Revert "Revert "more debug""

    donbright authored
    This reverts commit 4ef470b.
  7. @donbright

    Revert "Revert "Revert "more debug"""

    donbright authored
    This reverts commit 94de600.
  8. @donbright

    cleaning up for pull request

    donbright authored
  9. @donbright
  10. @donbright

    cleanup for pull request

    donbright authored
  11. @donbright
  12. @donbright
  13. @donbright
  14. @donbright

    cleanup

    donbright authored
Commits on Aug 20, 2012
  1. @kintel

    Merge branch 'lion' into eigen3

    kintel authored
  2. @kintel
This page is out of date. Refresh to see the latest.
View
2  README.md
@@ -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
2  common.pri
@@ -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
4 doc/testing.txt
@@ -85,7 +85,7 @@ 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 .
@@ -93,7 +93,7 @@ Some versions of Xvfb may fail, however.
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
72 eigen.pri
@@ -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
44 eigen2.pri
@@ -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
4 openscad.pro
@@ -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
View
21 scripts/linux-build-dependencies.sh
@@ -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
View
27 scripts/macosx-build-dependencies.sh
@@ -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
42 src/csgterm.cc
@@ -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
11 src/dxfdim.cc
@@ -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())
View
8 src/handle_dep.cc
@@ -6,7 +6,7 @@
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <boost/filesystem.hpp>
-using namespace boost::filesystem;
+namespace fs = boost::filesystem;
#include "boosty.h"
boost::unordered_set<std::string> dependencies;
@@ -14,14 +14,14 @@ const char *make_command = NULL;
void handle_dep(const std::string &filename)
{
- path filepath(filename);
+ fs::path filepath(filename);
if ( boosty::is_absolute( filepath )) {
dependencies.insert(filename);
}
else {
- dependencies.insert((current_path() / filepath).string());
+ dependencies.insert((fs::current_path() / filepath).string());
}
- if (!exists(filepath) && make_command) {
+ if (!fs::exists(filepath) && make_command) {
std::stringstream buf;
buf << make_command << " '" << boost::regex_replace(filename, boost::regex("'"), "'\\''") << "'";
system(buf.str().c_str()); // FIXME: Handle error
View
4 src/import.cc
@@ -47,7 +47,7 @@
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
-using namespace boost::filesystem;
+namespace fs = boost::filesystem;
#include <boost/assign/std/vector.hpp>
using namespace boost::assign; // bring 'operator+=()' into scope
#include "boosty.h"
@@ -80,7 +80,7 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati
std::string filename = c.getAbsolutePath(v.isUndefined() ? "" : v.toString());
import_type_e actualtype = this->type;
if (actualtype == TYPE_UNKNOWN) {
- std::string extraw = boosty::extension_str( path(filename) );
+ std::string extraw = boosty::extension_str( fs::path(filename) );
std::string ext = boost::algorithm::to_lower_copy( extraw );
if (ext == ".stl") actualtype = TYPE_STL;
else if (ext == ".off") actualtype = TYPE_OFF;
View
4 src/linalg.h
@@ -12,7 +12,11 @@ typedef Eigen::AlignedBox<double, 3> BoundingBox;
using Eigen::Matrix3f;
using Eigen::Matrix3d;
using Eigen::Matrix4d;
+#if EIGEN_WORLD_VERSION >= 3
+#define Transform3d Eigen::Affine3d
+#else
using Eigen::Transform3d;
+#endif
BoundingBox operator*(const Transform3d &m, const BoundingBox &box);
View
81 tests/CMakeLists.txt
@@ -86,6 +86,17 @@ if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -frounding-math")
endif()
+# Clang compiler
+
+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")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-extensions")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
+endif()
+
#
# Build test apps
#
@@ -176,7 +187,8 @@ endif()
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
-# Eigen2
+
+# Eigen
@donbright Collaborator

it would be possible to just set all the 'HINTS' and do one 'find_path' but i have seen find_path be very buggy in various situations and perferred to keep the calls to find_path extremely simple and straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
# Turn off Eigen SIMD optimization
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -185,34 +197,63 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()
endif()
-if (NOT $ENV{EIGEN2DIR} STREQUAL "")
- set(EIGEN2_DIR "$ENV{EIGEN2DIR}")
-elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
- set(EIGEN2_DIR "$ENV{OPENSCAD_LIBRARIES}")
+# Priority
+# 3. EIGENDIR if set (EIGEN2DIR for backwards compatability)
+# 1. OPENSCAD_LIBRARIES eigen3
+# 2. OPENSCAD_LIBRARIES eigen2
+# 4. system's standard include paths for eigen3
+# 5. system's standard include paths for eigen2
+
+set(EIGEN2_DIR "$ENV{EIGEN2DIR}")
+set(EIGEN_DIR "$ENV{EIGENDIR}")
+set(OPENSCAD_LIBDIR "$ENV{OPENSCAD_LIBRARIES}")
+
+if (EIGEN_DIR)
+ set(EIGHINT ${EIGEN_DIR}/include/eigen3 ${EIGEN_DIR}/include/eigen2 ${EIGEN_DIR})
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${EIGHINT})
+endif()
+if (EIGEN2_DIR)
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${EIGEN2_DIR}/include/eigen2 ${EIGEN2_DIR})
endif()
-if (NOT EIGEN2_INCLUDE_DIR)
- if (EIGEN2_DIR)
- set(EIGEN2_FIND_HINTS "${EIGEN2_DIR}/include/eigen2")
- endif()
+if (NOT EIGEN_INCLUDE_DIR)
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${OPENSCAD_LIBDIR}/include/eigen3)
+endif()
+if (NOT EIGEN_INCLUDE_DIR)
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${OPENSCAD_LIBDIR}/include/eigen2)
+endif()
+
+if (NOT EIGEN_INCLUDE_DIR)
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
- set(EIGEN2_FIND_PATHS /usr/local/include/eigen2)
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/local/include/eigen3)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
- set(EIGEN2_FIND_PATHS /usr/pkg/include/eigen2)
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/pkg/include/eigen3)
+ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /opt/local/include/eigen3)
else()
- set(EIGEN2_FIND_PATHS /opt/local/include/eigen2 /usr/include/eigen2)
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/include/eigen3)
endif()
- find_path(EIGEN2_INCLUDE_DIR
- Eigen/Core
- HINTS ${EIGEN2_FIND_HINTS}
- PATHS ${EIGEN2_FIND_PATHS})
- if (NOT EIGEN2_INCLUDE_DIR)
- message(FATAL_ERROR "Eigen2 not found")
+endif()
+
+if (NOT EIGEN_INCLUDE_DIR)
+ if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/local/include/eigen2)
+ elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/pkg/include/eigen2)
+ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /opt/local/include/eigen2)
else()
- message(STATUS "Eigen2 found in " ${EIGEN2_INCLUDE_DIR})
+ find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/include/eigen2)
endif()
endif()
-inclusion(EIGEN2_DIR EIGEN2_INCLUDE_DIR)
+
+if (NOT EIGEN_INCLUDE_DIR)
+ message(STATUS "Eigen not found")
+else()
+ message(STATUS "Eigen found in " ${EIGEN_INCLUDE_DIR})
+ inclusion(EIGEN_DIR EIGEN_INCLUDE_DIR)
+endif()
+
# OpenCSG
if (NOT $ENV{OPENCSGDIR} STREQUAL "")
View
2  tests/csgtestcore.cc
@@ -367,6 +367,8 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
OpenCSG::setContext(0);
OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
+ // FIXME: This is necessary for Mac OS X 10.7 for now. kintel 20120527.
+ OpenCSG::setOption(OpenCSG::AlgorithmSetting, OpenCSG::Goldfeather);
csgInfo.glview->paintGL();
Something went wrong with that request. Please try again.