File: Meshing_thread.cpp

package info (click to toggle)
cgal 6.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (82 lines) | stat: -rw-r--r-- 1,605 bytes parent folder | download | duplicates (3)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) 2010 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s)     : Stephane Tayeb
//
//******************************************************************************
// File Description :
//******************************************************************************

#include "config.h"

#include <QElapsedTimer>
#include <QApplication>

#include "Meshing_thread.h"
#include <CGAL/Three/Three.h>

class Scene_c3t3_item;

Meshing_thread::
Meshing_thread(Mesh_function_interface* f, Scene_c3t3_item* item)
  : f_(f)
  , item_(item)
  , time_(0)
  , timer_(new QTimer(this))
  , timer_period_(1)
{
  connect(timer_, SIGNAL(timeout()),
          this,   SLOT(emit_status()));

  timer_->start(static_cast<int>(timer_period_*1000));
}


Meshing_thread::
~Meshing_thread()
{
  delete f_;
  delete timer_;
  QApplication::restoreOverrideCursor();
}


void
Meshing_thread::
run()
{
  QElapsedTimer timer;
  timer.start();
  CGAL::Three::Three::CursorScopeGuard guard(Qt::BusyCursor);
  f_->launch();
  time_ = double(timer.elapsed()) / 1000;
  CGAL::Three::Three::getMutex()->lock();
  CGAL::Three::Three::getWaitCondition()->wakeAll();
  CGAL::Three::Three::getMutex()->unlock();
  Q_EMIT done(this);

}


void
Meshing_thread::
stop()
{
  f_->stop();
  QApplication::setOverrideCursor(Qt::WaitCursor); //restored in mesh_3_plugin lambda
}


void
Meshing_thread::
emit_status()
{
  Q_EMIT (status_report(f_->status(timer_period_)));
}