VR-Forces Developer's Guide
 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) 2022 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 
44 #define DO_NOT_USE_CUTOUT_CACHE
45 
51 
52 typedef std::multimap<int, DtTerrainPagerCommand*> DtCommandPriorityMultimap;
53 
60 {
61 public:
62 
64  DtTerrainSourcePager(DtVantageTerrainEngine* terrainEngine, osgEarth::MapNode* mapNode);
65 
67  virtual ~DtTerrainSourcePager();
68 
70  virtual bool init();
71 
75  virtual void tick();
76 
79  virtual void setEarthFileName(const DtFilename& file);
80 
82  virtual void setCutoutFilename(const char* OptionalSuffixe=NULL);
83 
89  virtual bool isContainedWithinCutoutCache(const osgEarth::GeoExtent & extent, const osgEarth::TileKey & key);
90 
92  virtual DtTerrainSourceTracker* createTerrainSourceTracker(DtVantageTerrainEngine*) = 0;
93 
95  virtual DtTerrainSourceTracker* terrainSourceTracker();
96 
97  virtual void updatePageTracker(DtTerrainIntersectIDType intersectId = 0) = 0;
98 
102  virtual int highestPriorityPendingWork();
103 
106  virtual void processCommandQueue();
107 
111  virtual void setCurrentTime(const double& currentTime);
112 
114  virtual unsigned long numTriangles() const;
115 
117  virtual bool quitFlagSet() const;
118 
120  virtual void setQuit(bool);
121 
123  virtual const Coordinate_System* localCS() const;
124 
126  virtual void setLabel(const DtString&);
127  virtual DtString label() const;
128 
130  virtual unsigned queuePageReloadsWithinExtent(const osgEarth::GeoExtent & extent, const DtUUID& dynamicUuid, bool isRemoval = false);
131 
133  virtual void clearCutoutCache();
134 
136  virtual void clearTerrainEngineReference();
137 
138 protected:
140  {
141  public:
142  typedef boost::unordered_map<DtNodeId, TerrainRecord> Map;
143 
145  void pageOut();
146 
147  protected:
149  };
150 
152  {
153  public:
154  DynamicTerrainNode(const DtUUID& dynamicTerrainUUID, const osgEarth::GeoExtent& extent);
155  DynamicTerrainNode(const DynamicTerrainNode & clone);
156  DynamicTerrainNode& operator=(const DynamicTerrainNode& rhs);
157 
158  void setGeoExent(const osgEarth::GeoExtent& extent);
159  const osgEarth::GeoExtent& geoExtent() const;
160 
161  void setUUID(const DtUUID& dynamicTerrainUUID);
162  const DtUUID& uuid() const;
163 
164  protected:
165  osgEarth::GeoExtent myExtent;
167 
168  };
169 
170  typedef boost::geometry::model::point<double, 2, boost::geometry::cs::geographic<boost::geometry::degree> > DtDynamicTerrainRtreeCoord;
171  typedef boost::geometry::model::box<DtDynamicTerrainRtreeCoord> DtDynamicTerrainRtreeBox;
172  typedef std::pair<DtDynamicTerrainRtreeBox, boost::shared_ptr<DynamicTerrainNode> > DtDynamicTerrainRtreeValue;
173 
174  typedef boost::geometry::index::rtree<DtDynamicTerrainRtreeValue, boost::geometry::index::quadratic<16> > DtDynamicTerrainRtree;
175 
176 
178  {
179  public:
182  DtPendingTileKeyReload(const osgEarth::TileKey & key, bool isRemoval, unsigned count = 1);
183  bool operator<(const DtPendingTileKeyReload & rhs) const;
184  bool operator==(const DtPendingTileKeyReload & rhs) const;
185  bool operator!=(const DtPendingTileKeyReload & rhs) const;
186  DtPendingTileKeyReload & operator=(const DtPendingTileKeyReload & rhs);
187 
189  osgEarth::TileKey myTileKey;
190  };
191 
192  typedef std::set<DtPendingTileKeyReload> DtPendingTileKeyReloadSet;
193 
195  virtual unsigned int addTerrain(const osg::ref_ptr<osg::Node>& node, DtVrfSimTerrainProcessor&, const char* debugWhoisCalling="unknown");
196 
198  virtual unsigned int removeTerrain(const osg::ref_ptr<osg::Node>& node, const char* debugWhoisCalling = "unknown");
199 
201  virtual void addTriangles(unsigned int, const char* debugString="unknown");
202 
204  virtual void removeTriangles(unsigned int, const char* debugString = "unknown");
205 
210  void modifyDynamicTerrainExtent(const DtPoint & swCorner, const DtPoint & neCorner, bool isRemoval, unsigned amount = 1);
211 
216  bool hasDynamicTerrainWithinExtent(const DtPoint & swCorner, const DtPoint& neCorner) const;
217 
218  bool modifyDynamicTerrain(const osgEarth::GeoExtent& dynamicTerrainExtent, const DtUUID& dynamicTerrainUUID, bool isRemoval);
219  bool hasDynamicTerrainWithinExtent(std::vector<DtDynamicTerrainRtreeValue> & values, const osgEarth::GeoExtent & extent);
220 
222  void eraseCommand(DtCommandPriorityMultimap::iterator& itr);
224  void eraseAndInsertCommand(DtCommandPriorityMultimap::iterator& itr);
226  bool getFirsCommand(DtCommandPriorityMultimap::iterator& itrToProcess);
227 
229  typedef tbb::spin_rw_mutex Mutex;
230  mutable Mutex myMutex;
231  static tbb::spin_rw_mutex myMultiMapMutex;
232 
235 
237  tbb::atomic<bool> myQuitFlag;
238 
242 
245 
250 
253 
257 
259  unsigned long myNumTriangles;
260 
261  tbb::spin_mutex myTerrainRecordsMutex;
263 
264  boost::optional<short int> myDefaultBulletObjectMask;
265 
267  osgEarth::MapNode* myMapNode;
268  const osgEarth::Map* myMap;
269  const osgEarth::Profile* myMapProfile;
270 
272  DtFilename myEarthFile;
273 
278  boost::scoped_ptr<DtCutoutCache> myCutoutCache;
279 
281  mutable tbb::spin_rw_mutex myPagedInTilesMapMutex;
282 
285 
287  mutable tbb::spin_rw_mutex myTileKeysForReloadMutex;
290 
292  mutable tbb::spin_rw_mutex myDynamicTerrainRtreeMutex;
294 
296 
297  std::set<osgEarth::TileKey> mySetOfTileKeysToReload;
298 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
boost::geometry::model::point< double, 2, boost::geometry::cs::geographic< boost::geometry::degree > > DtDynamicTerrainRtreeCoord
Definition: terrainSourcePager.h:170
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:272
osgEarth::TileKey myTileKey
Definition: terrainSourcePager.h:189
DtTerrainSourcePager is the base class for terrain pagers. There will be one terrainSourcePager per t...
Definition: terrainSourcePager.h:58
std::set< DtPendingTileKeyReload > DtPendingTileKeyReloadSet
Definition: terrainSourcePager.h:192
std::multimap< int, DtTerrainPagerCommand * > DtCommandPriorityMultimap
Definition: terrainSourcePager.h:50
This class keeps track of what parts of the terrain database are currently paged in and what ones are...
Definition: activePageTracker.h:38
boost::unordered_map< DtNodeId, TerrainRecord > Map
Definition: terrainSourcePager.h:142
TerrainRecord::Map myTerrainRecords
Definition: terrainSourcePager.h:262
DtPendingTileKeyReloadSet myTileKeysForReload
Definition: terrainSourcePager.h:289
Mutex myMutex
Definition: terrainSourcePager.h:230
DT_DLL_terrainCS bool operator==(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
unsigned long long DtTerrainIntersectIDType
Definition: terrainInterfaceDefines.h:28
boost::geometry::index::rtree< DtDynamicTerrainRtreeValue, boost::geometry::index::quadratic< 16 > > DtDynamicTerrainRtree
Definition: terrainSourcePager.h:174
DtUUID myUuid
Definition: terrainSourcePager.h:166
tbb::spin_rw_mutex myTileKeysForReloadMutex
Definition: terrainSourcePager.h:287
makVrv::DtDynamicTerrainWorld::FeatureHandle myFeatures
Definition: terrainSourcePager.h:148
tbb::concurrent_queue< DtTerrainPagerCommand * > DtPagerCommandQueue
Definition: vantageTerrainImplementationUtil.h:41
tbb::spin_rw_mutex myDynamicTerrainRtreeMutex
Definition: terrainSourcePager.h:292
DtVantageTerrainEngine * myTerrainEngine
Pointer to the terrain implementation&#39;s terrain engine. This class does not own the terrain engine...
Definition: terrainSourcePager.h:241
DtDynamicTerrainRtree myDynamicTerrainRtree
Definition: terrainSourcePager.h:295
std::set< osgEarth::TileKey > mySetOfTileKeysToReload
Definition: terrainSourcePager.h:297
Definition: coordSystem.h:54
Definition: terrainSourcePager.h:151
double myCurrentTime
Time to compare a command&#39;s expire time to before executing the command. If the command&#39;s expire time...
Definition: terrainSourcePager.h:249
tbb::atomic< bool > myQuitFlag
Set when the paging should stop.
Definition: terrainSourcePager.h:237
std::map< osgEarth::TileKey, boost::shared_ptr< DtTileData > > DtTerrainTileMap
Definition: tileData.h:335
Definition: terrainSourcePager.h:139
tbb::spin_mutex myTerrainRecordsMutex
Definition: terrainSourcePager.h:261
Base class for Terrain Source trackers. Determines if the necessary data To perform an intersection i...
Definition: terrainSourceTracker.h:75
bool myIsRemoval
Definition: terrainSourcePager.h:188
tbb::spin_rw_mutex myPagedInTilesMapMutex
Mutex for page in map.
Definition: terrainSourcePager.h:281
tbb::spin_rw_mutex Mutex
Definition: terrainSourcePager.h:229
std::pair< DtDynamicTerrainRtreeBox, boost::shared_ptr< DynamicTerrainNode > > DtDynamicTerrainRtreeValue
Definition: terrainSourcePager.h:172
DtCommandPriorityMultimap myPriorityCommandMultimap
Multimap of priorities to paging commands. Commands are taken off the queue and put here until they a...
Definition: terrainSourcePager.h:256
unsigned long myNumTriangles
Number of triangles paged in to this pager.
Definition: terrainSourcePager.h:259
const osgEarth::Profile * myMapProfile
Definition: terrainSourcePager.h:269
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
osgEarth::MapNode * myMapNode
Map node.
Definition: terrainSourcePager.h:267
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
Contains makVrv::DtDynamicTerrainWorld class.
Note: The implementation of this processor class can be found in osgToBullet.cxx (class called DtVrfS...
Definition: osgToBullet.h:272
Definition: terrainSourcePager.h:177
Feature Insertion/Removal/Paging Features represent parts of the terrain which are individually ident...
Definition: DtDynamicTerrainWorld.h:99
const osgEarth::Map * myMap
Definition: terrainSourcePager.h:268
DT_DLL_terrainCS bool operator!=(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
boost::geometry::model::box< DtDynamicTerrainRtreeCoord > DtDynamicTerrainRtreeBox
Definition: terrainSourcePager.h:171
DtTerrainTileMap myPagedInTilesMap
Map of tileIds to terrainTiles.
Definition: terrainSourcePager.h:284
This class wraps the VR-Vantage Display Engine, and uses as a terrain loader and intersector. This is the terrain engine that powers the DtVantageTerrainImplementation. The DtVantageTerrainEngine runs the DtDe it its own thread, and processes commands thought the command queue.
Definition: vantageTerrainEngine.h:109
osgEarth::GeoExtent myExtent
Definition: terrainSourcePager.h:165
DtPagerCommandQueue myCommandQueue
Thread-safe queue to put commands on.
Definition: terrainSourcePager.h:252
DtTerrainSourceTracker * myTerrainSourceTracker
The terrain source tracker that is updated by this pager.
Definition: terrainSourcePager.h:244
boost::scoped_ptr< DtCutoutCache > myCutoutCache
Cache for storing mask cutout areas and skirt geometry. Creating the cutout masks (areas of the eleva...
Definition: terrainSourcePager.h:278
static tbb::spin_rw_mutex myMultiMapMutex
Definition: terrainSourcePager.h:231
Definition: point.h:34
DtString myName
Definition: terrainSourcePager.h:234
boost::optional< short int > myDefaultBulletObjectMask
Definition: terrainSourcePager.h:264

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)