From 077a914ac68c3b32d2633bc7d0bb9b11f4544569 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Tue, 22 Nov 2011 12:00:49 +0100 Subject: Upgraded to boost 1.48, added boost filesystem diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 29da173..6b86fde 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() @@ -197,7 +198,7 @@ echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR build_gmp 5.0.2 build_mpfr 3.1.0 -build_boost 1.47.0 +build_boost 1.48.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 3.9 build_glew 1.7.0 -- cgit v0.10.1 From 1969396b9d1ec34778f9568652b0864f64365a23 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 23 Nov 2011 14:35:43 +0100 Subject: Reverted to boost-1.47 for now - 1.48 causes some tests to fail; *_polygon-holes-touch *_polygon-mesh diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index 6b86fde..32b15cd 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -198,7 +198,7 @@ echo "Using basedir:" $BASEDIR mkdir -p $SRCDIR $DEPLOYDIR build_gmp 5.0.2 build_mpfr 3.1.0 -build_boost 1.48.0 +build_boost 1.47.0 # NB! For CGAL, also update the actual download URL in the function build_cgal 3.9 build_glew 1.7.0 -- cgit v0.10.1 From 73092dd4c89829bb0a7fa0a026addd2d54171cbb Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 23 Nov 2011 16:11:48 +0100 Subject: Added support for 3D object in the hull() module 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/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 #include +#include #include #include @@ -29,6 +30,7 @@ #include #include +#include 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 polys; - bool all2d = true; + std::list 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(&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/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/tests/regression/cgalpngtest/hull3-tests-expected.png b/tests/regression/cgalpngtest/hull3-tests-expected.png index 50d838c..e34ae89 100644 Binary files a/tests/regression/cgalpngtest/hull3-tests-expected.png and b/tests/regression/cgalpngtest/hull3-tests-expected.png differ 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/opencsgtest/hull3-tests-expected.png b/tests/regression/opencsgtest/hull3-tests-expected.png index 50d838c..5a363a1 100644 Binary files a/tests/regression/opencsgtest/hull3-tests-expected.png and b/tests/regression/opencsgtest/hull3-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/hull3-tests-expected.png b/tests/regression/throwntogethertest/hull3-tests-expected.png index 50d838c..5a363a1 100644 Binary files a/tests/regression/throwntogethertest/hull3-tests-expected.png and b/tests/regression/throwntogethertest/hull3-tests-expected.png differ -- cgit v0.10.1 From 60d7e80c482f78e5a8689ad1108d398aaad42f55 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 23 Nov 2011 16:49:09 +0100 Subject: Modified escape-test to avoid issues with Windows drive letters 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/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); -- cgit v0.10.1 From e0b5f3f33d974b60daf88a28ce86dc6013f44746 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Wed, 23 Nov 2011 16:55:03 +0100 Subject: Output relative filenames in warnings for echotest to give similar results across machines 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 #include +#include +#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/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 -- cgit v0.10.1