summaryrefslogtreecommitdiff
path: root/src/CGALEvaluator.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-12-14 23:20:35 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-12-14 23:20:35 (GMT)
commit0a2b7ca0d4d7fb1acda9996d69b25ff6b5495856 (patch)
tree465fb326c433297bb88182de7f215ff21925cf5f /src/CGALEvaluator.cc
parentf175bae46a8f15823780c5a9c89b11476acb3107 (diff)
FIXME leaking polyset by altering functions signatures
Diffstat (limited to 'src/CGALEvaluator.cc')
-rw-r--r--src/CGALEvaluator.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc
index ec01315..26d3e4c 100644
--- a/src/CGALEvaluator.cc
+++ b/src/CGALEvaluator.cc
@@ -668,16 +668,30 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const PolySet &ps)
else // not (this->is2d)
{
CGAL_Nef_polyhedron3 *N = NULL;
+ bool plane_error = false;
CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
try {
- // FIXME: Are we leaking memory for the CGAL_Polyhedron object?
- CGAL_Polyhedron *P = createPolyhedronFromPolySet(ps);
- if (P) {
- N = new CGAL_Nef_polyhedron3(*P);
+ CGAL_Polyhedron P;
+ createPolyhedronFromPolySet(ps,P);
+ N = new CGAL_Nef_polyhedron3(P);
+ }
+ catch (const CGAL::Assertion_exception &e) {
+ if (std::string(e.what()).find("Plane_constructor")!=std::string::npos) {
+ PRINT("PolySet has nonplanar faces. Attempting alternate construction");
+ plane_error=true;
+ } else {
+ PRINTB("CGAL error in CGAL_Nef_polyhedron3(): %s", e.what());
}
}
+ if (plane_error) try {
+ PolySet ps2;
+ CGAL_Polyhedron P;
+ tessellate_faces( ps, ps2 );
+ createPolyhedronFromPolySet(ps2,P);
+ N = new CGAL_Nef_polyhedron3(P);
+ }
catch (const CGAL::Assertion_exception &e) {
- PRINTB("CGAL error in CGAL_Nef_polyhedron3(): %s", e.what());
+ PRINTB("Alternate construction failed. CGAL error in CGAL_Nef_polyhedron3(): %s", e.what());
}
CGAL::set_error_behaviour(old_behaviour);
return CGAL_Nef_polyhedron(N);
contact: Jan Huwald // Impressum