VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
osgEarthTerrainSourceTracker.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
19 
21 
22 #include <vrfutil/vertexList.h>
23 
24 //Mak Terrain Toolkit includes
25 #include <geometry/sphere.h>
26 
27 #include <osgTerrain/TerrainTile>
28 #include <osgEarth/LandCoverLayer>
29 #include <osgEarth/Profile>
30 #include <osgEarth/TileKey>
31 #include <osgEarth/MapNode>
32 #include <osgEarth/TerrainTileModel>
33 #include <osgEarthProcedural/LifeMapLayer>
34 
35 #include <string>
36 #include <list>
37 #include <vector>
38 #include <map>
39 
40 #include <boost/ptr_container/ptr_vector.hpp>
41 
42 #include <tbb/spin_rw_mutex.h>
43 #include <tbb/task_arena.h>
44 #include <vrfutil/RTree.h>
45 
46 #undef final
47 
51 class DtPoint;
52 class DtGeodeticCoord;
60 
61 namespace makVrf
62 {
64 }
65 
67 {
68 public:
69  class OsgEarthTileDataCallback;
70  typedef boost::ptr_vector<TileSpatialIndex> TileRoots;
71 
74  static const unsigned int theGuiMaxRenderLod;
75 
78  osgEarth::MapNode* mapNode);
79 
80  virtual DtTerrainCategoryMask terrainCategories() const override;
81 
83  virtual bool useRawElevation() const override;
84 
85  virtual bool useLandCoverData() const override;
86 
87  virtual bool useLifeMapLayer() const override;
88 
89  unsigned getHighestLodForLandCover() const;
90 
91  void setLandCoverSurfaceCharacteristicsMapper(makVrf::DtSurfaceCharacteristicMap * mapper);
92 
93  virtual void getSoilFromString(const std::string & soilType, DtSurface& surface) const override;
94 
95  virtual const osg::ref_ptr<osgEarth::LandCoverLayer> getBestLandCoverLayer(const osgEarth::TileKey& key) const;
96 
98  virtual boost::optional<DtTerrainIntersectOptions::Fidelity> intersectFidelity() const override;
99 
102  virtual unsigned maxLOD() const override;
103  virtual void setMaxLOD(unsigned);
105 
109  virtual unsigned getMaxLODForBilinearIntersection() const override;
110  virtual void setMaxLODForBilinearIntersection(unsigned);
112 
119  virtual double triangleOutputMergeTolerance() const override;
120  virtual void setTriangleOutputMergeTolerance(double tol);
121  virtual double intersetionTriangleMergeTolerance() const override;
122  virtual void setIntersectionTriangleMergeTolerance(double tol);
124 
127  virtual unsigned minElevationIndexLOD() const override;
128  virtual void setMinElevationIndexLOD(unsigned);
129  virtual unsigned maxElevationIndexLOD() const override;
130  virtual void setMaxElevationIndexLOD(unsigned);
132 
135  virtual double maxChordLengthBeforeSplitSquared() const;
136  virtual void setMaxChordLengthBeforeSplit(double);
138 
141  virtual unsigned maxElevationChordSplitTestLOD() const;
142  virtual void setMaxElevationChordSplitTestLOD(unsigned);
144 
146  virtual unsigned tileCount() const;
147 
149  virtual unsigned cellCount() const;
150 
152  virtual bool init(DtTerrainSourcePager&) override;
153 
157  virtual void addPagedInTile(
158  const osgEarth::TileKey& tilekey,
159  const std::shared_ptr<DtTileData>& tileData);
160 
162  virtual void removePagedInTile(const osgEarth::TileKey tileKey);
163 
170  virtual bool dataAvailable(DtPagingMetaDataPtr metaData,
171  DtTerrainPagingGeometryPtr geometry) override;
172 
178  virtual bool findHeightFieldIntersections(
179  DtTerrainIntersectStatus& status,
180  const DtChord& chord,
182  const DtTerrainIntersectOptions& options);
183 
188  virtual bool halveChordAndFindHeightFieldIntrx(
189  const DtChord& chord, DtChord convertedChord,
190  const DtTerrainIntersectOptions& options,
191  DtTerrainIntersectStatus& status,
193 
197  virtual bool splitChordAt180AndFindHeightFieldIntrx(
198  const DtChord& chord,
199  const DtTerrainIntersectOptions& options,
200  DtTerrainIntersectStatus& status,
202 
206  virtual void processTriangles(
208  const DtTerrainProcessPolygonsBox& box);
209 
217  virtual void pageInData(DtPagingMetaDataPtr metaData,
218  DtTerrainPagingGeometryPtr geometry) override;
219 
225  virtual DtTerrainIntersectIDType findOldestPagedData(unsigned int& numTrianglesOut) override;
226 
229  virtual void pageOutOldestData(const int priority) override;
230 
232  virtual bool canPageOutData(DtTerrainIntersectIDType intersectId) override;
233 
234 
241  virtual osgEarth::TileKey getBestTileKey(const osgEarth::TileKey&) const override;
242 
244  virtual void findMissingTiles(const DtTerrainPagingGeometryPtr& geometry, DtTileKeyList& tiles) const;
245 
247  void findPagedInTilesWithinExtent(std::vector<osgEarth::TileKey> & tileKeysPagedIn, const osgEarth::GeoExtent & extent) const;
248 
249  void findPagesAtLodWithinExtents(std::vector<osgEarth::TileKey> &tileKeysFound, const osgEarth::GeoExtent & extent, unsigned lod) const;
250 
252  virtual void writeIndex(IndexInterface&, IndexOutputInterface&) const;
255  virtual bool writeIndexLayers(IndexInterface&, unsigned precision) const;
256 
260  {
262  std::vector<std::string> myPagedInTileKey;
264  std::vector<std::string> myPagedOutTileKey;
273  };
274 
276  virtual std::vector<IndexConfig<DtOsgEarthTerrainSourceTracker>> getIndexConfigInfoForLayer(
277  const osgEarth::ElevationLayer& layer) const;
278 
280  virtual void readIndex(
282  unsigned layerNumber,
284 
287  virtual bool readIndexLayers(osgEarth::ElevationLayerVector& flattenedElevationLayers);
288 
290  virtual void enableMetrics(bool value);
291 
293  virtual void getMetrics(TrackerMetric& trackerMetric) const;
294 
296  virtual DtOsgEarthTerrainSourcePager* getOsgEarthTerrainSourcePager() { return myOsgearthPager; }
297 
298 
299 protected:
300 
301  virtual DtPageInTilesCommand* createPageInTilesCommand(
302  DtPagingMetaDataPtr metaData);
303 
304  virtual DtPageOutTilesCommand* createPageOutTilesCommand(
305  DtPagingMetaDataPtr metaData);
306 
307  virtual bool aboveAllTerrain(
308  const DtChord& geocentricChord,
309  const DtChord& geodeticCoord) const;
310 
313  virtual bool shortEnoughForIntersection(
314  const DtChord& geocentricChord,
315  const DtChord& geodeticChord,
316  double chordLengthSq) const;
317 
320  virtual bool crosses180Lon(const DtChord& geodeticChord) const;
321 
322  virtual bool findData(
323  const DtTerrainPagingGeometry* geometry,
324  std::vector< std::shared_ptr<DtTileData> >& data,
325  const DtPagingMetaDataPtr& metaData = DtPagingMetaDataPtr(),
326  OsgEarthTileDataCallback* callback = nullptr) const;
327 
328  virtual bool findData(
329  const DtTerrainPagingGeometry* geometry,
330  std::vector< std::shared_ptr<DtTileData> >& data,
331  OsgEarthTileDataCallback* callback) const;
332 
333  virtual void findMissing(
334  const DtTerrainPagingGeometry& geometry,
335  DtTileKeyList& missing) const;
336 
337  virtual std::shared_ptr<DtTileData> findOldest() const;
338  virtual std::shared_ptr<DtTileData> findOldestUnlocked() const;
339 
341  virtual void resetMetrics();
342 
344  osgEarth::ElevationLayerVector myElevationLayers;
345 
347  osgEarth::ElevationLayerVector myFlattenedElevationLayers;
348 
350 
351  std::vector<osg::ref_ptr<osgEarth::LandCoverLayer> > myLandCoverLayers;
352  std::vector<osg::ref_ptr<osgEarth::Procedural::LifeMapLayer> > myLifeMapLayers;
353 
355 
357  const bool myUseRawElevation;
358 
361 
363  unsigned int myMaxLOD;
364 
367 
371 
375 
378 
381 
384 
386  const double myWorldWidth;
387 
390 
392  std::weak_ptr<DtTileData> myOldestData;
393  std::weak_ptr<DtTileData> myOldestLandData;
394 
396  tbb::task_arena myArena;
397 
400 
402  std::map<std::string, std::shared_ptr<DtLayerExtentTree> > myLayerExtentTrees;
403 
406 
409 
412 };
413 
415 {
416 public:
417  explicit OsgEarthTileDataCallback();
418 
419  virtual bool operator()(const std::shared_ptr<DtTileData>& tile) override = 0;
420 
421 private:
423 };
boost::ptr_vector< TileSpatialIndex > TileRoots
Definition: osgEarthTerrainSourceTracker.h:69
int myPagedInRequest
total number of pagedIn request
Definition: osgEarthTerrainSourceTracker.h:268
virtual unsigned minElevationIndexLOD() const
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
std::list< osgEarth::TileKey > DtTileKeyList
Definition: tileSpatialIndex.h:32
A terrain paging geometry which defines the paging area to be along a given shape.
Definition: terrainPagingShape.h:19
unsigned myMaxElevationIndexLOD
Definition: osgEarthTerrainSourceTracker.h:374
DtVrfChordIntersectionRecord represents a list of DtChordIntersectRecords. This is useful for followi...
Definition: vrfChordIntersectRecordList.h:31
double myTriangleOutputMergeTolerance
max error tolerances used to decide when it&#39;s not necessary triangle elevation to full resolution ...
Definition: osgEarthTerrainSourceTracker.h:369
Definition: osgEarthCommands.h:45
std::weak_ptr< DtTileData > myOldestLandData
Definition: osgEarthTerrainSourceTracker.h:393
double myMaxChordLengthBeforeSplitSquared
max chord length squared before chords are split
Definition: osgEarthTerrainSourceTracker.h:377
DtTerrainSourcePager is the base class for terrain pagers. There will be one terrainSourcePager per t...
Definition: terrainSourcePager.h:56
A terrain paging geometry which defines the paging area to be along a given set of local vertices...
Definition: terrainPagingSphere.h:20
DtOsgEarthTerrainSourcePager is a derived terrainSourcePager that handles a streaming terrain source...
Definition: osgEarthTerrainSourcePager.h:45
virtual unsigned getMaxLODForBilinearIntersection() const
unsigned int myFindHeightFieldIntersections
findHeightFieldIntersections count
Definition: osgEarthTerrainSourceTracker.h:272
unsigned myMaxElevationChordSplitLOD
max lod used for estimated max elevation under chord for spliting chords
Definition: osgEarthTerrainSourceTracker.h:380
Debug Metrics.
Definition: osgEarthTerrainSourceTracker.h:259
virtual bool useLandCoverData() const
Return true if the current tracker use land cover data.
unsigned long long DtTerrainIntersectIDType
Definition: terrainInterfaceDefines.h:28
unsigned myMinElevationIndexLOD
range of LODs where elevation from index will be used
Definition: osgEarthTerrainSourceTracker.h:373
virtual bool init(DtTerrainSourcePager &)
Called after options are set. Returns false if error.
virtual void pageInData(DtPagingMetaDataPtr metaData, DtTerrainPagingGeometryPtr geometry)=0
Page in data within geometry. Determines which tiles are within the geometry and adds a page in comma...
double myIntersetionTriangleMergeTolerance
Definition: osgEarthTerrainSourceTracker.h:370
std::weak_ptr< DtTileData > myOldestData
cached pointer to oldest tile data
Definition: osgEarthTerrainSourceTracker.h:392
const bool myUseRawElevation
use elevation (if false old geometry system will be used)
Definition: osgEarthTerrainSourceTracker.h:357
const double myWorldWidth
width of world in osgearth coord sys, used for wrapping coords
Definition: osgEarthTerrainSourceTracker.h:386
virtual void pageOutOldestData(const int priority)=0
Adds a page out command for the least-recently-used tileID to myCommandQueue.
Definition: surface.h:181
int myTileKeySize
number of paged tilekey metric (in the vector above)
Definition: osgEarthTerrainSourceTracker.h:266
Information about each individual index file.
Definition: terrainUtil.h:101
tbb::concurrent_queue< DtTerrainPagerCommand * > DtPagerCommandQueue
Definition: vantageTerrainImplementationUtil.h:42
virtual bool useRawElevation() const
Return true if the current tracker use raw elevation.
virtual unsigned maxLOD() const
Return the max lod.
virtual void getSoilFromString(const std::string &soilType, DtSurface &surface) const
DtTerrainIntersectOptions::Fidelity myFidelity
intersect fidelity for this layer
Definition: osgEarthTerrainSourceTracker.h:389
virtual bool dataAvailable(DtPagingMetaDataPtr metaData, DtTerrainPagingGeometryPtr geometry)=0
DtOsgEarthTerrainSourcePager * myOsgearthPager
Pointer to the associated pager.
Definition: osgEarthTerrainSourceTracker.h:411
unsigned int myMaxLOD
max LOD of the whole system
Definition: osgEarthTerrainSourceTracker.h:363
Definition: surfaceCharacteristicMap.h:27
unsigned int myMaxLODForBilinearIntersection
max LOD which will use exact intersection with bilinear surface
Definition: osgEarthTerrainSourceTracker.h:366
Definition: osgEarthTerrainSourceTracker.h:66
osgEarth::ElevationLayerVector myFlattenedElevationLayers
flattens composite layers
Definition: osgEarthTerrainSourceTracker.h:347
DtTerrainIntersectOptions Passed to terrain intersect functions to modify how intersect acts...
Definition: terrainIntersectOptions.h:22
Definition: surfaceCharacteristicsMap.h:51
std::vector< osg::ref_ptr< osgEarth::Procedural::LifeMapLayer > > myLifeMapLayers
Definition: osgEarthTerrainSourceTracker.h:352
virtual bool operator()(const std::shared_ptr< DtTileData > &tile)=0
std::map< std::string, std::shared_ptr< DtLayerExtentTree > > myLayerExtentTrees
Definition: osgEarthTerrainSourceTracker.h:402
bool myWarnedAboutCsType
Remember if a warning about CS type was given;.
Definition: osgEarthTerrainSourceTracker.h:399
std::shared_ptr< DtTerrainPagingGeometry > DtTerrainPagingGeometryPtr
Definition: terrainPagingGeometry.h:46
virtual osgEarth::TileKey getBestTileKey(const osgEarth::TileKey &) const
Return the best tile key to use (based on the tracker) for a pass tilekey.
virtual double intersetionTriangleMergeTolerance() const
Base class for Terrain Source trackers. Determines if the necessary data To perform an intersection i...
Definition: terrainSourceTracker.h:75
File I/O helper class, look below for implementation and notes.
Definition: RTree.h:58
makVrf::DtSurfaceCharacteristicMap * myLandCoverCharacteristicsMap
Definition: osgEarthTerrainSourceTracker.h:349
std::shared_ptr< DtPagingMetaData > DtPagingMetaDataPtr
Definition: terrainPagingGeometry.h:108
virtual boost::optional< DtTerrainIntersectOptions::Fidelity > intersectFidelity() const
Fidelity that this tracker is configured for. The default returns an empty optional which means that ...
virtual DtTerrainCategoryMask terrainCategories() const
Definition: terrainSourceTracker.h:253
tbb::task_arena myArena
Tbb arena to limit number of threads.
Definition: osgEarthTerrainSourceTracker.h:396
Generic interface for writing to index.
Definition: indexOutputInterface.h:16
virtual unsigned maxElevationIndexLOD() const
Definition: osgEarthCommands.h:20
makVrf::RTree< std::shared_ptr< osgEarth::DataExtent >, double, 2 > DtLayerExtentTree
Definition: osgEarthTerrainSourceTracker.h:401
Abstract base class for defining geometric areas for paging of terrain. Subclasses of this class will...
Definition: terrainPagingGeometry.h:24
virtual double triangleOutputMergeTolerance() const
virtual DtOsgEarthTerrainSourcePager * getOsgEarthTerrainSourcePager()
return the associated OsgEarthTerrainSourcePager
Definition: osgEarthTerrainSourceTracker.h:296
bool myUseLandCover
Definition: osgEarthTerrainSourceTracker.h:359
Fidelity
Allows the system to use differently fidelity data for intersecting against. Currently only implement...
Definition: terrainIntersectOptions.h:102
A terrain paging geometry which defines the paging area to be along a given chord.
Definition: terrainPagingChord.h:19
unsigned int DtTerrainCategoryMask
This bitmask is made using DtTerrainCategory values.
Definition: rwTerrainCategoryMask.h:27
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
std::vector< osg::ref_ptr< osgEarth::LandCoverLayer > > myLandCoverLayers
Definition: osgEarthTerrainSourceTracker.h:351
unsigned myHighestLodForLandCover
Definition: osgEarthTerrainSourceTracker.h:354
TrackerMetric myTrackerMetrics
Structure holding all the metric.
Definition: osgEarthTerrainSourceTracker.h:408
std::vector< std::string > myPagedInTileKey
debug metrics holding paged in tilekey
Definition: osgEarthTerrainSourceTracker.h:262
Generic interface for reading from index.
Definition: terrainUtil.h:88
Interface for getting terrain triangle data out of DtTerrainInterface::trianglesInArea. This object should always be created on the stack.
Definition: terrainProcessPolygonsBox.h:134
int myPagedOutRequest
total number of pagedOut request
Definition: osgEarthTerrainSourceTracker.h:270
std::vector< std::string > myPagedOutTileKey
debug metrics holding paged out tilekey
Definition: osgEarthTerrainSourceTracker.h:264
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:112
virtual bool canPageOutData(DtTerrainIntersectIDType intersectId)=0
bool myRecordMetrics
Are debug metrics enable.
Definition: osgEarthTerrainSourceTracker.h:405
virtual bool useLifeMapLayer() const
Return true if the current tracker use Biome data.
Interface for allowing users to monitor/control the indexing process.
Definition: indexInterface.h:13
osgEarth::ElevationLayerVector myElevationLayers
top level elevation layers
Definition: osgEarthTerrainSourceTracker.h:344
Definition: point.h:34
DtTerrainIntersectStatus Contains information about status of &quot;data available&quot; when an intersection c...
Definition: terrainIntersectStatus.h:23
virtual DtTerrainIntersectIDType findOldestPagedData(unsigned int &numTriangles)=0
Finds the least-recently-used tile and set myOldestPagedObject to it.
static const unsigned int theGuiMaxRenderLod
The LOD that the GUI renders to, regardless of data LOD. This is used to generate triangles from elev...
Definition: osgEarthTerrainSourceTracker.h:74
TileRoots myTileSpatialIndexRoots
roots of the quad tree (not necessarily 4, geodetic usually has 2)
Definition: osgEarthTerrainSourceTracker.h:383
Represents an area query which can be used to extract triangles from DtTerrainInterface. The box points are in local but the box is always projected against the local topo at the center point of the box.
Definition: terrainProcessPolygonsBox.h:60
bool myUseLifeMapLayer
Definition: osgEarthTerrainSourceTracker.h:360

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)