summaryrefslogtreecommitdiff
path: root/src/cgalworker.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-12-25 22:00:30 (GMT)
committerMarius Kintel <marius@kintel.net>2011-12-25 22:00:30 (GMT)
commit7c48b345b12981085bf6741208893a8206d77578 (patch)
treedec80733c559903f6c463a3827e4bf2e2cea562e /src/cgalworker.cc
parent3e64e63b0113a99666ad68aa3e82bb7b80324d9b (diff)
Perform CGAL evaluation in a separate thread. First steps towards better GUI responsiveness and parallelization
Diffstat (limited to 'src/cgalworker.cc')
-rw-r--r--src/cgalworker.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/cgalworker.cc b/src/cgalworker.cc
new file mode 100644
index 0000000..30bb1fe
--- /dev/null
+++ b/src/cgalworker.cc
@@ -0,0 +1,40 @@
+#include "cgalworker.h"
+#include <QThread>
+
+#include "Tree.h"
+#include "CGALEvaluator.h"
+#include "progress.h"
+#include "printutils.h"
+
+CGALWorker::CGALWorker()
+{
+ this->thread = new QThread();
+ 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 (ProgressCancelException e) {
+ PRINT("Rendering cancelled.");
+ }
+
+ emit done(root_N);
+ thread->quit();
+}
contact: Jan Huwald // Impressum