summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-11 08:51:55 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-11 08:51:55 (GMT)
commit95949cf961d84f65ad9bfb9f2dec7361059ca515 (patch)
treeb5d50e381362d013d8cce12c524571f013a990a2
parent18e97e0bd3f6bda4fdcd17de2a85173ba59b6b00 (diff)
Implemented CGAL caching
-rw-r--r--openscad.pro2
-rw-r--r--src/CGALEvaluator.cc92
-rw-r--r--src/CGALEvaluator.h8
-rw-r--r--src/CGAL_Nef_polyhedron.cc4
-rw-r--r--src/CGAL_Nef_polyhedron.h12
-rw-r--r--src/PolySetCGALEvaluator.cc2
-rw-r--r--src/PolySetEvaluator.cc8
-rw-r--r--src/Tree.cc24
-rw-r--r--src/Tree.h2
-rw-r--r--src/mainwin.cc11
-rw-r--r--src/nodecache.h5
-rw-r--r--src/openscad.cc4
-rw-r--r--tests/CMakeLists.txt6
-rw-r--r--tests/cgalpngtest.cc8
-rw-r--r--tests/cgaltest.cc8
-rw-r--r--tests/opencsgtest.cc3
16 files changed, 92 insertions, 107 deletions
diff --git a/openscad.pro b/openscad.pro
index baa9899..1abca19 100644
--- a/openscad.pro
+++ b/openscad.pro
@@ -217,6 +217,7 @@ HEADERS += src/cgal.h \
src/cgalfwd.h \
src/cgalutils.h \
src/CGALEvaluator.h \
+ src/CGALCache.h \
src/PolySetCGALEvaluator.h \
src/CGALRenderer.h \
src/CGAL_Nef_polyhedron.h
@@ -224,6 +225,7 @@ HEADERS += src/cgal.h \
SOURCES += src/cgalutils.cc \
src/CGALEvaluator.cc \
src/PolySetCGALEvaluator.cc \
+ src/CGALCache.cc \
src/CGALRenderer.cc \
src/CGAL_Nef_polyhedron.cc \
src/CGAL_Nef_polyhedron_DxfData.cc \
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc
index 51fe41a..d950cb8 100644
--- a/src/CGALEvaluator.cc
+++ b/src/CGALEvaluator.cc
@@ -1,3 +1,4 @@
+#include "CGALCache.h"
#include "CGALEvaluator.h"
#include "visitor.h"
#include "state.h"
@@ -11,6 +12,7 @@
#include "dxfdata.h"
#include "dxftess.h"
+#include "CGALCache.h"
#include "cgal.h"
#include "cgalutils.h"
#include <CGAL/assertions_behaviour.h>
@@ -31,12 +33,12 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const AbstractNode &node)
evaluate.execute();
assert(isCached(node));
}
- return this->cache[this->tree.getString(node)];
+ return CGALCache::instance()->get(this->tree.getIdString(node));
}
bool CGALEvaluator::isCached(const AbstractNode &node) const
{
- return this->cache.contains(this->tree.getString(node));
+ return CGALCache::instance()->contains(this->tree.getIdString(node));
}
/*!
@@ -68,10 +70,8 @@ void CGALEvaluator::process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedr
}
/*!
- FIXME: Let caller insert into the cache since caller might modify the result
- (e.g. transform)
*/
-void CGALEvaluator::applyToChildren(const AbstractNode &node, CGALEvaluator::CsgOp op)
+CGAL_Nef_polyhedron CGALEvaluator::applyToChildren(const AbstractNode &node, CGALEvaluator::CsgOp op)
{
CGAL_Nef_polyhedron N;
if (this->visitedchildren[node.index()].size() > 0) {
@@ -84,20 +84,21 @@ void CGALEvaluator::applyToChildren(const AbstractNode &node, CGALEvaluator::Csg
if (chnode->modinst->tag_background) continue;
assert(isCached(*chnode));
if (N.empty()) {
- N = this->cache[chcacheid].copy();
+ N = CGALCache::instance()->get(chcacheid).copy();
} else {
- process(N, this->cache[chcacheid], op);
+ process(N, CGALCache::instance()->get(chcacheid), op);
}
chnode->progress_report();
}
}
- this->cache.insert(this->tree.getString(node), N);
+ return N;
}
extern CGAL_Nef_polyhedron2 *convexhull2(std::list<CGAL_Nef_polyhedron2*> a);
-void CGALEvaluator::applyHull(const CgaladvNode &node)
+CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node)
{
+ CGAL_Nef_polyhedron N;
if (this->visitedchildren[node.index()].size() > 0) {
std::list<CGAL_Nef_polyhedron2*> polys;
bool all2d = true;
@@ -109,9 +110,9 @@ void CGALEvaluator::applyHull(const CgaladvNode &node)
// FIXME: Don't use deep access to modinst members
if (chnode->modinst->tag_background) continue;
assert(isCached(*chnode));
- const CGAL_Nef_polyhedron &ch = this->cache[chcacheid];
+ const CGAL_Nef_polyhedron &ch = CGALCache::instance()->get(chcacheid);
if (ch.dim == 2) {
- polys.push_back(ch.p2);
+ polys.push_back(ch.p2.get());
}
else if (ch.dim == 3) {
PRINT("WARNING: hull() is not implemented yet for 3D objects!");
@@ -121,10 +122,10 @@ void CGALEvaluator::applyHull(const CgaladvNode &node)
}
if (all2d) {
- CGAL_Nef_polyhedron N(convexhull2(polys));
- this->cache.insert(this->tree.getString(node), N);
+ N = CGAL_Nef_polyhedron(convexhull2(polys));
}
}
+ return N;
}
/*
@@ -138,7 +139,10 @@ Response CGALEvaluator::visit(State &state, const AbstractNode &node)
{
if (state.isPrefix() && isCached(node)) return PruneTraversal;
if (state.isPostfix()) {
- if (!isCached(node)) applyToChildren(node, CGE_UNION);
+ if (!isCached(node)) {
+ CGAL_Nef_polyhedron N = applyToChildren(node, CGE_UNION);
+ CGALCache::instance()->insert(this->tree.getIdString(node), N);
+ }
addToParent(state, node);
}
return ContinueTraversal;
@@ -148,7 +152,10 @@ Response CGALEvaluator::visit(State &state, const AbstractIntersectionNode &node
{
if (state.isPrefix() && isCached(node)) return PruneTraversal;
if (state.isPostfix()) {
- if (!isCached(node)) applyToChildren(node, CGE_INTERSECTION);
+ if (!isCached(node)) {
+ CGAL_Nef_polyhedron N = applyToChildren(node, CGE_INTERSECTION);
+ CGALCache::instance()->insert(this->tree.getIdString(node), N);
+ }
addToParent(state, node);
}
return ContinueTraversal;
@@ -173,7 +180,8 @@ Response CGALEvaluator::visit(State &state, const CsgNode &node)
default:
assert(false);
}
- applyToChildren(node, op);
+ CGAL_Nef_polyhedron N = applyToChildren(node, op);
+ CGALCache::instance()->insert(this->tree.getIdString(node), N);
}
addToParent(state, node);
}
@@ -186,10 +194,9 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node)
if (state.isPostfix()) {
if (!isCached(node)) {
// First union all children
- applyToChildren(node, CGE_UNION);
+ CGAL_Nef_polyhedron N = applyToChildren(node, CGE_UNION);
// Then apply transform
- CGAL_Nef_polyhedron N = this->cache[this->tree.getString(node)];
// If there is no geometry under the transform, N will be empty and of dim 0,
// just just silently ignore such nodes
if (N.dim == 2) {
@@ -223,7 +230,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);
}
- this->cache.insert(this->tree.getString(node), N);
+ CGALCache::instance()->insert(this->tree.getIdString(node), N);
}
addToParent(state, node);
}
@@ -239,16 +246,11 @@ Response CGALEvaluator::visit(State &state, const AbstractPolyNode &node)
shared_ptr<PolySet> ps = this->psevaluator.getPolySet(node, false);
CGAL_Nef_polyhedron N;
if (ps) {
- try {
- N = evaluateCGALMesh(*ps);
+ N = evaluateCGALMesh(*ps);
// print_messages_pop();
- node.progress_report();
- }
- catch (...) {
- throw;
- }
+ node.progress_report();
}
- this->cache.insert(this->tree.getString(node), N);
+ CGALCache::instance()->insert(this->tree.getIdString(node), N);
}
addToParent(state, node);
}
@@ -260,11 +262,12 @@ Response CGALEvaluator::visit(State &state, const CgaladvNode &node)
if (state.isPrefix() && isCached(node)) return PruneTraversal;
if (state.isPostfix()) {
if (!isCached(node)) {
+ CGAL_Nef_polyhedron N;
CGALEvaluator::CsgOp op;
switch (node.type) {
case MINKOWSKI:
op = CGE_MINKOWSKI;
- applyToChildren(node, op);
+ N = applyToChildren(node, op);
break;
case GLIDE:
PRINT("WARNING: glide() is not implemented yet!");
@@ -275,9 +278,10 @@ Response CGALEvaluator::visit(State &state, const CgaladvNode &node)
return PruneTraversal;
break;
case HULL:
- applyHull(node);
+ N = applyHull(node);
break;
}
+ CGALCache::instance()->insert(this->tree.getIdString(node), N);
}
addToParent(state, node);
}
@@ -293,37 +297,9 @@ void CGALEvaluator::addToParent(const State &state, const AbstractNode &node)
assert(state.isPostfix());
this->visitedchildren.erase(node.index());
if (state.parent()) {
- this->visitedchildren[state.parent()->index()].push_back(std::make_pair(&node, this->tree.getString(node)));
- }
-}
-
-#if 0
-/*!
- Static function to evaluate CGAL meshes.
- NB! This is just a support function used for development and debugging
-*/
-CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const AbstractPolyNode &node)
-{
- // FIXME: Lookup Nef polyhedron in cache.
-
- // print_messages_push();
-
- shared_ptr<PolySet> ps = this->psevaluator->getPolySet(node, false);
- if (ps) {
- try {
- CGAL_Nef_polyhedron N = ps->evaluateCSGMesh();
- // FIXME: Insert into cache
- // print_messages_pop();
- node.progress_report();
-
- return N;
- }
- catch (...) { // Don't leak the PolySet on ProgressCancelException
- throw;
- }
+ this->visitedchildren[state.parent()->index()].push_back(std::make_pair(&node, this->tree.getIdString(node)));
}
}
-#endif
CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const PolySet &ps)
{
diff --git a/src/CGALEvaluator.h b/src/CGALEvaluator.h
index a8e9844..c1b5ae8 100644
--- a/src/CGALEvaluator.h
+++ b/src/CGALEvaluator.h
@@ -20,8 +20,7 @@ class CGALEvaluator : public Visitor
{
public:
enum CsgOp {CGE_UNION, CGE_INTERSECTION, CGE_DIFFERENCE, CGE_MINKOWSKI};
- // FIXME: If a cache is not given, we need to fix this ourselves
- CGALEvaluator(QHash<string, CGAL_Nef_polyhedron> &cache, const Tree &tree) : cache(cache), tree(tree), psevaluator(*this) {}
+ CGALEvaluator(const Tree &tree) : tree(tree), psevaluator(*this) {}
virtual ~CGALEvaluator() {}
virtual Response visit(State &state, const AbstractNode &node);
@@ -40,14 +39,13 @@ private:
void addToParent(const State &state, const AbstractNode &node);
bool isCached(const AbstractNode &node) const;
void process(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedron &src, CGALEvaluator::CsgOp op);
- void applyToChildren(const AbstractNode &node, CGALEvaluator::CsgOp op);
- void applyHull(const CgaladvNode &node);
+ CGAL_Nef_polyhedron applyToChildren(const AbstractNode &node, CGALEvaluator::CsgOp op);
+ CGAL_Nef_polyhedron applyHull(const CgaladvNode &node);
string currindent;
typedef list<pair<const AbstractNode *, string> > ChildList;
map<int, ChildList> visitedchildren;
- QHash<string, CGAL_Nef_polyhedron> &cache;
const Tree &tree;
public:
// FIXME: Do we need to make this visible? Used for cache management
diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc
index ea08ca1..975c9a4 100644
--- a/src/CGAL_Nef_polyhedron.cc
+++ b/src/CGAL_Nef_polyhedron.cc
@@ -85,7 +85,7 @@ PolySet *CGAL_Nef_polyhedron::convertToPolyset()
CGAL_Nef_polyhedron CGAL_Nef_polyhedron::copy() const
{
CGAL_Nef_polyhedron copy = *this;
- if (copy.p2) copy.p2 = new CGAL_Nef_polyhedron2(*copy.p2);
- else if (copy.p3) copy.p3 = new CGAL_Nef_polyhedron3(*copy.p3);
+ if (copy.p2) copy.p2.reset(new CGAL_Nef_polyhedron2(*copy.p2));
+ else if (copy.p3) copy.p3.reset(new CGAL_Nef_polyhedron3(*copy.p3));
return copy;
}
diff --git a/src/CGAL_Nef_polyhedron.h b/src/CGAL_Nef_polyhedron.h
index 616ba23..a2eedaf 100644
--- a/src/CGAL_Nef_polyhedron.h
+++ b/src/CGAL_Nef_polyhedron.h
@@ -4,13 +4,14 @@
#ifdef ENABLE_CGAL
#include "cgalfwd.h"
+#include "memory.h"
class CGAL_Nef_polyhedron
{
public:
- CGAL_Nef_polyhedron() : dim(0), p2(0), p3(0) {}
- CGAL_Nef_polyhedron(CGAL_Nef_polyhedron2 *p) : dim(2), p2(p), p3(0) {}
- CGAL_Nef_polyhedron(CGAL_Nef_polyhedron3 *p) : dim(3), p2(0), p3(p) {}
+ 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() {}
bool empty() const { return (dim == 0 || !p2 && !p3); }
@@ -24,9 +25,8 @@ public:
class DxfData *convertToDxfData() const;
int dim;
- // FIXME: Define ownership of the CGAL objects, e.g. use reference-counted smart pointers
- CGAL_Nef_polyhedron2 *p2;
- CGAL_Nef_polyhedron3 *p3;
+ shared_ptr<CGAL_Nef_polyhedron2> p2;
+ shared_ptr<CGAL_Nef_polyhedron3> p3;
};
#endif /* ENABLE_CGAL */
diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc
index 9f9ab6e..b019ad5 100644
--- a/src/PolySetCGALEvaluator.cc
+++ b/src/PolySetCGALEvaluator.cc
@@ -162,7 +162,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node)
// FIXME: Should the CGAL_Nef_polyhedron2 be cached?
if (np.empty()) {
np.dim = 2;
- np.p2 = new CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED);
+ np.p2.reset(new CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED));
}
else {
(*np.p2) += CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED);
diff --git a/src/PolySetEvaluator.cc b/src/PolySetEvaluator.cc
index e46ae59..1f09127 100644
--- a/src/PolySetEvaluator.cc
+++ b/src/PolySetEvaluator.cc
@@ -10,11 +10,6 @@
class.
*/
-static bool filter(char c)
-{
- return c == ' ' || c == '\n' || c == '\t' || c == '\r';
-}
-
/*!
Factory method returning a PolySet from the given node. If the
node is already cached, the cached PolySet will be returned
@@ -23,8 +18,7 @@ static bool filter(char c)
*/
shared_ptr<PolySet> PolySetEvaluator::getPolySet(const AbstractNode &node, bool cache)
{
- std::string cacheid = this->tree.getString(node);
- cacheid.erase(std::remove_if(cacheid.begin(), cacheid.end(), filter), cacheid.end());
+ std::string cacheid = this->tree.getIdString(node);
if (PolySetCache::instance()->contains(cacheid)) {
// For cache debugging
diff --git a/src/Tree.cc b/src/Tree.cc
index e791e12..68cb2bf 100644
--- a/src/Tree.cc
+++ b/src/Tree.cc
@@ -21,6 +21,30 @@ const std::string &Tree::getString(const AbstractNode &node) const
return this->nodecache[node];
}
+static bool filter(char c)
+{
+ return c == ' ' || c == '\n' || c == '\t' || c == '\r';
+}
+
+/*!
+ Returns the cached ID string representation of the subtree rooted by \a node.
+ If node is not cached, the cache will be rebuilt.
+
+ The difference between this method and getString() is that the ID string
+ is stripped for whitespace. Especially indentation whitespace is important to
+ strip to enable cache hits for equivalent nodes from different scopes.
+*/
+const std::string &Tree::getIdString(const AbstractNode &node) const
+{
+ assert(this->root_node);
+ if (!this->nodeidcache.contains(node)) {
+ std::string str = getString(node);
+ str.erase(std::remove_if(str.begin(), str.end(), filter), str.end());
+ return this->nodeidcache.insert(node, str);
+ }
+ return this->nodeidcache[node];
+}
+
/*!
Sets a new root. Will clear the existing cache.
*/
diff --git a/src/Tree.h b/src/Tree.h
index 5df5bba..aaa61d7 100644
--- a/src/Tree.h
+++ b/src/Tree.h
@@ -21,10 +21,12 @@ public:
const AbstractNode *root() const { return this->root_node; }
const string &getString(const AbstractNode &node) const;
+ const string &getIdString(const AbstractNode &node) const;
private:
const AbstractNode *root_node;
mutable NodeCache nodecache;
+ mutable NodeCache nodeidcache;
};
#endif
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 130e237..f9b60a6 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -86,6 +86,7 @@ using namespace boost::lambda;
#ifdef ENABLE_CGAL
+#include "CGALCache.h"
#include "CGALEvaluator.h"
#include "PolySetCGALEvaluator.h"
#include "CGALRenderer.h"
@@ -780,9 +781,7 @@ void MainWindow::compileCSG(bool procevents)
progress_report_prep(root_node, report_func, pd);
try {
- // FIXME: put cache somewhere else as it's pretty useless now
- QHash<std::string, CGAL_Nef_polyhedron> cache;
- CGALEvaluator cgalevaluator(cache, this->tree);
+ CGALEvaluator cgalevaluator(this->tree);
PolySetCGALEvaluator psevaluator(cgalevaluator);
CSGTermEvaluator csgrenderer(this->tree, &psevaluator);
root_raw_term = csgrenderer.evaluateCSGTerm(*root_node, highlight_terms, background_terms);
@@ -792,6 +791,7 @@ void MainWindow::compileCSG(bool procevents)
QApplication::processEvents();
}
PolySetCache::instance()->print();
+ CGALCache::instance()->print();
}
catch (ProgressCancelException e) {
PRINT("CSG generation cancelled.");
@@ -1223,11 +1223,10 @@ void MainWindow::actionRenderCGAL()
progress_report_prep(this->root_node, report_func, pd);
try {
- // FIXME: put cache somewhere else as it's pretty useless now
- QHash<std::string, CGAL_Nef_polyhedron> cache;
- CGALEvaluator evaluator(cache, this->tree);
+ CGALEvaluator evaluator(this->tree);
this->root_N = new CGAL_Nef_polyhedron(evaluator.evaluateCGALMesh(*this->root_node));
PolySetCache::instance()->print();
+ CGALCache::instance()->print();
}
catch (ProgressCancelException e) {
PRINT("Rendering cancelled.");
diff --git a/src/nodecache.h b/src/nodecache.h
index cc3355e..61afe3e 100644
--- a/src/nodecache.h
+++ b/src/nodecache.h
@@ -25,9 +25,10 @@ public:
else return this->nullvalue;
}
- void insert(const class AbstractNode &node, const std::string & value) {
+ /*! Returns a reference to the cached string copy */
+ const std::string &insert(const class AbstractNode &node, const std::string & value) {
if (this->cache.size() <= node.index()) this->cache.resize(node.index() + 1);
- this->cache[node.index()] = value;
+ return this->cache[node.index()] = value;
}
void remove(const class AbstractNode &node) {
diff --git a/src/openscad.cc b/src/openscad.cc
index c3ee389..fd74de4 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -249,9 +249,7 @@ int main(int argc, char **argv)
NodeDumper dumper(nodecache);
Tree tree;
#ifdef ENABLE_CGAL
- // FIXME: enforce some maximum cache size (old version had 100K vertices as limit)
- QHash<std::string, CGAL_Nef_polyhedron> cache;
- CGALEvaluator cgalevaluator(cache, tree);
+ CGALEvaluator cgalevaluator(tree);
PolySetCGALEvaluator psevaluator(cgalevaluator);
#endif
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 08ae030..509180e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -144,7 +144,7 @@ include_directories(${CGAL_INCLUDE_DIRS})
# cgaltest
#
add_executable(cgaltest cgaltest.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc ../src/CSGTermEvaluator.cc
- ../src/CGALEvaluator.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc
+ ../src/CGALEvaluator.cc ../src/CGALCache.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc
../src/CGAL_Nef_polyhedron_DxfData.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_convexhull2.cc
${COMMON_SOURCES})
set_target_properties(cgaltest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
@@ -155,7 +155,7 @@ target_link_libraries(cgaltest ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_
#
add_executable(cgalpngtest cgalpngtest.cc OffscreenView.cc OffscreenContext.mm
../src/CGALRenderer.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc
- ../src/CSGTermEvaluator.cc ../src/CGALEvaluator.cc
+ ../src/CSGTermEvaluator.cc ../src/CGALEvaluator.cc ../src/CGALCache.cc
../src/PolySetCGALEvaluator.cc ../src/qhash.cc
../src/CGAL_Nef_polyhedron_DxfData.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_convexhull2.cc
${COMMON_SOURCES})
@@ -168,7 +168,7 @@ target_link_libraries(cgalpngtest ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${
add_executable(opencsgtest opencsgtest.cc OffscreenView.cc OffscreenContext.mm
../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc
../src/CSGTermEvaluator.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc
- ../src/CGALEvaluator.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc
+ ../src/CGALEvaluator.cc ../src/CGALCache.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc
../src/CGAL_Nef_polyhedron_DxfData.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_convexhull2.cc
${COMMON_SOURCES})
set_target_properties(opencsgtest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc
index 8e3859b..4c5c914 100644
--- a/tests/cgalpngtest.cc
+++ b/tests/cgalpngtest.cc
@@ -59,14 +59,11 @@ QString librarydir;
using std::string;
-// FIXME: enforce some maximum cache size (old version had 100K vertices as limit)
-QHash<std::string, CGAL_Nef_polyhedron> cache;
-
void cgalTree(Tree &tree)
{
assert(tree.root());
- CGALEvaluator evaluator(cache, tree);
+ CGALEvaluator evaluator(tree);
Traverser evaluate(evaluator, *tree.root(), Traverser::PRE_AND_POSTFIX);
evaluate.execute();
}
@@ -174,8 +171,7 @@ int main(int argc, char **argv)
Tree tree(root_node);
CsgInfo csgInfo;
- QHash<std::string, CGAL_Nef_polyhedron> cache;
- CGALEvaluator cgalevaluator(cache, tree);
+ CGALEvaluator cgalevaluator(tree);
PolySetCGALEvaluator psevaluator(cgalevaluator);
CGAL_Nef_polyhedron N = cgalevaluator.evaluateCGALMesh(*root_node);
diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc
index 029fcfc..8dfb63c 100644
--- a/tests/cgaltest.cc
+++ b/tests/cgaltest.cc
@@ -54,14 +54,11 @@ QString librarydir;
using std::string;
-// FIXME: enforce some maximum cache size (old version had 100K vertices as limit)
-QHash<std::string, CGAL_Nef_polyhedron> cache;
-
void cgalTree(Tree &tree)
{
assert(tree.root());
- CGALEvaluator evaluator(cache, tree);
+ CGALEvaluator evaluator(tree);
Traverser evaluate(evaluator, *tree.root(), Traverser::PRE_AND_POSTFIX);
evaluate.execute();
}
@@ -163,8 +160,7 @@ int main(int argc, char **argv)
Tree tree(root_node);
- QHash<std::string, CGAL_Nef_polyhedron> cache;
- CGALEvaluator cgalevaluator(cache, tree);
+ CGALEvaluator cgalevaluator(tree);
PolySetCGALEvaluator psevaluator(cgalevaluator);
CGAL_Nef_polyhedron N = cgalevaluator.evaluateCGALMesh(*root_node);
diff --git a/tests/opencsgtest.cc b/tests/opencsgtest.cc
index 28c0daa..59501a0 100644
--- a/tests/opencsgtest.cc
+++ b/tests/opencsgtest.cc
@@ -142,8 +142,7 @@ int main(int argc, char *argv[])
Tree tree(root_node);
CsgInfo csgInfo;
- QHash<std::string, CGAL_Nef_polyhedron> cache;
- CGALEvaluator cgalevaluator(cache, tree);
+ CGALEvaluator cgalevaluator(tree);
CSGTermEvaluator evaluator(tree, &cgalevaluator.psevaluator);
CSGTerm *root_raw_term = evaluator.evaluateCSGTerm(*root_node,
csgInfo.highlight_terms,
contact: Jan Huwald // Impressum