summaryrefslogtreecommitdiff
path: root/src
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 /src
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
Diffstat (limited to 'src')
-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
5 files changed, 49 insertions, 15 deletions
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