VR-Forces 4.10 Class Documentation
 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) 2020 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 
33 #include <string>
34 #include <list>
35 #include <vector>
36 
37 #include <boost/ptr_container/ptr_vector.hpp>
38 
39 #include <tbb/spin_rw_mutex.h>
40 #include <tbb/task_arena.h>
41 
42 #undef final
43 
47 class DtPoint;
48 class DtGeodeticCoord;
56 
57 namespace makVrf
58 {
60 }
61 
63 {
64 public:
65  class OsgEarthTileDataCallback;
66 
69  osgEarth::MapNode* mapNode);
70 
72  virtual bool useRawElevation() const;
73 
74  virtual bool useLandCoverData() const;
75 
76  unsigned getHighestLodForLandCover() const;
77 
78  void setLandCoverSurfaceCharacteristicsMapper(makVrf::DtSurfaceCharacteristicMap * mapper);
79 
80  void getSoilFromString(const std::string & soilType, DtSurface& surface) const;
81 
82  virtual const osg::ref_ptr<osgEarth::LandCoverLayer> getBestLandCoverLayer(const osgEarth::TileKey& key) const;
83 
85  virtual boost::optional<DtTerrainIntersectOptions::Fidelity> intersectFidelity() const;
86 
89  virtual unsigned maxLOD() const;
90  virtual void setMaxLOD(unsigned);
92 
96  virtual unsigned getMaxLODForBilinearIntersection() const;
97  virtual void setMaxLODForBilinearIntersection(unsigned);
99 
106  virtual double triangleOutputMergeTolerance() const;
107  virtual void setTriangleOutputMergeTolerance(double tol);
108  virtual double intersetionTriangleMergeTolerance() const;
109  virtual void setIntersectionTriangleMergeTolerance(double tol);
111 
114  virtual unsigned minElevationIndexLOD() const;
115  virtual void setMinElevationIndexLOD(unsigned);
116  virtual unsigned maxElevationIndexLOD() const;
117  virtual void setMaxElevationIndexLOD(unsigned);
119 
122  virtual double maxChordLengthBeforeSplitSquared() const;
123  virtual void setMaxChordLengthBeforeSplit(double);
125 
128  virtual unsigned maxElevationChordSplitTestLOD() const;
129  virtual void setMaxElevationChordSplitTestLOD(unsigned);
131 
133  virtual unsigned tileCount() const;
134 
136  virtual unsigned cellCount() const;
137 
139  virtual bool init(DtTerrainSourcePager&);
140 
144  virtual void addPagedInTile(
145  const osgEarth::TileKey& tilekey,
146  const boost::shared_ptr<DtTileData>& tileData);
147 
149  virtual void removePagedInTile(const osgEarth::TileKey tileKey);
150 
157  virtual bool dataAvailable(DtPagingMetaDataPtr metaData,
158  DtTerrainPagingGeometryPtr geometry);
159 
165  virtual bool findHeightFieldIntersections(
166  DtTerrainIntersectStatus& status,
167  const DtChord& chord,
169  const DtTerrainIntersectOptions& options) const;
170 
175  virtual bool halveChordAndFindHeightFieldIntrx(
176  const DtChord& chord, DtChord convertedChord,
177  const DtTerrainIntersectOptions& options,
178  DtTerrainIntersectStatus& status,
179  DtVrfChordIntersectRecordList& intList) const;
180 
184  virtual bool splitChordAt180AndFindHeightFieldIntrx(
185  const DtChord& chord,
186  const DtTerrainIntersectOptions& options,
187  DtTerrainIntersectStatus& status,
188  DtVrfChordIntersectRecordList& intList) const;
189 
193  virtual void processTriangles(
195  const DtTerrainProcessPolygonsBox& box);
196 
204  virtual void pageInData(DtPagingMetaDataPtr metaData,
205  DtTerrainPagingGeometryPtr geometry);
206 
212  virtual DtTerrainIntersectIDType findOldestPagedData(unsigned int& numTrianglesOut);
213 
216  virtual void pageOutOldestData(const int priority);
217 
219  virtual bool canPageOutData(DtTerrainIntersectIDType intersectId);
220 
221 
228  virtual osgEarth::TileKey getBestTileKey(const osgEarth::TileKey&) const;
229 
231  virtual void findMissingTiles(const DtTerrainPagingGeometryPtr& geometry, DtTileKeyList& tiles) const;
232 
234  void findPagedInTilesWithinExtent(std::vector<osgEarth::TileKey> & tileKeysPagedIn, const osgEarth::GeoExtent & extent) const;
235 
236  void findPagesAtLodWithinExtents(std::vector<osgEarth::TileKey> &tileKeysFound, const osgEarth::GeoExtent & extent, unsigned lod) const;
237 
239  virtual void writeIndex(IndexInterface&, IndexOutputInterface&) const;
242  virtual bool writeIndexLayers(IndexInterface&, unsigned precision) const;
243 
246  {
247  public:
249  static std::auto_ptr<IndexInputInterface> Create(const DtFilename&);
250 
251  virtual ~IndexInputInterface();
252 
253  virtual bool read(unsigned& lod, unsigned& x, unsigned& y, double& min, double& max, bool& valid) = 0;
254  };
255 
258  {
259  std::string name;
260  osgEarth::URI file;
261  bool isDefault;
262  double minTolerance, maxTolerance;
263  unsigned minlod, maxlod;
264  osgEarth::GeoExtent extent;
265 
266  explicit IndexConfig(const DtOsgEarthTerrainSourceTracker&, const osgEarth::Config&);
268  };
269 
271  virtual std::vector<IndexConfig> getIndexConfigInfoForLayer(
272  const osgEarth::ElevationLayer& layer) const;
273 
275  virtual void readIndex(
277  unsigned layerNumber,
278  const IndexConfig& idxConfig);
279 
282  virtual bool readIndexLayers();
283 
284 protected:
285 
286  virtual DtPageInTilesCommand* createPageInTilesCommand(
287  DtPagingMetaDataPtr metaData);
288 
289  virtual DtPageOutTilesCommand* createPageOutTilesCommand(
290  DtPagingMetaDataPtr metaData);
291 
292  virtual bool aboveAllTerrain(
293  const DtChord& geocentricChord,
294  const DtChord& geodeticCoord) const;
295 
298  virtual bool shortEnoughForIntersection(
299  const DtChord& geocentricChord,
300  const DtChord& geodeticChord,
301  double chordLengthSq) const;
302 
305  virtual bool crosses180Lon(const DtChord& geodeticChord) const;
306 
307  virtual bool findData(
308  const DtTerrainPagingGeometry* geometry,
309  std::vector< boost::shared_ptr<DtTileData> >& data,
310  const DtPagingMetaDataPtr& metaData = DtPagingMetaDataPtr(),
311  OsgEarthTileDataCallback* callback = 0) const;
312 
313  virtual bool findData(
314  const DtTerrainPagingGeometry* geometry,
315  std::vector< boost::shared_ptr<DtTileData> >& data,
316  OsgEarthTileDataCallback* callback) const;
317 
318  virtual void findMissing(
319  const DtTerrainPagingGeometry& geometry,
320  DtTileKeyList& missing) const;
321 
322  virtual boost::shared_ptr<DtTileData> findOldest() const;
323  virtual boost::shared_ptr<DtTileData> findOldestUnlocked() const;
324 
325  typedef boost::ptr_vector<TileSpatialIndex> TileRoots;
326 
328  osgEarth::ElevationLayerVector myElevationLayers;
329 
331  osgEarth::ElevationLayerVector myFlattenedElevationLayers;
332 
334 
335  std::vector<osg::ref_ptr<osgEarth::LandCoverLayer> > myLandCoverLayers;
336 
338 
340  const bool myUseRawElevation;
341 
343 
345  unsigned int myMaxLOD;
346 
349 
353 
357 
360 
363 
366 
368  const double myWorldWidth;
369 
372 
374  boost::weak_ptr<DtTileData> myOldestData;
375  boost::weak_ptr<DtTileData> myOldestLandData;
376 
378  tbb::task_arena myArena;
379 };
380 
382 {
383 public:
384  explicit OsgEarthTileDataCallback();
385 
386  virtual bool operator()(const boost::shared_ptr<DtTileData>& tile) = 0;
387 
388 private:
390 };
boost::ptr_vector< TileSpatialIndex > TileRoots
Definition: osgEarthTerrainSourceTracker.h:325
boost::weak_ptr< DtTileData > myOldestData
cached pointer to oldest tile data
Definition: osgEarthTerrainSourceTracker.h:374
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:356
DtVrfChordIntersectionRecord represents a list of DtChordIntersectRecords.
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:351
Definition: osgEarthCommands.h:44
double myMaxChordLengthBeforeSplitSquared
max chord length squared before chords are split
Definition: osgEarthTerrainSourceTracker.h:359
DtTerrainSourcePager is the base class for terrain pagers.
Definition: terrainSourcePager.h:58
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:40
virtual unsigned getMaxLODForBilinearIntersection() const
unsigned myMaxElevationChordSplitLOD
max lod used for estimated max elevation under chord for spliting chords
Definition: osgEarthTerrainSourceTracker.h:362
unsigned minlod
Definition: osgEarthTerrainSourceTracker.h:263
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:262
unsigned myMinElevationIndexLOD
range of LODs where elevation from index will be used
Definition: osgEarthTerrainSourceTracker.h:355
virtual bool init(DtTerrainSourcePager &)
Called after options are set.
virtual void pageInData(DtPagingMetaDataPtr metaData, DtTerrainPagingGeometryPtr geometry)=0
Page in data within geometry.
double myIntersetionTriangleMergeTolerance
Definition: osgEarthTerrainSourceTracker.h:352
const bool myUseRawElevation
use elevation (if false old geometry system will be used)
Definition: osgEarthTerrainSourceTracker.h:340
const double myWorldWidth
width of world in osgearth coord sys, used for wrapping coords
Definition: osgEarthTerrainSourceTracker.h:368
bool isDefault
Definition: osgEarthTerrainSourceTracker.h:261
virtual void pageOutOldestData(const int priority)=0
Adds a page out command for the least-recently-used tileID to myCommandQueue.
Definition: surface.h:179
std::string name
Definition: osgEarthTerrainSourceTracker.h:259
tbb::concurrent_queue< DtTerrainPagerCommand * > DtPagerCommandQueue
Definition: vantageTerrainImplementationUtil.h:30
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:371
virtual bool dataAvailable(DtPagingMetaDataPtr metaData, DtTerrainPagingGeometryPtr geometry)=0
unsigned int myMaxLOD
max LOD of the whole system
Definition: osgEarthTerrainSourceTracker.h:345
Definition: surfaceCharacteristicMap.h:27
unsigned int myMaxLODForBilinearIntersection
max LOD which will use exact intersection with bilinear surface
Definition: osgEarthTerrainSourceTracker.h:348
Definition: osgEarthTerrainSourceTracker.h:62
Generic interface for reading from index.
Definition: osgEarthTerrainSourceTracker.h:245
osgEarth::ElevationLayerVector myFlattenedElevationLayers
flattens composite layers
Definition: osgEarthTerrainSourceTracker.h:331
DtTerrainIntersectOptions Passed to terrain intersect functions to modify how intersect acts...
Definition: terrainIntersectOptions.h:15
Definition: surfaceCharacteristicsMap.h:28
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.
Definition: terrainSourceTracker.h:75
virtual bool operator()(const boost::shared_ptr< DtTileData > &tile)=0
makVrf::DtSurfaceCharacteristicMap * myLandCoverCharacteristicsMap
Definition: osgEarthTerrainSourceTracker.h:333
Information about each individual index file.
Definition: osgEarthTerrainSourceTracker.h:257
virtual boost::optional< DtTerrainIntersectOptions::Fidelity > intersectFidelity() const
Fidelity that this tracker is configured for.
Definition: terrainSourceTracker.h:235
tbb::task_arena myArena
Tbb arena to limit number of threads.
Definition: osgEarthTerrainSourceTracker.h:378
Generic interface for writing to index.
Definition: indexOutputInterface.h:16
osgEarth::GeoExtent extent
Definition: osgEarthTerrainSourceTracker.h:264
virtual unsigned maxElevationIndexLOD() const
Definition: osgEarthCommands.h:19
Abstract base class for defining geometric areas for paging of terrain.
Definition: terrainPagingGeometry.h:24
virtual double triangleOutputMergeTolerance() const
bool myUseLandCover
Definition: osgEarthTerrainSourceTracker.h:342
Fidelity
Allows the system to use differently fidelity data for intersecting against.
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:260
std::vector< osg::ref_ptr< osgEarth::LandCoverLayer > > myLandCoverLayers
Definition: osgEarthTerrainSourceTracker.h:335
unsigned myHighestLodForLandCover
Definition: osgEarthTerrainSourceTracker.h:337
boost::weak_ptr< DtTileData > myOldestLandData
Definition: osgEarthTerrainSourceTracker.h:375
Interface for getting terrain triangle data out of DtTerrainInterface::trianglesInArea.
Definition: terrainProcessPolygonsBox.h:113
This class wraps the VR-Vantage Display Engine, and uses as a terrain loader and intersector.
Definition: vantageTerrainEngine.h:99
virtual bool canPageOutData(DtTerrainIntersectIDType intersectId)=0
DtBoost::shared_ptr< DtPagingMetaData > DtPagingMetaDataPtr
Definition: terrainPagingGeometry.h:101
Interface for allowing users to monitor/control the indexing process.
Definition: indexInterface.h:13
osgEarth::ElevationLayerVector myElevationLayers
top level elevation layers
Definition: osgEarthTerrainSourceTracker.h:328
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.
TileRoots myTileSpatialIndexRoots
roots of the quad tree (not necessarily 4, geodetic usually has 2)
Definition: osgEarthTerrainSourceTracker.h:365
Represents an area query which can be used to extract triangles from DtTerrainInterface.
Definition: terrainProcessPolygonsBox.h:39

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)