summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CGALEvaluator.cc11
-rw-r--r--src/CGAL_Nef_polyhedron.cc23
-rw-r--r--src/CGAL_Nef_polyhedron.h4
-rw-r--r--src/cgalutils.cc4
4 files changed, 34 insertions, 8 deletions
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc
index 7921b85..78b9c78 100644
--- a/src/CGALEvaluator.cc
+++ b/src/CGALEvaluator.cc
@@ -598,19 +598,20 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const PolySet &ps)
}
else // not (this->is2d)
{
+ CGAL_Nef_polyhedron3 *N = NULL;
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) {
- CGAL_Nef_polyhedron3 *N = new CGAL_Nef_polyhedron3(*P);
- return CGAL_Nef_polyhedron(N);
+ N = new CGAL_Nef_polyhedron3(*P);
}
}
catch (CGAL::Assertion_exception e) {
- PRINTF("CGAL error in CGA_Nef_polyhedron3(): %s", e.what());
- CGAL::set_error_behaviour(old_behaviour);
- return CGAL_Nef_polyhedron();
+ PRINTF("CGAL error in CGAL_Nef_polyhedron3(): %s", e.what());
}
+ CGAL::set_error_behaviour(old_behaviour);
+ return CGAL_Nef_polyhedron(N);
}
return CGAL_Nef_polyhedron();
}
diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc
index 2538b64..61ca2f8 100644
--- a/src/CGAL_Nef_polyhedron.cc
+++ b/src/CGAL_Nef_polyhedron.cc
@@ -7,6 +7,29 @@
#include "dxftess.h"
#include <CGAL/minkowski_sum_3.h>
+CGAL_Nef_polyhedron::CGAL_Nef_polyhedron(CGAL_Nef_polyhedron2 *p)
+{
+ if (p) {
+ dim = 2;
+ p2.reset(p);
+ }
+ else {
+ dim = 0;
+ }
+}
+
+CGAL_Nef_polyhedron::CGAL_Nef_polyhedron(CGAL_Nef_polyhedron3 *p)
+{
+ if (p) {
+ dim = 3;
+ p3.reset(p);
+ }
+ else {
+ dim = 0;
+ }
+}
+
+
CGAL_Nef_polyhedron& CGAL_Nef_polyhedron::operator+=(const CGAL_Nef_polyhedron &other)
{
if (this->dim == 2) (*this->p2) += (*other.p2);
diff --git a/src/CGAL_Nef_polyhedron.h b/src/CGAL_Nef_polyhedron.h
index fda4bc5..f93905f 100644
--- a/src/CGAL_Nef_polyhedron.h
+++ b/src/CGAL_Nef_polyhedron.h
@@ -8,8 +8,8 @@ class CGAL_Nef_polyhedron
{
public:
CGAL_Nef_polyhedron() : dim(0) {}
- CGAL_Nef_polyhedron(CGAL_Nef_polyhedron2 *p) : dim(2), p2(p) {}
- CGAL_Nef_polyhedron(CGAL_Nef_polyhedron3 *p) : dim(3), p3(p) {}
+ CGAL_Nef_polyhedron(CGAL_Nef_polyhedron2 *p);
+ CGAL_Nef_polyhedron(CGAL_Nef_polyhedron3 *p);
~CGAL_Nef_polyhedron() {}
bool empty() const { return (dim == 0 || (!p2 && !p3)); }
diff --git a/src/cgalutils.cc b/src/cgalutils.cc
index e77f5dd..1de7ab4 100644
--- a/src/cgalutils.cc
+++ b/src/cgalutils.cc
@@ -140,8 +140,10 @@ CGAL_Polyhedron *createPolyhedronFromPolySet(const PolySet &ps)
}
catch (CGAL::Assertion_exception e) {
PRINTF("CGAL error in CGAL_Build_PolySet: %s", e.what());
- CGAL::set_error_behaviour(old_behaviour);
+ delete P;
+ P = NULL;
}
+ CGAL::set_error_behaviour(old_behaviour);
return P;
}
contact: Jan Huwald // Impressum