/usr/include/osgEarth/TerrainTileModelFactory is in libosgearth-dev 2.9.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2008-2014 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_TERRAIN_TILE_MODEL_FACTORY_H
#define OSGEARTH_TERRAIN_TILE_MODEL_FACTORY_H 1
#include <osgEarth/TerrainTileModel>
#include <osgEarth/TerrainOptions>
#include <osgEarth/TerrainEngineRequirements>
#include <osgEarth/ImageLayer>
#include <osgEarth/Progress>
namespace osgEarth
{
class MapFrame;
/**
* Filter you can pass to TerrainTileModelFactory::createTileModel
*/
class CreateTileModelFilter
{
public:
CreateTileModelFilter() : _elevation(false) { }
/** Whether to fetch elevation data and normal maps */
optional<bool>& elevation() { return _elevation; }
const optional<bool>& elevation() const { return _elevation; }
/** List of other layers to accept */
std::set<UID>& layers() { return _layers; }
const std::set<UID>& layers() const { return _layers; }
bool accept(const Layer* layer) const {
return empty() || _layers.find(layer->getUID()) != _layers.end();
}
bool empty() const {
return !_elevation.isSet() && _layers.empty();
}
void clear() {
_elevation.unset();
_layers.clear();
}
protected:
optional<bool> _elevation;
std::set<UID> _layers;
};
/**
* Builds a TerrainTileModel from a map frame.
*/
class OSGEARTH_EXPORT TerrainTileModelFactory : public osg::Referenced
{
public:
/** Constructor */
TerrainTileModelFactory(
const TerrainOptions& options);
/**
* Creates a tile model and populates it with data from the map.
*
* @param frame Map frame from which to read source data
* @param key Tile key for which to create the model
* @param layers Set of layer UIDs for which to fetch data; NULL => all layers
* @param requirements Hints that tell the factory what types of data to add
* @param progress Progress tracking callback
*/
virtual TerrainTileModel* createTileModel(
const MapFrame& frame,
const TileKey& key,
const CreateTileModelFilter& filter,
const TerrainEngineRequirements* requirements,
ProgressCallback* progress);
protected:
virtual void addImageLayers(
TerrainTileModel* model,
const MapFrame& frame,
const TerrainEngineRequirements* reqs,
const TileKey& key,
const CreateTileModelFilter& filter,
ProgressCallback* progress);
virtual void addColorLayers(
TerrainTileModel* model,
const MapFrame& frame,
const TerrainEngineRequirements* reqs,
const TileKey& key,
const CreateTileModelFilter& filter,
ProgressCallback* progress);
virtual void addElevation(
TerrainTileModel* model,
const MapFrame& frame,
const TileKey& key,
const CreateTileModelFilter& filter,
unsigned border,
ProgressCallback* progress);
virtual void addNormalMap(
TerrainTileModel* model,
const MapFrame& frame,
const TileKey& key,
ProgressCallback* progress);
virtual void addPatchLayers(
TerrainTileModel* model,
const MapFrame& frame,
const TileKey& key,
const CreateTileModelFilter& filter,
ProgressCallback* progress);
protected:
/** Find a heightfield in the cache, or fetch it from the source. */
bool getOrCreateHeightField(
const MapFrame& frame,
const TileKey& key,
ElevationSamplePolicy samplePolicy,
ElevationInterpolation interpolation,
unsigned border,
osg::ref_ptr<osg::HeightField>& out_hf,
osg::ref_ptr<NormalMap>& out_normalMap,
ProgressCallback* progress);
osg::Texture* createImageTexture(
osg::Image* image,
const ImageLayer* layer) const;
osg::Texture* createCoverageTexture(
osg::Image* image,
const ImageLayer* layer) const;
osg::Texture* createElevationTexture(
osg::Image* image) const;
osg::Texture* createNormalTexture(
osg::Image* image) const;
const TerrainOptions& _options;
/** Key into the height field cache */
struct HFCacheKey
{
TileKey _key;
Revision _revision;
ElevationSamplePolicy _samplePolicy;
bool operator < (const HFCacheKey& rhs) const {
if ( _key < rhs._key ) return true;
if ( rhs._key < _key ) return false;
if ( _revision < rhs._revision ) return true;
if ( _revision > rhs._revision ) return false;
return _samplePolicy < rhs._samplePolicy;
}
};
struct HFCacheValue
{
osg::ref_ptr<osg::HeightField> _hf;
osg::ref_ptr<NormalMap> _normalMap;
};
//typedef osg::ref_ptr<osg::HeightField> HFCacheValue;
typedef LRUCache<HFCacheKey, HFCacheValue> HFCache;
HFCache _heightFieldCache;
bool _heightFieldCacheEnabled;
osg::ref_ptr<osg::Texture> _emptyTexture;
};
}
#endif // OSGEARTH_TERRAIN_TILE_MODEL_FACTORY_H
|