This file is indexed.

/usr/include/osgEarthDrivers/engine_mp/TileModel is in libosgearth-dev 2.7.0+dfsg-2+b3.

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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 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.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* 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_DRIVERS_MP_TERRAIN_ENGINE_TILE_MODEL
#define OSGEARTH_DRIVERS_MP_TERRAIN_ENGINE_TILE_MODEL 1

#include "Common"
#include <osgEarth/Common>
#include <osgEarth/Map>
#include <osgEarth/ImageLayer>
#include <osgEarth/TileKey>
#include <osgEarth/Locators>
#include <osgEarth/HeightFieldUtils>
#include <osgEarth/MapInfo>
#include <osgTerrain/Locator>
#include <osgTerrain/Layer>
#include <osg/Image>
#include <osg/StateSet>
#include <osg/Texture2D>
#include <osg/State>
#include <osg/NodeVisitor>
#include <map>

namespace osgEarth { namespace Drivers { namespace MPTerrainEngine
{
    using namespace osgEarth;

    class TileModel : public osg::Referenced
    {
    public:
        void resizeGLObjectBuffers(unsigned maxSize);
        void releaseGLObjects(osg::State* state) const;

    public:
        // do not change the order of these.
        enum Neighbor
        {
            NORTHWEST = 0,
            NORTH     = 1,
            NORTHEAST = 2,
            WEST      = 3,
            EAST      = 4,
            SOUTHWEST = 5,
            SOUTH     = 6,
            SOUTHEAST = 7
        };

        class ElevationData
        {
        public:
            ElevationData() : _fallbackData(true) { }
            ElevationData(const ElevationData& rhs);

            virtual ~ElevationData() { }

            ElevationData(
                osg::HeightField* hf,
                GeoLocator*       locator,
                bool              fallbackData);

            osg::HeightField* getHeightField() const { return _hf.get(); }
            GeoLocator* getLocator() const { return _locator.get(); }
            bool isFallbackData() const { return _fallbackData; }

            // get a height value using a normalized coord and a locator.
            bool getHeight( const osg::Vec3d& ndc, const GeoLocator* ndcLocator, float& output, ElevationInterpolation interp ) const;

            // get a normal vector (in woord space)
            bool getNormal( const osg::Vec3d& ndc, const GeoLocator* ndcLocator, osg::Vec3& output, ElevationInterpolation interp ) const;
            
            osg::HeightField* getNeighbor(int xoffset, int yoffset) const
            {
                return _neighbors.getNeighbor(xoffset, yoffset);
            }

            void setNeighbor(int xoffset, int yoffset, osg::HeightField* hf )
            {
                _neighbors.setNeighbor(xoffset, yoffset, hf);
            }

            const HeightFieldNeighborhood& getNeighborhood() const 
            {
                return _neighbors;
            }

            void setParent(osg::HeightField* hf)
            {
                _parent = hf;
            }

            osg::HeightField* getParent() const
            {
                return _parent.get();
            }

        private:
            osg::ref_ptr<osg::HeightField> _hf;
            osg::ref_ptr<GeoLocator>       _locator;
            bool                           _fallbackData;
            osg::ref_ptr<osg::HeightField> _parent;

            HeightFieldNeighborhood _neighbors;
        };

        class NormalData
        {
        public:
            NormalData() : _fallbackData(true) { }
            NormalData(const NormalData& rhs);

            virtual ~NormalData() { }

            NormalData(
                osg::HeightField* hf,
                GeoLocator*       locator,
                bool              fallbackData);

            osg::HeightField* getHeightField() const { return _hf.get(); }
            GeoLocator* getLocator() const { return _locator.get(); }
            bool isFallbackData() const { return _fallbackData; }

            void setNeighbor(int xoffset, int yoffset, osg::HeightField* hf )
            {
                _neighbors.setNeighbor(xoffset, yoffset, hf);
            }

            void setParent(osg::HeightField* hf)
            {
                _parent = hf;
            }

            osg::HeightField* getParent() const
            {
                return _parent.get();
            }

            const HeightFieldNeighborhood& getNeighborhood() const 
            {
                return _neighbors;
            }

        public:
            osg::ref_ptr<osg::HeightField> _hf;
            osg::ref_ptr<GeoLocator>       _locator;
            bool                           _fallbackData;
            osg::ref_ptr<osg::HeightField> _parent;

            HeightFieldNeighborhood _neighbors;
        };


        class ColorData
        {
        public:
            ColorData() : _fallbackData(true) { }

            /** Copy ctor - shallow */
            ColorData(const ColorData& rhs);

            /** dtor */
            virtual ~ColorData() { }

            ColorData(
                const osgEarth::ImageLayer* imageLayer,
                unsigned                    order,
                osg::Image*                 image,
                GeoLocator*                 locator,
                bool                        fallbackData =false );
    
            void resizeGLObjectBuffers(unsigned maxSize);
            void releaseGLObjects(osg::State* state) const;


            osgEarth::UID getUID() const {
                return _layer->getUID();
            }

            unsigned getOrder() const {
                return _order;
            }

            const GeoLocator* getLocator() const {
                return _locator.get();
            }

            osg::Texture* getTexture() const {
                return _texture.get();
            }

            const osgEarth::ImageLayer* getMapLayer() const {
                return _layer.get(); }

            bool isFallbackData() const {
                return _fallbackData;
            }
            void setIsFallbackData(bool value) {
                _fallbackData = value;
            }

            bool hasAlpha() const {
                return _hasAlpha;
            }


            osg::BoundingSphere computeBound() const {
                osg::BoundingSphere bs;
                osg::Vec3d v;
                if (getLocator()->convertLocalToModel(osg::Vec3d(0.5,0.5,0.0), v)) {
                    bs.center() = v;
                }
                if (getLocator()->convertLocalToModel(osg::Vec3d(0.0,0.0,0.0), v)) {
                    bs.radius() = (bs.center() - v).length();
                }
                return bs;
            }


            osg::ref_ptr<const osgEarth::ImageLayer> _layer;
            osg::ref_ptr<GeoLocator>                 _locator;
            osg::ref_ptr<osg::Texture>               _texture;
            bool                                     _fallbackData;
            unsigned                                 _order;
            bool                                     _hasAlpha;
        };

        class ColorDataRef : public osg::Referenced
        {
        public:
            ColorDataRef( const ColorData& layer ) : _layer(layer) { }
            ColorData _layer;
        };


        typedef std::map<UID, ColorData> ColorDataByUID;


    public:
        TileModel( const osgEarth::Revision& mapModelRevision, const MapInfo& mapInfo )
            : _revision(mapModelRevision), _mapInfo(mapInfo), _useParentData(false) { }
        TileModel(const TileModel& rhs);
        virtual ~TileModel() { }

        /**
         * Creates a TileModel representing a quadrant of this tile model.
         * Used for upsampling.
         */
        TileModel* createQuadrant(unsigned q) const;

        /** Map revision used to build this model */
        const Revision& getMapRevision() const { return _revision; }

        /** Whether this tile contains any real data (versus being comprised entirely of fallback data) */
        bool hasRealData() const;

        /** Parent model pointer. */
        void setParentTileModel(const TileModel* parent);
        const TileModel* getParentTileModel() const { return _parentModel.get(); }

        /** Whether there is a heightfield */
        bool hasElevation() const { return _elevationData.getHeightField() != 0L; }

        /** Whether there's a normal map */
        bool hasNormalMap() const { return _normalData.getHeightField() != 0L; }

        /** Whether to use parent data if it's available. */
        bool useParentData() const { return _useParentData; }

        MapInfo                      _mapInfo;
        Revision                     _revision;
        TileKey                      _tileKey;
        osg::ref_ptr<GeoLocator>     _tileLocator;
        ColorDataByUID               _colorData;
        ElevationData                _elevationData;
        NormalData                   _normalData;
        float                        _sampleRatio;
        osg::ref_ptr<osg::Texture>   _elevationTexture;
        osg::ref_ptr<osg::Texture>   _normalTexture;
        bool                         _useParentData;
        
        osg::ref_ptr<osg::StateSet>        _parentStateSet;
        osg::observer_ptr<const TileModel> _parentModel;

        // convenience funciton to pull out a layer by its UID.
        bool getColorData( UID layerUID, ColorData& out ) const {
            ColorDataByUID::const_iterator i = _colorData.find( layerUID );
            if ( i != _colorData.end() ) {
                out = i->second;
                return true;
            }
            return false;
        }

        bool requiresUpdateTraverse() const;

        void updateTraverse(osg::NodeVisitor&) const;

        void generateElevationTexture();

        void generateNormalTexture();
    };

} } } // namespace osgEarth::Drivers::MPTerrainEngine

#endif // OSGEARTH_DRIVERS_MP_TERRAIN_ENGINE_TILE_MODEL