From d25e197ac7d72214bbdc2753ef84104932c625dd Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sun, 11 Sep 2011 11:07:18 +0200 Subject: Forgot to commit CGALCache class diff --git a/src/CGALCache.cc b/src/CGALCache.cc new file mode 100644 index 0000000..6bdad41 --- /dev/null +++ b/src/CGALCache.cc @@ -0,0 +1,17 @@ +#include "CGALCache.h" +#include "printutils.h" +#include "CGAL_Nef_polyhedron.h" + +CGALCache *CGALCache::inst = NULL; + +void CGALCache::insert(const std::string &id, const CGAL_Nef_polyhedron &N) +{ + this->cache.insert(id, new CGAL_Nef_polyhedron(N), N.weight()); + PRINTF("CGAL Cache insert: %s (%d verts)", id.substr(0, 40).c_str(), N.weight()); +} + +void CGALCache::print() +{ + PRINTF("CGAL Polyhedrons in cache: %d", this->cache.size()); + PRINTF("Vertices in cache: %d", this->cache.totalCost()); +} diff --git a/src/CGALCache.h b/src/CGALCache.h new file mode 100644 index 0000000..7d3a2d9 --- /dev/null +++ b/src/CGALCache.h @@ -0,0 +1,28 @@ +#ifndef CGALCACHE_H_ +#define CGALCACHE_H_ + +#include "myqhash.h" +#include + +/*! +*/ +class CGALCache +{ +public: + CGALCache(size_t limit = 100000) : cache(limit) {} + + static CGALCache *instance() { if (!inst) inst = new CGALCache; return inst; } + + bool contains(const std::string &id) const { return this->cache.contains(id); } + const class CGAL_Nef_polyhedron &get(const std::string &id) const { return *this->cache[id]; } + void insert(const std::string &id, const CGAL_Nef_polyhedron &N); + void clear() { cache.clear(); } + void print(); + +private: + static CGALCache *inst; + + QCache cache; +}; + +#endif -- cgit v0.10.1