2011-12-26 02:00:30 +04:00
|
|
|
#include "cgalworker.h"
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
#include "Tree.h"
|
|
|
|
#include "CGALEvaluator.h"
|
|
|
|
#include "progress.h"
|
|
|
|
#include "printutils.h"
|
|
|
|
|
|
|
|
CGALWorker::CGALWorker()
|
|
|
|
{
|
|
|
|
this->thread = new QThread();
|
2013-05-24 23:16:58 +04:00
|
|
|
if (this->thread->stackSize() < 1024*1024) this->thread->setStackSize(1024*1024);
|
2011-12-26 02:00:30 +04:00
|
|
|
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()));
|
|
|
|
}
|
2012-10-09 04:49:02 +04:00
|
|
|
catch (const ProgressCancelException &e) {
|
2011-12-26 02:00:30 +04:00
|
|
|
PRINT("Rendering cancelled.");
|
|
|
|
}
|
|
|
|
|
|
|
|
emit done(root_N);
|
|
|
|
thread->quit();
|
|
|
|
}
|