VR-Forces 5.0.3 Developer's Guide
 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) 2022 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 <terrainCS/coordSystem.h>
22 
23 #include <geometry/surface.h>
24 #include <geometry/chord.h>
25 
26 #include <boost/shared_ptr.hpp>
27 
28 #include <tbb/atomic.h>
29 #include <tbb/spin_rw_mutex.h>
30 
31 #include <vector>
32 #include <string>
33 #include <map>
34 
36 
39 {
40  enum TileType
41  {
43  Empty
44  };
45 
48  {
49  typedef std::vector<Extent> Vector;
50 
52  static Vector Simplify(const Vector& extents);
53 
54  explicit Extent(const osgEarth::TileKey&);
55  explicit Extent(const DtVector& min, const DtVector& max);
56  bool operator==(const Extent & rhs) const;
57 
58  DtVector min, max;
59  };
60 
63  {
64  typedef std::vector<IndexExtent> Vector;
65 
66  explicit IndexExtent(const DtTileData& tile, const Extent& extent);
67 
68  unsigned minx, miny, maxx, maxy;
69  };
70 
72  explicit DtTileData(
73  const DtTerrainSourceTracker& tracker,
74  const osgEarth::TileKey& key);
75 
77  virtual ~DtTileData();
78 
79  virtual bool inUse() const { return false; };
80 
82  const DtTerrainSourceTracker& tracker;
83 
86 
89 
91  const osgEarth::TileKey tileKey;
92 
95 
100 
103  bool setSoilType(const DtPoint & geodeticPt, DtSurface & surface, bool blockIfUnavailable, bool& landDataAvailable) const;
104 
106  DtSurface setSoilType(const DtTerrainTriangleStruct & tri, bool blockIfUnavailable) const;
107 
109  virtual void addMaskExtents(const Extent::Vector& extents);
110 
112  virtual void addMaskExtent(const Extent& extent);
113 
115  virtual void removeMaskExtent(const Extent& extent);
116 
118  virtual void getMaskExtents(Extent::Vector& extents);
119 
125  virtual bool insideValidArea(const DtPoint& p) const;
126 
133  virtual bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
134 
140  virtual bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
141 
147  virtual bool addActiveTileKey(const osgEarth::TileKey& key) = 0;
148 
154  virtual void recomputeActiveTileKeyAreas() = 0;
155 
158 
161  std::vector< osg::ref_ptr<osg::Node> > geometries;
162 
165  std::vector< osg::ref_ptr<osg::Node> > features;
166 
170  std::vector < osgEarth::TileKey > featuresTileKey;
171  std::vector < std::string > featuresLayerName;
172 
174  virtual std::string description() const = 0;
175 
177  virtual unsigned numberOfVertices() const = 0;
178 
182  virtual unsigned numberOfTrianglesForVertices() const;
183 
185  virtual void getTriangleVerticesGridSpaced(unsigned xindex, unsigned yindex, double& x, double& y) const = 0;
186 
188  virtual void getTriangleVertices(unsigned xindex, unsigned yindex, double& x, double& y) const = 0;
189 
190 
192  virtual void getTriangleIndices(double x, double y, unsigned& xindex, unsigned& yindex) const = 0;
193 
195  virtual double getTriangleIdxVsHeightFieldIdxRatio() const;
196 
198  virtual double interpolateHeight(
199  unsigned triangleXIndex, unsigned triangleYIndex,
200  unsigned* heightFieldXUsed = 0, unsigned* heightFieldYUsed = 0) const = 0;
201 
203  virtual double heightField(unsigned col, unsigned row) const = 0;
204 
206  virtual bool getLandCoverName(const DtPoint & pt, std::string & landCoverName, bool &dataAvailable, bool blockOnUnavailable) const = 0;
207 
209  virtual int getLandCoverValue(const DtPoint & pt, bool & dataAvailable, bool blockOnUnavailable) const = 0;
210 
213  tbb::atomic<unsigned int> numTriangles;
214 
218 
220  virtual DtTerrainIntersectIDType getLastUsed() const = 0;
221 
223  virtual bool updateLastUsed(DtTerrainIntersectIDType value) = 0;
224 
229  virtual bool findIntersectionsNonRecursive(
230  const DtChord& chord,
231  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
233  const DtTerrainIntersectOptions& options,
235 
236 
239  virtual bool findIntersections(
240  const DtChord& chord,
242  const DtTerrainIntersectOptions& options) const = 0;
243 
250  virtual void findTriangles(
251  const DtTerrainProcessPolygonsBox& box,
252  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
254  bool singleCell = false,
255  bool insideValidAreaChecked = false) const;
256 
259  virtual void findTriangles(
260  const DtTerrainProcessPolygonsBox& box,
261  DtTriangleOutputInterface&) const = 0;
262 
264  virtual osgEarth::FeatureList& groundFeatureList();
265 
266  virtual void forceLoadAllData(bool isBlocking = true) { }
267 protected:
268 
270  virtual void checkIntersect(const DtChord& chord, const int& cellX, const int& cellY,
272  const DtTerrainIntersectOptions& options,
274  bool tileLargeEnoughForBilinear,
275  bool& foundIntersection) const;
276 
277  mutable tbb::spin_rw_mutex maskExtentsMutex;
278 
279 
283 
285 
288 
290  osgEarth::FeatureList myGroundFeatureList;
291 };
292 
293 class TileData : public DtTileData
294 {
295 public:
297  const osgEarth::TileKey& key);
298 
300 
302 
307  bool addActiveTileKey(const osgEarth::TileKey& key);
308 
310 
311  bool insideValidArea(const DtPoint& p) const;
312 
313  bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
314 
315  bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
316 
317  bool getLandCoverName(const DtPoint & pt, std::string & landCoverName, bool & dataAvailable, bool blockOnUnavailable) const;
318 
319  int getLandCoverValue(const DtPoint & pt, bool & dataAvailable, bool blockOnUnavailable) const;
320 
321 
322 protected:
323  tbb::atomic<DtTerrainIntersectIDType> myLastUsed;
324 
325  typedef std::set<osgEarth::TileKey> TileKeySet;
326 
329 
330  mutable tbb::spin_rw_mutex myInactiveAreasMutex;
333 };
334 
335 typedef std::map< osgEarth::TileKey, boost::shared_ptr<DtTileData> > DtTerrainTileMap;
336 
DtTileData is tracked by the DtOsgEarthTerrainSourceTracker for paging out tiles. ...
Definition: tileData.h:38
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. This is useful for followi...
Definition: vrfChordIntersectRecordList.h:31
unsigned miny
Definition: tileData.h:68
bool getLandCoverName(const DtPoint &pt, std::string &landCoverName, bool &dataAvailable, bool blockOnUnavailable) const
Return the land cover name for a location.
bool pendingRemoval
Whether this tile has had a page out command issued for it and should be ignored when calculating the...
Definition: tileData.h:217
TileData(const DtTerrainSourceTracker &tracker, const osgEarth::TileKey &key)
virtual void forceLoadAllData(bool isBlocking=true)
Definition: tileData.h:266
int getLandCoverValue(const DtPoint &pt, bool &dataAvailable, bool blockOnUnavailable) const
Return the land cover index value for a location.
Definition: tileData.h:42
CS_Type cstype
tracker coord system
Definition: tileData.h:88
DT_DLL_terrainCS bool operator==(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
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:284
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
Axis aligned extents in osgearth coordinate system.
Definition: tileData.h:47
osgEarth::FeatureList myGroundFeatureList
Ground Feature List (procedural trees from osgEarth)
Definition: tileData.h:290
tbb::spin_rw_mutex myInactiveAreasMutex
Definition: tileData.h:330
Definition: surface.h:179
Extent::Vector myInactiveAreas
Definition: tileData.h:331
Axis aligned extent whose coordinates are in triangle vertex indices.
Definition: tileData.h:62
std::set< osgEarth::TileKey > TileKeySet
Definition: tileData.h:325
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. Invalid areas are areas which are covered by a mask...
tbb::atomic< DtTerrainIntersectIDType > myLastUsed
Definition: tileData.h:323
std::vector< osg::ref_ptr< osg::Node > > geometries
Geometries associated with this tile. Could be geometry for tile or just the skirt part if it exists...
Definition: tileData.h:161
Definition: terrainProcessPolygonsBox.h:25
DtExtent dtExtent
DtExtent of the tile.
Definition: tileData.h:99
TileKeySet myActiveTileKeys
Definition: tileData.h:328
bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const
Returns true if the extent is entirely outside the valid area. This means that there is no data to in...
std::map< osgEarth::TileKey, boost::shared_ptr< DtTileData > > DtTerrainTileMap
Definition: tileData.h:335
std::vector< Extent > Vector
Definition: tileData.h:49
TileType type
Abstract notion of type so we can annotate tiles.
Definition: tileData.h:157
std::vector< std::string > featuresLayerName
Definition: tileData.h:171
Base class for Terrain Source trackers. Determines if the necessary data To perform an intersection i...
Definition: terrainSourceTracker.h:75
TileKeySet myInactiveTileKeys
Definition: tileData.h:327
IndexExtent::Vector maskIndexExtents
Same masks as maskExtents but in triangle index coordinates.
Definition: tileData.h:287
Extent
Definition: DtAxisAlignedBoundingBox.h:16
std::vector< osgEarth::TileKey > featuresTileKey
List of ground features key generated associated with the current tileKey (groundcover is often not a...
Definition: tileData.h:170
Extent::Vector maskExtents
Masks computed from masked out areas in osgearth. Points inside these extents are not part of this ti...
Definition: tileData.h:282
DtTerrainIntersectIDType getLastUsed() const
Return the last intersect id which touch this tile.
const osgEarth::TileKey tileKey
TileKey for this tile.
Definition: tileData.h:91
tbb::spin_rw_mutex maskExtentsMutex
Definition: tileData.h:277
CS_Type
Definition: coordSystem.h:35
std::vector< IndexExtent > Vector
Definition: tileData.h:64
IndexExtent::Vector myInactiveIndexAreas
Definition: tileData.h:332
bool addActiveTileKey(const osgEarth::TileKey &key)
Activate this tile (i.e a subregion) of this tile. This complexity is b/c sometimes tiles are only va...
A DtChord is a finite line segment in 3-space, represented by two points. Data derived from the two e...
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:40
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
double elevationTolerance
Tracker elevation tolerance.
Definition: tileData.h:85
Interface for getting terrain triangle data out of DtTerrainInterface::trianglesInArea. This object should always be created on the stack.
Definition: terrainProcessPolygonsBox.h:113
Definition: tileData.h:293
osg::ref_ptr< osgEarth::TerrainTileModel > tileModel
osgearth tile model if using elevation.
Definition: tileData.h:94
std::vector< osg::ref_ptr< osg::Node > > features
list of geometries box created from the features like sim trees
Definition: tileData.h:165
Extent extent
Extent of tile.
Definition: tileData.h:97
DtVector min
Definition: tileData.h:58
tbb::atomic< unsigned int > numTriangles
The number of triangles this tile, and therefore its collision object, contain. Used for estimating p...
Definition: tileData.h:213
Definition: point.h:34
DtIntersectionType
Definition: intersectionRecord.h:41
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

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)