summaryrefslogtreecommitdiff
path: root/src/cgalworker.cc
blob: f011262ec97d871bd8360c3bc36bbda5586d15ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "cgalworker.h"
#include <QThread>

#include "Tree.h"
#include "CGALEvaluator.h"
#include "progress.h"
#include "printutils.h"

CGALWorker::CGALWorker()
{
	this->thread = new QThread();
	if (this->thread->stackSize() < 1024*1024) this->thread->setStackSize(1024*1024);
	connect(this->thread, SIGNAL(started()), this, SLOT(work()));
	moveToThread(this->thread);
}

CGALWorker::~CGALWorker()
{
	delete this->thread;
}

void CGALWorker::start(const Tree &tree)
{
	this->tree = &tree;
	this->thread->start();
}

void CGALWorker::work()
{
	CGAL_Nef_polyhedron *root_N = NULL;
	try {
		CGALEvaluator evaluator(*this->tree);
		root_N = new CGAL_Nef_polyhedron(evaluator.evaluateCGALMesh(*this->tree->root()));
	}
	catch (const ProgressCancelException &e) {
		PRINT("Rendering cancelled.");
	}

	emit done(root_N);
	thread->quit();
}
contact: Jan Huwald // Impressum