Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
jobs.h
Go to the documentation of this file.
1 #ifndef JOBS_H
2 #define JOBS_H
3 
4 #include <algorithm.h>
5 #include <app/workerthread.h>
6 
7 namespace frechet { namespace poly {
14 {
15 protected:
25  double param;
26 public:
38  double aparam)
39  : alg(analg), fs(anfs), fspath(apath), param(aparam), status_before(alg->status())
40  { }
41 
45  virtual void runAlg() =0;
50  virtual void runJob() override {
51  alg->cancelFlag = &this->cancelRequested;
52  runAlg();
53  alg->cancelFlag = nullptr;
54  }
61  virtual void afterInterrupted() override {
62  alg->cancelFlag = nullptr;
63  alg->resetStatus(true);
64  alg->setStatus(status_before);
65  if (fspath) fspath->clear();
66  }
67 };
68 
74 {
75 public:
86  double epsilon)
87  : PolygonWorkerJob(analg,anfs,apath,epsilon) {}
92  virtual void runAlg() override {
93  alg->decidePolygon(fs, fspath, param, true);
94  }
95 };
96 
106 {
107 public:
119  double approx)
120  : PolygonWorkerJob(analg,FreeSpace::ptr(),apath,approx) {}
121 
125  virtual void runAlg() override {
126  alg->optimisePolygon(fspath, param);
127  }
128 };
129 
141 {
142 public:
152  : PolygonWorkerJob(analg,FreeSpace::ptr(),reach::FSPath::ptr(),approx) {}
153 
157  virtual void runAlg() {
158  alg->optimiseCurve(param);
159  }
160 };
161 
162 } } // namespace frechet::poly
163 
164 #endif // JOBS_H
worker job for executing the optimisation variant, or approximation variant, on curves (not on simple...
Definition: jobs.h:140
OptimisePolyWorkerJob(poly::Algorithm::ptr analg, frechet::reach::FSPath::ptr apath, double approx)
default constructor
Definition: jobs.h:117
virtual void runJob() override
implements abstract method. Sets up the cancel flags and delegates to runAlg().
Definition: jobs.h:50
global definitions for all algorithms.
volatile bool cancelRequested
cancellation flag
Definition: workerthread.h:66
double param
parameter to the algorithm (epsilon)
Definition: jobs.h:25
Status
indicates the current status of the algorithm. Negative values indicate that the algorithm is current...
Definition: algorithm.h:76
boost::shared_ptr< Algorithm > ptr
(smart) pointer to an Algorithm object
Definition: algorithm.h:236
DecideWorkerJob(poly::Algorithm::ptr analg, frechet::FreeSpace::ptr anfs, frechet::reach::FSPath::ptr apath, double epsilon)
default constructor
Definition: jobs.h:83
Abstract base class for executing the algorithm for simple polygons in a background thread....
Definition: jobs.h:13
frechet::FreeSpace::ptr fs
the underlying free-space
Definition: jobs.h:19
virtual void afterInterrupted() override
implements abstract method. Handles user interruption. Resets the status of the algorithm (see poly::...
Definition: jobs.h:61
frechet::reach::FSPath::ptr fspath
holds the feasible path on return
Definition: jobs.h:21
virtual void runAlg()=0
implemented by derived classes
virtual void runAlg()
implements actual execution
Definition: jobs.h:157
virtual void runAlg() override
executes the decision variant. Results are placed in fspath and poly::Algorithm::Status.
Definition: jobs.h:92
Background job to run long-runner tasks in a seperate thread.
Definition: workerthread.h:48
boost::shared_ptr< FSPath > ptr
smart pointer to an FSPath object
Definition: fs_path.h:65
OptimiseCurveWorkerJob(poly::Algorithm::ptr analg, double approx)
default constructor
Definition: jobs.h:151
worker job for executing the decision variant of the algorithm for simple polygons.
Definition: jobs.h:73
poly::Algorithm::ptr alg
the algorithm
Definition: jobs.h:17
worker job for executing the optimisation variant, or approximation variant, of the algorithm for sim...
Definition: jobs.h:105
The FreeSpace class models the Free-Space Diagram calculated from two curves.
Definition: freespace.h:83
PolygonWorkerJob(poly::Algorithm::ptr analg, frechet::FreeSpace::ptr anfs, frechet::reach::FSPath::ptr apath, double aparam)
default constructor
Definition: jobs.h:35
poly::Algorithm::Status status_before
previous algorithm status; will be reset in the case of user interruption
Definition: jobs.h:23
boost::shared_ptr< FreeSpace > ptr
smart pointer to FreeSpace object
Definition: freespace.h:92
virtual void runAlg() override
implements actual execution
Definition: jobs.h:125
Calculates a feasible path in the Free-Space given a start point (0,0) and an end point (n-1,...
Definition: fs_path.h:44