vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ComputeThread.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <OpenThreads/Thread>
4 #include "ComputeStrategy.h"
5 #include "Utils.h"
6 #include <random>
7 
8 namespace APDYNAMICART
9 {
10 
11 struct InitSettings
12 {
15  float size;
19  bool randomRun;
20 };
21 
22 class ComputeThread : public OpenThreads::Thread, public osg::Referenced
23 {
24 
25 public:
27  ComputeThread();
28  virtual void run();
29 
30  bool isTooSmall( int i, int iter );
31 
32  virtual int cancel();
33 
35  void init(const InitSettings& settings);
36  bool getData(osg::Vec3Array* points, osg::Vec4Array* colors, Limits& limits, Parameters& params);
37  void addPoint( osg::Vec3 point );
38  void setColor( osg::Vec4 color, int index );
39  void interpolatePoints();
40 
41 protected:
42  bool _dirty;
43  bool _done;
44 
45  OpenThreads::Mutex _mutex;
50  static std::tr1::mt19937 eng;
51  osg::Vec3 _initPoint;
52 private:
53  bool isDiverging( osg::Vec3 &point );
54  void createRandomParameters();
55  void computeColors();
56  void computePoints();
57 };
58 
59 typedef osg::ref_ptr<ComputeThread> ComputeThreadPtr;
60 
61 }