diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-11 05:33:18 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-11 05:33:18 (GMT) |
commit | c0641d6916775309d64944ca121cc736f0c8d7a1 (patch) | |
tree | 801e0b5d67d13ff4773c5906c9cb68d271a2be02 /src/CGALEvaluator.cc | |
parent | 09cc0496f7ce61e2bcbce80e067e0fac8054599a (diff) |
Reenabled PolySet caching. Pass shared_ptrs to polysets around to better manage memory
Diffstat (limited to 'src/CGALEvaluator.cc')
-rw-r--r-- | src/CGALEvaluator.cc | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 6bd7092..51fe41a 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -91,8 +91,7 @@ void CGALEvaluator::applyToChildren(const AbstractNode &node, CGALEvaluator::Csg chnode->progress_report(); } } - const std::string &cacheid = this->tree.getString(node); - this->cache.insert(cacheid, N); + this->cache.insert(this->tree.getString(node), N); } extern CGAL_Nef_polyhedron2 *convexhull2(std::list<CGAL_Nef_polyhedron2*> a); @@ -123,8 +122,7 @@ void CGALEvaluator::applyHull(const CgaladvNode &node) if (all2d) { CGAL_Nef_polyhedron N(convexhull2(polys)); - const std::string &cacheid = this->tree.getString(node); - this->cache.insert(cacheid, N); + this->cache.insert(this->tree.getString(node), N); } } } @@ -225,8 +223,7 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node) node.matrix[2], node.matrix[6], node.matrix[10], node.matrix[14], node.matrix[15]); N.p3->transform(t); } - const std::string &cacheid = this->tree.getString(node); - this->cache.insert(cacheid, N); + this->cache.insert(this->tree.getString(node), N); } addToParent(state, node); } @@ -239,7 +236,7 @@ Response CGALEvaluator::visit(State &state, const AbstractPolyNode &node) if (state.isPostfix()) { if (!isCached(node)) { // Apply polyset operation - PolySet *ps = this->psevaluator.getPolySet(node); + shared_ptr<PolySet> ps = this->psevaluator.getPolySet(node, false); CGAL_Nef_polyhedron N; if (ps) { try { @@ -251,8 +248,7 @@ Response CGALEvaluator::visit(State &state, const AbstractPolyNode &node) throw; } } - const std::string &cacheid = this->tree.getString(node); - this->cache.insert(cacheid, N); + this->cache.insert(this->tree.getString(node), N); } addToParent(state, node); } @@ -312,7 +308,7 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const AbstractPolyNode &node // print_messages_push(); - PolySet *ps = this->psevaluator->getPolySet(node); + shared_ptr<PolySet> ps = this->psevaluator->getPolySet(node, false); if (ps) { try { CGAL_Nef_polyhedron N = ps->evaluateCSGMesh(); @@ -320,11 +316,9 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const AbstractPolyNode &node // print_messages_pop(); node.progress_report(); - ps->unlink(); return N; } catch (...) { // Don't leak the PolySet on ProgressCancelException - ps->unlink(); throw; } } |