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) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
18 
20 
21 #include <vrfutil/vertexList.h>
22 
23 //Mak Terrain Toolkit includes
24 #include <geometry/sphere.h>
25 
26 #include <osgTerrain/TerrainTile>
27 #include <osgEarth/LandCoverLayer>
28 #include <osgEarth/Profile>
29 #include <osgEarth/TileKey>
30 #include <osgEarth/MapNode>
31 #include <osgEarth/TerrainTileModel>
32 #include <osgEarthProcedural/LifeMapLayer>
33 
34 #include <string>
35 #include <list>
36 #include <vector>
37 #include <map>
38 
39 #include <boost/ptr_container/ptr_vector.hpp>
40 
41 #include <tbb/spin_rw_mutex.h>
42 #include <tbb/task_arena.h>
43 #include <vrfutil/RTree.h>
44 
45 #undef final
46 
50 class DtPoint;
51 class DtGeodeticCoord;
59 
60 namespace makVrf
61 {
63 }
64 
66 {
67 public:
68  class OsgEarthTileDataCallback;
69  typedef boost::ptr_vector<TileSpatialIndex> TileRoots;
70 
73  static const unsigned int theGuiMaxRenderLod;
74 
77  osgEarth::MapNode* mapNode);
78 
80  virtual bool useRawElevation() const;
81 
82  virtual bool useLandCoverData() const;
83 
84  virtual bool useLifeMapLayer() const override;
85 
86  unsigned getHighestLodForLandCover() const;
87 
88  void setLandCoverSurfaceCharacteristicsMapper(makVrf::DtSurfaceCharacteristicMap * mapper);
89 
90  void getSoilFromString(const std::string & soilType, DtSurface& surface) const;
91 
92  virtual const osg::ref_ptr<osgEarth::LandCoverLayer> getBestLandCoverLayer(const osgEarth::TileKey& key) const;
93 
95  virtual boost::optional<DtTerrainIntersectOptions::Fidelity> intersectFidelity() const;
96 
99  virtual unsigned maxLOD() const;
100  virtual void setMaxLOD(unsigned);
102 
106  virtual unsigned getMaxLODForBilinearIntersection() const;
107  virtual void setMaxLODForBilinearIntersection(unsigned);
109 
116  virtual double triangleOutputMergeTolerance() const;
117  virtual void setTriangleOutputMergeTolerance(double tol);
118  virtual double intersetionTriangleMergeTolerance() const;
119  virtual void setIntersectionTriangleMergeTolerance(double tol);
121 
124  virtual unsigned minElevationIndexLOD() const;
125  virtual void setMinElevationIndexLOD(unsigned);
126  virtual unsigned maxElevationIndexLOD() const;
127  virtual void setMaxElevationIndexLOD(unsigned);
129 
132  virtual double maxChordLengthBeforeSplitSquared() const;
133  virtual void setMaxChordLengthBeforeSplit(double);
135 
138  virtual unsigned maxElevationChordSplitTestLOD() const;
139  virtual void setMaxElevationChordSplitTestLOD(unsigned);
141 
143  virtual unsigned tileCount() const;
144 
146  virtual unsigned cellCount() const;
147 
149  virtual bool init(DtTerrainSourcePager&);
150 
154  virtual void addPagedInTile(
155  const osgEarth::TileKey& tilekey,
156  const boost::shared_ptr<DtTileData>& tileData);
157 
159  virtual void removePagedInTile(const osgEarth::TileKey tileKey);
160 
167  virtual bool dataAvailable(DtPagingMetaDataPtr metaData,
168  DtTerrainPagingGeometryPtr geometry);
169 
175  virtual bool findHeightFieldIntersections(
176  DtTerrainIntersectStatus& status,
177  const DtChord& chord,
179  const DtTerrainIntersectOptions& options);
180 
185  virtual bool halveChordAndFindHeightFieldIntrx(
186  const DtChord& chord, DtChord convertedChord,
187  const DtTerrainIntersectOptions& options,
188  DtTerrainIntersectStatus& status,
190 
194  virtual bool splitChordAt180AndFindHeightFieldIntrx(
195  const DtChord& chord,
196  const DtTerrainIntersectOptions& options,
197  DtTerrainIntersectStatus& status,
199 
203  virtual void processTriangles(
205  const DtTerrainProcessPolygonsBox& box);
206 
214  virtual void pageInData(DtPagingMetaDataPtr metaData,
215  DtTerrainPagingGeometryPtr geometry);
216 
222  virtual DtTerrainIntersectIDType findOldestPagedData(unsigned int& numTrianglesOut);
223 
226  virtual void pageOutOldestData(const int priority);
227 
229  virtual bool canPageOutData(DtTerrainIntersectIDType intersectId);
230 
231 
238  virtual osgEarth::TileKey getBestTileKey(const osgEarth::TileKey&) const;
239 
241  virtual void findMissingTiles(const DtTerrainPagingGeometryPtr& geometry, DtTileKeyList& tiles) const;
242 
244  void findPagedInTilesWithinExtent(std::vector<osgEarth::TileKey> & tileKeysPagedIn, const osgEarth::GeoExtent & extent) const;
245 
246  void findPagesAtLodWithinExtents(std::vector<osgEarth::TileKey> &tileKeysFound, const osgEarth::GeoExtent & extent, unsigned lod) const;
247 
249  virtual void writeIndex(IndexInterface&, IndexOutputInterface&) const;
252  virtual bool writeIndexLayers(IndexInterface&, unsigned precision) const;
253 
256  {
257  public:
259  static std::auto_ptr<IndexInputInterface> Create(const DtFilename&);
260 
261  virtual ~IndexInputInterface();
262 
263  virtual bool read(unsigned& lod, unsigned& x, unsigned& y, double& min, double& max, bool& valid) = 0;
264  };
265 
268  {
269  std::string name;
270  osgEarth::URI file;
271  bool isDefault;
272  double minTolerance, maxTolerance;
273  unsigned minlod, maxlod;
274  osgEarth::GeoExtent extent;
275 
276  explicit IndexConfig(const DtOsgEarthTerrainSourceTracker&, const osgEarth::Config&);
278  };
279 
281  virtual std::vector<IndexConfig> getIndexConfigInfoForLayer(
282  const osgEarth::ElevationLayer& layer) const;
283 
285  virtual void readIndex(
287  unsigned layerNumber,
288  const IndexConfig& idxConfig);
289 
292  virtual bool readIndexLayers();
293 
294 protected:
295 
296  virtual DtPageInTilesCommand* createPageInTilesCommand(
297  DtPagingMetaDataPtr metaData);
298 
299  virtual DtPageOutTilesCommand* createPageOutTilesCommand(
300  DtPagingMetaDataPtr metaData);
301 
302  virtual bool aboveAllTerrain(
303  const DtChord& geocentricChord,
304  const DtChord& geodeticCoord) const;
305 
308  virtual bool shortEnoughForIntersection(
309  const DtChord& geocentricChord,
310  const DtChord& geodeticChord,
311  double chordLengthSq) const;
312 
315  virtual bool crosses180Lon(const DtChord& geodeticChord) const;
316 
317  virtual bool findData(
318  const DtTerrainPagingGeometry* geometry,
319  std::vector< boost::shared_ptr<DtTileData> >& data,
320  const DtPagingMetaDataPtr& metaData = DtPagingMetaDataPtr(),
321  OsgEarthTileDataCallback* callback = 0) const;
322 
323  virtual bool findData(
324  const DtTerrainPagingGeometry* geometry,
325  std::vector< boost::shared_ptr<DtTileData> >& data,
326  OsgEarthTileDataCallback* callback) const;
327 
328  virtual void findMissing(
329  const DtTerrainPagingGeometry& geometry,
330  DtTileKeyList& missing) const;
331 
332  virtual boost::shared_ptr<DtTileData> findOldest() const;
333  virtual boost::shared_ptr<DtTileData> findOldestUnlocked() const;
334 
336  osgEarth::ElevationLayerVector myElevationLayers;
337 
339  osgEarth::ElevationLayerVector myFlattenedElevationLayers;
340 
342 
343  std::vector<osg::ref_ptr<osgEarth::LandCoverLayer> > myLandCoverLayers;
344  std::vector<osg::ref_ptr<osgEarth::Procedural::LifeMapLayer> > myLifeMapLayers;
345 
347 
349  const bool myUseRawElevation;
350 
353 
355  unsigned int myMaxLOD;
356 
359 
363 
367 
370 
373 
376 
378  const double myWorldWidth;
379 
382 
384  boost::weak_ptr<DtTileData> myOldestData;
385  boost::weak_ptr<DtTileData> myOldestLandData;
386 
388  tbb::task_arena myArena;
389 
392 
394  std::map<std::string, boost::shared_ptr<DtLayerExtentTree> > myLayerExtentTrees;
395 };
396 
398 {
399 public:
400  explicit OsgEarthTileDataCallback();
401 
402  virtual bool operator()(const boost::shared_ptr<DtTileData>& tile) = 0;
403 
404 private:
406 };
boost::ptr_vector< TileSpatialIndex > TileRoots
Definition: osgEarthTerrainSourceTracker.h:68
boost::weak_ptr< DtTileData > myOldestData
cached pointer to oldest tile data
Definition: osgEarthTerrainSourceTracker.h:384
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
DtBoost::shared_ptr< DtTerrainPagingGeometry > DtTerrainPagingGeometryPtr
Definition: terrainPagingGeometry.h:46
A terrain paging geometry which defines the paging area to be along a given shape.
Definition: terrainPagingShape.h:19
unsigned myMaxElevationIndexLOD
Definition: osgEarthTerrainSourceTracker.h:366
DtVrfChordIntersectionRecord represents a list of DtChordIntersectRecords. This is useful for followi...
Definition: vrfChordIntersectRecordList.h:31
makVrf::RTree< boost::shared_ptr< osgEarth::DataExtent >, double, 2 > DtLayerExtentTree
Definition: osgEarthTerrainSourceTracker.h:393
double myTriangleOutputMergeTolerance
max error tolerances used to decide when it&#39;s not necessary triangle elevation to full resolution ...
Definition: osgEarthTerrainSourceTracker.h:361
Definition: osgEarthCommands.h:45
double myMaxChordLengthBeforeSplitSquared
max chord length squared before chords are split
Definition: osgEarthTerrainSourceTracker.h:369
DtTerrainSourcePager is the base class for terrain pagers. There will be one terrainSourcePager per t...
Definition: terrainSourcePager.h:58
std::map< std::string, boost::shared_ptr< DtLayerExtentTree > > myLayerExtentTrees
Definition: osgEarthTerrainSourceTracker.h:394
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:36
virtual unsigned getMaxLODForBilinearIntersection() const
unsigned myMaxElevationChordSplitLOD
max lod used for estimated max elevation under chord for spliting chords
Definition: osgEarthTerrainSourceTracker.h:372
unsigned minlod
Definition: osgEarthTerrainSourceTracker.h:273
virtual bool useLandCoverData() const
Return true if the current tracker use land cover data.
unsigned long long DtTerrainIntersectIDType
Definition: terrainInterfaceDefines.h:28
double minTolerance
Definition: osgEarthTerrainSourceTracker.h:272
unsigned myMinElevationIndexLOD
range of LODs where elevation from index will be used
Definition: osgEarthTerrainSourceTracker.h:365
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:362
const bool myUseRawElevation
use elevation (if false old geometry system will be used)
Definition: osgEarthTerrainSourceTracker.h:349
const double myWorldWidth
width of world in osgearth coord sys, used for wrapping coords
Definition: osgEarthTerrainSourceTracker.h:378
bool isDefault
Definition: osgEarthTerrainSourceTracker.h:271
virtual void pageOutOldestData(const int priority)=0
Adds a page out command for the least-recently-used tileID to myCommandQueue.
Definition: surface.h:181
std::string name
Definition: osgEarthTerrainSourceTracker.h:269
tbb::concurrent_queue< DtTerrainPagerCommand * > DtPagerCommandQueue
Definition: vantageTerrainImplementationUtil.h:41
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:381
virtual bool dataAvailable(DtPagingMetaDataPtr metaData, DtTerrainPagingGeometryPtr geometry)=0
unsigned int myMaxLOD
max LOD of the whole system
Definition: osgEarthTerrainSourceTracker.h:355
Definition: surfaceCharacteristicMap.h:27
unsigned int myMaxLODForBilinearIntersection
max LOD which will use exact intersection with bilinear surface
Definition: osgEarthTerrainSourceTracker.h:358
Definition: osgEarthTerrainSourceTracker.h:65
Generic interface for reading from index.
Definition: osgEarthTerrainSourceTracker.h:255
osgEarth::ElevationLayerVector myFlattenedElevationLayers
flattens composite layers
Definition: osgEarthTerrainSourceTracker.h:339
DtTerrainIntersectOptions Passed to terrain intersect functions to modify how intersect acts...
Definition: terrainIntersectOptions.h:15
Definition: surfaceCharacteristicsMap.h:46
std::vector< osg::ref_ptr< osgEarth::Procedural::LifeMapLayer > > myLifeMapLayers
Definition: osgEarthTerrainSourceTracker.h:344
bool myWarnedAboutCsType
Remember if a warning about CS type was given;.
Definition: osgEarthTerrainSourceTracker.h:391
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
virtual bool operator()(const boost::shared_ptr< DtTileData > &tile)=0
makVrf::DtSurfaceCharacteristicMap * myLandCoverCharacteristicsMap
Definition: osgEarthTerrainSourceTracker.h:341
Information about each individual index file.
Definition: osgEarthTerrainSourceTracker.h:267
virtual boost::optional< DtTerrainIntersectOptions::Fidelity > intersectFidelity() const
Fidelity that this tracker is configured for. The default returns an empty optional which means that ...
Definition: terrainSourceTracker.h:247
tbb::task_arena myArena
Tbb arena to limit number of threads.
Definition: osgEarthTerrainSourceTracker.h:388
Generic interface for writing to index.
Definition: indexOutputInterface.h:16
osgEarth::GeoExtent extent
Definition: osgEarthTerrainSourceTracker.h:274
virtual unsigned maxElevationIndexLOD() const
Definition: osgEarthCommands.h:20
Abstract base class for defining geometric areas for paging of terrain. Subclasses of this class will...
Definition: terrainPagingGeometry.h:24
virtual double triangleOutputMergeTolerance() const
bool myUseLandCover
Definition: osgEarthTerrainSourceTracker.h:351
Fidelity
Allows the system to use differently fidelity data for intersecting against. Currently only implement...
Definition: terrainIntersectOptions.h:76
A terrain paging geometry which defines the paging area to be along a given chord.
Definition: terrainPagingChord.h:19
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
osgEarth::URI file
Definition: osgEarthTerrainSourceTracker.h:270
std::vector< osg::ref_ptr< osgEarth::LandCoverLayer > > myLandCoverLayers
Definition: osgEarthTerrainSourceTracker.h:343
unsigned myHighestLodForLandCover
Definition: osgEarthTerrainSourceTracker.h:346
boost::weak_ptr< DtTileData > myOldestLandData
Definition: osgEarthTerrainSourceTracker.h:385
Interface for getting terrain triangle data out of DtTerrainInterface::trianglesInArea. This object should always be created on the stack.
Definition: terrainProcessPolygonsBox.h:113
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
virtual bool canPageOutData(DtTerrainIntersectIDType intersectId)=0
DtBoost::shared_ptr< DtPagingMetaData > DtPagingMetaDataPtr
Definition: terrainPagingGeometry.h:101
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:336
Definition: point.h:34
DtTerrainIntersectStatus Contains information about result of terrain intersection.
Definition: terrainIntersectStatus.h:16
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:73
TileRoots myTileSpatialIndexRoots
roots of the quad tree (not necessarily 4, geodetic usually has 2)
Definition: osgEarthTerrainSourceTracker.h:375
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:39
bool myUseLifeMapLayer
Definition: osgEarthTerrainSourceTracker.h:352

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)