summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2011-11-24 01:26:34 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2011-11-24 01:26:34 (GMT)
commit0db6e95e2de1c59a3587eb590e930f0f1e74876e (patch)
tree08cf4dec262059b7efea830e9cf1a3d36dcbfe48
parentcea502f9a3531888dbbb55099421fb1ab565f2c1 (diff)
parente0b5f3f33d974b60daf88a28ce86dc6013f44746 (diff)
Merge remote branch 'upstream/master' into cakebaby
-rw-r--r--RELEASE_NOTES1
-rwxr-xr-xscripts/macosx-build-dependencies.sh3
-rw-r--r--src/CGALEvaluator.cc29
-rw-r--r--src/dxfdata.cc7
-rw-r--r--testdata/scad/features/hull3-tests.scad34
-rw-r--r--testdata/scad/misc/escape-test.scad3
-rw-r--r--tests/regression/cgalpngtest/hull3-tests-expected.pngbin4408 -> 11978 bytes
-rw-r--r--tests/regression/dumptest/escape-test-expected.txt2
-rw-r--r--tests/regression/dumptest/hull3-tests-expected.txt34
-rw-r--r--tests/regression/echotest/dim-all-expected.txt16
-rw-r--r--tests/regression/opencsgtest/hull3-tests-expected.pngbin4408 -> 12471 bytes
-rw-r--r--tests/regression/throwntogethertest/hull3-tests-expected.pngbin4408 -> 12471 bytes
12 files changed, 67 insertions, 62 deletions
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 2de956d..f25de79 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -3,6 +3,7 @@ OpenSCAD 20xx.yy
Features:
o The MCAD library is now bundled with OpenSCAD
+o hull() Now supports 3D objects
o Added import and export of the OFF file format
o New import() statement reads the correct file format based on the filename extension
(.stl, .dxf and .off is supported)
diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh
index 29da173..32b15cd 100755
--- a/scripts/macosx-build-dependencies.sh
+++ b/scripts/macosx-build-dependencies.sh
@@ -140,11 +140,12 @@ build_boost()
tar xjf boost_$bversion.tar.bz2
cd boost_$bversion
# We only need the thread and program_options libraries
- ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options
+ ./bootstrap.sh --prefix=$DEPLOYDIR --with-libraries=thread,program_options,filesystem
./bjam cflags="-mmacosx-version-min=10.5 -arch i386 -arch x86_64" linkflags="-mmacosx-version-min=10.5 -arch i386 -arch x86_64"
./bjam install
install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib
install_name_tool -id $DEPLOYDIR/lib/libboost_program_options.dylib $DEPLOYDIR/lib/libboost_program_options.dylib
+ install_name_tool -id $DEPLOYDIR/lib/libboost_filesystem.dylib $DEPLOYDIR/lib/libboost_filesystem.dylib
}
build_cgal()
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());
}
}
diff --git a/testdata/scad/features/hull3-tests.scad b/testdata/scad/features/hull3-tests.scad
index 2bd7d73..12c8a11 100644
--- a/testdata/scad/features/hull3-tests.scad
+++ b/testdata/scad/features/hull3-tests.scad
@@ -1,27 +1,17 @@
-// 3d not currently implemented
-module convex3dSimple() {
- hull() {
- translate([15,10]) cylinder(r=10);
- cylinder(r=10);
- }
-}
-
-// 3d not currently implemented
-module convex3dHole() {
- hull() {
- translate([15,10,0]) cylinder(10);
- difference() {
- cylinder(10);
- cylinder(5);
- }
- }
-}
-
-translate([0,40,0]) convex3dHole();
-translate([40,40,0]) convex3dSimple();
-
// Empty
hull();
// No children
hull() { }
+hull() {
+ cylinder(r=10, h=1);
+ translate([0,0,10]) cube([5,5,5], center=true);
+}
+
+translate([25,0,0]) hull() {
+ translate([0,0,10]) cylinder(r=3);
+ difference() {
+ cylinder(r=10, h=4, center=true);
+ cylinder(r=5, h=5, center=true);
+ }
+}
diff --git a/testdata/scad/misc/escape-test.scad b/testdata/scad/misc/escape-test.scad
index 81b5fe4..c4400b3 100644
--- a/testdata/scad/misc/escape-test.scad
+++ b/testdata/scad/misc/escape-test.scad
@@ -1,2 +1 @@
-import(file="A:\\ B:\" C:\t D:\n E:' F:\\\\", layer="A:\\ B:\" C:\t D:\n E:' F:\\\\");
-
+import(file="A-\\ B-\" C-\t D-\n E-' F-\\\\", layer="A:\\ B:\" C:\t D:\n E:' F:\\\\");
diff --git a/tests/regression/cgalpngtest/hull3-tests-expected.png b/tests/regression/cgalpngtest/hull3-tests-expected.png
index 50d838c..e34ae89 100644
--- a/tests/regression/cgalpngtest/hull3-tests-expected.png
+++ b/tests/regression/cgalpngtest/hull3-tests-expected.png
Binary files differ
diff --git a/tests/regression/dumptest/escape-test-expected.txt b/tests/regression/dumptest/escape-test-expected.txt
index 1b2aa0d..bea0156 100644
--- a/tests/regression/dumptest/escape-test-expected.txt
+++ b/tests/regression/dumptest/escape-test-expected.txt
@@ -1,2 +1,2 @@
- import(file = "A:\\ B:\" C:\t D:\n E:' F:\\\\", layer = "A:\\ B:\" C:\t D:\n E:' F:\\\\", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 1);
+ import(file = "A-\\ B-\" C-\t D-\n E-' F-\\\\", layer = "A:\\ B:\" C:\t D:\n E:' F:\\\\", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 1);
diff --git a/tests/regression/dumptest/hull3-tests-expected.txt b/tests/regression/dumptest/hull3-tests-expected.txt
index 831aae2..bde58c9 100644
--- a/tests/regression/dumptest/hull3-tests-expected.txt
+++ b/tests/regression/dumptest/hull3-tests-expected.txt
@@ -1,26 +1,20 @@
- multmatrix([[1, 0, 0, 0], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) {
- group() {
- hull() {
- multmatrix([[1, 0, 0, 15], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) {
- cylinder($fn = 0, $fa = 12, $fs = 1, h = 10, r1 = 1, r2 = 1, center = false);
- }
- difference() {
- cylinder($fn = 0, $fa = 12, $fs = 1, h = 10, r1 = 1, r2 = 1, center = false);
- cylinder($fn = 0, $fa = 12, $fs = 1, h = 5, r1 = 1, r2 = 1, center = false);
- }
- }
+ hull();
+ hull();
+ hull() {
+ cylinder($fn = 0, $fa = 12, $fs = 1, h = 1, r1 = 10, r2 = 10, center = false);
+ multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 10], [0, 0, 0, 1]]) {
+ cube(size = [5, 5, 5], center = true);
}
}
- multmatrix([[1, 0, 0, 40], [0, 1, 0, 40], [0, 0, 1, 0], [0, 0, 0, 1]]) {
- group() {
- hull() {
- multmatrix([[1, 0, 0, 15], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) {
- cylinder($fn = 0, $fa = 12, $fs = 1, h = 1, r1 = 10, r2 = 10, center = false);
- }
- cylinder($fn = 0, $fa = 12, $fs = 1, h = 1, r1 = 10, r2 = 10, center = false);
+ multmatrix([[1, 0, 0, 25], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
+ hull() {
+ multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 10], [0, 0, 0, 1]]) {
+ cylinder($fn = 0, $fa = 12, $fs = 1, h = 1, r1 = 3, r2 = 3, center = false);
+ }
+ difference() {
+ cylinder($fn = 0, $fa = 12, $fs = 1, h = 4, r1 = 10, r2 = 10, center = true);
+ cylinder($fn = 0, $fa = 12, $fs = 1, h = 5, r1 = 5, r2 = 5, center = true);
}
}
}
- hull();
- hull();
diff --git a/tests/regression/echotest/dim-all-expected.txt b/tests/regression/echotest/dim-all-expected.txt
index 702f026..74044a1 100644
--- a/tests/regression/echotest/dim-all-expected.txt
+++ b/tests/regression/echotest/dim-all-expected.txt
@@ -1,16 +1,16 @@
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: linearX = 51.44957554275265
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: linearY = 29.13025467434841
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: aligned = 60.00000000000001
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: ordinateX = -49.17542445724735
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: ordinateY = 30.86974532565159
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: radius = 60
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: diameter = 120
-WARNING: Unsupported DXF Entity `LEADER' (1) in `/Users/kintel/code/OpenSCAD/openscad/testdata/scad/misc/dim-all.dxf'.
+WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'.
ECHO: arc = 59.03624346792648
diff --git a/tests/regression/opencsgtest/hull3-tests-expected.png b/tests/regression/opencsgtest/hull3-tests-expected.png
index 50d838c..5a363a1 100644
--- a/tests/regression/opencsgtest/hull3-tests-expected.png
+++ b/tests/regression/opencsgtest/hull3-tests-expected.png
Binary files differ
diff --git a/tests/regression/throwntogethertest/hull3-tests-expected.png b/tests/regression/throwntogethertest/hull3-tests-expected.png
index 50d838c..5a363a1 100644
--- a/tests/regression/throwntogethertest/hull3-tests-expected.png
+++ b/tests/regression/throwntogethertest/hull3-tests-expected.png
Binary files differ
contact: Jan Huwald // Impressum