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) 2020 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< boost::shared_ptr<DtTileData> >& data,
81  TileDataCallback* callback = 0) const;
82 
85  boost::optional<double> getMaxAltForChord(const DtChord& chord, unsigned maxlod) const;
86 
88  boost::shared_ptr<DtTileData> findOldest() const;
89 
95  bool addTile(const osgEarth::TileKey& key, const boost::shared_ptr<DtTileData>& data);
96 
98  void 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 
130 protected:
131 
135  bool findDataChord(
136  const DtTerrainPagingChord* geometry,
137  std::vector< boost::shared_ptr<DtTileData> >& data, bool verifyInCache,
138  TileDataCallback* callback = 0) const;
139 
143  bool findDataShape(
144  const DtTerrainPagingShape* geometry,
145  std::vector< boost::shared_ptr<DtTileData> >& data, bool verifyInCache,
146  TileDataCallback* callback = 0) const;
147 
151  bool findDataSphere(
152  const DtTerrainPagingSphere* geometry,
153  std::vector< boost::shared_ptr<DtTileData> >& data, bool verifyInCache,
154  TileDataCallback* callback = 0) const;
155 
156  bool chordIntersectsSubTile(const DtChord& chord, int i, bool useElevation = true) const;
157  bool extentIntersectsSubTile(const DtExtent& shape, int i) const;
158  bool sphereIntersectsSubTile(const DtSphere& sphere, int i) const;
159  bool shapeIntersectsSubTile(const DtLocalVertexList& shape, int i) const;
160 
162  bool isTileEmpty() const;
163 
166  virtual void recomputePagedInData();
167 
168  bool allPagedIn() const;
169 
172 
174  const osgEarth::TileKey myTileKey;
176  const osgEarth::GeoExtent myGeoExtent;
178  const bool myUseElevationFlag;
179 
181  boost::optional<ElevationRange> myElevationRange;
182 
187  {
190 
191  ValidElevationRange(const ElevationRange& range, bool coversTile)
192  : range(range), coversTile(coversTile) { }
193  };
194 
195  std::vector< boost::optional<ValidElevationRange> > myPreviousLayersElevationRange;
197 
199  bool myPinned;
200 
201  struct SubTileSlot
202  {
203  osgEarth::GeoExtent extent;
204  boost::scoped_ptr<TileSpatialIndex> subtile;
205  };
206 
208  SubTileSlot& getOrCreateSlot(unsigned i);
209 
211  void pageOutSlotIfUnused(unsigned i);
212 
214  SubTileSlot mySubTiles[4];
215 
217  boost::shared_ptr<DtTileData> myTileData;
218 
222 
225 
226  mutable tbb::spin_rw_mutex myMutex;
227 };
228 
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:221
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:199
std::list< osgEarth::TileKey > DtTileKeyList
Definition: tileSpatialIndex.h:32
osgEarth::GeoExtent extent
Definition: tileSpatialIndex.h:203
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:176
Definition: sphere.h:22
const bool myUseElevationFlag
Whether the min/max elevation should be used for this index cell.
Definition: tileSpatialIndex.h:178
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:170
double min
Definition: tileSpatialIndex.h:47
Definition: tileSpatialIndex.h:201
tbb::spin_rw_mutex myMutex
Definition: tileSpatialIndex.h:226
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
boost::shared_ptr< DtTileData > myTileData
Elevation data for this tile.
Definition: tileSpatialIndex.h:217
ValidElevationRange(const ElevationRange &range, bool coversTile)
Definition: tileSpatialIndex.h:191
boost::optional< ElevationRange > myElevationRange
Elevation range for this tile, computed from highest resolution data (i.e. children) ...
Definition: tileSpatialIndex.h:181
ElevationRange range
Definition: tileSpatialIndex.h:188
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:224
bool coversTile
Definition: tileSpatialIndex.h:189
boost::scoped_ptr< TileSpatialIndex > subtile
Definition: tileSpatialIndex.h:204
std::vector< boost::optional< ValidElevationRange > > myPreviousLayersElevationRange
Definition: tileSpatialIndex.h:195
Definition: terrainSourceTracker.h:247
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:174
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:186
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:171
boost::ptr_vector< TileSpatialIndex > TileRoots
Definition: tileSpatialIndex.h:36

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)