summaryrefslogtreecommitdiff
path: root/src/CGALCache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/CGALCache.cc')
-rw-r--r--src/CGALCache.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/CGALCache.cc b/src/CGALCache.cc
index 9f308f0..8a92082 100644
--- a/src/CGALCache.cc
+++ b/src/CGALCache.cc
@@ -8,12 +8,23 @@ CGALCache::CGALCache(size_t limit) : cache(limit)
{
}
-void CGALCache::insert(const std::string &id, const CGAL_Nef_polyhedron &N)
+const CGAL_Nef_polyhedron &CGALCache::get(const std::string &id) const
{
- this->cache.insert(id, new CGAL_Nef_polyhedron(N), N.weight());
+ const CGAL_Nef_polyhedron &N = *this->cache[id];
#ifdef DEBUG
- PRINTF("CGAL Cache insert: %s (%d bytes)", id.substr(0, 40).c_str(), N.weight());
+ PRINTF("CGAL Cache hit: %s (%d bytes)", id.substr(0, 40).c_str(), N.weight());
#endif
+ return N;
+}
+
+bool CGALCache::insert(const std::string &id, const CGAL_Nef_polyhedron &N)
+{
+ bool inserted = this->cache.insert(id, new CGAL_Nef_polyhedron(N), N.weight());
+#ifdef DEBUG
+ if (inserted) PRINTF("CGAL Cache insert: %s (%d bytes)", id.substr(0, 40).c_str(), N.weight());
+ else PRINTF("CGAL Cache insert failed: %s (%d bytes)", id.substr(0, 40).c_str(), N.weight());
+#endif
+ return inserted;
}
size_t CGALCache::maxSize() const
contact: Jan Huwald // Impressum