summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-11 05:37:14 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-11 05:37:14 (GMT)
commit9afeded46c0e9023002dc04ba6131adcb39762b1 (patch)
tree0096a12ce36a5b39aa18d7ec5da45c05eb3d42dd
parentb087e68e5430c3dde6adfe452becbaba0f680196 (diff)
parentdc7eeb30d06a928a30ee47a765be3e5a61288d35 (diff)
Merge branch 'polyset-cleanup' into visitor
-rw-r--r--setenv_mjau.sh4
-rw-r--r--src/CGALEvaluator.cc24
-rw-r--r--src/CGALEvaluator.h3
-rw-r--r--src/CGALRenderer.cc2
-rw-r--r--src/CSGTermEvaluator.cc29
-rw-r--r--src/OpenCSGRenderer.cc8
-rw-r--r--src/PolySetCGALEvaluator.cc111
-rw-r--r--src/PolySetCGALEvaluator.h13
-rw-r--r--src/PolySetEvaluator.cc37
-rw-r--r--src/PolySetEvaluator.h36
-rw-r--r--src/ThrownTogetherRenderer.cc2
-rw-r--r--src/Tree.cc15
-rw-r--r--src/Tree.h3
-rw-r--r--src/cgaladv.cc6
-rw-r--r--src/cgaladvnode.h1
-rw-r--r--src/csgterm.cc17
-rw-r--r--src/csgterm.h9
-rw-r--r--src/dxflinextrude.cc9
-rw-r--r--src/dxflinextrudenode.h2
-rw-r--r--src/dxfrotextrude.cc9
-rw-r--r--src/dxfrotextrudenode.h2
-rw-r--r--src/import.cc2
-rw-r--r--src/importnode.h2
-rw-r--r--src/mainwin.cc4
-rw-r--r--src/node.h6
-rw-r--r--src/polyset.cc18
-rw-r--r--src/polyset.h4
-rw-r--r--src/primitives.cc6
-rw-r--r--src/projection.cc8
-rw-r--r--src/projectionnode.h2
-rw-r--r--src/render.cc10
-rw-r--r--src/rendernode.h1
-rw-r--r--src/surface.cc8
-rw-r--r--tests/csgtermtest.cc4
-rw-r--r--tests/opencsgtest.cc3
-rw-r--r--tests/regression/csgtermtest/allmodules-expected.txt2
-rw-r--r--tests/regression/csgtermtest/dxf_linear_extrude-expected.txt2
-rw-r--r--tests/regression/csgtermtest/dxf_rotate_extrude-expected.txt2
-rw-r--r--tests/regression/csgtermtest/linear_extrude-expected.txt2
-rw-r--r--tests/regression/csgtermtest/projection-expected.txt2
-rw-r--r--tests/regression/csgtermtest/rotate_extrude-expected.txt2
-rw-r--r--tests/regression/csgtermtest/surface-expected.txt2
42 files changed, 219 insertions, 215 deletions
diff --git a/setenv_mjau.sh b/setenv_mjau.sh
index b8012f6..f6a16d2 100644
--- a/setenv_mjau.sh
+++ b/setenv_mjau.sh
@@ -5,3 +5,7 @@ export DYLD_LIBRARY_PATH=$MACOSX_DEPLOY_DIR/lib
#export CGALDIR=$PWD/../install/CGAL-3.6
#export QCODEEDITDIR=$PWD/../qcodeedit-2.2.3/install
#export DYLD_LIBRARY_PATH=$OPENCSGDIR/lib:$QCODEEDITDIR/lib
+
+# ccache:
+export PATH=/opt/local/libexec/ccache:$PATH
+export CCACHE_BASEDIR=$PWD/..
diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc
index 34911b1..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);
}
}
}
@@ -216,7 +214,6 @@ Response CGALEvaluator::visit(State &state, const TransformNode &node)
dxf_tesselate(&ps, *dd, 0, true, false, 0);
N = evaluateCGALMesh(ps);
- ps.refcount = 0;
delete dd;
}
else if (N.dim == 3) {
@@ -226,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);
}
@@ -240,23 +236,19 @@ Response CGALEvaluator::visit(State &state, const AbstractPolyNode &node)
if (state.isPostfix()) {
if (!isCached(node)) {
// Apply polyset operation
- PolySet *ps = node.evaluate_polyset(AbstractPolyNode::RENDER_CGAL, &this->psevaluator);
+ shared_ptr<PolySet> ps = this->psevaluator.getPolySet(node, false);
CGAL_Nef_polyhedron N;
if (ps) {
try {
N = evaluateCGALMesh(*ps);
// print_messages_pop();
node.progress_report();
-
- ps->unlink();
}
- catch (...) { // Don't leak the PolySet on ProgressCancelException
- ps->unlink();
+ catch (...) {
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);
}
@@ -316,7 +308,7 @@ CGAL_Nef_polyhedron CGALEvaluator::evaluateCGALMesh(const AbstractPolyNode &node
// print_messages_push();
- PolySet *ps = node.evaluate_polyset(AbstractPolyNode::RENDER_CGAL);
+ shared_ptr<PolySet> ps = this->psevaluator->getPolySet(node, false);
if (ps) {
try {
CGAL_Nef_polyhedron N = ps->evaluateCSGMesh();
@@ -324,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;
}
}
diff --git a/src/CGALEvaluator.h b/src/CGALEvaluator.h
index 2453c25..a8e9844 100644
--- a/src/CGALEvaluator.h
+++ b/src/CGALEvaluator.h
@@ -49,6 +49,9 @@ private:
QHash<string, CGAL_Nef_polyhedron> &cache;
const Tree &tree;
+public:
+ // FIXME: Do we need to make this visible? Used for cache management
+ // Note: psevaluator constructor needs this->tree to be initialized first
PolySetCGALEvaluator psevaluator;
};
diff --git a/src/CGALRenderer.cc b/src/CGALRenderer.cc
index f8e914b..4d165ce 100644
--- a/src/CGALRenderer.cc
+++ b/src/CGALRenderer.cc
@@ -68,7 +68,7 @@ CGALRenderer::CGALRenderer(const CGAL_Nef_polyhedron &root) : root(root)
CGALRenderer::~CGALRenderer()
{
- if (this->polyset) this->polyset->unlink();
+ delete this->polyset;
delete this->polyhedron;
}
diff --git a/src/CSGTermEvaluator.cc b/src/CSGTermEvaluator.cc
index dafa6a6..ebea89c 100644
--- a/src/CSGTermEvaluator.cc
+++ b/src/CSGTermEvaluator.cc
@@ -86,11 +86,11 @@ Response CSGTermEvaluator::visit(State &state, const AbstractIntersectionNode &n
}
static CSGTerm *evaluate_csg_term_from_ps(const State &state,
- vector<CSGTerm*> &highlights,
- vector<CSGTerm*> &background,
- PolySet *ps,
- const ModuleInstantiation *modinst,
- const AbstractNode &node)
+ vector<CSGTerm*> &highlights,
+ vector<CSGTerm*> &background,
+ const shared_ptr<PolySet> &ps,
+ const ModuleInstantiation *modinst,
+ const AbstractNode &node)
{
std::stringstream stream;
stream << node.name() << node.index();
@@ -108,10 +108,12 @@ Response CSGTermEvaluator::visit(State &state, const AbstractPolyNode &node)
{
if (state.isPostfix()) {
CSGTerm *t1 = NULL;
- PolySet *ps = node.evaluate_polyset(AbstractPolyNode::RENDER_OPENCSG, this->psevaluator);
- if (ps) {
- t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
- ps, node.modinst, node);
+ if (this->psevaluator) {
+ shared_ptr<PolySet> ps = this->psevaluator->getPolySet(node, true);
+ if (ps) {
+ t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
+ ps, node.modinst, node);
+ }
}
this->stored_term[node.index()] = t1;
addToParent(state, node);
@@ -182,10 +184,9 @@ Response CSGTermEvaluator::visit(State &state, const RenderNode &node)
{
if (state.isPostfix()) {
CSGTerm *t1 = NULL;
- // FIXME: Calling evaluator directly since we're not a PolyNode. Generalize this.
- PolySet *ps = NULL;
+ shared_ptr<PolySet> ps;
if (this->psevaluator) {
- ps = this->psevaluator->evaluatePolySet(node, AbstractPolyNode::RENDER_OPENCSG);
+ ps = this->psevaluator->getPolySet(node, true);
}
if (ps) {
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
@@ -202,9 +203,9 @@ Response CSGTermEvaluator::visit(State &state, const CgaladvNode &node)
if (state.isPostfix()) {
CSGTerm *t1 = NULL;
// FIXME: Calling evaluator directly since we're not a PolyNode. Generalize this.
- PolySet *ps = NULL;
+ shared_ptr<PolySet> ps;
if (this->psevaluator) {
- ps = this->psevaluator->evaluatePolySet(node, AbstractPolyNode::RENDER_OPENCSG);
+ ps = this->psevaluator->getPolySet(node, true);
}
if (ps) {
t1 = evaluate_csg_term_from_ps(state, this->highlights, this->background,
diff --git a/src/OpenCSGRenderer.cc b/src/OpenCSGRenderer.cc
index a16d920..4a86c5c 100644
--- a/src/OpenCSGRenderer.cc
+++ b/src/OpenCSGRenderer.cc
@@ -28,6 +28,7 @@
#include "OpenCSGRenderer.h"
#include "polyset.h"
#include "csgterm.h"
+#include "stl-utils.h"
#ifdef ENABLE_OPENCSG
# include <opencsg.h>
#endif
@@ -37,13 +38,13 @@ class OpenCSGPrim : public OpenCSG::Primitive
public:
OpenCSGPrim(OpenCSG::Operation operation, unsigned int convexity) :
OpenCSG::Primitive(operation, convexity) { }
- PolySet *p;
+ shared_ptr<PolySet> ps;
double *m;
int csgmode;
virtual void render() {
glPushMatrix();
glMultMatrixd(m);
- p->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m);
+ ps->render_surface(PolySet::COLORMODE_NONE, PolySet::csgmode_e(csgmode), m);
glPopMatrix();
}
};
@@ -120,11 +121,12 @@ void OpenCSGRenderer::renderCSGChain(CSGChain *chain, GLint *shaderinfo,
OpenCSGPrim *prim = new OpenCSGPrim(chain->types[i] == CSGTerm::TYPE_DIFFERENCE ?
OpenCSG::Subtraction : OpenCSG::Intersection, chain->polysets[i]->convexity);
- prim->p = chain->polysets[i];
+ prim->ps = chain->polysets[i];
prim->m = chain->matrices[i];
prim->csgmode = chain->types[i] == CSGTerm::TYPE_DIFFERENCE ? PolySet::CSGMODE_DIFFERENCE : PolySet::CSGMODE_NORMAL;
if (highlight) prim->csgmode += 20;
else if (background) prim->csgmode += 10;
primitives.push_back(prim);
}
+ std::for_each(primitives.begin(), primitives.end(), del_fun<OpenCSG::Primitive>());
}
diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc
index a648587..9f9ab6e 100644
--- a/src/PolySetCGALEvaluator.cc
+++ b/src/PolySetCGALEvaluator.cc
@@ -1,5 +1,6 @@
#include "PolySetCGALEvaluator.h"
#include "cgal.h"
+#include "cgalutils.h"
#include "polyset.h"
#include "CGALEvaluator.h"
#include "projectionnode.h"
@@ -15,11 +16,13 @@
#include "openscad.h" // get_fragments_from_r()
#include <boost/foreach.hpp>
-PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node, AbstractPolyNode::render_mode_e)
+PolySetCGALEvaluator::PolySetCGALEvaluator(CGALEvaluator &cgalevaluator)
+ : PolySetEvaluator(cgalevaluator.getTree()), cgalevaluator(cgalevaluator)
{
- const string &cacheid = this->cgalevaluator.getTree().getString(node);
- if (this->cache.contains(cacheid)) return this->cache[cacheid]->ps->link();
+}
+PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node)
+{
// Before projecting, union all children
CGAL_Nef_polyhedron sum;
BOOST_FOREACH (AbstractNode * v, node.getChildren()) {
@@ -38,47 +41,46 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node, Abstr
if (node.cut_mode)
{
- PolySet *cube = new PolySet();
+ PolySet cube;
double infval = 1e8, eps = 0.1;
double x1 = -infval, x2 = +infval, y1 = -infval, y2 = +infval, z1 = 0, z2 = eps;
- cube->append_poly(); // top
- cube->append_vertex(x1, y1, z2);
- cube->append_vertex(x2, y1, z2);
- cube->append_vertex(x2, y2, z2);
- cube->append_vertex(x1, y2, z2);
-
- cube->append_poly(); // bottom
- cube->append_vertex(x1, y2, z1);
- cube->append_vertex(x2, y2, z1);
- cube->append_vertex(x2, y1, z1);
- cube->append_vertex(x1, y1, z1);
-
- cube->append_poly(); // side1
- cube->append_vertex(x1, y1, z1);
- cube->append_vertex(x2, y1, z1);
- cube->append_vertex(x2, y1, z2);
- cube->append_vertex(x1, y1, z2);
-
- cube->append_poly(); // side2
- cube->append_vertex(x2, y1, z1);
- cube->append_vertex(x2, y2, z1);
- cube->append_vertex(x2, y2, z2);
- cube->append_vertex(x2, y1, z2);
-
- cube->append_poly(); // side3
- cube->append_vertex(x2, y2, z1);
- cube->append_vertex(x1, y2, z1);
- cube->append_vertex(x1, y2, z2);
- cube->append_vertex(x2, y2, z2);
-
- cube->append_poly(); // side4
- cube->append_vertex(x1, y2, z1);
- cube->append_vertex(x1, y1, z1);
- cube->append_vertex(x1, y1, z2);
- cube->append_vertex(x1, y2, z2);
- CGAL_Nef_polyhedron Ncube = this->cgalevaluator.evaluateCGALMesh(*cube);
- cube->unlink();
+ cube.append_poly(); // top
+ cube.append_vertex(x1, y1, z2);
+ cube.append_vertex(x2, y1, z2);
+ cube.append_vertex(x2, y2, z2);
+ cube.append_vertex(x1, y2, z2);
+
+ cube.append_poly(); // bottom
+ cube.append_vertex(x1, y2, z1);
+ cube.append_vertex(x2, y2, z1);
+ cube.append_vertex(x2, y1, z1);
+ cube.append_vertex(x1, y1, z1);
+
+ cube.append_poly(); // side1
+ cube.append_vertex(x1, y1, z1);
+ cube.append_vertex(x2, y1, z1);
+ cube.append_vertex(x2, y1, z2);
+ cube.append_vertex(x1, y1, z2);
+
+ cube.append_poly(); // side2
+ cube.append_vertex(x2, y1, z1);
+ cube.append_vertex(x2, y2, z1);
+ cube.append_vertex(x2, y2, z2);
+ cube.append_vertex(x2, y1, z2);
+
+ cube.append_poly(); // side3
+ cube.append_vertex(x2, y2, z1);
+ cube.append_vertex(x1, y2, z1);
+ cube.append_vertex(x1, y2, z2);
+ cube.append_vertex(x2, y2, z2);
+
+ cube.append_poly(); // side4
+ cube.append_vertex(x1, y2, z1);
+ cube.append_vertex(x1, y1, z1);
+ cube.append_vertex(x1, y1, z2);
+ cube.append_vertex(x1, y2, z2);
+ CGAL_Nef_polyhedron Ncube = this->cgalevaluator.evaluateCGALMesh(cube);
// N.p3 *= CGAL_Nef_polyhedron3(CGAL_Plane(0, 0, 1, 0), CGAL_Nef_polyhedron3::INCLUDED);
sum *= Ncube;
@@ -109,7 +111,7 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node, Abstr
}
next_ps3_polygon_cut_mode:;
}
- ps3->unlink();
+ delete ps3;
}
else
{
@@ -166,16 +168,14 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const ProjectionNode &node, Abstr
(*np.p2) += CGAL_Nef_polyhedron2(plist.begin(), plist.end(), CGAL_Nef_polyhedron2::INCLUDED);
}
}
+ delete ps3;
DxfData *dxf = np.convertToDxfData();
dxf_tesselate(ps, *dxf, 0, true, false, 0);
dxf_border_to_ps(ps, *dxf);
- ps3->unlink();
delete dxf;
}
cant_project_non_simple_polyhedron:
-
- this->cache.insert(cacheid, new cache_entry(ps->link()));
return ps;
}
@@ -251,12 +251,8 @@ static void add_slice(PolySet *ps, const DxfData &dxf, DxfData::Path &path, doub
}
}
-PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfLinearExtrudeNode &node,
- AbstractPolyNode::render_mode_e)
+PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfLinearExtrudeNode &node)
{
- const string &cacheid = this->cgalevaluator.getTree().getString(node);
- if (this->cache.contains(cacheid)) return this->cache[cacheid]->ps->link();
-
DxfData *dxf;
if (node.filename.empty())
@@ -283,7 +279,6 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfLinearExtrudeNode &node,
}
PolySet *ps = extrudeDxfData(node, *dxf);
- this->cache.insert(cacheid, new cache_entry(ps->link()));
delete dxf;
return ps;
}
@@ -354,12 +349,8 @@ PolySet *PolySetCGALEvaluator::extrudeDxfData(const DxfLinearExtrudeNode &node,
return ps;
}
-PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfRotateExtrudeNode &node,
- AbstractPolyNode::render_mode_e)
+PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfRotateExtrudeNode &node)
{
- const string &cacheid = this->cgalevaluator.getTree().getString(node);
- if (this->cache.contains(cacheid)) return this->cache[cacheid]->ps->link();
-
DxfData *dxf;
if (node.filename.empty())
@@ -386,20 +377,20 @@ PolySet *PolySetCGALEvaluator::evaluatePolySet(const DxfRotateExtrudeNode &node,
}
PolySet *ps = rotateDxfData(node, *dxf);
- this->cache.insert(cacheid, new cache_entry(ps->link()));
delete dxf;
return ps;
}
-PolySet *PolySetCGALEvaluator::evaluatePolySet(const CgaladvNode &node, AbstractPolyNode::render_mode_e)
+PolySet *PolySetCGALEvaluator::evaluatePolySet(const CgaladvNode &node)
{
CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(node);
PolySet *ps = NULL;
if (!N.empty()) ps = N.convertToPolyset();
+
return ps;
}
-PolySet *PolySetCGALEvaluator::evaluatePolySet(const RenderNode &node, AbstractPolyNode::render_mode_e)
+PolySet *PolySetCGALEvaluator::evaluatePolySet(const RenderNode &node)
{
CGAL_Nef_polyhedron N = this->cgalevaluator.evaluateCGALMesh(node);
PolySet *ps = NULL;
@@ -479,6 +470,6 @@ PolySet *PolySetCGALEvaluator::rotateDxfData(const DxfRotateExtrudeNode &node, D
}
delete[] points;
}
-
+
return ps;
}
diff --git a/src/PolySetCGALEvaluator.h b/src/PolySetCGALEvaluator.h
index f5b8665..2aa5b13 100644
--- a/src/PolySetCGALEvaluator.h
+++ b/src/PolySetCGALEvaluator.h
@@ -10,14 +10,13 @@
class PolySetCGALEvaluator : public PolySetEvaluator
{
public:
- PolySetCGALEvaluator(class CGALEvaluator &CGALEvaluator) :
- PolySetEvaluator(), cgalevaluator(CGALEvaluator) { }
+ PolySetCGALEvaluator(class CGALEvaluator &cgalevaluator);
virtual ~PolySetCGALEvaluator() { }
- virtual PolySet *evaluatePolySet(const ProjectionNode &node, AbstractPolyNode::render_mode_e);
- virtual PolySet *evaluatePolySet(const DxfLinearExtrudeNode &node, AbstractPolyNode::render_mode_e);
- virtual PolySet *evaluatePolySet(const DxfRotateExtrudeNode &node, AbstractPolyNode::render_mode_e);
- virtual PolySet *evaluatePolySet(const CgaladvNode &node, AbstractPolyNode::render_mode_e);
- virtual PolySet *evaluatePolySet(const RenderNode &node, AbstractPolyNode::render_mode_e);
+ virtual PolySet *evaluatePolySet(const ProjectionNode &node);
+ virtual PolySet *evaluatePolySet(const DxfLinearExtrudeNode &node);
+ virtual PolySet *evaluatePolySet(const DxfRotateExtrudeNode &node);
+ virtual PolySet *evaluatePolySet(const CgaladvNode &node);
+ virtual PolySet *evaluatePolySet(const RenderNode &node);
protected:
PolySet *extrudeDxfData(const DxfLinearExtrudeNode &node, class DxfData &dxf);
diff --git a/src/PolySetEvaluator.cc b/src/PolySetEvaluator.cc
index 56acb1d..a2bdca5 100644
--- a/src/PolySetEvaluator.cc
+++ b/src/PolySetEvaluator.cc
@@ -2,14 +2,41 @@
#include "printutils.h"
#include "polyset.h"
-PolySetEvaluator *PolySetEvaluator::global_evaluator = NULL;
+/*!
+ The task of PolySetEvaluator is to create, keep track of and cache PolySet instances.
-PolySetEvaluator::cache_entry::cache_entry(PolySet *ps) :
- ps(ps), msg(print_messages_stack.last())
+ All instances of PolySet which are not strictly temporary should be requested through this
+ class.
+*/
+
+QCache<std::string, PolySetEvaluator::cache_entry> PolySetEvaluator::cache(100000);
+
+/*!
+ Factory method returning a PolySet from the given node. If the
+ node is already cached, the cached PolySet will be returned
+ otherwise a new PolySet will be created from the node. If cache is
+ true, the newly created PolySet will be cached.
+ */
+shared_ptr<PolySet> PolySetEvaluator::getPolySet(const AbstractNode &node, bool cache)
+{
+ std::string cacheid = this->tree.getString(node);
+ if (this->cache.contains(cacheid)) {
+ PRINTF("Cache hit: %s", cacheid.substr(0, 40).c_str());
+ return this->cache[cacheid]->ps;
+ }
+
+ shared_ptr<PolySet> ps(node.evaluate_polyset(this));
+ if (cache) this->cache.insert(cacheid, new cache_entry(ps), ps?ps->polygons.size():0);
+ return ps;
+}
+
+PolySetEvaluator::cache_entry::cache_entry(const shared_ptr<PolySet> &ps) : ps(ps)
{
+ if (print_messages_stack.size() > 0) this->msg = print_messages_stack.last();
}
-PolySetEvaluator::cache_entry::~cache_entry()
+void PolySetEvaluator::printCache()
{
- ps->unlink();
+ PRINTF("PolySets in cache: %d", cache.size());
+ PRINTF("Polygons in cache: %d", cache.totalCost());
}
diff --git a/src/PolySetEvaluator.h b/src/PolySetEvaluator.h
index 70ec7ed..6319e55 100644
--- a/src/PolySetEvaluator.h
+++ b/src/PolySetEvaluator.h
@@ -3,39 +3,43 @@
#include "myqhash.h"
#include "node.h"
+#include "Tree.h"
#include <QCache>
+#include "memory.h"
class PolySetEvaluator
{
public:
- enum EvaluateMode { EVALUATE_CGAL, EVALUATE_OPENCSG };
- PolySetEvaluator() : cache(100) {}
-
+ PolySetEvaluator(const Tree &tree) : tree(tree) {}
virtual ~PolySetEvaluator() {}
- virtual PolySet *evaluatePolySet(const class ProjectionNode &, AbstractPolyNode::render_mode_e) = 0;
- virtual PolySet *evaluatePolySet(const class DxfLinearExtrudeNode &, AbstractPolyNode::render_mode_e) = 0;
- virtual PolySet *evaluatePolySet(const class DxfRotateExtrudeNode &, AbstractPolyNode::render_mode_e) = 0;
- virtual PolySet *evaluatePolySet(const class CgaladvNode &, AbstractPolyNode::render_mode_e) = 0;
- virtual PolySet *evaluatePolySet(const class RenderNode &, AbstractPolyNode::render_mode_e) = 0;
+ const Tree &getTree() const { return this->tree; }
- void clearCache() {
- this->cache.clear();
- }
+ virtual shared_ptr<PolySet> getPolySet(const class AbstractNode &, bool cache);
+ virtual PolySet *evaluatePolySet(const class ProjectionNode &) { return NULL; }
+ virtual PolySet *evaluatePolySet(const class DxfLinearExtrudeNode &) { return NULL; }
+ virtual PolySet *evaluatePolySet(const class DxfRotateExtrudeNode &) { return NULL; }
+ virtual PolySet *evaluatePolySet(const class CgaladvNode &) { return NULL; }
+ virtual PolySet *evaluatePolySet(const class RenderNode &) { return NULL; }
+
+ static void clearCache() {
+ cache.clear();
+ }
+ void printCache();
protected:
struct cache_entry {
- class PolySet *ps;
+ shared_ptr<class PolySet> ps;
QString msg;
- cache_entry(PolySet *ps);
- ~cache_entry();
+ cache_entry(const shared_ptr<PolySet> &ps);
+ ~cache_entry() { }
};
- QCache<std::string, cache_entry> cache;
+ static QCache<std::string, cache_entry> cache;
private:
- static PolySetEvaluator *global_evaluator;
+ const Tree &tree;
};
#endif
diff --git a/src/ThrownTogetherRenderer.cc b/src/ThrownTogetherRenderer.cc
index c3ba2a6..956fc11 100644
--- a/src/ThrownTogetherRenderer.cc
+++ b/src/ThrownTogetherRenderer.cc
@@ -63,7 +63,7 @@ void ThrownTogetherRenderer::renderCSGChain(CSGChain *chain, bool highlight,
glDepthFunc(GL_LEQUAL);
QHash<QPair<PolySet*,double*>,int> polySetVisitMark;
for (size_t i = 0; i < chain->polysets.size(); i++) {
- if (polySetVisitMark[QPair<PolySet*,double*>(chain->polysets[i], chain->matrices[i])]++ > 0)
+ if (polySetVisitMark[QPair<PolySet*,double*>(chain->polysets[i].get(), chain->matrices[i])]++ > 0)
continue;
double *m = chain->matrices[i];
double *c = chain->colors[i];
diff --git a/src/Tree.cc b/src/Tree.cc
index a451f24..7615a3d 100644
--- a/src/Tree.cc
+++ b/src/Tree.cc
@@ -2,12 +2,18 @@
#include "nodedumper.h"
#include <assert.h>
+#include <algorithm>
+
+static bool filter(char c)
+{
+ return c == ' ' || c == '\n' || c == '\t' || c == '\r';
+}
/*!
- Returns the cached string representation of the subtree rootet by \a node.
+ Returns the cached string representation of the subtree rooted by \a node.
If node is not cached, the cache will be rebuilt.
*/
-const std::string &Tree::getString(const AbstractNode &node) const
+const std::string Tree::getString(const AbstractNode &node) const
{
assert(this->root_node);
if (!this->nodecache.contains(node)) {
@@ -17,7 +23,10 @@ const std::string &Tree::getString(const AbstractNode &node) const
assert(this->nodecache.contains(*this->root_node) &&
"NodeDumper failed to create a cache");
}
- return this->nodecache[node];
+ std::string str = this->nodecache[node];
+ str.erase(std::remove_if(str.begin(), str.end(), filter), str.end());
+
+ return str;
}
/*!
diff --git a/src/Tree.h b/src/Tree.h
index 2c3f0b8..5fda0c3 100644
--- a/src/Tree.h
+++ b/src/Tree.h
@@ -20,8 +20,7 @@ public:
void setRoot(const AbstractNode *root);
const AbstractNode *root() const { return this->root_node; }
- // FIXME: Really return a reference?
- const string &getString(const AbstractNode &node) const;
+ const string getString(const AbstractNode &node) const;
private:
const AbstractNode *root_node;
diff --git a/src/cgaladv.cc b/src/cgaladv.cc
index 8ffd626..5014133 100644
--- a/src/cgaladv.cc
+++ b/src/cgaladv.cc
@@ -29,6 +29,7 @@
#include "context.h"
#include "builtin.h"
#include "printutils.h"
+#include "PolySetEvaluator.h"
#include <sstream>
#include <assert.h>
#include <boost/assign/std/vector.hpp>
@@ -92,6 +93,11 @@ AbstractNode *CgaladvModule::evaluate(const Context *ctx, const ModuleInstantiat
return node;
}
+PolySet *CgaladvNode::evaluate_polyset(PolySetEvaluator *ps) const
+{
+ return ps->evaluatePolySet(*this);
+}
+
void register_builtin_cgaladv()
{
builtin_modules["minkowski"] = new CgaladvModule(MINKOWSKI);
diff --git a/src/cgaladvnode.h b/src/cgaladvnode.h
index a3f8bea..8e769bf 100644
--- a/src/cgaladvnode.h
+++ b/src/cgaladvnode.h
@@ -24,6 +24,7 @@ public:
}
virtual std::string toString() const;
virtual std::string name() const;
+ PolySet *evaluate_polyset(class PolySetEvaluator *ps) const;
Value path;
std::string subdiv_type;
diff --git a/src/csgterm.cc b/src/csgterm.cc
index f24a41a..8306aaf 100644
--- a/src/csgterm.cc
+++ b/src/csgterm.cc
@@ -47,24 +47,17 @@
*/
-CSGTerm::CSGTerm(PolySet *polyset, const double matrix[16], const double color[4], const std::string &label)
+CSGTerm::CSGTerm(const shared_ptr<PolySet> &polyset, const double matrix[16], const double color[4], const std::string &label)
+ : type(TYPE_PRIMITIVE), polyset(polyset), label(label), left(NULL), right(NULL)
{
- this->type = TYPE_PRIMITIVE;
- this->polyset = polyset;
- this->label = label;
- this->left = NULL;
- this->right = NULL;
for (int i = 0; i < 16; i++) this->m[i] = matrix[i];
for (int i = 0; i < 4; i++) this->color[i] = color[i];
refcounter = 1;
}
CSGTerm::CSGTerm(type_e type, CSGTerm *left, CSGTerm *right)
+ : type(type), left(left), right(right)
{
- this->type = type;
- this->polyset = NULL;
- this->left = left;
- this->right = right;
refcounter = 1;
}
@@ -167,8 +160,6 @@ CSGTerm *CSGTerm::link()
void CSGTerm::unlink()
{
if (--refcounter <= 0) {
- if (polyset)
- polyset->unlink();
if (left)
left->unlink();
if (right)
@@ -197,7 +188,7 @@ CSGChain::CSGChain()
{
}
-void CSGChain::add(PolySet *polyset, double *m, double *color, CSGTerm::type_e type, std::string label)
+void CSGChain::add(const shared_ptr<PolySet> &polyset, double *m, double *color, CSGTerm::type_e type, std::string label)
{
polysets.push_back(polyset);
matrices.push_back(m);
diff --git a/src/csgterm.h b/src/csgterm.h
index 2a89ef1..c12b7ae 100644
--- a/src/csgterm.h
+++ b/src/csgterm.h
@@ -4,6 +4,7 @@
#include <string>
#include <vector>
#include "polyset.h"
+#include "memory.h"
class CSGTerm
{
@@ -16,7 +17,7 @@ public:
};
type_e type;
- PolySet *polyset;
+ shared_ptr<PolySet> polyset;
std::string label;
CSGTerm *left;
CSGTerm *right;
@@ -24,7 +25,7 @@ public:
double color[4];
int refcounter;
- CSGTerm(PolySet *polyset, const double matrix[16], const double color[4], const std::string &label);
+ CSGTerm(const shared_ptr<PolySet> &polyset, const double matrix[16], const double color[4], const std::string &label);
CSGTerm(type_e type, CSGTerm *left, CSGTerm *right);
CSGTerm *normalize();
@@ -38,7 +39,7 @@ public:
class CSGChain
{
public:
- std::vector<PolySet*> polysets;
+ std::vector<shared_ptr<PolySet> > polysets;
std::vector<double*> matrices;
std::vector<double*> colors;
std::vector<CSGTerm::type_e> types;
@@ -46,7 +47,7 @@ public:
CSGChain();
- void add(PolySet *polyset, double *m, double *color, CSGTerm::type_e type, std::string label);
+ void add(const shared_ptr<PolySet> &polyset, double *m, double *color, CSGTerm::type_e type, std::string label);
void import(CSGTerm *term, CSGTerm::type_e type = CSGTerm::TYPE_UNION);
std::string dump();
diff --git a/src/dxflinextrude.cc b/src/dxflinextrude.cc
index fd37ffa..ca98b66 100644
--- a/src/dxflinextrude.cc
+++ b/src/dxflinextrude.cc
@@ -124,19 +124,16 @@ void register_builtin_dxf_linear_extrude()
builtin_modules["linear_extrude"] = new DxfLinearExtrudeModule();
}
-PolySet *DxfLinearExtrudeNode::evaluate_polyset(render_mode_e mode,
- PolySetEvaluator *evaluator) const
+PolySet *DxfLinearExtrudeNode::evaluate_polyset(PolySetEvaluator *evaluator) const
{
if (!evaluator) {
PRINTF("WARNING: No suitable PolySetEvaluator found for %s module!", this->name().c_str());
- PolySet *ps = new PolySet();
- ps->is2d = true;
- return ps;
+ return NULL;
}
print_messages_push();
- PolySet *ps = evaluator->evaluatePolySet(*this, mode);
+ PolySet *ps = evaluator->evaluatePolySet(*this);
print_messages_pop();
diff --git a/src/dxflinextrudenode.h b/src/dxflinextrudenode.h
index 3c3beca..360fd28 100644
--- a/src/dxflinextrudenode.h
+++ b/src/dxflinextrudenode.h
@@ -24,7 +24,7 @@ public:
double origin_x, origin_y, scale;
bool center, has_twist;
std::string filename, layername;
- virtual PolySet *evaluate_polyset(render_mode_e mode, class PolySetEvaluator *) const;
+ virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const;
};
#endif
diff --git a/src/dxfrotextrude.cc b/src/dxfrotextrude.cc
index 5889cee..cd585aa 100644
--- a/src/dxfrotextrude.cc
+++ b/src/dxfrotextrude.cc
@@ -100,19 +100,16 @@ void register_builtin_dxf_rotate_extrude()
builtin_modules["rotate_extrude"] = new DxfRotateExtrudeModule();
}
-PolySet *DxfRotateExtrudeNode::evaluate_polyset(render_mode_e mode,
- PolySetEvaluator *evaluator) const
+PolySet *DxfRotateExtrudeNode::evaluate_polyset(PolySetEvaluator *evaluator) const
{
if (!evaluator) {
PRINTF("WARNING: No suitable PolySetEvaluator found for %s module!", this->name().c_str());
- PolySet *ps = new PolySet();
- ps->is2d = true;
- return ps;
+ return NULL;
}
print_messages_push();
- PolySet *ps = evaluator->evaluatePolySet(*this, mode);
+ PolySet *ps = evaluator->evaluatePolySet(*this);
print_messages_pop();
diff --git a/src/dxfrotextrudenode.h b/src/dxfrotextrudenode.h
index 797b53a..e0ade82 100644
--- a/src/dxfrotextrudenode.h
+++ b/src/dxfrotextrudenode.h
@@ -22,7 +22,7 @@ public:
double fn, fs, fa;
double origin_x, origin_y, scale;
std::string filename, layername;
- virtual PolySet *evaluate_polyset(render_mode_e mode, class PolySetEvaluator *) const;
+ virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const;
};
#endif
diff --git a/src/import.cc b/src/import.cc
index 0fdc156..f64a8f6 100644
--- a/src/import.cc
+++ b/src/import.cc
@@ -111,7 +111,7 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati
return node;
}
-PolySet *ImportNode::evaluate_polyset(render_mode_e, class PolySetEvaluator *) const
+PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *evaluator) const
{
PolySet *p = NULL;
diff --git a/src/importnode.h b/src/importnode.h
index 49e9f16..c08ecc9 100644
--- a/src/importnode.h
+++ b/src/importnode.h
@@ -27,7 +27,7 @@ public:
int convexity;
double fn, fs, fa;
double origin_x, origin_y, scale;
- virtual PolySet *evaluate_polyset(render_mode_e mode, class PolySetEvaluator *) const;
+ virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const;
};
#endif
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 8dc1fea..e4d9684 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -790,6 +790,7 @@ void MainWindow::compileCSG(bool procevents)
if (procevents)
QApplication::processEvents();
}
+ psevaluator.printCache();
}
catch (ProgressCancelException e) {
PRINT("CSG generation cancelled.");
@@ -1225,6 +1226,7 @@ void MainWindow::actionRenderCGAL()
QHash<std::string, CGAL_Nef_polyhedron> cache;
CGALEvaluator evaluator(cache, this->tree);
this->root_N = new CGAL_Nef_polyhedron(evaluator.evaluateCGALMesh(*this->root_node));
+ evaluator.psevaluator.printCache();
}
catch (ProgressCancelException e) {
PRINT("Rendering cancelled.");
@@ -1495,7 +1497,7 @@ void MainWindow::actionExportImage()
void MainWindow::actionFlushCaches()
{
// FIXME: Polycache -> PolySetEvaluator
-// FIXME: PolySetEvaluator->clearCache();
+ PolySetEvaluator::clearCache();
#ifdef ENABLE_CGAL
// FIXME: Flush caches through whatever channels we have
// CGALEvaluator::evaluator()->getCache().clear();
diff --git a/src/node.h b/src/node.h
index a3e1cad..9f25627 100644
--- a/src/node.h
+++ b/src/node.h
@@ -36,6 +36,8 @@ public:
overloaded to provide specialization for e.g. CSG nodes, primitive nodes etc.
Used for human-readable output. */
virtual std::string name() const;
+ /*! Should return a PolySet of the given geometry. Returns NULL if smth. goes wrong */
+ virtual class PolySet *evaluate_polyset(class PolySetEvaluator *) const { return NULL; }
// FIXME: Make return value a reference
const std::vector<AbstractNode*> &getChildren() const {
@@ -79,10 +81,6 @@ public:
RENDER_CGAL,
RENDER_OPENCSG
};
- /*! Should return a PolySet of the given geometry. It's normal to return an
- empty PolySet if smth. is wrong, but don't return NULL unless we change the calling
- strategy for this method. */
- virtual class PolySet *evaluate_polyset(render_mode_e mode, class PolySetEvaluator *evaluator) const = 0;
};
std::ostream &operator<<(std::ostream &stream, const AbstractNode &node);
diff --git a/src/polyset.cc b/src/polyset.cc
index db37b49..23b9876 100644
--- a/src/polyset.cc
+++ b/src/polyset.cc
@@ -36,28 +36,12 @@
#include <Eigen/LU>
#include <QColor>
-PolySet::PolySet() : grid(GRID_FINE)
+PolySet::PolySet() : grid(GRID_FINE), is2d(false), convexity(1)
{
- is2d = false;
- convexity = 1;
- refcount = 1;
}
PolySet::~PolySet()
{
- assert(refcount == 0);
-}
-
-PolySet* PolySet::link()
-{
- refcount++;
- return this;
-}
-
-void PolySet::unlink()
-{
- if (--refcount == 0)
- delete this;
}
void PolySet::append_poly()
diff --git a/src/polyset.h b/src/polyset.h
index e80d182..c59d86a 100644
--- a/src/polyset.h
+++ b/src/polyset.h
@@ -51,10 +51,6 @@ public:
void render_surface(colormode_e colormode, csgmode_e csgmode, double *m, GLint *shaderinfo = NULL) const;
void render_edges(colormode_e colormode, csgmode_e csgmode) const;
-
- int refcount;
- PolySet *link();
- void unlink();
};
#endif
diff --git a/src/primitives.cc b/src/primitives.cc
index 50a197d..08b9c62 100644
--- a/src/primitives.cc
+++ b/src/primitives.cc
@@ -102,7 +102,7 @@ public:
primitive_type_e type;
int convexity;
Value points, paths, triangles;
- virtual PolySet *evaluate_polyset(render_mode_e mode, class PolySetEvaluator *) const;
+ virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const;
};
AbstractNode *PrimitiveModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
@@ -273,7 +273,7 @@ static void generate_circle(point2d *circle, double r, int fragments)
}
}
-PolySet *PrimitiveNode::evaluate_polyset(render_mode_e, class PolySetEvaluator *) const
+PolySet *PrimitiveNode::evaluate_polyset(class PolySetEvaluator *) const
{
PolySet *p = new PolySet();
@@ -518,7 +518,7 @@ sphere_next_r2:
double x,y;
if (!this->points.vec[i]->getv2(x, y)) {
PRINTF("ERROR: Unable to convert point at index %d to a vec2 of numbers", i);
- p->unlink();
+ delete p;
return NULL;
}
dd.points.push_back(Vector2d(x, y));
diff --git a/src/projection.cc b/src/projection.cc
index 5a7ea6e..2c9d821 100644
--- a/src/projection.cc
+++ b/src/projection.cc
@@ -79,18 +79,16 @@ AbstractNode *ProjectionModule::evaluate(const Context *ctx, const ModuleInstant
return node;
}
-PolySet *ProjectionNode::evaluate_polyset(render_mode_e mode, PolySetEvaluator *evaluator) const
+PolySet *ProjectionNode::evaluate_polyset(PolySetEvaluator *evaluator) const
{
if (!evaluator) {
PRINTF("WARNING: No suitable PolySetEvaluator found for %s module!", this->name().c_str());
- PolySet *ps = new PolySet();
- ps->is2d = true;
- return ps;
+ return NULL;
}
print_messages_push();
- PolySet *ps = evaluator->evaluatePolySet(*this, mode);
+ PolySet *ps = evaluator->evaluatePolySet(*this);
print_messages_pop();
diff --git a/src/projectionnode.h b/src/projectionnode.h
index 4c29b7b..41cca7c 100644
--- a/src/projectionnode.h
+++ b/src/projectionnode.h
@@ -19,7 +19,7 @@ public:
int convexity;
bool cut_mode;
- virtual PolySet *evaluate_polyset(render_mode_e mode, class PolySetEvaluator *evaluator) const;
+ virtual PolySet *evaluate_polyset(class PolySetEvaluator *evaluator) const;
};
#endif
diff --git a/src/render.cc b/src/render.cc
index 48a8535..f08423a 100644
--- a/src/render.cc
+++ b/src/render.cc
@@ -26,15 +26,12 @@
#include "rendernode.h"
#include "module.h"
-#include "polyset.h"
#include "context.h"
-#include "dxfdata.h"
-#include "dxftess.h"
-#include "csgterm.h"
#include "builtin.h"
#include "printutils.h"
#include "progress.h"
#include "visitor.h"
+#include "PolySetEvaluator.h"
#include <sstream>
#include <boost/assign/std/vector.hpp>
@@ -68,6 +65,11 @@ AbstractNode *RenderModule::evaluate(const Context *ctx, const ModuleInstantiati
return node;
}
+class PolySet *RenderNode::evaluate_polyset(PolySetEvaluator *ps) const
+{
+ return ps->evaluatePolySet(*this);
+}
+
void register_builtin_render()
{
builtin_modules["render"] = new RenderModule();
diff --git a/src/rendernode.h b/src/rendernode.h
index 9138c29..9e49baf 100644
--- a/src/rendernode.h
+++ b/src/rendernode.h
@@ -14,6 +14,7 @@ public:
}
virtual std::string toString() const;
virtual std::string name() const { return "render"; }
+ PolySet *evaluate_polyset(class PolySetEvaluator *ps) const;
int convexity;
};
diff --git a/src/surface.cc b/src/surface.cc
index 22598bf..35449ed 100644
--- a/src/surface.cc
+++ b/src/surface.cc
@@ -62,7 +62,7 @@ public:
std::string filename;
bool center;
int convexity;
- virtual PolySet *evaluate_polyset(render_mode_e mode, class PolySetEvaluator *) const;
+ virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const;
};
AbstractNode *SurfaceModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
@@ -98,17 +98,17 @@ void register_builtin_surface()
builtin_modules["surface"] = new SurfaceModule();
}
-PolySet *SurfaceNode::evaluate_polyset(render_mode_e, class PolySetEvaluator *) const
+PolySet *SurfaceNode::evaluate_polyset(class PolySetEvaluator *) const
{
- PolySet *p = new PolySet();
handle_dep(filename);
QFile f(QString::fromStdString(filename));
if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
PRINTF("WARNING: Can't open DAT file `%s'.", filename.c_str());
- return p;
+ return NULL;
}
+ PolySet *p = new PolySet();
int lines = 0, columns = 0;
boost::unordered_map<std::pair<int,int>,double> data;
double min_val = 0;
diff --git a/tests/csgtermtest.cc b/tests/csgtermtest.cc
index 26b809a..7c37b0a 100644
--- a/tests/csgtermtest.cc
+++ b/tests/csgtermtest.cc
@@ -24,6 +24,7 @@
*/
#include "myqhash.h"
+#include "PolySetEvaluator.h"
#include "CSGTermEvaluator.h"
#include "CSGTextCache.h"
#include "openscad.h"
@@ -145,7 +146,8 @@ int main(int argc, char **argv)
vector<CSGTerm*> highlights;
vector<CSGTerm*> background;
- CSGTermEvaluator evaluator(tree);
+ PolySetEvaluator psevaluator(tree);
+ CSGTermEvaluator evaluator(tree, &psevaluator);
CSGTerm *root_term = evaluator.evaluateCSGTerm(*root_node, highlights, background);
// cout << "Stored terms: " << evaluator.stored_term.size() << "\n";
diff --git a/tests/opencsgtest.cc b/tests/opencsgtest.cc
index 72f7488..28c0daa 100644
--- a/tests/opencsgtest.cc
+++ b/tests/opencsgtest.cc
@@ -144,8 +144,7 @@ int main(int argc, char *argv[])
CsgInfo csgInfo;
QHash<std::string, CGAL_Nef_polyhedron> cache;
CGALEvaluator cgalevaluator(cache, tree);
- PolySetCGALEvaluator psevaluator(cgalevaluator);
- CSGTermEvaluator evaluator(tree, &psevaluator);
+ CSGTermEvaluator evaluator(tree, &cgalevaluator.psevaluator);
CSGTerm *root_raw_term = evaluator.evaluateCSGTerm(*root_node,
csgInfo.highlight_terms,
csgInfo.background_terms);
diff --git a/tests/regression/csgtermtest/allmodules-expected.txt b/tests/regression/csgtermtest/allmodules-expected.txt
index d7a04fc..f544c01 100644
--- a/tests/regression/csgtermtest/allmodules-expected.txt
+++ b/tests/regression/csgtermtest/allmodules-expected.txt
@@ -1 +1 @@
-(((((((((((((linear_extrude14 + linear_extrude15) + rotate_extrude16) + rotate_extrude17) + import21) + cube23) + sphere24) + cylinder25) + polyhedron26) + square27) + circle28) + polygon29) + projection30) + surface32)
+((((((cube23 + sphere24) + cylinder25) + polyhedron26) + square27) + circle28) + polygon29)
diff --git a/tests/regression/csgtermtest/dxf_linear_extrude-expected.txt b/tests/regression/csgtermtest/dxf_linear_extrude-expected.txt
index bebcc7a..a40cf60 100644
--- a/tests/regression/csgtermtest/dxf_linear_extrude-expected.txt
+++ b/tests/regression/csgtermtest/dxf_linear_extrude-expected.txt
@@ -1 +1 @@
-linear_extrude2
+No top-level CSG object
diff --git a/tests/regression/csgtermtest/dxf_rotate_extrude-expected.txt b/tests/regression/csgtermtest/dxf_rotate_extrude-expected.txt
index 318aa70..a40cf60 100644
--- a/tests/regression/csgtermtest/dxf_rotate_extrude-expected.txt
+++ b/tests/regression/csgtermtest/dxf_rotate_extrude-expected.txt
@@ -1 +1 @@
-rotate_extrude2
+No top-level CSG object
diff --git a/tests/regression/csgtermtest/linear_extrude-expected.txt b/tests/regression/csgtermtest/linear_extrude-expected.txt
index bebcc7a..a40cf60 100644
--- a/tests/regression/csgtermtest/linear_extrude-expected.txt
+++ b/tests/regression/csgtermtest/linear_extrude-expected.txt
@@ -1 +1 @@
-linear_extrude2
+No top-level CSG object
diff --git a/tests/regression/csgtermtest/projection-expected.txt b/tests/regression/csgtermtest/projection-expected.txt
index 2a4c47e..a40cf60 100644
--- a/tests/regression/csgtermtest/projection-expected.txt
+++ b/tests/regression/csgtermtest/projection-expected.txt
@@ -1 +1 @@
-projection2
+No top-level CSG object
diff --git a/tests/regression/csgtermtest/rotate_extrude-expected.txt b/tests/regression/csgtermtest/rotate_extrude-expected.txt
index 318aa70..a40cf60 100644
--- a/tests/regression/csgtermtest/rotate_extrude-expected.txt
+++ b/tests/regression/csgtermtest/rotate_extrude-expected.txt
@@ -1 +1 @@
-rotate_extrude2
+No top-level CSG object
diff --git a/tests/regression/csgtermtest/surface-expected.txt b/tests/regression/csgtermtest/surface-expected.txt
index d0e3459..a40cf60 100644
--- a/tests/regression/csgtermtest/surface-expected.txt
+++ b/tests/regression/csgtermtest/surface-expected.txt
@@ -1 +1 @@
-surface2
+No top-level CSG object
contact: Jan Huwald // Impressum