26 #include <osgTerrain/TerrainTile>
27 #include <osgEarth/Profile>
28 #include <osgEarth/TileKey>
29 #include <osgEarth/MapNode>
30 #include <osgEarth/TerrainTileModel>
36 #include <boost/ptr_container/ptr_vector.hpp>
38 #include <tbb/spin_rw_mutex.h>
44 class DtGeodeticCoord;
72 explicit Extent(
const osgEarth::TileKey&);
81 typedef std::vector<IndexExtent>
Vector;
85 unsigned minx,
miny, maxx, maxy;
91 const osgEarth::TileKey& key);
116 virtual bool insideValidArea(
const DtPoint& p)
const;
124 virtual bool extentInsideValidArea(
unsigned x1,
unsigned y1,
unsigned x2,
unsigned y2)
const;
131 virtual bool extentOutsideValidArea(
unsigned x1,
unsigned y1,
unsigned x2,
unsigned y2)
const;
138 virtual bool addActiveTileKey(
const osgEarth::TileKey& key) = 0;
145 virtual void recomputeActiveTileKeyAreas() = 0;
155 virtual std::string description()
const = 0;
158 virtual unsigned numberOfVertices()
const = 0;
163 virtual unsigned numberOfTrianglesForVertices()
const;
166 virtual void getTriangleVertices(
unsigned xindex,
unsigned yindex,
double& x,
double& y)
const = 0;
169 virtual DtVector getTriangleVertices(
unsigned xindex,
unsigned yindex)
const;
172 virtual void getTriangleIndices(
double x,
double y,
unsigned& xindex,
unsigned& yindex)
const = 0;
176 virtual void heightfieldIndexForTriangleIndex(
177 unsigned triangleXIndex,
unsigned triangleYIndex,
178 unsigned& heightFieldXUsed,
unsigned& heightFieldYUsed)
const = 0;
181 virtual double interpolateHeight(
182 unsigned triangleXIndex,
unsigned triangleYIndex,
183 unsigned* heightFieldXUsed = 0,
unsigned* heightFieldYUsed = 0)
const = 0;
205 virtual bool findIntersections(
207 unsigned x1,
unsigned y1,
unsigned x2,
unsigned y2,
210 bool singleCell =
false,
211 bool insideValidAreaChecked =
false)
const;
215 virtual bool findIntersections(
226 virtual void findTriangles(
228 unsigned x1,
unsigned y1,
unsigned x2,
unsigned y2,
230 bool singleCell =
false,
231 bool insideValidAreaChecked =
false)
const;
235 virtual void findTriangles(
257 osgEarth::MapNode* mapNode);
260 virtual bool useRawElevation()
const;
263 virtual boost::optional<DtTerrainIntersectOptions::Fidelity>
intersectFidelity()
const;
267 virtual unsigned maxLOD()
const;
268 virtual void setMaxLOD(
unsigned);
274 virtual unsigned getMaxLODForBilinearIntersection()
const;
275 virtual void setMaxLODForBilinearIntersection(
unsigned);
284 virtual double triangleOutputMergeTolerance()
const;
285 virtual void setTriangleOutputMergeTolerance(
double tol);
286 virtual double intersetionTriangleMergeTolerance()
const;
287 virtual void setIntersectionTriangleMergeTolerance(
double tol);
292 virtual unsigned minElevationIndexLOD()
const;
293 virtual void setMinElevationIndexLOD(
unsigned);
294 virtual unsigned maxElevationIndexLOD()
const;
295 virtual void setMaxElevationIndexLOD(
unsigned);
300 virtual double maxChordLengthBeforeSplitSquared()
const;
301 virtual void setMaxChordLengthBeforeSplit(
double);
306 virtual unsigned maxElevationChordSplitTestLOD()
const;
307 virtual void setMaxElevationChordSplitTestLOD(
unsigned);
311 virtual unsigned tileCount()
const;
314 virtual unsigned cellCount()
const;
317 virtual osgEarth::MapNode* mapNode()
const;
325 virtual void addPagedInTile(
326 const osgEarth::TileKey& tilekey,
327 const boost::shared_ptr<DtTileData>& tileData);
330 virtual void removePagedInTile(
const osgEarth::TileKey tileKey);
346 virtual bool findHeightFieldIntersections(
356 virtual bool halveChordAndFindHeightFieldIntrx(
365 virtual bool splitChordAt180AndFindHeightFieldIntrx(
374 virtual void processTriangles(
408 virtual osgEarth::TileKey getBestTileKey(
const osgEarth::TileKey&)
const;
420 virtual bool process(
const osgEarth::TileKey& key) {
return true; }
422 virtual bool traverse(
const osgEarth::TileKey& key) {
return true; }
424 virtual void tileWritten(
const osgEarth::TileKey& key,
double min,
double max) { }
433 static std::auto_ptr<IndexOutputInterface> Create(
const DtFilename&,
unsigned precision);
437 virtual void write(
const osgEarth::TileKey& tile,
double min,
double max,
bool valid) = 0;
444 virtual bool writeIndexLayers(
IndexInterface&,
unsigned precision)
const;
451 static std::auto_ptr<IndexInputInterface> Create(
const DtFilename&);
455 virtual bool read(
unsigned& lod,
unsigned& x,
unsigned& y,
double& min,
double& max,
bool& valid) = 0;
473 virtual std::vector<IndexConfig> getIndexConfigInfoForLayer(
474 const osgEarth::ElevationLayer& layer)
const;
477 virtual void readIndex(
479 unsigned layerNumber,
484 virtual bool readIndexLayers();
501 static boost::optional<ElevationRange> Merge(
502 const boost::optional<ElevationRange>& r1,
503 const boost::optional<ElevationRange>& r2);
515 const osgEarth::TileKey& tilekey,
518 void getExtent(
DtVector& lower,
DtVector& upper,
bool useElevation =
true)
const;
519 void getSubTileExtent(
unsigned i,
DtVector& lower,
DtVector& upper,
bool useElevation =
true)
const;
524 bool chordIntersects(
const DtChord& chord,
bool useElevation =
true)
const;
525 bool extentIntersects(
const DtExtent& extent)
const;
526 bool sphereIntersects(
const DtSphere& sphere)
const;
528 bool chordIntersectsSubTile(
const DtChord& chord,
int i,
bool useElevation =
true)
const;
529 bool extentIntersectsSubTile(
const DtExtent& shape,
int i)
const;
530 bool sphereIntersectsSubTile(
const DtSphere& sphere,
int i)
const;
542 std::vector< boost::shared_ptr<DtTileData> >& data,
547 boost::optional<double> getMaxAltForChord(
const DtChord& chord,
unsigned maxlod)
const;
550 boost::shared_ptr<DtTileData> findOldest()
const;
557 bool addTile(
const osgEarth::TileKey& key,
const boost::shared_ptr<DtTileData>& data);
560 void removeTile(
const osgEarth::TileKey& tilekey);
563 unsigned tileCount()
const;
566 unsigned cellCount()
const;
569 const osgEarth::TileKey
tileKey()
const {
return myTileKey; }
573 const osgEarth::TileKey& key,
574 const ElevationRange& range,
575 const ElevationRange& offsets,
580 bool postProcessIndexLayer(
unsigned layerNum);
587 osgEarth::ElevationLayer* layer = 0)
const;
591 bool isTileEmpty()
const;
595 virtual void recomputePagedInData();
619 : range(range), coversTile(coversTile) { }
638 void pageOutSlotIfUnused(
unsigned i);
656 virtual void convertGeometry(
658 std::vector<DtTerrainPagingGeometryPtr>& output)
const;
660 virtual bool convertGeometry(
662 std::vector<DtTerrainPagingGeometryPtr>& output)
const;
664 virtual bool convertGeometry(
666 std::vector<DtTerrainPagingGeometryPtr>& output)
const;
668 virtual bool convertGeometry(
670 std::vector<DtTerrainPagingGeometryPtr>& output)
const;
673 virtual bool nearCenterOfEarth(
const DtChord& chord)
const;
675 virtual bool aboveAllTerrain(
676 const DtChord& geocentricChord,
677 const DtChord& geodeticCoord)
const;
681 virtual bool shortEnoughForIntersection(
682 const DtChord& geocentricChord,
684 double chordLengthSq)
const;
688 virtual bool crosses180Lon(
const DtChord& geodeticChord)
const;
690 virtual bool findData(
692 std::vector< boost::shared_ptr<DtTileData> >& data,
696 virtual bool findData(
698 std::vector< boost::shared_ptr<DtTileData> >& data,
701 virtual void findMissing(
705 virtual boost::shared_ptr<DtTileData> findOldest()
const;
706 virtual boost::shared_ptr<DtTileData> findOldestUnlocked()
const;
760 virtual bool operator()(
const boost::shared_ptr<DtTileData>& tile) = 0;