summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2012-08-18 20:28:36 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2012-08-18 20:28:36 (GMT)
commit9f6819e68501de16563aeaaadd65dfc915092169 (patch)
tree26beade954d4748b44ec303e2fd2e12584abe885
parent8740ac3574c5249c9c22f5436d3b14f4f0563a66 (diff)
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
-rw-r--r--common.pri5
-rw-r--r--eigen2.pri2
-rw-r--r--eigen3.pri43
-rw-r--r--openscad.pro8
-rwxr-xr-xscripts/linux-build-dependencies.sh20
-rw-r--r--src/csgterm.cc42
-rw-r--r--src/dxfdata.h2
-rw-r--r--src/dxfdim.cc12
-rw-r--r--src/import.cc2
-rw-r--r--src/linalg.h6
10 files changed, 116 insertions, 26 deletions
diff --git a/common.pri b/common.pri
index d6e8480..9e3555f 100644
--- a/common.pri
+++ b/common.pri
@@ -9,5 +9,8 @@ include(bison.pri)
include(cgal.pri)
include(opencsg.pri)
include(glew.pri)
-include(eigen2.pri)
include(boost.pri)
+
+CONFIG(eigen2) { include(eigen2.pri) }
+CONFIG(eigen3) { include(eigen3.pri) }
+
diff --git a/eigen2.pri b/eigen2.pri
index 0bda55b..701f92a 100644
--- a/eigen2.pri
+++ b/eigen2.pri
@@ -1,5 +1,5 @@
eigen2 {
-
+message("hi 2")
CONFIG(mingw-cross-env) {
EIGEN2_INCLUDEPATH = mingw-cross-env/include/eigen2
}
diff --git a/eigen3.pri b/eigen3.pri
new file mode 100644
index 0000000..20d85fc
--- /dev/null
+++ b/eigen3.pri
@@ -0,0 +1,43 @@
+eigen3 {
+ CONFIG(mingw-cross-env) {
+ EIGEN3_INCLUDEPATH = mingw-cross-env/include/eigen3
+ }
+
+ # Optionally specify location of Eigen3 using the
+ # OPENSCAD_LIBRARIES env. variable
+ isEmpty(EIGEN3_INCLUDEPATH) {
+ OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
+ !isEmpty(OPENSCAD_LIBRARIES_DIR) {
+ exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) {
+ EIGEN3_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3
+ }
+ }
+ }
+
+ # Optionally specify location of Eigen3 using the
+ # EIGEN3DIR env. variable
+ isEmpty(EIGEN3_INCLUDEPATH) {
+ EIGEN3_DIR = $$(EIGEN3DIR)
+ !isEmpty(EIGEN3_DIR) {
+ EIGEN3_INCLUDEPATH = $$EIGEN3_DIR
+ message("EIGEN3 location: $$EIGEN3_INCLUDEPATH")
+ }
+ }
+
+ isEmpty(EIGEN3_INCLUDEPATH) {
+ freebsd-g++: EIGEN3_INCLUDEPATH = /usr/local/include/eigen3
+ macx: EIGEN3_INCLUDEPATH = /opt/local/include/eigen3
+ linux*|hurd*: EIGEN3_INCLUDEPATH = /usr/include/eigen3
+ netbsd*: EIGEN3_INCLUDEPATH = /usr/pkg/include/eigen3
+ }
+
+ # EIGEN3 being under 'include/eigen3' needs special prepending
+ QMAKE_INCDIR_QT = $$EIGEN3_INCLUDEPATH $$QMAKE_INCDIR_QT
+
+ # disable Eigen SIMD optimizations for platforms where it breaks compilation
+ !macx {
+ !freebsd-g++ {
+ QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
+ }
+ }
+}
diff --git a/openscad.pro b/openscad.pro
index f11a494..a76383c 100644
--- a/openscad.pro
+++ b/openscad.pro
@@ -4,6 +4,7 @@
# BOOSTDIR
# CGALDIR
# EIGEN2DIR
+# EIGEN3DIR
# GLEWDIR
# OPENCSGDIR
# OPENSCAD_LIBRARIES
@@ -123,7 +124,12 @@ macx:CONFIG += mdi
CONFIG += cgal
CONFIG += opencsg
CONFIG += boost
-CONFIG += eigen2
+#macx {
+unix {
+ CONFIG += eigen3
+} else {
+ CONFIG += eigen2
+}
#Uncomment the following line to enable QCodeEdit
#CONFIG += qcodeedit
diff --git a/scripts/linux-build-dependencies.sh b/scripts/linux-build-dependencies.sh
index aee423c..6f31d5d 100755
--- a/scripts/linux-build-dependencies.sh
+++ b/scripts/linux-build-dependencies.sh
@@ -248,6 +248,7 @@ build_eigen()
rm -rf eigen-$version
## Directory name for v2.0.17
rm -rf eigen-eigen-b23437e61a07
+ rm -rf eigen-eigen-43d9075b23ef # 3.1.1
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
@@ -255,13 +256,15 @@ build_eigen()
tar xjf eigen-$version.tar.bz2
## File name for v2.0.17
ln -s eigen-eigen-b23437e61a07 eigen-$version
+ ln -s eigen-eigen-43d9075b23ef eigen-$version # 3.1.1
cd eigen-$version
- cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR
+ mkdir build
+ cd build
+ cmake -DCMAKE_INSTALL_PREFIX=$DEPLOYDIR ..
make -j$NUMCPU
make install
}
-
OPENSCADDIR=$PWD
if [ ! -f $OPENSCADDIR/openscad.pro ]; then
echo "Must be run from the OpenSCAD source root directory"
@@ -321,12 +324,13 @@ fi
#
build_eigen 2.0.17
-build_gmp 5.0.5
-build_mpfr 3.1.1
-build_boost 1.47.0
+#build_eigen 3.1.1
+#build_gmp 5.0.5
+#build_mpfr 3.1.1
+#build_boost 1.47.0
# NB! For CGAL, also update the actual download URL in the function
-build_cgal 4.0.2
-build_glew 1.7.0
-build_opencsg 1.3.2
+#build_cgal 4.0.2
+#build_glew 1.7.0
+#build_opencsg 1.3.2
echo "OpenSCAD dependencies built and installed to " $BASEDIR
diff --git a/src/csgterm.cc b/src/csgterm.cc
index 0e68320..aed97b2 100644
--- a/src/csgterm.cc
+++ b/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;
diff --git a/src/dxfdata.h b/src/dxfdata.h
index 64853dc..80a23f6 100644
--- a/src/dxfdata.h
+++ b/src/dxfdata.h
@@ -30,6 +30,8 @@ public:
#ifdef __APPLE__
std::vector<Vector2d, Eigen::aligned_allocator<Vector2d> > points;
+#elif EIGEN_WORLD_VERSION == 3
+ std::vector<Vector2d, Eigen::aligned_allocator<Vector3d> > points;
#else
std::vector<Vector2d> points;
#endif
diff --git a/src/dxfdim.cc b/src/dxfdim.cc
index 8f68ac6..4af3526 100644
--- a/src/dxfdim.cc
+++ b/src/dxfdim.cc
@@ -36,10 +36,10 @@
#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,13 +65,14 @@ 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;
DxfData dxf(36, 0, 0, filename, layername, xorigin, yorigin, scale);
+/*
for (size_t i = 0; i < dxf.dims.size(); i++)
{
@@ -123,12 +124,13 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam
PRINTB("WARNING: Can't find dimension '%s' in '%s', layer '%s'!",
name % filename % layername);
+*/
return Value();
}
Value builtin_dxf_cross(const Context *ctx, const std::vector<std::string> &argnames, const std::vector<Value> &args)
{
- std::string filename;
+/* std::string filename;
std::string layername;
double xorigin = 0;
double yorigin = 0;
@@ -186,7 +188,7 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector<std::string> &argn
}
PRINTB("WARNING: Can't find cross in '%s', layer '%s'!", filename % layername);
-
+*/
return Value();
}
diff --git a/src/import.cc b/src/import.cc
index dc40c8d..2f08b11 100644
--- a/src/import.cc
+++ b/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"
diff --git a/src/linalg.h b/src/linalg.h
index 65243dc..eb3d22d 100644
--- a/src/linalg.h
+++ b/src/linalg.h
@@ -12,7 +12,11 @@ typedef Eigen::AlignedBox<double, 3> BoundingBox;
using Eigen::Matrix3f;
using Eigen::Matrix3d;
using Eigen::Matrix4d;
-using Eigen::Transform3d;
+#if EIGEN_WORLD_VERSION>=3
+#define Transform3d Eigen::Affine3d
+#else
+using Eigen::Transform3d
+#endif
BoundingBox operator*(const Transform3d &m, const BoundingBox &box);
contact: Jan Huwald // Impressum