2011-12-26 02:00:30 +04:00
|
|
|
#include "cgalworker.h"
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
#include "Tree.h"
|
2013-10-31 08:45:00 +04:00
|
|
|
#include "GeometryEvaluator.h"
|
2011-12-26 02:00:30 +04:00
|
|
|
#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()
|
|
|
|
{
|
2013-12-22 10:43:08 +04:00
|
|
|
shared_ptr<const Geometry> root_geom;
|
2011-12-26 02:00:30 +04:00
|
|
|
try {
|
2013-10-31 08:45:00 +04:00
|
|
|
GeometryEvaluator evaluator(*this->tree);
|
2013-12-22 10:43:08 +04:00
|
|
|
root_geom = evaluator.evaluateGeometry(*this->tree->root(), true);
|
2011-12-26 02:00:30 +04:00
|
|
|
}
|
2012-10-09 04:49:02 +04:00
|
|
|
catch (const ProgressCancelException &e) {
|
2011-12-26 02:00:30 +04:00
|
|
|
PRINT("Rendering cancelled.");
|
|
|
|
}
|
|
|
|
|
2013-12-22 10:43:08 +04:00
|
|
|
emit done(root_geom);
|
2011-12-26 02:00:30 +04:00
|
|
|
thread->quit();
|
|
|
|
}
|