Compile-time options to manipulate caching behaviour

This commit is contained in:
Thomas Krijnen
2016-03-18 11:21:04 +01:00
parent 614148e5e4
commit 8ecc1269d7
5 changed files with 36 additions and 13 deletions
+23 -1
View File
@@ -46,22 +46,35 @@
#include "../ifcgeom/IfcRepresentationShapeItem.h"
#include "../ifcgeom/IfcGeomShapeType.h"
#define NO_CACHE
#ifdef NO_CACHE
#define IN_CACHE(T,E,t,e)
#define CACHE(T,E,e)
#else
#define IN_CACHE(T,E,t,e) std::map<int,t>::const_iterator it = cache.T.find(E->entity->id());\
if ( it != cache.T.end() ) { e = it->second; return true; }
#define CACHE(T,E,e) cache.T[E->entity->id()] = e;
#endif
namespace IfcGeom {
class Cache {
public:
#include "IfcRegisterCreateCache.h"
std::map<int, SurfaceStyle> Style;
std::map<int, TopoDS_Shape> Shape;
};
class Kernel {
private:
#ifndef NO_CACHE
Cache cache;
#endif
std::map<int, SurfaceStyle> style_cache;
public:
// Tolerances and settings for various geometrical operations:
enum GeomValue {
@@ -182,6 +195,15 @@ public:
return std::make_pair<IfcSchema::IfcSurfaceStyle*, T*>(0,0);
}
void purge_cache() {
// Rather hack-ish, but a stopgap solution to keep memory under control
// for large files. SurfaceStyles need to be kept at all costs, as they
// are read later on when serializing Collada files.
#ifndef NO_CACHE
cache = Cache();
#endif
}
#include "IfcRegisterGeomHeader.h"
};