diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CGALEvaluator.cc | 29 | ||||
-rw-r--r-- | src/dxfdata.cc | 7 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 3646af2..7921b85 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -18,6 +18,7 @@ #include "cgalutils.h" #include <CGAL/assertions_behaviour.h> #include <CGAL/exceptions.h> +#include <CGAL/convex_hull_3.h> #include <string> #include <map> @@ -29,6 +30,7 @@ #include <boost/foreach.hpp> #include <boost/unordered_map.hpp> +#include <boost/bind.hpp> CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const AbstractNode &node) { @@ -114,25 +116,40 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) { CGAL_Nef_polyhedron N; std::list<CGAL_Nef_polyhedron2*> polys; - bool all2d = true; + std::list<CGAL_Polyhedron::Vertex::Point_3> points; + int dim = 0; BOOST_FOREACH(const ChildItem &item, this->visitedchildren[node.index()]) { const AbstractNode *chnode = item.first; const CGAL_Nef_polyhedron &chN = item.second; // FIXME: Don't use deep access to modinst members if (chnode->modinst->tag_background) continue; - if (chN.dim == 2) { + if (dim == 0) { + dim = chN.dim; + } + else if (dim != chN.dim) { + PRINT("WARNING: hull() does not support mixing 2D and 3D objects."); + continue; + } + if (dim == 2) { polys.push_back(chN.p2.get()); } - else if (chN.dim == 3) { - PRINT("WARNING: hull() is not implemented yet for 3D objects!"); - all2d = false; + else if (dim == 3) { + CGAL_Polyhedron P; + chN.p3->convert_to_Polyhedron(P); + std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points), + boost::bind(static_cast<const CGAL_Polyhedron::Vertex::Point_3&(CGAL_Polyhedron::Vertex::*)() const>(&CGAL_Polyhedron::Vertex::point), _1)); } chnode->progress_report(); } - if (all2d) { + if (dim == 2) { N = CGAL_Nef_polyhedron(convexhull2(polys)); } + else if (dim == 3) { + CGAL_Polyhedron P; + CGAL::convex_hull_3(points.begin(), points.end(), P); + N = CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron3(P)); + } return N; } diff --git a/src/dxfdata.cc b/src/dxfdata.cc index bf689f7..cf9248f 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -39,6 +39,9 @@ #include <boost/algorithm/string.hpp> #include <algorithm> +#include <QDir> +#include "value.h" + struct Line { int idx[2]; // indices into DxfData::points bool disabled; @@ -370,10 +373,10 @@ DxfData::DxfData(double fn, double fs, double fa, BOOST_FOREACH(const EntityList::value_type &i, unsupported_entities_list) { if (layername.empty()) { PRINTF("WARNING: Unsupported DXF Entity `%s' (%x) in `%s'.", - i.first.c_str(), i.second, filename.c_str()); + i.first.c_str(), i.second, QuotedString(QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString()).c_str()); } else { PRINTF("WARNING: Unsupported DXF Entity `%s' (%x) in layer `%s' of `%s'.", - i.first.c_str(), i.second, layername.c_str(), filename.c_str()); + i.first.c_str(), i.second, layername.c_str(), QuotedString(QDir::current().relativeFilePath(QString::fromStdString(filename)).toStdString()).c_str()); } } |