Skip to content
This repository

Eigen3 #183

Closed
wants to merge 45 commits into from

2 participants

donbright Marius Kintel
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 )

and others added some commits May 27, 2012
Marius Kintel Enable running the test in a non-accelerated environment 2f446ce
Marius Kintel No need to link OpenCSG with Qt f7a6742
Marius Kintel Goldfeather fix for Mac OS X Lion, also for tests fa7dfe2
Marius Kintel Support for building under Lion a8f5a8f
Marius Kintel Force gcc under Lion fa872b9
Marius Kintel Merge branch 'value' into lion 4a16b03
Marius Kintel Support building using the LLVM compiler also on Snow Leopard, for te…
…sting
6efd183
Marius Kintel Support building using the LLVM compiler also on Snow Leopard, for te…
…sting
3a0cb88
Marius Kintel Merged with master dfa7d80
Marius Kintel Merge branch 'master' into lion
Conflicts:
	README.md
	scripts/macosx-build-dependencies.sh
	src/linearextrude.cc
	src/parsersettings.cc
ebc382d
Marius Kintel Merge branch 'master' into lion
Conflicts:
	README.md
	src/linearextrude.cc
	src/parsersettings.cc
	src/value.cc
7375d72
Marius Kintel fixed conflict ff10729
Marius Kintel Upgraded CGAL to 4.0.2 8fbda9b
Marius Kintel Updated Macports dependencies bbb0538
Marius Kintel Merge branch 'master' into lion 548a568
Marius Kintel Merge remote-tracking branch 'origin/issue148' into lion 1026be9
Marius Kintel Merge branch 'master' into lion
Conflicts:
	src/dxfdata.cc
43acfe5
Marius Kintel Merge branch 'master' into lion 6960d58
Marius Kintel Merge branch 'master' into lion 2291995
Marius Kintel Merge branch 'master' into lion f07e298
Marius Kintel Merge branch 'master' into lion e059146
Marius Kintel Merge branch 'master' into lion f3dcc20
Marius Kintel Merge branch 'master' into lion 11ffcd2
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 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 modify build system to auto-detect eigen3, and fallback to eigen2 c4d6858
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 restore commented-out build commands 526ed73
donbright fix bug in build script for boost e7ebf47
donbright update eigen version in README. dont use alignment in dxfdata vector. 7a2f91e
donbright make EIGEN_DONT_ALIGN flag work. also remove warnings when using clang. aa2c67d
donbright debugging failed test: throwntogethertest polygons d656f55
donbright more debug 8f17a48
donbright Revert "more debug"
This reverts commit 8f17a48.
4ef470b
donbright Revert "Revert "more debug""
This reverts commit 4ef470b.
94de600
donbright Revert "Revert "Revert "more debug"""
This reverts commit 94de600.
5bba950
donbright cleaning up for pull request 17e9fe2
donbright Merge branch 'master' of github.com:openscad/openscad into eigen3 ca03eec
donbright cleanup for pull request 702525f
donbright rewrite Eigen detection in CMakelists. cleanup files for pull request. a904531
donbright look for EIGENDIR env var. (also look for EIGEN2DIR for backwards com…
…patability)
5d31f56
donbright fix small bugs in eigen build scripts fc945bf
donbright cleanup 765f1a9
donbright donbright commented on the diff August 19, 2012
tests/CMakeLists.txt
@@ -157,7 +168,8 @@ endif()
157 168
 
158 169
 set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
159 170
 
160  
-# Eigen2
  171
+
  172
+# Eigen
1
donbright Collaborator
donbright added a note August 19, 2012

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)

Marius Kintel
Owner

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

Marius Kintel kintel closed this August 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 45 unique commits by 2 authors.

May 27, 2012
Marius Kintel Enable running the test in a non-accelerated environment 2f446ce
Marius Kintel No need to link OpenCSG with Qt f7a6742
Marius Kintel Goldfeather fix for Mac OS X Lion, also for tests fa7dfe2
Marius Kintel Support for building under Lion a8f5a8f
Marius Kintel Force gcc under Lion fa872b9
May 28, 2012
Marius Kintel Merge branch 'value' into lion 4a16b03
Marius Kintel Support building using the LLVM compiler also on Snow Leopard, for te…
…sting
6efd183
Marius Kintel Support building using the LLVM compiler also on Snow Leopard, for te…
…sting
3a0cb88
Jul 04, 2012
Marius Kintel Merged with master dfa7d80
Jul 09, 2012
Marius Kintel Merge branch 'master' into lion
Conflicts:
	README.md
	scripts/macosx-build-dependencies.sh
	src/linearextrude.cc
	src/parsersettings.cc
ebc382d
Jul 16, 2012
Marius Kintel Merge branch 'master' into lion
Conflicts:
	README.md
	src/linearextrude.cc
	src/parsersettings.cc
	src/value.cc
7375d72
Marius Kintel fixed conflict ff10729
Jul 25, 2012
Marius Kintel Upgraded CGAL to 4.0.2 8fbda9b
Marius Kintel Updated Macports dependencies bbb0538
Marius Kintel Merge branch 'master' into lion 548a568
Marius Kintel Merge remote-tracking branch 'origin/issue148' into lion 1026be9
Jul 26, 2012
Marius Kintel Merge branch 'master' into lion
Conflicts:
	src/dxfdata.cc
43acfe5
Jul 29, 2012
Marius Kintel Merge branch 'master' into lion 6960d58
Aug 01, 2012
Marius Kintel Merge branch 'master' into lion 2291995
Marius Kintel Merge branch 'master' into lion f07e298
Aug 16, 2012
Marius Kintel Merge branch 'master' into lion e059146
Aug 18, 2012
Marius Kintel Merge branch 'master' into lion f3dcc20
Marius Kintel Merge branch 'master' into lion 11ffcd2
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 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 restore commented-out build commands 526ed73
donbright fix bug in build script for boost e7ebf47
donbright update eigen version in README. dont use alignment in dxfdata vector. 7a2f91e
donbright make EIGEN_DONT_ALIGN flag work. also remove warnings when using clang. aa2c67d
donbright debugging failed test: throwntogethertest polygons d656f55
donbright more debug 8f17a48
Aug 19, 2012
donbright modify build system to auto-detect eigen3, and fallback to eigen2 c4d6858
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 Revert "more debug"
This reverts commit 8f17a48.
4ef470b
donbright Revert "Revert "more debug""
This reverts commit 4ef470b.
94de600
donbright Revert "Revert "Revert "more debug"""
This reverts commit 94de600.
5bba950
donbright cleaning up for pull request 17e9fe2
donbright Merge branch 'master' of github.com:openscad/openscad into eigen3 ca03eec
donbright cleanup for pull request 702525f
donbright rewrite Eigen detection in CMakelists. cleanup files for pull request. a904531
donbright look for EIGENDIR env var. (also look for EIGEN2DIR for backwards com…
…patability)
5d31f56
donbright fix small bugs in eigen build scripts fc945bf
donbright cleanup 765f1a9
Aug 20, 2012
Marius Kintel Merge branch 'lion' into eigen3 b0543f4
Marius Kintel Merge branch 'master' into eigen3 f92463a
This page is out of date. Refresh to see the latest.
2  README.md
Source Rendered
@@ -92,7 +92,7 @@ Follow the instructions for the platform you're compiling on below.
92 92
  * [boost (1.35 - 1.47)](http://www.boost.org/)
93 93
 * [OpenCSG (1.3.2)](http://www.opencsg.org/)
94 94
 * [GLEW (1.6 ->)](http://glew.sourceforge.net/)
95  
-* [Eigen2 (2.0.13->)](http://eigen.tuxfamily.org/)
  95
+* [Eigen (2.0.13->3.1.1)](http://eigen.tuxfamily.org/)
96 96
 * [GCC C++ Compiler (4.2 ->)](http://gcc.gnu.org/)
97 97
 * [Bison (2.4)](http://www.gnu.org/software/bison/)
98 98
 * [Flex (2.5.35)](http://flex.sourceforge.net/)
2  common.pri
@@ -9,5 +9,5 @@ include(bison.pri)
9 9
 include(cgal.pri)
10 10
 include(opencsg.pri)
11 11
 include(glew.pri)
12  
-include(eigen2.pri)
  12
+include(eigen.pri)
13 13
 include(boost.pri)
4  doc/testing.txt
@@ -85,7 +85,7 @@ Some versions of Xvfb may fail, however.
85 85
 
86 86
 1. Trouble finding libraries on unix
87 87
 
88  
- To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use 
  88
+ To help CMAKE find eigen, OpenCSG, CGAL, Boost, and GLEW, you can use 
89 89
  environment variables, just like for the main qmake & openscad.pro. Examples:
90 90
 
91 91
  OPENSCAD_LIBRARIES=$HOME cmake .
@@ -93,7 +93,7 @@ Some versions of Xvfb may fail, however.
93 93
  
94 94
  Valid variables are as follows:
95 95
 
96  
- BOOSTDIR, CGALDIR, EIGEN2DIR, GLEWDIR, OPENCSGDIR, OPENSCAD_LIBRARIES
  96
+ BOOSTDIR, CGALDIR, EIGENDIR, GLEWDIR, OPENCSGDIR, OPENSCAD_LIBRARIES
97 97
 
98 98
  When running, this might help find your locally built libraries (assuming
99 99
  you installed into $HOME)
72  eigen.pri
... ...
@@ -0,0 +1,72 @@
  1
+# Detect eigen3 + eigen2, then use this priority list to determine
  2
+# which eigen to use:
  3
+#
  4
+# Priority
  5
+# 0. EIGENDIR if set (also EIGEN2DIR for backwards compatability)
  6
+# 1. OPENSCAD_LIBRARIES eigen3
  7
+# 2. OPENSCAD_LIBRARIES eigen2
  8
+# 3. system's standard include paths for eigen3
  9
+# 4. system's standard include paths for eigen2
  10
+
  11
+eigen {
  12
+
  13
+# read environment variables
  14
+OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
  15
+EIGEN2_DIR = $$(EIGEN2DIR)
  16
+EIGEN_DIR = $$(EIGENDIR)
  17
+
  18
+CONFIG(mingw-cross-env) {
  19
+  EIGEN_INCLUDEPATH = mingw-cross-env/include/eigen2
  20
+}
  21
+
  22
+# Optionally specify location of Eigen3 using the 
  23
+# OPENSCAD_LIBRARIES env. variable
  24
+!isEmpty(OPENSCAD_LIBRARIES_DIR) {
  25
+  isEmpty(EIGEN_INCLUDEPATH) {
  26
+    exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) {
  27
+      EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3
  28
+    } 
  29
+  }
  30
+  isEmpty(EIGEN_INCLUDEPATH) {
  31
+    exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) {
  32
+      EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2
  33
+    } 
  34
+  }
  35
+}
  36
+
  37
+
  38
+# Optionally specify location of Eigen using the 
  39
+# EIGENDIR env. variable (EIGEN2 for backwards compatability)
  40
+!isEmpty(EIGEN2_DIR) { 
  41
+  EIGEN_INCLUDEPATH = $$EIGEN2_DIR
  42
+  message("User set EIGEN location: $$EIGEN_INCLUDEPATH")
  43
+}
  44
+!isEmpty(EIGEN_DIR) { 
  45
+  EIGEN_INCLUDEPATH = $$EIGEN_DIR
  46
+  message("User set EIGEN location: $$EIGEN_INCLUDEPATH")
  47
+}
  48
+
  49
+isEmpty(EIGEN_INCLUDEPATH) {
  50
+  freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen3
  51
+  macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3
  52
+  linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen3
  53
+  netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3
  54
+  !exists($$EIGEN_INCLUDEPATH) {
  55
+    freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2
  56
+    macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2
  57
+    linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen2
  58
+    netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2
  59
+  }
  60
+}
  61
+
  62
+# disable Eigen SIMD optimizations for platforms where it breaks compilation
  63
+!macx {
  64
+  !freebsd-g++ {
  65
+    QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
  66
+  }
  67
+}
  68
+
  69
+# EIGEN being under 'include/eigen[2-3]' needs special prepending
  70
+QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT
  71
+
  72
+} # eigen
44  eigen2.pri
... ...
@@ -1,44 +0,0 @@
1  
-eigen2 {
2  
-
3  
-  CONFIG(mingw-cross-env) {
4  
-    EIGEN2_INCLUDEPATH = mingw-cross-env/include/eigen2
5  
-  }
6  
-
7  
-  # Optionally specify location of Eigen2 using the 
8  
-  # OPENSCAD_LIBRARIES env. variable
9  
-  isEmpty(EIGEN2_INCLUDEPATH) {
10  
-    OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
11  
-    !isEmpty(OPENSCAD_LIBRARIES_DIR) {
12  
-      exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) {
13  
-        EIGEN2_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2
14  
-      }
15  
-    }
16  
-  }
17  
-
18  
-  # Optionally specify location of Eigen2 using the 
19  
-  # EIGEN2DIR env. variable
20  
-  isEmpty(EIGEN2_INCLUDEPATH) {
21  
-    EIGEN2_DIR = $$(EIGEN2DIR)
22  
-    !isEmpty(EIGEN2_DIR) { 
23  
-      EIGEN2_INCLUDEPATH = $$EIGEN2_DIR
24  
-      message("EIGEN2 location: $$EIGEN2_INCLUDEPATH")
25  
-    }
26  
-  }
27  
-
28  
-  isEmpty(EIGEN2_INCLUDEPATH) {
29  
-    freebsd-g++: EIGEN2_INCLUDEPATH = /usr/local/include/eigen2
30  
-    macx: EIGEN2_INCLUDEPATH = /opt/local/include/eigen2
31  
-    linux*|hurd*: EIGEN2_INCLUDEPATH = /usr/include/eigen2
32  
-    netbsd*: EIGEN2_INCLUDEPATH = /usr/pkg/include/eigen2
33  
-  }
34  
-
35  
-  # eigen2 being under 'include/eigen2' needs special prepending
36  
-  QMAKE_INCDIR_QT = $$EIGEN2_INCLUDEPATH $$QMAKE_INCDIR_QT
37  
-
38  
-  # disable Eigen SIMD optimizations for platforms where it breaks compilation
39  
-  !macx {
40  
-    !freebsd-g++ {
41  
-      QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
42  
-    }
43  
-  }
44  
-}
4  openscad.pro
@@ -3,7 +3,7 @@
3 3
 #   MPFRDIR
4 4
 #   BOOSTDIR
5 5
 #   CGALDIR
6  
-#   EIGEN2DIR
  6
+#   EIGENDIR
7 7
 #   GLEWDIR
8 8
 #   OPENCSGDIR
9 9
 #   OPENSCAD_LIBRARIES
@@ -123,7 +123,7 @@ macx:CONFIG += mdi
123 123
 CONFIG += cgal
124 124
 CONFIG += opencsg
125 125
 CONFIG += boost
126  
-CONFIG += eigen2
  126
+CONFIG += eigen
127 127
 
128 128
 #Uncomment the following line to enable QCodeEdit
129 129
 #CONFIG += qcodeedit
21  scripts/linux-build-dependencies.sh
@@ -124,7 +124,7 @@ build_boost()
124 124
   # We only need certain portions of boost
125 125
   ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem,system,regex
126 126
 	if [ $CXX ]; then
127  
-		if [ $CXX = "clang" ]; then
  127
+		if [ $CXX = "clang++" ]; then
128 128
 		  ./b2 -j$NUMCPU toolset=clang install
129 129
 		  # ./b2 -j$NUMCPU toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" install
130 130
 		fi
@@ -246,17 +246,24 @@ build_eigen()
246 246
   echo "Building eigen" $version "..."
247 247
   cd $BASEDIR/src
248 248
   rm -rf eigen-$version
249  
-  ## Directory name for v2.0.17
250  
-  rm -rf eigen-eigen-b23437e61a07
  249
+  EIGENDIR="none"
  250
+  if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi
  251
+  if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi
  252
+  if [ $EIGENDIR = "none" ]; then
  253
+    echo Unknown eigen version. Please edit script.
  254
+    exit 1
  255
+  fi
  256
+  rm -rf ./$EIGENDIR
251 257
   if [ ! -f eigen-$version.tar.bz2 ]; then
252 258
     curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2
253 259
     mv $version.tar.bz2 eigen-$version.tar.bz2
254 260
   fi
255 261
   tar xjf eigen-$version.tar.bz2
256  
-  ## File name for v2.0.17
257  
-  ln -s eigen-eigen-b23437e61a07 eigen-$version
  262
+  ln -s ./$EIGENDIR eigen-$version
258 263
   cd eigen-$version
259  
-  cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR
  264
+  mkdir build
  265
+  cd build
  266
+  cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR ..
260 267
   make -j$NUMCPU
261 268
   make install
262 269
 }
@@ -320,7 +327,7 @@ fi
320 327
 # edit version numbers here as needed.
321 328
 #
322 329
 
323  
-build_eigen 2.0.17
  330
+build_eigen 3.1.1
324 331
 build_gmp 5.0.5
325 332
 build_mpfr 3.1.1
326 333
 build_boost 1.47.0
27  scripts/macosx-build-dependencies.sh
@@ -174,9 +174,9 @@ build_boost()
174 174
   echo "Building boost" $version "..."
175 175
   cd $BASEDIR/src
176 176
   rm -rf boost_$bversion
177  
-  if [ ! -f boost_$bversion.tar.bz2 ]; then
178  
-    curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2
179  
-  fi
  177
+#  if [ ! -f boost_$bversion.tar.bz2 ]; then
  178
+#    curl -LO http://downloads.sourceforge.net/project/boost/boost/$version/boost_$bversion.tar.bz2
  179
+#  fi
180 180
   tar xjf boost_$bversion.tar.bz2
181 181
   cd boost_$bversion
182 182
   # We only need the thread and program_options libraries
@@ -271,20 +271,29 @@ build_eigen()
271 271
   echo "Building eigen" $version "..."
272 272
   cd $BASEDIR/src
273 273
   rm -rf eigen-$version
274  
-  ## Directory name for v2.0.17
275  
-  rm -rf eigen-eigen-b23437e61a07
  274
+
  275
+  EIGENDIR="none"
  276
+  if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi
  277
+  if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi
  278
+  if [ $EIGENDIR = "none" ]; then
  279
+    echo Unknown eigen version. Please edit script.
  280
+    exit 1
  281
+  fi
  282
+  rm -rf ./$EIGENDIR
  283
+
276 284
   if [ ! -f eigen-$version.tar.bz2 ]; then
277 285
     curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2
278 286
     mv $version.tar.bz2 eigen-$version.tar.bz2
279 287
   fi
280 288
   tar xjf eigen-$version.tar.bz2
281  
-  ## File name for v2.0.17
282  
-  ln -s eigen-eigen-b23437e61a07 eigen-$version
  289
+  ln -s ./$EIGENDIR eigen-$version
283 290
   cd eigen-$version
  291
+  mkdir build
  292
+  cd build
284 293
   if $OPTION_32BIT; then
285 294
     EIGEN_EXTRA_FLAGS=";i386"
286 295
   fi
287  
-  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"
  296
+  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" ..
288 297
   make -j4
289 298
   make install
290 299
 }
@@ -325,7 +334,7 @@ fi
325 334
 
326 335
 echo "Using basedir:" $BASEDIR
327 336
 mkdir -p $SRCDIR $DEPLOYDIR
328  
-build_eigen 2.0.17
  337
+build_eigen 3.1.1
329 338
 build_gmp 5.0.5
330 339
 build_mpfr 3.1.0
331 340
 build_boost 1.47.0
42  src/csgterm.cc
@@ -66,16 +66,29 @@ shared_ptr<CSGTerm> CSGTerm::createCSGTerm(type_e type, shared_ptr<CSGTerm> left
66 66
   // http://www.cc.gatech.edu/~turk/my_papers/pxpl_csg.pdf
67 67
 	const BoundingBox &leftbox = left->getBoundingBox();
68 68
 	const BoundingBox &rightbox = right->getBoundingBox();
  69
+	Vector3d newmin, newmax;
69 70
 	if (type == TYPE_INTERSECTION) {
70  
-		BoundingBox newbox(leftbox.min().cwise().max(rightbox.min()),
71  
-											 leftbox.max().cwise().min(rightbox.max()));
  71
+#if EIGEN_WORLD_VERSION == 2
  72
+		newmin = leftbox.min().cwise().max( rightbox.min() );
  73
+		newmax = leftbox.max().cwise().min( rightbox.max() );
  74
+#else
  75
+		newmin = leftbox.min().array().cwiseMax( rightbox.min().array() );
  76
+		newmax = leftbox.max().array().cwiseMin( rightbox.max().array() );
  77
+#endif
  78
+		BoundingBox newbox( newmin, newmax );
72 79
 		if (newbox.isNull()) {
73 80
 			return shared_ptr<CSGTerm>(); // Prune entire product
74 81
 		}
75 82
 	}
76 83
 	else if (type == TYPE_DIFFERENCE) {
77  
-		BoundingBox newbox(leftbox.min().cwise().max(rightbox.min()),
78  
-											 leftbox.max().cwise().min(rightbox.max()));
  84
+#if EIGEN_WORLD_VERSION == 2
  85
+		newmin = leftbox.min().cwise().max( rightbox.min() );
  86
+		newmax = leftbox.max().cwise().min( rightbox.max() );
  87
+#else
  88
+		newmin = leftbox.min().array().cwiseMax( rightbox.min().array() );
  89
+		newmax = leftbox.max().array().cwiseMin( rightbox.max().array() );
  90
+#endif
  91
+		BoundingBox newbox( newmin, newmax );
79 92
 		if (newbox.isNull()) {
80 93
 			return left; // Prune the negative component
81 94
 		}
@@ -119,14 +132,27 @@ void CSGTerm::initBoundingBox()
119 132
 	else {
120 133
 		const BoundingBox &leftbox = this->left->getBoundingBox();
121 134
 		const BoundingBox &rightbox = this->right->getBoundingBox();
  135
+		Vector3d newmin, newmax;
122 136
 		switch (this->type) {
123 137
 		case TYPE_UNION:
124  
-			this->bbox = this->m * BoundingBox(leftbox.min().cwise().min(rightbox.min()), 
125  
-																				 leftbox.max().cwise().max(rightbox.max()));
  138
+#if EIGEN_WORLD_VERSION == 2
  139
+			newmin = leftbox.min().cwise().min( rightbox.min() );
  140
+			newmax = leftbox.max().cwise().max( rightbox.max() );
  141
+#else
  142
+			newmin = leftbox.min().array().cwiseMin( rightbox.min().array() );
  143
+			newmax = leftbox.max().array().cwiseMax( rightbox.max().array() );
  144
+#endif
  145
+			this->bbox = this->m * BoundingBox( newmin, newmax );
126 146
 			break;
127 147
 		case TYPE_INTERSECTION:
128  
-			this->bbox = this->m * BoundingBox(leftbox.min().cwise().max(rightbox.min()),
129  
-																				 leftbox.max().cwise().min(rightbox.max()));
  148
+#if EIGEN_WORLD_VERSION == 2
  149
+			newmin = leftbox.min().cwise().max( rightbox.min() );
  150
+			newmax = leftbox.max().cwise().min( rightbox.max() );
  151
+#else
  152
+			newmin = leftbox.min().array().cwiseMax( rightbox.min().array() );
  153
+			newmax = leftbox.max().array().cwiseMin( rightbox.max().array() );
  154
+#endif
  155
+			this->bbox = this->m * BoundingBox( newmin, newmax );
130 156
 			break;
131 157
 		case TYPE_DIFFERENCE:
132 158
 			this->bbox = this->m * leftbox;
11  src/dxfdim.cc
@@ -36,10 +36,9 @@
36 36
 #include <sstream>
37 37
 
38 38
 #include <boost/filesystem.hpp>
39  
-using namespace boost::filesystem;
40  
-
41 39
 boost::unordered_map<std::string,Value> dxf_dim_cache;
42 40
 boost::unordered_map<std::string,Value> dxf_cross_cache;
  41
+namespace fs = boost::filesystem;
43 42
 
44 43
 Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnames, const std::vector<Value> &args)
45 44
 {
@@ -65,8 +64,8 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam
65 64
 
66 65
 	std::stringstream keystream;
67 66
 	keystream << filename << "|" << layername << "|" << name << "|" << xorigin
68  
-						<< "|" << yorigin <<"|" << scale << "|" << last_write_time(filename)
69  
-						<< "|" << file_size(filename);
  67
+						<< "|" << yorigin <<"|" << scale << "|" << fs::last_write_time(filename)
  68
+						<< "|" << fs::file_size(filename);
70 69
 	std::string key = keystream.str();
71 70
 	if (dxf_dim_cache.find(key) != dxf_dim_cache.end())
72 71
 		return dxf_dim_cache.find(key)->second;
@@ -147,8 +146,8 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector<std::string> &argn
147 146
 
148 147
 	std::stringstream keystream;
149 148
 	keystream << filename << "|" << layername << "|" << xorigin << "|" << yorigin
150  
-						<< "|" << scale << "|" << last_write_time(filename)
151  
-						<< "|" << file_size(filename);
  149
+						<< "|" << scale << "|" << fs::last_write_time(filename)
  150
+						<< "|" << fs::file_size(filename);
152 151
 	std::string key = keystream.str();
153 152
 
154 153
 	if (dxf_cross_cache.find(key) != dxf_cross_cache.end())
8  src/handle_dep.cc
@@ -6,7 +6,7 @@
6 6
 #include <boost/foreach.hpp>
7 7
 #include <boost/regex.hpp>
8 8
 #include <boost/filesystem.hpp>
9  
-using namespace boost::filesystem;
  9
+namespace fs = boost::filesystem;
10 10
 #include "boosty.h"
11 11
 
12 12
 boost::unordered_set<std::string> dependencies;
@@ -14,14 +14,14 @@ const char *make_command = NULL;
14 14
 
15 15
 void handle_dep(const std::string &filename)
16 16
 {
17  
-	path filepath(filename);
  17
+	fs::path filepath(filename);
18 18
 	if ( boosty::is_absolute( filepath )) {
19 19
 		dependencies.insert(filename);
20 20
 	}
21 21
 	else {
22  
-		dependencies.insert((current_path() / filepath).string());
  22
+		dependencies.insert((fs::current_path() / filepath).string());
23 23
 	}
24  
-	if (!exists(filepath) && make_command) {
  24
+	if (!fs::exists(filepath) && make_command) {
25 25
 		std::stringstream buf;
26 26
 		buf << make_command << " '" << boost::regex_replace(filename, boost::regex("'"), "'\\''") << "'";
27 27
 		system(buf.str().c_str()); // FIXME: Handle error
4  src/import.cc
@@ -47,7 +47,7 @@
47 47
 #include <boost/regex.hpp>
48 48
 #include <boost/lexical_cast.hpp>
49 49
 #include <boost/filesystem.hpp>
50  
-using namespace boost::filesystem;
  50
+namespace fs = boost::filesystem;
51 51
 #include <boost/assign/std/vector.hpp>
52 52
 using namespace boost::assign; // bring 'operator+=()' into scope
53 53
 #include "boosty.h"
@@ -80,7 +80,7 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati
80 80
 	std::string filename = c.getAbsolutePath(v.isUndefined() ? "" : v.toString());
81 81
 	import_type_e actualtype = this->type;
82 82
 	if (actualtype == TYPE_UNKNOWN) {
83  
-		std::string extraw = boosty::extension_str( path(filename) );
  83
+		std::string extraw = boosty::extension_str( fs::path(filename) );
84 84
 		std::string ext = boost::algorithm::to_lower_copy( extraw );
85 85
 		if (ext == ".stl") actualtype = TYPE_STL;
86 86
 		else if (ext == ".off") actualtype = TYPE_OFF;
4  src/linalg.h
@@ -12,7 +12,11 @@ typedef Eigen::AlignedBox<double, 3> BoundingBox;
12 12
 using Eigen::Matrix3f;
13 13
 using Eigen::Matrix3d;
14 14
 using Eigen::Matrix4d;
  15
+#if EIGEN_WORLD_VERSION >= 3
  16
+#define Transform3d Eigen::Affine3d
  17
+#else
15 18
 using Eigen::Transform3d;
  19
+#endif
16 20
 
17 21
 BoundingBox operator*(const Transform3d &m, const BoundingBox &box);
18 22
 
81  tests/CMakeLists.txt
@@ -86,6 +86,17 @@ if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
86 86
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -frounding-math")
87 87
 endif()
88 88
 
  89
+# Clang compiler
  90
+
  91
+if(CMAKE_CXX_COMPILER MATCHES ".*clang.*")
  92
+  # disable enormous amount of warnings about CGAL
  93
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
  94
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
  95
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
  96
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-extensions")
  97
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
  98
+endif()
  99
+
89 100
 #
90 101
 # Build test apps
91 102
 #
@@ -176,7 +187,8 @@ endif()
176 187
 
177 188
 set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
178 189
 
179  
-# Eigen2
  190
+
  191
+# Eigen
180 192
 
181 193
 # Turn off Eigen SIMD optimization
182 194
 if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -185,34 +197,63 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
185 197
   endif()
186 198
 endif()
187 199
 
188  
-if (NOT $ENV{EIGEN2DIR} STREQUAL "")
189  
-  set(EIGEN2_DIR "$ENV{EIGEN2DIR}")
190  
-elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
191  
-  set(EIGEN2_DIR "$ENV{OPENSCAD_LIBRARIES}")
  200
+# Priority
  201
+# 3. EIGENDIR if set (EIGEN2DIR for backwards compatability)
  202
+# 1. OPENSCAD_LIBRARIES eigen3
  203
+# 2. OPENSCAD_LIBRARIES eigen2
  204
+# 4. system's standard include paths for eigen3
  205
+# 5. system's standard include paths for eigen2
  206
+
  207
+set(EIGEN2_DIR "$ENV{EIGEN2DIR}")
  208
+set(EIGEN_DIR "$ENV{EIGENDIR}")
  209
+set(OPENSCAD_LIBDIR "$ENV{OPENSCAD_LIBRARIES}")
  210
+
  211
+if (EIGEN_DIR)
  212
+  set(EIGHINT ${EIGEN_DIR}/include/eigen3 ${EIGEN_DIR}/include/eigen2 ${EIGEN_DIR})
  213
+  find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${EIGHINT})
  214
+endif()
  215
+if (EIGEN2_DIR)
  216
+  find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${EIGEN2_DIR}/include/eigen2 ${EIGEN2_DIR})
192 217
 endif()
193 218
 
194  
-if (NOT EIGEN2_INCLUDE_DIR)
195  
-  if (EIGEN2_DIR)
196  
-    set(EIGEN2_FIND_HINTS "${EIGEN2_DIR}/include/eigen2")
197  
-  endif()
  219
+if (NOT EIGEN_INCLUDE_DIR)
  220
+  find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${OPENSCAD_LIBDIR}/include/eigen3)
  221
+endif()
  222
+if (NOT EIGEN_INCLUDE_DIR)
  223
+  find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS ${OPENSCAD_LIBDIR}/include/eigen2)
  224
+endif()
  225
+
  226
+if (NOT EIGEN_INCLUDE_DIR)
198 227
   if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
199  
-    set(EIGEN2_FIND_PATHS /usr/local/include/eigen2)
  228
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/local/include/eigen3)
200 229
   elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
201  
-    set(EIGEN2_FIND_PATHS /usr/pkg/include/eigen2)
  230
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/pkg/include/eigen3)
  231
+  elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  232
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /opt/local/include/eigen3)
202 233
   else()
203  
-    set(EIGEN2_FIND_PATHS /opt/local/include/eigen2 /usr/include/eigen2)
  234
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/include/eigen3)
204 235
   endif()
205  
-  find_path(EIGEN2_INCLUDE_DIR
206  
-            Eigen/Core 
207  
-            HINTS ${EIGEN2_FIND_HINTS}
208  
-            PATHS ${EIGEN2_FIND_PATHS})
209  
-  if (NOT EIGEN2_INCLUDE_DIR)
210  
-    message(FATAL_ERROR "Eigen2 not found")
  236
+endif()
  237
+
  238
+if (NOT EIGEN_INCLUDE_DIR)
  239
+  if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  240
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/local/include/eigen2)
  241
+  elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
  242
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/pkg/include/eigen2)
  243
+  elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  244
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /opt/local/include/eigen2)
211 245
   else()
212  
-    message(STATUS "Eigen2 found in " ${EIGEN2_INCLUDE_DIR})
  246
+    find_path(EIGEN_INCLUDE_DIR Eigen/Core HINTS /usr/include/eigen2)
213 247
   endif()
214 248
 endif()
215  
-inclusion(EIGEN2_DIR EIGEN2_INCLUDE_DIR)
  249
+
  250
+if (NOT EIGEN_INCLUDE_DIR)
  251
+  message(STATUS "Eigen not found")
  252
+else()
  253
+  message(STATUS "Eigen found in " ${EIGEN_INCLUDE_DIR})
  254
+  inclusion(EIGEN_DIR EIGEN_INCLUDE_DIR)
  255
+endif()
  256
+
216 257
 
217 258
 # OpenCSG
218 259
 if (NOT $ENV{OPENCSGDIR} STREQUAL "")
2  tests/csgtestcore.cc
@@ -367,6 +367,8 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
367 367
 
368 368
 	OpenCSG::setContext(0);
369 369
 	OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
  370
+  // FIXME: This is necessary for Mac OS X 10.7 for now. kintel 20120527.
  371
+	OpenCSG::setOption(OpenCSG::AlgorithmSetting, OpenCSG::Goldfeather);
370 372
 
371 373
 	csgInfo.glview->paintGL();
372 374
 	
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.