VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
terrainSourcePager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #pragma once
6 
9 
10 #include <string>
11 
12 #include <tbb/spin_rw_mutex.h>
13 #include <tbb/concurrent_queue.h>
14 #include <tbb/atomic.h>
15 
16 #include <osg/Node>
17 
22 
24 
26 
27 #include <boost/unordered_map.hpp>
28 #include <boost/optional.hpp>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/scoped_ptr.hpp>
31 
33 #include <boost/geometry.hpp>
34 #include <boost/geometry/geometries/point.hpp>
35 #include <boost/geometry/geometries/box.hpp>
36 
37 #include <boost/geometry/index/rtree.hpp>
38 
39 #include <map>
40 
46 
47 typedef std::multimap<int, DtTerrainPagerCommand*> DtCommandPriorityMultimap;
48 
55 {
56 public:
57 
59  DtTerrainSourcePager(DtVantageTerrainEngine* terrainEngine, osgEarth::MapNode* mapNode);
60 
62  virtual ~DtTerrainSourcePager();
63 
65  virtual bool init();
66 
70  virtual void tick();
71 
74  virtual void setEarthFileName(const DtFilename& file);
75 
77  virtual void setCutoutFilename(const char* OptionalSuffixe=NULL);
78 
84  virtual bool isContainedWithinCutoutCache(const osgEarth::GeoExtent & extent, const osgEarth::TileKey & key);
85 
87  virtual DtTerrainSourceTracker* createTerrainSourceTracker(DtVantageTerrainEngine*) = 0;
88 
90  virtual DtTerrainSourceTracker* terrainSourceTracker();
91 
92  virtual void updatePageTracker(DtTerrainIntersectIDType intersectId = 0) = 0;
93 
97  virtual int highestPriorityPendingWork();
98 
101  virtual void processCommandQueue();
102 
106  virtual void setCurrentTime(const double& currentTime);
107 
109  virtual unsigned long numTriangles() const;
110 
112  virtual bool quitFlagSet() const;
113 
115  virtual void setQuit(bool);
116 
118  virtual const Coordinate_System* localCS() const;
119 
121  virtual void setLabel(const DtString&);
122  virtual DtString label() const;
123 
124  virtual unsigned queuePageReloadsWithinExtent(const osgEarth::GeoExtent & extent, const DtUUID& dynamicUuid, bool isRemoval = false);
125 protected:
127  {
128  public:
129  typedef boost::unordered_map<DtNodeId, TerrainRecord> Map;
130 
132  void pageOut();
133 
134  protected:
136  };
137 
139  {
140  public:
141  DynamicTerrainNode(const DtUUID& dynamicTerrainUUID, const osgEarth::GeoExtent& extent);
142  DynamicTerrainNode(const DynamicTerrainNode & clone);
143  DynamicTerrainNode& operator=(const DynamicTerrainNode& rhs);
144 
145  void setGeoExent(const osgEarth::GeoExtent& extent);
146  const osgEarth::GeoExtent& geoExtent() const;
147 
148  void setUUID(const DtUUID& dynamicTerrainUUID);
149  const DtUUID& uuid() const;
150 
151  protected:
152  osgEarth::GeoExtent myExtent;
154 
155  };
156 
157  typedef boost::geometry::model::point<double, 2, boost::geometry::cs::geographic<boost::geometry::degree> > DtDynamicTerrainRtreeCoord;
158  typedef boost::geometry::model::box<DtDynamicTerrainRtreeCoord> DtDynamicTerrainRtreeBox;
159  typedef std::pair<DtDynamicTerrainRtreeBox, boost::shared_ptr<DynamicTerrainNode> > DtDynamicTerrainRtreeValue;
160 
161  typedef boost::geometry::index::rtree<DtDynamicTerrainRtreeValue, boost::geometry::index::quadratic<16> > DtDynamicTerrainRtree;
162 
163 
165  {
166  public:
169  DtPendingTileKeyReload(const osgEarth::TileKey & key, bool isRemoval, unsigned count = 1);
170  bool operator<(const DtPendingTileKeyReload & rhs) const;
171  bool operator==(const DtPendingTileKeyReload & rhs) const;
172  bool operator!=(const DtPendingTileKeyReload & rhs) const;
173  DtPendingTileKeyReload & operator=(const DtPendingTileKeyReload & rhs);
174 
176  osgEarth::TileKey myTileKey;
177  };
178 
179  typedef std::set<DtPendingTileKeyReload> DtPendingTileKeyReloadSet;
180 
182  virtual void addTerrain(const osg::ref_ptr<osg::Node>& node, DtVrfSimTerrainProcessor&);
183 
185  virtual void removeTerrain(const osg::ref_ptr<osg::Node>& node);
186 
188  virtual void addTriangles(unsigned int);
189 
191  virtual void removeTriangles(unsigned int);
192 
197  void modifyDynamicTerrainExtent(const DtPoint & swCorner, const DtPoint & neCorner, bool isRemoval, unsigned amount = 1);
198 
203  bool hasDynamicTerrainWithinExtent(const DtPoint & swCorner, const DtPoint& neCorner) const;
204 
205  bool modifyDynamicTerrain(const osgEarth::GeoExtent& dynamicTerrainExtent, const DtUUID& dynamicTerrainUUID, bool isRemoval);
206  bool hasDynamicTerrainWithinExtent(std::vector<DtDynamicTerrainRtreeValue> & values, const osgEarth::GeoExtent & extent);
207 
209  typedef tbb::spin_rw_mutex Mutex;
210  mutable Mutex myMutex;
211 
214 
216  tbb::atomic<bool> myQuitFlag;
217 
221 
224 
229 
232 
236 
238  unsigned long myNumTriangles;
239 
241 
242  boost::optional<short int> myDefaultBulletObjectMask;
243 
246 
248  DtFilename myEarthFile;
249 
254  boost::scoped_ptr<DtCutoutCache> myCutoutCache;
255 
258 
260  mutable tbb::spin_rw_mutex myTileKeysForReloadMutex;
263 
265  mutable tbb::spin_rw_mutex myDynamicTerrainRtreeMutex;
267 
269 
270  std::set<osgEarth::TileKey> mySetOfTileKeysToReload;
271 
272 };
UUID is a unique ID wrapper class.
Definition: rwUUID.h:222
boost::geometry::model::point< double, 2, boost::geometry::cs::geographic< boost::geometry::degree > > DtDynamicTerrainRtreeCoord
Definition: terrainSourcePager.h:157
Class DtTerrainInterfaceConfig is a readable-writable class holding terrain interface configuration o...
Definition: terrainInterfaceConfig.h:32
DtFilename myEarthFile
Path to earth file that was used to load this elevation source.
Definition: terrainSourcePager.h:248
osgEarth::TileKey myTileKey
Definition: terrainSourcePager.h:176
DtTerrainSourcePager is the base class for terrain pagers.
Definition: terrainSourcePager.h:53
std::set< DtPendingTileKeyReload > DtPendingTileKeyReloadSet
Definition: terrainSourcePager.h:179
std::multimap< int, DtTerrainPagerCommand * > DtCommandPriorityMultimap
Definition: terrainSourcePager.h:45
This class keeps track of what parts of the terrain database are currently paged in and what ones are...
Definition: activePageTracker.h:37
boost::unordered_map< DtNodeId, TerrainRecord > Map
Definition: terrainSourcePager.h:129
TerrainRecord::Map myTerrainRecords
Definition: terrainSourcePager.h:240
DtPendingTileKeyReloadSet myTileKeysForReload
Definition: terrainSourcePager.h:262
Mutex myMutex
Definition: terrainSourcePager.h:210
DT_DLL_terrainCS bool operator==(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
unsigned long long DtTerrainIntersectIDType
Definition: terrainInterfaceDefines.h:28
osg::ref_ptr< osgEarth::MapNode > myMapNode
Map node.
Definition: terrainSourcePager.h:245
boost::geometry::index::rtree< DtDynamicTerrainRtreeValue, boost::geometry::index::quadratic< 16 > > DtDynamicTerrainRtree
Definition: terrainSourcePager.h:161
DtUUID myUuid
Definition: terrainSourcePager.h:153
tbb::spin_rw_mutex myTileKeysForReloadMutex
Definition: terrainSourcePager.h:260
makVrv::DtDynamicTerrainWorld::FeatureHandle myFeatures
Definition: terrainSourcePager.h:135
tbb::concurrent_queue< DtTerrainPagerCommand * > DtPagerCommandQueue
Definition: vantageTerrainImplementationUtil.h:29
tbb::spin_rw_mutex myDynamicTerrainRtreeMutex
Definition: terrainSourcePager.h:265
DtVantageTerrainEngine * myTerrainEngine
Pointer to the terrain implementation&#39;s terrain engine.
Definition: terrainSourcePager.h:220
DtDynamicTerrainRtree myDynamicTerrainRtree
Definition: terrainSourcePager.h:268
std::set< osgEarth::TileKey > mySetOfTileKeysToReload
Definition: terrainSourcePager.h:270
Definition: coordSystem.h:54
Definition: terrainSourcePager.h:138
double myCurrentTime
Time to compare a command&#39;s expire time to before executing the command.
Definition: terrainSourcePager.h:228
tbb::atomic< bool > myQuitFlag
Set when the paging should stop.
Definition: terrainSourcePager.h:216
std::map< osgEarth::TileKey, boost::shared_ptr< DtTileData > > DtTerrainTileMap
Definition: tileData.h:316
Definition: terrainSourcePager.h:126
Base class for Terrain Source trackers.
Definition: terrainSourceTracker.h:40
bool myIsRemoval
Definition: terrainSourcePager.h:175
tbb::spin_rw_mutex Mutex
Definition: terrainSourcePager.h:209
std::pair< DtDynamicTerrainRtreeBox, boost::shared_ptr< DynamicTerrainNode > > DtDynamicTerrainRtreeValue
Definition: terrainSourcePager.h:159
DtCommandPriorityMultimap myPriorityCommandMultimap
Multimap of priorities to paging commands.
Definition: terrainSourcePager.h:235
unsigned long myNumTriangles
Number of triangles paged in to this pager.
Definition: terrainSourcePager.h:238
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
Contains makVrv::DtDynamicTerrainWorld class.
Definition: osgToBullet.h:99
Definition: terrainSourcePager.h:164
Feature Insertion/Removal/Paging Features represent parts of the terrain which are individually ident...
Definition: DtDynamicTerrainWorld.h:99
DT_DLL_terrainCS bool operator!=(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
boost::geometry::model::box< DtDynamicTerrainRtreeCoord > DtDynamicTerrainRtreeBox
Definition: terrainSourcePager.h:158
DtTerrainTileMap myPagedInTilesMap
Map of tileIds to terrainTiles.
Definition: terrainSourcePager.h:257
This class wraps the VR-Vantage Display Engine, and uses as a terrain loader and intersector.
Definition: vantageTerrainEngine.h:93
osgEarth::GeoExtent myExtent
Definition: terrainSourcePager.h:152
DtPagerCommandQueue myCommandQueue
Thread-safe queue to put commands on.
Definition: terrainSourcePager.h:231
DtTerrainSourceTracker * myTerrainSourceTracker
The terrain source tracker that is updated by this pager.
Definition: terrainSourcePager.h:223
boost::scoped_ptr< DtCutoutCache > myCutoutCache
Cache for storing mask cutout areas and skirt geometry.
Definition: terrainSourcePager.h:254
Definition: point.h:34
DtString myName
Definition: terrainSourcePager.h:213
boost::optional< short int > myDefaultBulletObjectMask
Definition: terrainSourcePager.h:242

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)