diff options
author | Marius Kintel <marius@kintel.net> | 2013-12-15 23:25:22 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-12-15 23:25:22 (GMT) |
commit | 4be55c016ec0af199820e116a9b358180581eaf4 (patch) | |
tree | 1d0030c4754d8df60f1515e52a0cb1fb16bc70f9 /src/cgalutils.cc | |
parent | 70dfdf42c33356fa0c7b7cdf7b2681eab84a4a30 (diff) | |
parent | dced79fb2d6a4bb1bd5992e611e1c209b910f820 (diff) |
Merge branch 'master' of github.com:openscad/openscad
Diffstat (limited to 'src/cgalutils.cc')
-rw-r--r-- | src/cgalutils.cc | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/cgalutils.cc b/src/cgalutils.cc index bb46f1c..12e743d 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -8,10 +8,9 @@ #include <map> -PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p) +bool createPolySetFromPolyhedron(const CGAL_Polyhedron &p, PolySet &ps) { - PolySet *ps = new PolySet(); - + bool err = false; typedef CGAL_Polyhedron::Vertex Vertex; typedef CGAL_Polyhedron::Vertex_const_iterator VCI; typedef CGAL_Polyhedron::Facet_const_iterator FCI; @@ -35,13 +34,13 @@ PolySet *createPolySetFromPolyhedron(const CGAL_Polyhedron &p) double x3 = CGAL::to_double(v3.point().x()); double y3 = CGAL::to_double(v3.point().y()); double z3 = CGAL::to_double(v3.point().z()); - ps->append_poly(); - ps->append_vertex(x1, y1, z1); - ps->append_vertex(x2, y2, z2); - ps->append_vertex(x3, y3, z3); + ps.append_poly(); + ps.append_vertex(x1, y1, z1); + ps.append_vertex(x2, y2, z2); + ps.append_vertex(x3, y3, z3); } while (hc != hc_end); } - return ps; + return err; } #undef GEN_SURFACE_DEBUG @@ -127,22 +126,20 @@ public: } }; -CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps) +bool createPolyhedronFromPolySet(const PolySet &ps, CGAL_Polyhedron &p) { - CGAL_Polyhedron *P = NULL; + bool err = false; CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); try { - P = new CGAL_Polyhedron; CGAL_Build_PolySet builder(ps); - P->delegate(builder); + p.delegate(builder); } catch (const CGAL::Assertion_exception &e) { PRINTB("CGAL error in CGAL_Build_PolySet: %s", e.what()); - delete P; - P = NULL; + err = true; } CGAL::set_error_behaviour(old_behaviour); - return P; + return err; } CGAL_Iso_cuboid_3 bounding_box( const CGAL_Nef_polyhedron3 &N ) |