VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtStreamedSpeedTreeThread.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvSt/vrvSt.h>
13 
14 #include <vrvCore/DtTreeRecord.h>
15 
17 
19 
20 #include <osg/ref_ptr>
21 #include <osg/OperationThread>
22 
23 #include <OpenThreads/Thread>
24 #include <OpenThreads/Block>
25 
26 #include <boost/thread/mutex.hpp>
27 #include <boost/unordered_set.hpp>
28 #include <tbb/atomic.h>
29 #include <tbb/task.h>
30 #include <deque>
31 
32 namespace osg
33 {
34  class Node;
35  class RenderInfo;
36  class EllipsoidModel;
37 }
38 
39 namespace osgUtil
40 {
41  class SceneView;
42 }
43 
44 namespace makVrv
45 {
46  class DtDe;
47  class DtStreamedSpeedTreeForest;
48  class DtSpeedTreeMergeJob;
49  class DtStreamedSpeedTreeThread;
50 
53  class DT_DLL_VRVST DtSpeedTreeMergeJob : public osg::Operation
54  {
55  public:
57  virtual void operator () (osg::Object* sv);
58 
60  virtual void release();
61 
63  };
64 
67  class DT_DLL_VRVST DtSpeedTreeMergeTask : public tbb::task
68  {
69  public:
70  DtSpeedTreeMergeTask(DtStreamedSpeedTreeThread * stThread, osgUtil::SceneView* sceneView);
72  virtual tbb::task* execute();
73 
75  osgUtil::SceneView* mySceneView;
76  };
77 
81  {
82  public:
84  static DtStreamedSpeedTreeThread& instance(DtDe& de);
85 
87  virtual ~DtStreamedSpeedTreeThread();
88 
90  enum RequestStatus { UNUSED, WORKING, DONE };
91 
92 
97  {
99  std::vector<DtVectorTreeRecords> myRecordsArray;
100 
103 
107  const osg::Node* myDataNode;
108 
109 
116  };
117 
120  {
121  public:
123  : myOutput(NULL)
124  , myForest(NULL)
125  , myUseScaleRandomization(false)
126  , myUseOrientationRandomization(false)
127  , myTreeMinScale(1.0)
128  , myTreeMaxScale(1.0)
129  , myDataNode(NULL)
130  { ; }
132 
135 
141 
144 
152 
154  const osg::Node* myDataNode;
155 
156  private:
158  TreeRequestMsg(const TreeRequestMsg &other);
160  TreeRequestMsg &operator=(const TreeRequestMsg &other);
161  };
162 
164  typedef std::list<TreeRequestOutput> RequestOutputList;
165 
167  typedef boost::unordered_set<const osg::Node*> NodeSet;
168 
170  typedef boost::unordered_set<DtStreamedSpeedTreeForest*> ForestSet;
171 
173  typedef boost::unordered_set<std::string> StringSet;
174 
179  RequestOutputList& requestOutput();
180 
185  NodeSet& unloaded();
186 
188  void setForestDeleted(DtStreamedSpeedTreeForest* forest);
189 
191  void setNodeUnloaded(const osg::Node* node);
192 
194  void enqueue(
195  const osgEarth::CustomFeatureNode *featureNode,
196  TreeRequestOutput* out,
198  const osg::Node* dataNode,
199  bool useScaleRandomization,
200  bool useOrientationRandomization,
201  float treeMinScale,
202  float treeMaxScale);
203 
205  virtual void run();
206 
208  void handleRequest(const TreeRequestMsg& msg);
209 
211  bool isForestDeleted(DtStreamedSpeedTreeForest* forest);
212 
214  bool isNodeUnloaded(const osg::Node* node);
215 
219  static std::size_t hash_value(const std::string& modelDefName,
221 
223  void mergeTreeRequests(osg::RenderInfo& renderInfo);
224 
226  void block();
227 
229  void release();
230 
232  virtual void updateBlock();
233 
235  virtual void stopMergingWork();
236 
238  virtual bool workToDo();
239 
241  virtual bool fetchAndActivateTask();
242  protected:
243 
246 
247  virtual double rotationAngleFromGeocentricQuaternion(const osg::Quat& rotation,
248  const osg::Vec3d& location);
249 
250  private:
253 
254  protected:
255 
257 
261  std::deque<TreeRequestMsg*> myMessageQueue;
262 
263  // Don't keep spinning if we don't have data
264  OpenThreads::Block myBlock;
265 
267  boost::mutex myMessageQueueMutex;
268 
273 
279 
285 
291 
294 
295  osg::EllipsoidModel* myEllipsoidModel;
296 
298  tbb::atomic< bool> myStopWork;
299  tbb::atomic< bool> myWorkToDo;
300  tbb::atomic < bool> myTbbTaskActive;
301 
302  };
303 }
boost::unordered_set< const osg::Node * > NodeSet
Set of request nodes.
Definition: DtStreamedSpeedTreeThread.h:167
DtDe & myDe
Definition: DtStreamedSpeedTreeThread.h:256
TreeRequestOutput * myOutput
Pointer to an output object.
Definition: DtStreamedSpeedTreeThread.h:140
OpenThreads::Thread Thread
Definition: DtOsgThreadingUtils.h:14
float myTreeMinScale
Definition: DtStreamedSpeedTreeThread.h:149
Virtual base class.
Definition: DtVirtualBaseClass.h:19
float myTreeMaxScale
Definition: DtStreamedSpeedTreeThread.h:150
DtStreamedSpeedTreeForest manages the streaming management for The DtSpeedTreeForest that is contains...
Definition: DtStreamedSpeedTreeForest.h:51
#define DT_DLL_VRVST
Definition: vrvSt.h:20
tbb::atomic< bool > myStopWork
Flag to tell the merging to stop.
Definition: DtStreamedSpeedTreeThread.h:298
osg::ref_ptr< const osgEarth::CustomFeatureNode > myFeatureNode
Request list.
Definition: DtStreamedSpeedTreeThread.h:134
RequestStatus
Status of a request to convert markers.
Definition: DtStreamedSpeedTreeThread.h:90
osg::Operation responsible for launching async tbb task, currently done in swap buffers ...
Definition: DtStreamedSpeedTreeThread.h:53
std::deque< TreeRequestMsg * > myMessageQueue
Queue of marker request messages.
Definition: DtStreamedSpeedTreeThread.h:261
~TreeRequestMsg()
Definition: DtStreamedSpeedTreeThread.h:131
OpenThreads::Block myBlock
Definition: DtStreamedSpeedTreeThread.h:264
Contains DLL export macros.
NodeSet myUnloadedNodes
Set of unloaded feature request nodes.
Definition: DtStreamedSpeedTreeThread.h:290
DtStreamedSpeedTreeThread * myThread
Definition: DtStreamedSpeedTreeThread.h:62
StringSet myValidModelDefinitions
Cache of valid SpeedTree model definitions.
Definition: DtStreamedSpeedTreeThread.h:272
tbb::atomic< bool > myWorkToDo
Definition: DtStreamedSpeedTreeThread.h:299
RequestOutputList myTreeRequestOutput
List of allocated output objects.
Definition: DtStreamedSpeedTreeThread.h:284
The Filter pushes these onto the CustomFeatureNode&#39;s MarkerRequestList.
Definition: CustomFeatureNode.h:51
osgUtil::SceneView * mySceneView
Definition: DtStreamedSpeedTreeThread.h:75
Contains makVrv::DtVirtualBaseClass class.
osg::EllipsoidModel * myEllipsoidModel
Definition: DtStreamedSpeedTreeThread.h:295
Custom Feature Node.
Definition: CustomFeatureNode.h:43
boost::mutex myMessageQueueMutex
Mutex controlling access to q.
Definition: DtStreamedSpeedTreeThread.h:267
Contains the CustomFeatureNode class declaration.
DtStreamedSpeedTreeThread * myThread
Definition: DtStreamedSpeedTreeThread.h:74
TreeRequestMsg()
Definition: DtStreamedSpeedTreeThread.h:122
A message to convert some tree requests into tree records.
Definition: DtStreamedSpeedTreeThread.h:119
Output of a processed set of marker requests.
Definition: DtStreamedSpeedTreeThread.h:96
bool myTimeToStop
Flag to tell the thread to stop.
Definition: DtStreamedSpeedTreeThread.h:293
bool myUseScaleRandomization
Definition: DtStreamedSpeedTreeThread.h:147
Thread object to convert tree marker requests into tree records in a worker thread.
Definition: DtStreamedSpeedTreeThread.h:80
Definition: DtStreamedSpeedTreeThread.h:90
const osg::Node * myDataNode
Node source of the marker requests.
Definition: DtStreamedSpeedTreeThread.h:154
bool myUseOrientationRandomization
Definition: DtStreamedSpeedTreeThread.h:148
boost::unordered_set< std::string > StringSet
Set of model definition names.
Definition: DtStreamedSpeedTreeThread.h:173
boost::unordered_set< DtStreamedSpeedTreeForest * > ForestSet
Set of forests.
Definition: DtStreamedSpeedTreeThread.h:170
ForestSet myDeletedForests
Set of deleted forest objects.
Definition: DtStreamedSpeedTreeThread.h:278
std::list< TreeRequestOutput > RequestOutputList
List type for output objects.
Definition: DtStreamedSpeedTreeThread.h:164
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
DtStreamedSpeedTreeForest * myForest
The forest making the request.
Definition: DtStreamedSpeedTreeThread.h:102
Async task responsible for adding trees during swap buffers, launched by DtSpeedTreeMergeJob.
Definition: DtStreamedSpeedTreeThread.h:67
DtStreamedSpeedTreeForest * myForest
Forest requesting the markers.
Definition: DtStreamedSpeedTreeThread.h:143
std::vector< DtVectorTreeRecords > myRecordsArray
Record output.
Definition: DtStreamedSpeedTreeThread.h:99
tbb::atomic< bool > myTbbTaskActive
Definition: DtStreamedSpeedTreeThread.h:300
std::size_t hash_value(DtUnicode const &val)
Definition: DtUnicode.h:323
Contains makVrv::DtTreeRecord class.
volatile RequestStatus myStatus
Current status of this output object.
Definition: DtStreamedSpeedTreeThread.h:115
const osg::Node * myDataNode
The request node from osgEarth.
Definition: DtStreamedSpeedTreeThread.h:107

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)