osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_osgterrain/TileBuilder

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003 * Copyright 2008-2010 Pelican Mapping
00004 * http://osgearth.org
00005 *
00006 * osgEarth is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU Lesser General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU Lesser General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU Lesser General Public License
00017 * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018 */
00019 #ifndef OSGEARTH_ENGINE_TILE_BUILDER
00020 #define OSGEARTH_ENGINE_TILE_BUILDER 1
00021 
00022 #include "Common"
00023 #include "Tile"
00024 #include <osgEarth/Map>
00025 #include <osgEarth/TaskService>
00026 #include <osg/Group>
00027 
00028 using namespace osgEarth;
00029 
00030 class TileBuilder : public osg::Referenced
00031 {
00032 public:
00033     struct SourceRepo
00034     {
00035         SourceRepo() { }
00036 
00037         void add( const CustomColorLayer& layer )
00038         {
00039             Threading::ScopedMutexLock lock(_m);
00040             _colorLayers[ layer.getUID() ] = layer;
00041         }
00042 
00043         void set( const CustomElevLayer& elevLayer )
00044         {
00045             // only one...no lock required
00046             _elevLayer = elevLayer;
00047         }
00048 
00049         ColorLayersByUID _colorLayers;
00050         CustomElevLayer _elevLayer;
00051         Threading::Mutex _m;
00052     };
00053 
00054     struct Job : public osg::Referenced
00055     {
00056         Job(const TileKey& key, const Map* map) : _key(key), _mapf(map, Map::TERRAIN_LAYERS) { }
00057 
00058         TileKey           _key;
00059         MapFrame          _mapf;
00060         SourceRepo        _repo;
00061         TaskRequestVector _tasks;
00062     };
00063 
00064 public:
00065     TileBuilder(
00066         const Map*               map,
00067         const OSGTerrainOptions& terrainOptions,
00068         TaskService*             service );
00069 
00070     void createTile(
00071         const TileKey&      key,
00072         bool                parallelize,
00073         osg::ref_ptr<Tile>& out_tile,
00074         bool&               out_hasRealData,
00075         bool&               out_hasLodBlendedLayers );
00076 
00077     Job* createJob( const TileKey& key, Threading::MultiEvent& semaphore );
00078 
00079     void runJob( Job* job );
00080 
00081     void finalizeJob( 
00082         Job*                job, 
00083         osg::ref_ptr<Tile>& out_tile,
00084         bool&               out_hasRealData,
00085         bool&               out_hasLodBlending );
00086 
00087     TaskService* getTaskService() const { return _service; }
00088 
00089 private:
00090     const Map*               _map;
00091     TaskService*             _service;
00092     const OSGTerrainOptions& _terrainOptions;
00093 };
00094 
00095 #endif // OSGEARTH_ENGINE_TILE_BUILDER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines