VR-Forces 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) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
11 
12 #include <geometry/chord.h>
13 #include <geometry/surface.h>
14 
15 #include <osgEarth/Feature>
16 #include <osgEarth/TerrainTileModel>
17 #include <osgEarth/TileKey>
18 
19 #include <terrainCS/coordSystem.h>
20 
23 
25 
26 #include <atomic>
27 #include <tbb/spin_rw_mutex.h>
28 
29 #include <map>
30 #include <string>
31 #include <vector>
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 
78  virtual bool inUse() const { return false; };
79 
81  const DtTerrainSourceTracker& tracker;
82 
85 
88 
90  const osgEarth::TileKey tileKey;
91 
94 
100  const osgEarth::TileKey& myKey;
101 
104  bool setSoilType(const DtPoint & geodeticPt, DtSurface & surface, bool blockIfUnavailable, bool& landDataAvailable) const;
105 
107  DtSurface setSoilType(const DtTerrainTriangleStruct & tri, bool blockIfUnavailable) const;
108 
110  virtual void addMaskExtents(const Extent::Vector& extents);
111 
113  virtual void addMaskExtent(const Extent& extent);
114 
116  virtual void removeMaskExtent(const Extent& extent);
117 
119  virtual void getMaskExtents(Extent::Vector& extents);
120 
126  virtual bool insideValidArea(const DtPoint& p) const;
127 
134  virtual bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
135 
141  virtual bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const;
142 
148  virtual bool addActiveTileKey(const osgEarth::TileKey& key) = 0;
149 
155  virtual void recomputeActiveTileKeyAreas() = 0;
156 
159 
162  std::vector< osg::ref_ptr<osg::Node> > geometries;
163 
166  std::vector< osg::ref_ptr<osg::Node> > features;
167 
171  std::vector < osgEarth::TileKey > featuresTileKey;
172  std::vector < std::string > featuresLayerName;
173 
175  virtual std::string description() const = 0;
176 
178  virtual unsigned numberOfVertices() const = 0;
179 
183  virtual unsigned numberOfTrianglesForVertices() const;
184 
186  virtual void getTriangleVerticesGridSpaced(unsigned xindex, unsigned yindex, double& x, double& y) const = 0;
187 
189  virtual void getTriangleVertices(unsigned xindex, unsigned yindex, double& x, double& y) const = 0;
190 
191 
193  virtual void getTriangleIndices(double x, double y, unsigned& xindex, unsigned& yindex) const = 0;
194 
196  virtual double getTriangleIdxVsHeightFieldIdxRatio() const;
197 
199  virtual double interpolateHeight(
200  unsigned triangleXIndex, unsigned triangleYIndex,
201  unsigned* heightFieldXUsed = 0, unsigned* heightFieldYUsed = 0) const = 0;
202 
204  virtual double heightField(unsigned col, unsigned row) const = 0;
205 
207  virtual bool getLandCoverName(const DtPoint & pt, std::string & landCoverName, bool &dataAvailable, bool blockOnUnavailable) const = 0;
208 
210  virtual int getLandCoverValue(const DtPoint & pt, bool & dataAvailable, bool blockOnUnavailable) const = 0;
211 
213  unsigned numberOfTriangles() const;
214 
217  std::atomic<unsigned int> numTriangles;
218 
220  bool blacklist;
221 
225 
227  virtual DtTerrainIntersectIDType getLastUsed() const = 0;
228 
230  virtual bool updateLastUsed(DtTerrainIntersectIDType value) = 0;
231 
236  virtual bool findIntersectionsNonRecursive(
237  const DtChord& chord,
238  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
240  const DtTerrainIntersectOptions& options,
242 
243 
246  virtual bool findIntersections(
247  const DtChord& chord,
249  const DtTerrainIntersectOptions& options) const = 0;
250 
257  virtual void findTriangles(
258  const DtTerrainProcessPolygonsBox& box,
259  unsigned x1, unsigned y1, unsigned x2, unsigned y2,
261  bool singleCell = false,
262  bool insideValidAreaChecked = false) const;
263 
266  virtual void findTriangles(
267  const DtTerrainProcessPolygonsBox& box,
268  DtTriangleOutputInterface&) const = 0;
269 
271  virtual osgEarth::FeatureList& groundFeatureList();
272 
273  virtual void forceLoadAllData(bool isBlocking = true) { }
274 protected:
275 
277  virtual void checkIntersect(const DtChord& chord, const int& cellX, const int& cellY,
279  const DtTerrainIntersectOptions& options,
281  bool tileLargeEnoughForBilinear,
282  bool& foundIntersection) const;
283 
284  mutable tbb::spin_rw_mutex maskExtentsMutex;
285 
286 
290 
292 
295 
297  osgEarth::FeatureList myGroundFeatureList;
298 };
299 
300 class TileData : public DtTileData
301 {
302 public:
303  TileData(const DtTerrainSourceTracker& tracker, const osgEarth::TileKey& key);
304 
305  virtual DtTerrainIntersectIDType getLastUsed() const override;
306 
307  virtual bool updateLastUsed(DtTerrainIntersectIDType value) override;
308 
313  virtual bool addActiveTileKey(const osgEarth::TileKey& key) override;
314 
315  virtual void recomputeActiveTileKeyAreas() override;
316 
317  virtual bool insideValidArea(const DtPoint& p) const override;
318 
319  virtual bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const override;
320 
321  virtual bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const override;
322 
323  virtual bool getLandCoverName(
324  const DtPoint& pt, std::string& landCoverName, bool& dataAvailable, bool blockOnUnavailable) const override;
325 
326  virtual int getLandCoverValue(const DtPoint& pt, bool& dataAvailable, bool blockOnUnavailable) const override;
327 
328 
329 protected:
330  std::atomic<DtTerrainIntersectIDType> myLastUsed;
331 
332  typedef std::set<osgEarth::TileKey> TileKeySet;
333 
336 
337  mutable tbb::spin_rw_mutex myInactiveAreasMutex;
340 };
341 
342 typedef std::map< osgEarth::TileKey, std::shared_ptr<DtTileData> > DtTerrainTileMap;
343 
DtTileData is tracked by the DtOsgEarthTerrainSourceTracker for paging out tiles. ...
Definition: tileData.h:37
std::atomic< DtTerrainIntersectIDType > myLastUsed
Definition: tileData.h:330
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
DtVrfChordIntersectionRecord represents a list of DtChordIntersectRecords. This is useful for followi...
Definition: vrfChordIntersectRecordList.h:31
unsigned miny
Definition: tileData.h:67
bool pendingRemoval
Whether this tile has had a page out command issued for it and should be ignored when calculating the...
Definition: tileData.h:224
TileData(const DtTerrainSourceTracker &tracker, const osgEarth::TileKey &key)
virtual void forceLoadAllData(bool isBlocking=true)
Definition: tileData.h:273
virtual bool addActiveTileKey(const osgEarth::TileKey &key) override
Activate this tile (i.e a subregion) of this tile. This complexity is b/c sometimes tiles are only va...
virtual bool updateLastUsed(DtTerrainIntersectIDType value) override
Update last intersect id.
virtual bool getLandCoverName(const DtPoint &pt, std::string &landCoverName, bool &dataAvailable, bool blockOnUnavailable) const override
Return the land cover name for a location.
Definition: tileData.h:41
CS_Type cstype
tracker coord system
Definition: tileData.h:87
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:78
std::set< GroundFeatureProcess > groundFeatureList
Definition: GroundFeatureProcess.h:43
Extent::Vector unSimplifiedMaskExtents
Definition: tileData.h:291
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
Axis aligned extents in osgearth coordinate system.
Definition: tileData.h:46
osgEarth::FeatureList myGroundFeatureList
Ground Feature List (procedural trees from osgEarth)
Definition: tileData.h:297
tbb::spin_rw_mutex myInactiveAreasMutex
Definition: tileData.h:337
Definition: surface.h:181
Extent::Vector myInactiveAreas
Definition: tileData.h:338
Axis aligned extent whose coordinates are in triangle vertex indices.
Definition: tileData.h:61
virtual void recomputeActiveTileKeyAreas() override
Should be called to enable a tilekey subarea once everything else needed for it is setup...
std::set< osgEarth::TileKey > TileKeySet
Definition: tileData.h:332
DtTerrainIntersectOptions Passed to terrain intersect functions to modify how intersect acts...
Definition: terrainIntersectOptions.h:22
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:162
Definition: terrainProcessPolygonsBox.h:25
DtExtent dtExtent
DtExtent of the tile.
Definition: tileData.h:98
TileKeySet myActiveTileKeys
Definition: tileData.h:335
std::map< osgEarth::TileKey, std::shared_ptr< DtTileData > > DtTerrainTileMap
Definition: tileData.h:342
std::vector< Extent > Vector
Definition: tileData.h:48
TileType type
Abstract notion of type so we can annotate tiles.
Definition: tileData.h:158
bool blacklist
blacklist the tile if there is 0 triangles
Definition: tileData.h:220
std::vector< std::string > featuresLayerName
Definition: tileData.h:172
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:334
IndexExtent::Vector maskIndexExtents
Same masks as maskExtents but in triangle index coordinates.
Definition: tileData.h:294
Extent
Definition: DtAxisAlignedBoundingBox.h:16
virtual DtTerrainIntersectIDType getLastUsed() const override
Return the last intersect id which touch this tile.
std::vector< osgEarth::TileKey > featuresTileKey
List of ground features key generated associated with the current tileKey (groundcover is often not a...
Definition: tileData.h:171
Extent::Vector maskExtents
Masks computed from masked out areas in osgearth. Points inside these extents are not part of this ti...
Definition: tileData.h:289
const osgEarth::TileKey tileKey
TileKey for this tile.
Definition: tileData.h:90
virtual bool extentOutsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const override
Returns true if the extent is entirely outside the valid area. This means that there is no data to in...
tbb::spin_rw_mutex maskExtentsMutex
Definition: tileData.h:284
CS_Type
Definition: coordSystem.h:35
std::vector< IndexExtent > Vector
Definition: tileData.h:63
IndexExtent::Vector myInactiveIndexAreas
Definition: tileData.h:339
A DtChord is a finite line segment in 3-space, represented by two points. Data derived from the two e...
TileType
Definition: tileData.h:39
#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:84
virtual int getLandCoverValue(const DtPoint &pt, bool &dataAvailable, bool blockOnUnavailable) const override
Return the land cover index value for a location.
Interface for getting terrain triangle data out of DtTerrainInterface::trianglesInArea. This object should always be created on the stack.
Definition: terrainProcessPolygonsBox.h:134
virtual bool insideValidArea(const DtPoint &p) const override
Returns true if the point is inside a valid area. Invalid areas are areas which are covered by a mask...
Definition: tileData.h:300
virtual bool extentInsideValidArea(unsigned x1, unsigned y1, unsigned x2, unsigned y2) const override
Returns true if the extent is entirely inside a valid area (doesn&#39;t intersect any invalid areas)...
osg::ref_ptr< osgEarth::TerrainTileModel > tileModel
osgearth tile model if using elevation.
Definition: tileData.h:93
const osgEarth::TileKey & myKey
Key of this tile.
Definition: tileData.h:100
std::atomic< unsigned int > numTriangles
The number of triangles this tile, and therefore its collision object, contain. Used for estimating p...
Definition: tileData.h:217
std::vector< osg::ref_ptr< osg::Node > > features
list of geometries box created from the features like sim trees
Definition: tileData.h:166
Extent extent
Extent of tile.
Definition: tileData.h:96
DtVector min
Definition: tileData.h:57
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:60

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)