VR-Forces 4.6 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) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
16 
18 
20 
21 #include <vrfutil/vertexList.h>
22 
23 //Mak Terrain Toolkit includes
24 #include <geometry/sphere.h>
25 
26 //#include <vlutil/vlSmartPointers.h>
27 
28 #include <osgTerrain/TerrainTile>
29 #include <osgEarth/Profile>
30 #include <osgEarth/TileKey>
31 #include <osgEarth/MapNode>
32 #include <osgEarth/TerrainTileModel>
33 
34 #include <string>
35 #include <list>
36 #include <vector>
37 
38 #include <boost/ptr_container/ptr_vector.hpp>
39 
40 #include <tbb/spin_rw_mutex.h>
41 
45 class DtPoint;
46 class DtGeodeticCoord;
51 
52 typedef std::list<osgEarth::TileKey> DtTileKeyList;
53 
57 {
58  enum TileType
59  {
61  Empty
62  };
63 
66  {
67  typedef std::vector<Extent> Vector;
68 
70  static Vector Simplify(const Vector& extents);
71 
72  explicit Extent(const osgEarth::TileKey&);
73  explicit Extent(const DtVector& min, const DtVector& max);
74 
75  DtVector min, max;
76  };
77 
79  explicit DtTileData(
80  const DtOsgEarthTerrainSourceTracker& tracker,
81  const osgEarth::TileKey& key);
82 
84  virtual ~DtTileData();
85 
88 
90  const osgEarth::TileKey tileKey;
91 
93  osg::ref_ptr<osgEarth::TerrainTileModel> tileModel;
94 
97 
99  virtual void addMaskExtents(const Extent::Vector& extents);
100 
106  virtual bool insideValidArea(const DtPoint& p) const;
107 
114  virtual bool extentInsideValidArea(double x1, double y1, double x2, double y2) const;
115 
120  virtual bool extentOutsideValidArea(double x1, double y1, double x2, double y2) const;
121 
127  virtual bool addActiveTileKey(const osgEarth::TileKey& key) = 0;
128 
134  virtual void recomputeActiveTileKeyAreas() = 0;
135 
138 
141  std::vector< osg::ref_ptr<osg::Node> > geometries;
142 
144  virtual std::string description() const = 0;
145 
147  virtual unsigned numberOfVertices() const = 0;
148 
152  virtual unsigned numberOfTrianglesForVertices() const;
153 
155  virtual void getTriangleVertices(unsigned xindex, unsigned yindex, double& x, double& y) const = 0;
156 
159  virtual void heightfieldIndexForTriangleIndex(
160  unsigned triangleXIndex, unsigned triangleYIndex,
161  unsigned& heightFieldXUsed, unsigned& heightFieldYUsed) const = 0;
162 
164  virtual double interpolateHeight(
165  unsigned triangleXIndex, unsigned triangleYIndex,
166  unsigned* heightFieldXUsed = 0, unsigned* heightFieldYUsed = 0) const = 0;
167 
170  tbb::atomic<unsigned int> numTriangles;
171 
175 
177  virtual DtTerrainIntersectIDType getLastUsed() const = 0;
178 
180  virtual bool updateLastUsed(DtTerrainIntersectIDType value) = 0;
181 
188  virtual bool findIntersections(
189  const DtChord& chord,
190  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
192  bool singleCell = false,
193  bool insideValidAreaChecked = false) const;
194 
197  virtual bool findIntersections(
198  const DtChord& chord,
199  DtVrfChordIntersectRecordList& intList) const = 0;
200 
207  virtual void findTriangles(
208  const DtTerrainProcessPolygonsBox& box,
209  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
211  bool singleCell = false,
212  bool insideValidAreaChecked = false) const;
213 
216  virtual void findTriangles(
217  const DtTerrainProcessPolygonsBox& box,
218  DtTriangleOutputInterface&) const = 0;
219 
220 protected:
221  mutable tbb::spin_rw_mutex maskExtentsMutex;
222 
226 };
227 
229 {
230 public:
233  osgEarth::MapNode* mapNode);
234 
236 
238  virtual bool useRawElevation() const;
239 
242  virtual unsigned getMaxLOD() const;
243  virtual void setMaxLOD(unsigned);
245 
252  virtual double triangleOutputMergeTolerance() const;
253  virtual void setTriangleOutputMergeTolerance(double tol);
254  virtual double intersetionTriangleMergeTolerance() const;
255  virtual void setIntersectionTriangleMergeTolerance(double tol);
257 
262  virtual double maskTolerance() const;
263  virtual void setMaskTolerance(double tol);
265 
267  virtual unsigned tileCount() const;
268 
270  virtual unsigned cellCount() const;
271 
275  virtual void addPagedInTile(
276  const osgEarth::TileKey& tilekey,
277  const boost::shared_ptr<DtTileData>& tileData);
278 
280  virtual void removePagedInTile(const osgEarth::TileKey tileKey);
281 
288  virtual bool dataAvailable(DtPagingMetaDataPtr metaData,
289  DtTerrainPagingGeometryPtr geometry);
290 
291  virtual bool findHeightFieldIntersections(
292  const DtChord& chord,
294  bool* dataAvailable = 0) const;
295 
296  virtual void processTriangles(
298  const DtTerrainProcessPolygonsBox& box) const;
299 
307  virtual void pageInData(DtPagingMetaDataPtr metaData,
308  DtTerrainPagingGeometryPtr geometry);
309 
315  virtual DtTerrainIntersectIDType findOldestPagedData(unsigned int& numTrianglesOut);
316 
319  virtual void pageOutOldestData(const int priority);
320 
322  virtual void drawDebugInfo(btIDebugDraw* debugDrawer);
323 
325  virtual void drawElevation();
326 
328  virtual bool canPageOutData(DtTerrainIntersectIDType intersectId);
329 
332  virtual osgEarth::TileKey getBestTileKey(const osgEarth::TileKey&) const;
333 
335  virtual void findMissingTiles(const DtTerrainPagingGeometryPtr& geometry, DtTileKeyList& tiles) const;
336 
337 protected:
338 
339  virtual DtPageInTilesCommand* createPageInTilesCommand(
340  DtPagingMetaDataPtr metaData);
341 
342  virtual DtPageOutTilesCommand* createPageOutTilesCommand(
343  DtPagingMetaDataPtr metaData);
344 
345  virtual bool setDrawMode(DtDrawMode);
346 
347 protected:
348 
350  {
351  public:
352  explicit TileSpatialIndex(const DtOsgEarthTerrainSourceTracker&, const osgEarth::TileKey& tilekey);
353 
354  bool intersects(const DtTerrainPagingGeometry& geometry) const;
355  bool intersectsSubTile(const DtTerrainPagingGeometry& geometry, int i) const;
356 
357  bool chordIntersects(const DtChord& chord) const;
358  bool extentIntersects(const DtExtent& extent) const;
359  bool sphereIntersects(const DtSphere& sphere) const;
360  bool shapeIntersects(const DtLocalVertexList& shape) const;
361  bool chordIntersectsSubTile(const DtChord& chord, int i) const;
362  bool extentIntersectsSubTile(const DtExtent& shape, int i) const;
363  bool sphereIntersectsSubTile(const DtSphere& sphere, int i) const;
364  bool shapeIntersectsSubTile(const DtLocalVertexList& shape, int i) const;
365 
366  void findMissing(
367  const DtTerrainPagingGeometry& geometry,
368  DtTileKeyList& missing) const;
369 
370  bool findData(
371  const DtTerrainPagingGeometry* geometry,
372  std::vector< boost::shared_ptr<DtTileData> >& data) const;
373 
374  boost::shared_ptr<DtTileData> findOldest() const;
375 
376  bool addTile(const osgEarth::TileKey& key, const boost::shared_ptr<DtTileData>& data);
377  void removeTile(const osgEarth::TileKey& tilekey);
378  unsigned tileCount() const;
379  unsigned cellCount() const;
380 
381  const osgEarth::TileKey tileKey() const { return myTileKey; }
382 
383  protected:
384  void getExtent(DtVector& lower, DtVector& upper) const;
385  void getSubTileExtent(unsigned i, DtVector& lower, DtVector& upper, bool useElevation = true) const;
386 
388  bool isTileEmpty() const;
389 
392  virtual void recomputePagedInData();
393 
395 
396  const osgEarth::TileKey myTileKey;
397  const osgEarth::GeoExtent myGeoExtent;
398 
399  struct SubTileSlot
400  {
401  osgEarth::GeoExtent extent;
402  boost::scoped_ptr<TileSpatialIndex> subtile;
403  };
404 
406  SubTileSlot mySubTiles[4];
407 
409  boost::shared_ptr<DtTileData> myTileData;
410 
414 
417  };
418 
420  virtual void convertGeometry(
421  const DtTerrainPagingGeometryPtr& geometry,
422  std::vector<DtTerrainPagingGeometryPtr>& output) const;
423 
424  virtual bool convertGeometry(
425  const DtTerrainPagingChord& geometry,
426  std::vector<DtTerrainPagingGeometryPtr>& output) const;
427 
428  virtual bool convertGeometry(
429  const DtTerrainPagingSphere& geometry,
430  std::vector<DtTerrainPagingGeometryPtr>& output) const;
431 
432  virtual bool convertGeometry(
433  const DtTerrainPagingShape& geometry,
434  std::vector<DtTerrainPagingGeometryPtr>& output) const;
435 
436  virtual bool nearCenterOfEarth(const DtChord& chord) const;
437 
438  virtual bool findData(
439  const DtTerrainPagingGeometry* geometry,
440  std::vector< boost::shared_ptr<DtTileData> >& data,
441  const DtPagingMetaDataPtr& metaData = DtPagingMetaDataPtr()) const;
442 
443  virtual void findMissing(
444  const DtTerrainPagingGeometry& geometry,
445  DtTileKeyList& missing) const;
446 
447  virtual boost::shared_ptr<DtTileData> findOldest() const;
448  virtual boost::shared_ptr<DtTileData> findOldestUnlocked() const;
449 
450  typedef boost::ptr_vector<TileSpatialIndex> TileRoots;
451 
452  const osg::ref_ptr<osgEarth::MapNode> myMapNode;
453  std::vector< osg::ref_ptr<osgEarth::ElevationLayer> > myElevationLayers;
454 
456  unsigned int myMaxLOD;
460 
462  double myWorldWidth;
463 
464  boost::weak_ptr<DtTileData> myOldestData;
465 
466  typedef tbb::spin_mutex DrawerMutex;
468  std::auto_ptr<DtSharedMemoryBulletDebugDrawer> myExtentDrawer;
469  std::auto_ptr<DtSharedMemoryBulletDebugDrawer> myElevationDrawer;
470 };
471 
472 

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)