VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tileData.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
11 
14 
15 #include <osgEarth/Feature>
16 #include <osgEarth/TerrainTileModel>
17 #include <osgEarth/TileKey>
18 
20 
21 #include <geometry/surface.h>
22 #include <geometry/chord.h>
23 
24 #include <boost/shared_ptr.hpp>
25 
26 #include <tbb/atomic.h>
27 #include <tbb/spin_rw_mutex.h>
28 
29 #include <vector>
30 #include <string>
31 #include <map>
32 
33 
35 
38 {
39  enum TileType
40  {
42  Empty
43  };
44 
47  {
48  typedef std::vector<Extent> Vector;
49 
51  static Vector Simplify(const Vector& extents);
52 
53  explicit Extent(const osgEarth::TileKey&);
54  explicit Extent(const DtVector& min, const DtVector& max);
55  bool operator==(const Extent & rhs) const;
56 
57  DtVector min, max;
58  };
59 
62  {
63  typedef std::vector<IndexExtent> Vector;
64 
65  explicit IndexExtent(const DtTileData& tile, const Extent& extent);
66 
67  unsigned minx, miny, maxx, maxy;
68  };
69 
71  explicit DtTileData(
72  const DtTerrainSourceTracker& tracker,
73  const osgEarth::TileKey& key);
74 
76  virtual ~DtTileData();
77 
80 
82  const osgEarth::TileKey tileKey;
83 
86 
89 
91  bool setSoilType(const DtPoint & geodeticPt, DtSurface & surface, bool blockIfUnavailable) const;
92 
94  DtSurface setSoilType(const DtTerrainTriangleStruct & tri, bool blockIfUnavailable) const;
95 
97  virtual void addMaskExtents(const Extent::Vector& extents);
98 
100  virtual void addMaskExtent(const Extent& extent);
101 
103  virtual void removeMaskExtent(const Extent& extent);
104 
106  virtual void getMaskExtents(Extent::Vector& extents);
107 
113  virtual bool insideValidArea(const DtPoint& p) const;
114 
121  virtual bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
122 
128  virtual bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
129 
135  virtual bool addActiveTileKey(const osgEarth::TileKey& key) = 0;
136 
142  virtual void recomputeActiveTileKeyAreas() = 0;
143 
146 
149  std::vector< osg::ref_ptr<osg::Node> > geometries;
150 
153  std::vector< osg::ref_ptr<osg::Node> > features;
154 
158  std::vector < osgEarth::TileKey > featuresTileKey;
159  std::vector < std::string > featuresLayerName;
160 
162  virtual std::string description() const = 0;
163 
165  virtual unsigned numberOfVertices() const = 0;
166 
170  virtual unsigned numberOfTrianglesForVertices() const;
171 
173  virtual void getTriangleVertices(unsigned xindex, unsigned yindex, double& x, double& y) const = 0;
174 
176  virtual DtVector getTriangleVertices(unsigned xindex, unsigned yindex) const;
177 
179  virtual void getTriangleIndices(double x, double y, unsigned& xindex, unsigned& yindex) const = 0;
180 
181  virtual double getTriangleIdxVsHeightFieldIdxRatio() const;
182 
185  virtual void heightfieldIndexForTriangleIndex(
186  unsigned triangleXIndex, unsigned triangleYIndex,
187  unsigned& heightFieldXUsed, unsigned& heightFieldYUsed) const = 0;
188 
190  virtual double interpolateHeight(
191  unsigned triangleXIndex, unsigned triangleYIndex,
192  unsigned* heightFieldXUsed = 0, unsigned* heightFieldYUsed = 0) const = 0;
193 
195  virtual bool getLandCoverName(const DtPoint & pt, std::string & landCoverName, bool &dataAvailable, bool blockOnUnavailable) const = 0;
196 
198  virtual int getLandCoverValue(const DtPoint & pt, bool & dataAvailable, bool blockOnUnavailable) const = 0;
199 
202  tbb::atomic<unsigned int> numTriangles;
203 
207 
209  virtual DtTerrainIntersectIDType getLastUsed() const = 0;
210 
212  virtual bool updateLastUsed(DtTerrainIntersectIDType value) = 0;
213 
220  virtual bool findIntersections(
221  const DtChord& chord,
222  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
224  const DtTerrainIntersectOptions& options,
225  bool singleCell = false,
226  bool insideValidAreaChecked = false) const;
227 
230  virtual bool findIntersections(
231  const DtChord& chord,
233  const DtTerrainIntersectOptions& options) const = 0;
234 
241  virtual void findTriangles(
242  const DtTerrainProcessPolygonsBox& box,
243  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
245  bool singleCell = false,
246  bool insideValidAreaChecked = false) const;
247 
250  virtual void findTriangles(
251  const DtTerrainProcessPolygonsBox& box,
252  DtTriangleOutputInterface&) const = 0;
253 
255  virtual osgEarth::FeatureList& groundFeatureList();
256 
257 protected:
258 
259  mutable tbb::spin_rw_mutex maskExtentsMutex;
260 
261 
265 
267 
270 
272  osgEarth::FeatureList myGroundFeatureList;
273 };
274 
275 class TileData : public DtTileData
276 {
277 public:
279  const osgEarth::TileKey& key);
280 
282 
284 
289  bool addActiveTileKey(const osgEarth::TileKey& key);
290 
292 
293  bool insideValidArea(const DtPoint& p) const;
294 
295  bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
296 
297  bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
298 
299  bool getLandCoverName(const DtPoint & pt, std::string & landCoverName, bool & dataAvailable, bool blockOnUnavailable) const;
300 
301  int getLandCoverValue(const DtPoint & pt, bool & dataAvailable, bool blockOnUnavailable) const;
302 
303 protected:
304  tbb::atomic<DtTerrainIntersectIDType> myLastUsed;
305 
306  typedef std::set<osgEarth::TileKey> TileKeySet;
307 
310 
311  mutable tbb::spin_rw_mutex myInactiveAreasMutex;
314 };
315 
316 typedef std::map< osgEarth::TileKey, boost::shared_ptr<DtTileData> > DtTerrainTileMap;
317 
DtTileData is tracked by the DtOsgEarthTerrainSourceTracker for paging out tiles. ...
Definition: tileData.h:37
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
void recomputeActiveTileKeyAreas()
Should be called to enable a tilekey subarea once everything else needed for it is setup...
DtVrfChordIntersectionRecord represents a list of DtChordIntersectRecords.
Definition: vrfChordIntersectRecordList.h:31
unsigned miny
Definition: tileData.h:67
bool getLandCoverName(const DtPoint &pt, std::string &landCoverName, bool &dataAvailable, bool blockOnUnavailable) const
bool pendingRemoval
Whether this tile has had a page out command issued for it and should be ignored when calculating the...
Definition: tileData.h:206
TileData(const DtTerrainSourceTracker &tracker, const osgEarth::TileKey &key)
int getLandCoverValue(const DtPoint &pt, bool &dataAvailable, bool blockOnUnavailable) const
Definition: tileData.h:41
DT_DLL_terrainCS bool operator==(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
unsigned long long DtTerrainIntersectIDType
Definition: terrainInterfaceDefines.h:28
const DtTerrainSourceTracker & tracker
Tracker that owns this tile.
Definition: tileData.h:79
std::set< GroundFeatureProcess > groundFeatureList
Definition: GroundFeatureProcess.h:43
bool updateLastUsed(DtTerrainIntersectIDType value)
Update last intersect id.
Extent::Vector unSimplifiedMaskExtents
Definition: tileData.h:266
Axis aligned extents in osgearth coordinate system.
Definition: tileData.h:46
osgEarth::FeatureList myGroundFeatureList
Ground Feature List (procedural trees from osgEarth)
Definition: tileData.h:272
tbb::spin_rw_mutex myInactiveAreasMutex
Definition: tileData.h:311
Definition: surface.h:179
Extent::Vector myInactiveAreas
Definition: tileData.h:312
Axis aligned extent whose coordinates are in triangle vertex indices.
Definition: tileData.h:61
std::set< osgEarth::TileKey > TileKeySet
Definition: tileData.h:306
DtTerrainIntersectOptions Passed to terrain intersect functions to modify how intersect acts...
Definition: terrainIntersectOptions.h:15
bool insideValidArea(const DtPoint &p) const
Returns true if the point is inside a valid area.
tbb::atomic< DtTerrainIntersectIDType > myLastUsed
Definition: tileData.h:304
std::vector< osg::ref_ptr< osg::Node > > geometries
Geometries associated with this tile.
Definition: tileData.h:149
Definition: terrainProcessPolygonsBox.h:25
TileKeySet myActiveTileKeys
Definition: tileData.h:309
bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const
Returns true if the extent is entirely outside the valid area.
std::map< osgEarth::TileKey, boost::shared_ptr< DtTileData > > DtTerrainTileMap
Definition: tileData.h:316
std::vector< Extent > Vector
Definition: tileData.h:48
TileType type
Abstract notion of type so we can annotate tiles.
Definition: tileData.h:145
std::vector< std::string > featuresLayerName
Definition: tileData.h:159
Base class for Terrain Source trackers.
Definition: terrainSourceTracker.h:40
TileKeySet myInactiveTileKeys
Definition: tileData.h:308
IndexExtent::Vector maskIndexExtents
Same masks as maskExtents but in triangle index coordinates.
Definition: tileData.h:269
Extent
Definition: DtAxisAlignedBoundingBox.h:15
std::vector< osgEarth::TileKey > featuresTileKey
List of ground features key generated associated with the current tileKey (groundcover is often not a...
Definition: tileData.h:158
Extent::Vector maskExtents
Masks computed from masked out areas in osgearth.
Definition: tileData.h:264
DtTerrainIntersectIDType getLastUsed() const
Return the last intersect id which touch this tile.
const osgEarth::TileKey tileKey
TileKey for this tile.
Definition: tileData.h:82
tbb::spin_rw_mutex maskExtentsMutex
Definition: tileData.h:259
std::vector< IndexExtent > Vector
Definition: tileData.h:63
IndexExtent::Vector myInactiveIndexAreas
Definition: tileData.h:313
bool addActiveTileKey(const osgEarth::TileKey &key)
Activate this tile (i.e a subregion) of this tile.
A DtChord is a finite line segment in 3-space, represented by two points.
bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const
Returns true if the extent is entirely inside a valid area (doesn&#39;t intersect any invalid areas)...
TileType
Definition: tileData.h:39
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
Interface for getting terrain triangle data out of DtTerrainInterface::trianglesInArea.
Definition: terrainProcessPolygonsBox.h:113
Definition: tileData.h:275
osg::ref_ptr< osgEarth::TerrainTileModel > tileModel
osgearth tile model if using elevation.
Definition: tileData.h:85
std::vector< osg::ref_ptr< osg::Node > > features
list of geometries box created from the features like sim trees
Definition: tileData.h:153
Extent extent
Extent of tile.
Definition: tileData.h:88
DtVector min
Definition: tileData.h:57
tbb::atomic< unsigned int > numTriangles
The number of triangles this tile, and therefore its collision object, contain.
Definition: tileData.h:202
Definition: point.h:34
Represents an area query which can be used to extract triangles from DtTerrainInterface.
Definition: terrainProcessPolygonsBox.h:39

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)