VR-Forces 5.0.2 Developer's Guide
 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) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvSt/vrvSt.h>
14 
15 #include <vrvCore/DtTreeRecord.h>
16 
18 
20 
21 #include <osg/ref_ptr>
22 #include <osg/OperationThread>
23 
24 #include <OpenThreads/Thread>
25 #include <OpenThreads/Block>
26 
27 #include <boost/thread/mutex.hpp>
28 #include <tbb/atomic.h>
29 
30 #include <unordered_set>
31 #include <deque>
32 
33 namespace osg
34 {
35  class Node;
36  class RenderInfo;
37  class EllipsoidModel;
38  class EllipsoidModel;
39 }
40 
41 namespace osgUtil
42 {
43  class SceneView;
44 }
45 
46 namespace makVrv
47 {
48  class DtDe;
49  class DtStreamedSpeedTreeForest;
50  class DtSpeedTreeMergeJob;
51  class DtStreamedSpeedTreeThread;
52 
53 
57  {
58  public:
60  static DtStreamedSpeedTreeThread& instance(DtDe& de);
61 
63  virtual ~DtStreamedSpeedTreeThread();
64  public:
66  typedef std::list<DtTreeRequestOutput> RequestOutputList;
67 
69  typedef std::unordered_set<const osg::Node*> NodeSet;
70 
72  typedef std::unordered_set<DtStreamedSpeedTreeForest*> ForestSet;
73 
75  typedef std::unordered_set<std::string> StringSet;
76 
81  RequestOutputList& requestOutput();
82 
87  NodeSet& unloaded();
88 
90  void setForestDeleted(DtStreamedSpeedTreeForest* forest);
91 
93  void setNodeUnloaded(const osg::Node* node);
94 
96  void enqueue(
97  const osgEarth::CustomFeatureNode *featureNode,
100  const osg::Node* dataNode,
101  bool useScaleRandomization,
102  bool useOrientationRandomization,
103  float treeMinScale,
104  float treeMaxScale);
105 
107  virtual void run();
108 
110  void handleRequest(const DtTreeRequestMessage& msg);
111 
113  bool isForestDeleted(DtStreamedSpeedTreeForest* forest);
114 
116  bool isNodeUnloaded(const osg::Node* node);
117 
121  static std::size_t hash_value(const std::string& modelDefName,
123 
125  void mergeTreeRequests();
126 
128  void block();
129 
131  void release();
132 
134  virtual void updateBlock();
135 
137  virtual void stopMergingWork();
138 
140  virtual bool workToDo() const;
141 
143  virtual bool fetchAndActivateTask();
144  protected:
145 
148 
149  virtual double rotationAngleFromGeocentricQuaternion(const osg::Quat& rotation,
150  const osg::Vec3d& location);
151 
152  private:
155 
156  protected:
157 
159 
163  std::deque<DtTreeRequestMessage*> myMessageQueue;
164 
165  // Don't keep spinning if we don't have data
166  OpenThreads::Block myBlock;
167 
169  boost::mutex myMessageQueueMutex;
170 
175 
181 
187 
193 
196 
197  osg::EllipsoidModel* myEllipsoidModel;
198 
200  tbb::atomic< bool> myStopWork;
201  tbb::atomic< bool> myWorkToDo;
202  tbb::atomic < bool> myTbbTaskActive;
203 
204  };
205 }
DtDe & myDe
Definition: DtStreamedSpeedTreeThread.h:158
OpenThreads::Thread Thread
Definition: DtOsgThreadingUtils.h:14
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
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:200
std::unordered_set< DtStreamedSpeedTreeForest * > ForestSet
Set of forests.
Definition: DtStreamedSpeedTreeThread.h:72
OpenThreads::Block myBlock
Definition: DtStreamedSpeedTreeThread.h:166
std::deque< DtTreeRequestMessage * > myMessageQueue
Queue of marker request messages.
Definition: DtStreamedSpeedTreeThread.h:163
Contains DLL export macros.
NodeSet myUnloadedNodes
Set of unloaded feature request nodes.
Definition: DtStreamedSpeedTreeThread.h:192
StringSet myValidModelDefinitions
Cache of valid SpeedTree model definitions.
Definition: DtStreamedSpeedTreeThread.h:174
tbb::atomic< bool > myWorkToDo
Definition: DtStreamedSpeedTreeThread.h:201
RequestOutputList myTreeRequestOutput
List of allocated output objects.
Definition: DtStreamedSpeedTreeThread.h:186
The Filter pushes these onto the CustomFeatureNode&#39;s MarkerRequestList.
Definition: CustomFeatureNode.h:51
std::list< DtTreeRequestOutput > RequestOutputList
List type for output objects.
Definition: DtStreamedSpeedTreeThread.h:66
Contains makVrv::DtVirtualBaseClass class.
A message to convert some tree requests into tree records.
Definition: DtTreeRequestMessage.h:52
osg::EllipsoidModel * myEllipsoidModel
Definition: DtStreamedSpeedTreeThread.h:197
Output of a processed set of marker requests.
Definition: DtTreeRequestMessage.h:29
Custom Feature Node.
Definition: CustomFeatureNode.h:43
boost::mutex myMessageQueueMutex
Mutex controlling access to q.
Definition: DtStreamedSpeedTreeThread.h:169
Contains the CustomFeatureNode class declaration.
bool myTimeToStop
Flag to tell the thread to stop.
Definition: DtStreamedSpeedTreeThread.h:195
Thread object to convert tree marker requests into tree records in a worker thread.
Definition: DtStreamedSpeedTreeThread.h:56
ForestSet myDeletedForests
Set of deleted forest objects.
Definition: DtStreamedSpeedTreeThread.h:180
std::unordered_set< const osg::Node * > NodeSet
Set of request nodes.
Definition: DtStreamedSpeedTreeThread.h:69
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
std::unordered_set< std::string > StringSet
Set of model definition names.
Definition: DtStreamedSpeedTreeThread.h:75
tbb::atomic< bool > myTbbTaskActive
Definition: DtStreamedSpeedTreeThread.h:202
std::size_t hash_value(DtUnicode const &val)
Definition: DtUnicode.h:323
Contains makVrv::DtTreeRecord class.

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)