VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tileSpatialIndex.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
10 
14 
15 #include <osgEarth/ElevationLayer>
16 
17 #include <boost/ptr_container/ptr_vector.hpp>
18 
19 #include <tbb/spin_rw_mutex.h>
20 
22 class DtChord;
23 class DtExtent;
24 class DtSphere;
25 class DtLocalVertexList;
26 class TileDataCallback;
27 class TileSpatialIndex;
28 class IndexInterface;
33 
34 typedef std::list<osgEarth::TileKey> DtTileKeyList;
35 
36 typedef boost::ptr_vector<TileSpatialIndex> TileRoots;
37 
39 {
40 public:
42  {
43  static boost::optional<ElevationRange> Merge(
44  const boost::optional<ElevationRange>& r1,
45  const boost::optional<ElevationRange>& r2);
46 
47  double min, max;
48 
50  ElevationRange(double min, double max);
51 
52  void merge(const ElevationRange&);
53  };
54 
56  const DtTerrainSourceTracker& tracker,
57  const osgEarth::TileKey& tilekey,
58  TileSpatialIndex* parent);
59 
60  void getExtent(DtVector& lower, DtVector& upper, bool useElevation = true) const;
61  void getSubTileExtent(unsigned i, DtVector& lower, DtVector& upper, bool useElevation = true) const;
62 
63  bool intersects(const DtTerrainPagingGeometry& geometry) const;
64  bool intersectsSubTile(const DtTerrainPagingGeometry& geometry, int i) const;
65 
66  bool chordIntersects(const DtChord& chord, bool useElevation = true) const;
67  bool extentIntersects(const DtExtent& extent) const;
68  bool sphereIntersects(const DtSphere& sphere) const;
69  bool shapeIntersects(const DtLocalVertexList& shape) const;
70 
72  void findMissing(
73  const DtTerrainPagingGeometry& geometry,
74  DtTileKeyList& missing) const;
75 
78  bool findData(
79  const DtTerrainPagingGeometry* geometry,
80  std::vector< std::shared_ptr<DtTileData> >& data,
81  TileDataCallback* callback = 0) const;
82 
85  boost::optional<double> getMaxAltForChord(const DtChord& chord, unsigned maxlod) const;
86 
88  std::shared_ptr<DtTileData> findOldest() const;
89 
95  bool addTile(const osgEarth::TileKey& key, const std::shared_ptr<DtTileData>& data);
96 
98  bool removeTile(const osgEarth::TileKey& tilekey);
99 
101  void getTiles(std::vector<osgEarth::TileKey>& keys, unsigned lod);
102 
104  unsigned tileCount() const;
105 
107  unsigned cellCount() const;
108 
110  const osgEarth::TileKey tileKey() const { return myTileKey; }
111 
113  TileSpatialIndex* setAltitudeRange(
114  const osgEarth::TileKey& key,
115  const ElevationRange& range,
116  const ElevationRange& offsets,
117  unsigned layerNum,
118  bool coversTile);
119 
121  bool postProcessIndexLayer(unsigned layerNum);
122 
125  void writeIndex(
126  IndexInterface& iface,
127  IndexOutputInterface& output,
128  osgEarth::ElevationLayer* layer = 0) const;
129 
131  void setBlackList(bool value);
132  bool blackList() const;
133 
134 
135 protected:
136 
140  bool findDataChord(
141  const DtTerrainPagingChord* geometry, std::vector<std::shared_ptr<DtTileData>>& data, bool verifyInCache,
142  TileDataCallback* callback = 0) const;
143 
147  bool findDataShape(
148  const DtTerrainPagingShape* geometry,
149  std::vector< std::shared_ptr<DtTileData> >& data, bool verifyInCache,
150  TileDataCallback* callback = 0) const;
151 
155  bool findDataSphere(
156  const DtTerrainPagingSphere* geometry,
157  std::vector< std::shared_ptr<DtTileData> >& data, bool verifyInCache,
158  TileDataCallback* callback = 0) const;
159 
160  bool chordIntersectsSubTile(const DtChord& chord, int i, bool useElevation = true) const;
161  bool extentIntersectsSubTile(const DtExtent& shape, int i) const;
162  bool sphereIntersectsSubTile(const DtSphere& sphere, int i) const;
163  bool shapeIntersectsSubTile(const DtLocalVertexList& shape, int i) const;
164 
166  bool isTileEmpty() const;
167 
170  virtual void recomputePagedInData();
171 
172  bool allPagedIn() const;
173 
176 
178  const osgEarth::TileKey myTileKey;
180  const osgEarth::GeoExtent myGeoExtent;
182  const bool myUseElevationFlag;
183 
185  boost::optional<ElevationRange> myElevationRange;
186 
191  {
194 
195  ValidElevationRange(const ElevationRange& range, bool coversTile)
196  : range(range), coversTile(coversTile) { }
197  };
198 
199  std::vector< boost::optional<ValidElevationRange> > myPreviousLayersElevationRange;
201 
203  bool myPinned;
204 
205  struct SubTileSlot
206  {
207  osgEarth::GeoExtent extent;
208  std::unique_ptr<TileSpatialIndex> subtile;
209  };
210 
212  SubTileSlot& getOrCreateSlot(unsigned i);
213 
215  void pageOutSlotIfUnused(unsigned i);
216 
218  SubTileSlot mySubTiles[4];
219 
221  std::shared_ptr<DtTileData> myTileData;
222 
226 
229 
230  mutable tbb::spin_rw_mutex myMutex;
231 
234 };
235 
bool myAllPagedInFlag
Will be set to true if all the data needed to satisify any request in this tile&#39;s extent is paged in...
Definition: tileSpatialIndex.h:225
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
bool myPinned
Index cell not unloaded if true.
Definition: tileSpatialIndex.h:203
std::list< osgEarth::TileKey > DtTileKeyList
Definition: tileSpatialIndex.h:32
osgEarth::GeoExtent extent
Definition: tileSpatialIndex.h:207
bool myBlacklist
If no triangles in this tile or its children blacklist this tile for intersections.
Definition: tileSpatialIndex.h:233
Definition: tileSpatialIndex.h:38
A terrain paging geometry which defines the paging area to be along a given shape.
Definition: terrainPagingShape.h:19
const osgEarth::GeoExtent myGeoExtent
Extent of this index cell.
Definition: tileSpatialIndex.h:180
Definition: sphere.h:22
const bool myUseElevationFlag
Whether the min/max elevation should be used for this index cell.
Definition: tileSpatialIndex.h:182
const osgEarth::TileKey tileKey() const
Tilekey for this index cell.
Definition: tileSpatialIndex.h:110
A terrain paging geometry which defines the paging area to be along a given set of local vertices...
Definition: terrainPagingSphere.h:20
const DtTerrainSourceTracker & myTracker
Definition: tileSpatialIndex.h:174
double min
Definition: tileSpatialIndex.h:47
Definition: tileSpatialIndex.h:205
tbb::spin_rw_mutex myMutex
Definition: tileSpatialIndex.h:230
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
ValidElevationRange(const ElevationRange &range, bool coversTile)
Definition: tileSpatialIndex.h:195
std::unique_ptr< TileSpatialIndex > subtile
Definition: tileSpatialIndex.h:208
boost::optional< ElevationRange > myElevationRange
Elevation range for this tile, computed from highest resolution data (i.e. children) ...
Definition: tileSpatialIndex.h:185
ElevationRange range
Definition: tileSpatialIndex.h:192
Base class for Terrain Source trackers. Determines if the necessary data To perform an intersection i...
Definition: terrainSourceTracker.h:75
bool myMaxDataLevelFlag
True if we have determined that there is no higher resolution data in any subtiles.
Definition: tileSpatialIndex.h:228
bool coversTile
Definition: tileSpatialIndex.h:193
std::vector< boost::optional< ValidElevationRange > > myPreviousLayersElevationRange
Definition: tileSpatialIndex.h:199
Definition: terrainSourceTracker.h:253
Definition: tileSpatialIndex.h:41
Generic interface for writing to index.
Definition: indexOutputInterface.h:16
Abstract base class for defining geometric areas for paging of terrain. Subclasses of this class will...
Definition: terrainPagingGeometry.h:24
A terrain paging geometry which defines the paging area to be along a given chord.
Definition: terrainPagingChord.h:19
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
const osgEarth::TileKey myTileKey
Tilekey for this index cell.
Definition: tileSpatialIndex.h:178
DT_DLL_vrfutil bool intersects(const DtVector &localPoint1, const DtVector &localPoint2, const DtLocalVertexList &localVertexList, const Coordinate_System &coordinateSystem)
Returns true if the line segment localPoint1-localPoint2 intersects any line segment in localVert...
Elevation range for previous layers. Used when a data for the current layer doesn&#39;t cover the whole t...
Definition: tileSpatialIndex.h:190
std::shared_ptr< DtTileData > myTileData
Elevation data for this tile.
Definition: tileSpatialIndex.h:221
class DtLocalVertexList:
Definition: localVertexList.h:20
Interface for allowing users to monitor/control the indexing process.
Definition: indexInterface.h:13
TileSpatialIndex * myParent
Definition: tileSpatialIndex.h:175
boost::ptr_vector< TileSpatialIndex > TileRoots
Definition: tileSpatialIndex.h:36

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)