VR-Forces 4.6.1 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 
80  {
81  typedef std::vector<IndexExtent> Vector;
82 
83  explicit IndexExtent(const DtTileData& tile, const Extent& extent);
84 
85  unsigned minx, miny, maxx, maxy;
86  };
87 
89  explicit DtTileData(
90  const DtOsgEarthTerrainSourceTracker& tracker,
91  const osgEarth::TileKey& key);
92 
94  virtual ~DtTileData();
95 
98 
100  const osgEarth::TileKey tileKey;
101 
103  osg::ref_ptr<osgEarth::TerrainTileModel> tileModel;
104 
107 
109  virtual void addMaskExtents(const Extent::Vector& extents);
110 
116  virtual bool insideValidArea(const DtPoint& p) const;
117 
124  virtual bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
125 
131  virtual bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
132 
138  virtual bool addActiveTileKey(const osgEarth::TileKey& key) = 0;
139 
145  virtual void recomputeActiveTileKeyAreas() = 0;
146 
149 
152  std::vector< osg::ref_ptr<osg::Node> > geometries;
153 
155  virtual std::string description() const = 0;
156 
158  virtual unsigned numberOfVertices() const = 0;
159 
163  virtual unsigned numberOfTrianglesForVertices() const;
164 
166  virtual void getTriangleVertices(unsigned xindex, unsigned yindex, double& x, double& y) const = 0;
167 
169  virtual void getTriangleIndices(double x, double y, unsigned& xindex, unsigned& yindex) const = 0;
170 
173  virtual void heightfieldIndexForTriangleIndex(
174  unsigned triangleXIndex, unsigned triangleYIndex,
175  unsigned& heightFieldXUsed, unsigned& heightFieldYUsed) const = 0;
176 
178  virtual double interpolateHeight(
179  unsigned triangleXIndex, unsigned triangleYIndex,
180  unsigned* heightFieldXUsed = 0, unsigned* heightFieldYUsed = 0) const = 0;
181 
184  tbb::atomic<unsigned int> numTriangles;
185 
189 
191  virtual DtTerrainIntersectIDType getLastUsed() const = 0;
192 
194  virtual bool updateLastUsed(DtTerrainIntersectIDType value) = 0;
195 
202  virtual bool findIntersections(
203  const DtChord& chord,
204  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
206  bool singleCell = false,
207  bool insideValidAreaChecked = false) const;
208 
211  virtual bool findIntersections(
212  const DtChord& chord,
213  DtVrfChordIntersectRecordList& intList) const = 0;
214 
221  virtual void findTriangles(
222  const DtTerrainProcessPolygonsBox& box,
223  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
225  bool singleCell = false,
226  bool insideValidAreaChecked = false) const;
227 
230  virtual void findTriangles(
231  const DtTerrainProcessPolygonsBox& box,
232  DtTriangleOutputInterface&) const = 0;
233 
234 protected:
235  mutable tbb::spin_rw_mutex maskExtentsMutex;
236 
240 
243 };
244 
246 {
247 public:
250  osgEarth::MapNode* mapNode);
251 
253 
255  virtual bool useRawElevation() const;
256 
259  virtual unsigned getMaxLOD() const;
260  virtual void setMaxLOD(unsigned);
262 
269  virtual double triangleOutputMergeTolerance() const;
270  virtual void setTriangleOutputMergeTolerance(double tol);
271  virtual double intersetionTriangleMergeTolerance() const;
272  virtual void setIntersectionTriangleMergeTolerance(double tol);
274 
276  virtual unsigned tileCount() const;
277 
279  virtual unsigned cellCount() const;
280 
284  virtual void addPagedInTile(
285  const osgEarth::TileKey& tilekey,
286  const boost::shared_ptr<DtTileData>& tileData);
287 
289  virtual void removePagedInTile(const osgEarth::TileKey tileKey);
290 
297  virtual bool dataAvailable(DtPagingMetaDataPtr metaData,
298  DtTerrainPagingGeometryPtr geometry);
299 
300  virtual bool findHeightFieldIntersections(
301  const DtChord& chord,
303  bool* dataAvailable = 0) const;
304 
305  virtual void processTriangles(
307  const DtTerrainProcessPolygonsBox& box) const;
308 
316  virtual void pageInData(DtPagingMetaDataPtr metaData,
317  DtTerrainPagingGeometryPtr geometry);
318 
324  virtual DtTerrainIntersectIDType findOldestPagedData(unsigned int& numTrianglesOut);
325 
328  virtual void pageOutOldestData(const int priority);
329 
331  virtual void drawDebugInfo(btIDebugDraw* debugDrawer);
332 
334  virtual void drawElevation();
335 
337  virtual bool canPageOutData(DtTerrainIntersectIDType intersectId);
338 
341  virtual osgEarth::TileKey getBestTileKey(const osgEarth::TileKey&) const;
342 
344  virtual void findMissingTiles(const DtTerrainPagingGeometryPtr& geometry, DtTileKeyList& tiles) const;
345 
346 protected:
347 
348  virtual DtPageInTilesCommand* createPageInTilesCommand(
349  DtPagingMetaDataPtr metaData);
350 
351  virtual DtPageOutTilesCommand* createPageOutTilesCommand(
352  DtPagingMetaDataPtr metaData);
353 
354  virtual bool setDrawMode(DtDrawMode);
355 
356 protected:
357 
359  {
360  public:
361  explicit TileSpatialIndex(const DtOsgEarthTerrainSourceTracker&, const osgEarth::TileKey& tilekey);
362 
363  bool intersects(const DtTerrainPagingGeometry& geometry) const;
364  bool intersectsSubTile(const DtTerrainPagingGeometry& geometry, int i) const;
365 
366  bool chordIntersects(const DtChord& chord) const;
367  bool extentIntersects(const DtExtent& extent) const;
368  bool sphereIntersects(const DtSphere& sphere) const;
369  bool shapeIntersects(const DtLocalVertexList& shape) const;
370  bool chordIntersectsSubTile(const DtChord& chord, int i) const;
371  bool extentIntersectsSubTile(const DtExtent& shape, int i) const;
372  bool sphereIntersectsSubTile(const DtSphere& sphere, int i) const;
373  bool shapeIntersectsSubTile(const DtLocalVertexList& shape, int i) const;
374 
375  void findMissing(
376  const DtTerrainPagingGeometry& geometry,
377  DtTileKeyList& missing) const;
378 
379  bool findData(
380  const DtTerrainPagingGeometry* geometry,
381  std::vector< boost::shared_ptr<DtTileData> >& data) const;
382 
383  boost::shared_ptr<DtTileData> findOldest() const;
384 
385  bool addTile(const osgEarth::TileKey& key, const boost::shared_ptr<DtTileData>& data);
386  void removeTile(const osgEarth::TileKey& tilekey);
387  unsigned tileCount() const;
388  unsigned cellCount() const;
389 
390  const osgEarth::TileKey tileKey() const { return myTileKey; }
391 
392  protected:
393  void getExtent(DtVector& lower, DtVector& upper) const;
394  void getSubTileExtent(unsigned i, DtVector& lower, DtVector& upper, bool useElevation = true) const;
395 
397  bool isTileEmpty() const;
398 
401  virtual void recomputePagedInData();
402 
404 
405  const osgEarth::TileKey myTileKey;
406  const osgEarth::GeoExtent myGeoExtent;
407 
408  struct SubTileSlot
409  {
410  osgEarth::GeoExtent extent;
411  boost::scoped_ptr<TileSpatialIndex> subtile;
412  };
413 
415  SubTileSlot mySubTiles[4];
416 
418  boost::shared_ptr<DtTileData> myTileData;
419 
423 
426  };
427 
429  virtual void convertGeometry(
430  const DtTerrainPagingGeometryPtr& geometry,
431  std::vector<DtTerrainPagingGeometryPtr>& output) const;
432 
433  virtual bool convertGeometry(
434  const DtTerrainPagingChord& geometry,
435  std::vector<DtTerrainPagingGeometryPtr>& output) const;
436 
437  virtual bool convertGeometry(
438  const DtTerrainPagingSphere& geometry,
439  std::vector<DtTerrainPagingGeometryPtr>& output) const;
440 
441  virtual bool convertGeometry(
442  const DtTerrainPagingShape& geometry,
443  std::vector<DtTerrainPagingGeometryPtr>& output) const;
444 
445  virtual bool nearCenterOfEarth(const DtChord& chord) const;
446 
447  virtual bool findData(
448  const DtTerrainPagingGeometry* geometry,
449  std::vector< boost::shared_ptr<DtTileData> >& data,
450  const DtPagingMetaDataPtr& metaData = DtPagingMetaDataPtr()) const;
451 
452  virtual void findMissing(
453  const DtTerrainPagingGeometry& geometry,
454  DtTileKeyList& missing) const;
455 
456  virtual boost::shared_ptr<DtTileData> findOldest() const;
457  virtual boost::shared_ptr<DtTileData> findOldestUnlocked() const;
458 
459  typedef boost::ptr_vector<TileSpatialIndex> TileRoots;
460 
461  const osg::ref_ptr<osgEarth::MapNode> myMapNode;
462  std::vector< osg::ref_ptr<osgEarth::ElevationLayer> > myElevationLayers;
463 
465  unsigned int myMaxLOD;
468 
470  double myWorldWidth;
471 
472  boost::weak_ptr<DtTileData> myOldestData;
473 
474  typedef tbb::spin_mutex DrawerMutex;
476  std::auto_ptr<DtSharedMemoryBulletDebugDrawer> myExtentDrawer;
477  std::auto_ptr<DtSharedMemoryBulletDebugDrawer> myElevationDrawer;
478 };
479 
480 

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)