VR-Forces 4.7 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) 2015 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 <OpenThreads/Thread>
21 #include <OpenThreads/Block>
22 
23 #include <boost/thread/mutex.hpp>
24 #include <boost/unordered_set.hpp>
25 
26 #include <deque>
27 
28 namespace osg
29 {
30  class Node;
31 }
32 
33 namespace makVrv
34 {
35  class DtDe;
36  class DtStreamedSpeedTreeForest;
37 
41  {
42  public:
44  static DtStreamedSpeedTreeThread& instance(DtDe& de);
45 
47  virtual ~DtStreamedSpeedTreeThread();
48 
50  enum RequestStatus { UNUSED, WORKING, DONE };
51 
56  {
59 
62 
66  const osg::Node* dataNode;
67 
74  };
75 
78  {
81 
87 
90 
95  float treeMinScale;
96  float treeMaxScale;
98 
100  const osg::Node* dataNode;
101  };
102 
104  typedef std::list<TreeRequestOutput> RequestOutputList;
105 
107  typedef boost::unordered_set<const osg::Node*> NodeSet;
108 
110  typedef boost::unordered_set<DtStreamedSpeedTreeForest*> ForestSet;
111 
113  typedef boost::unordered_set<std::string> StringSet;
114 
119  RequestOutputList& requestOutput();
120 
125  NodeSet& unloaded();
126 
128  void setForestDeleted(DtStreamedSpeedTreeForest* forest);
129 
131  void setNodeUnloaded(const osg::Node* node);
132 
134  void enqueue(
136  TreeRequestOutput* out,
138  const osg::Node* dataNode,
139  bool useScaleRandomization,
140  bool useOrientationRandomization,
141  float treeMinScale,
142  float treeMaxScale);
143 
145  virtual void run();
146 
148  void handleRequest(const TreeRequestMsg& msg);
149 
151  bool isForestDeleted(DtStreamedSpeedTreeForest* forest);
152 
154  bool isNodeUnloaded(const osg::Node* node);
155 
159  static std::size_t hash_value(const std::string& modelDefName,
161 
165  static void mergeTreeRequests(DtDe& de);
166 
168  void block();
169 
171  void release();
172 
174  virtual void updateBlock();
175 
176  protected:
177 
180 
181  protected:
182 
184 
188  std::deque<TreeRequestMsg> myMessageQueue;
189 
190  // Don't keep spinning if we don't have data
191  OpenThreads::Block myBlock;
192 
194  boost::mutex myMessageQueueMutex;
195 
200 
206 
212 
218 
221  };
222 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)