本文整理汇总了C++中imagelayervector::const_iterator::get方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::get方法的具体用法?C++ const_iterator::get怎么用?C++ const_iterator::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagelayervector::const_iterator
的用法示例。
在下文中一共展示了const_iterator::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
Revision
Map::getImageLayers( ImageLayerVector& out_list ) const
{
out_list.reserve( _imageLayers.size() );
Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
for( ImageLayerVector::const_iterator i = _imageLayers.begin(); i != _imageLayers.end(); ++i )
out_list.push_back( i->get() );
return _dataModelRevision;
}
示例2: mapf
TerrainEngineNode::~TerrainEngineNode()
{
//Remove any callbacks added to the image layers
if (_map.valid())
{
MapFrame mapf( _map.get(), Map::IMAGE_LAYERS, "TerrainEngineNode::~TerrainEngineNode" );
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
i->get()->removeCallback( _imageLayerController.get() );
}
}
}
示例3:
bool
MapFrame::isCached( const TileKey& key ) const
{
//Check to see if the tile will load fast
// Check the imagery layers
for( ImageLayerVector::const_iterator i = imageLayers().begin(); i != imageLayers().end(); i++ )
{
//If we're cache only we should be fast
if (i->get()->isCacheOnly()) continue;
osg::ref_ptr< TileSource > source = i->get()->getTileSource();
if (!source.valid()) continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key.getTileId() ) ) continue;
//If no data is available on this tile, we'll be fast
if ( !source->hasData( key ) ) continue;
if ( !i->get()->isCached( key ) ) return false;
}
for( ElevationLayerVector::const_iterator i = elevationLayers().begin(); i != elevationLayers().end(); ++i )
{
//If we're cache only we should be fast
if (i->get()->isCacheOnly()) continue;
osg::ref_ptr< TileSource > source = i->get()->getTileSource();
if (!source.valid()) continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key.getTileId() ) ) continue;
if ( !source->hasData( key ) ) continue;
if ( !i->get()->isCached( key ) )
{
return false;
}
}
return true;
}
示例4: getElevationTaskService
void
StreamingTerrainNode::updateTaskServiceThreads( const MapFrame& mapf )
{
//Get the maximum elevation weight
float elevationWeight = 0.0f;
for (ElevationLayerVector::const_iterator itr = mapf.elevationLayers().begin(); itr != mapf.elevationLayers().end(); ++itr)
{
ElevationLayer* layer = itr->get();
float w = layer->getElevationLayerOptions().loadingWeight().value();
if (w > elevationWeight) elevationWeight = w;
}
float totalImageWeight = 0.0f;
for (ImageLayerVector::const_iterator itr = mapf.imageLayers().begin(); itr != mapf.imageLayers().end(); ++itr)
{
totalImageWeight += itr->get()->getImageLayerOptions().loadingWeight().value();
}
float totalWeight = elevationWeight + totalImageWeight;
if (elevationWeight > 0.0f)
{
//Determine how many threads each layer gets
int numElevationThreads = (int)osg::round((float)_numLoadingThreads * (elevationWeight / totalWeight ));
OE_INFO << LC << "Elevation Threads = " << numElevationThreads << std::endl;
getElevationTaskService()->setNumThreads( numElevationThreads );
}
for (ImageLayerVector::const_iterator itr = mapf.imageLayers().begin(); itr != mapf.imageLayers().end(); ++itr)
{
const TerrainLayerOptions& opt = itr->get()->getImageLayerOptions();
int imageThreads = (int)osg::round((float)_numLoadingThreads * (opt.loadingWeight().value() / totalWeight ));
OE_INFO << LC << "Image Threads for " << itr->get()->getName() << " = " << imageThreads << std::endl;
getImageryTaskService( itr->get()->getUID() )->setNumThreads( imageThreads );
}
}
示例5: mapf
TerrainEngineNode::~TerrainEngineNode()
{
OE_DEBUG << LC << "~TerrainEngineNode\n";
//Remove any callbacks added to the image layers
if (_map)
{
MapFrame mapf( _map );
ImageLayerVector imageLayers;
mapf.getLayers(imageLayers);
for( ImageLayerVector::const_iterator i = imageLayers.begin(); i != imageLayers.end(); ++i )
{
i->get()->removeCallback( _imageLayerController.get() );
}
}
}
示例6:
bool
OSGTileFactory::hasMoreLevels( Map* map, const TileKey& key )
{
//Threading::ScopedReadLock lock( map->getMapDataMutex() );
bool more_levels = false;
ImageLayerVector imageLayers;
map->getImageLayers( imageLayers );
for ( ImageLayerVector::const_iterator i = imageLayers.begin(); i != imageLayers.end(); i++ )
{
const ImageLayerOptions& opt = i->get()->getImageLayerOptions();
if ( !opt.maxLevel().isSet() || key.getLevelOfDetail() < (unsigned int)*opt.maxLevel() )
{
more_levels = true;
break;
}
}
if ( !more_levels )
{
ElevationLayerVector elevLayers;
map->getElevationLayers( elevLayers );
for( ElevationLayerVector::const_iterator j = elevLayers.begin(); j != elevLayers.end(); j++ )
{
const ElevationLayerOptions& opt = j->get()->getElevationLayerOptions();
if ( !opt.maxLevel().isSet() || key.getLevelOfDetail() < (unsigned int)*opt.maxLevel() )
//if ( !j->get()->maxLevel().isSet() || key.getLevelOfDetail() < j->get()->maxLevel().get() )
{
more_levels = true;
break;
}
}
}
return more_levels;
}
示例7: mapf
void
TerrainEngineNode::postInitialize( const Map* map, const TerrainOptions& options )
{
if ( _map.valid() ) // i think this is always true [gw]
{
// manually trigger the map callbacks the first time:
if ( _map->getProfile() )
onMapInfoEstablished( MapInfo(_map.get()) );
// create a layer controller. This object affects the uniforms that control layer appearance properties
_imageLayerController = new ImageLayerController( _map.get(), this );
// register the layer Controller it with all pre-existing image layers:
MapFrame mapf( _map.get(), Map::IMAGE_LAYERS );
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
i->get()->addCallback( _imageLayerController.get() );
}
}
_initStage = INIT_POSTINIT_COMPLETE;
}
示例8:
bool
MapFrame::isCached( const TileKey& key ) const
{
// is there a map cache at all?
if ( _map->getCache() == 0L )
return false;
//Check to see if the tile will load fast
// Check the imagery layers
for( ImageLayerVector::const_iterator i = imageLayers().begin(); i != imageLayers().end(); i++ )
{
const ImageLayer* layer = i->get();
if (!layer->getEnabled())
continue;
// If we're cache only we should be fast
if (layer->isCacheOnly())
continue;
// no-cache mode? always slow
if (layer->isNoCache())
return false;
// No tile source? skip it
osg::ref_ptr< TileSource > source = layer->getTileSource();
if (!source.valid())
continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key ) )
continue;
//If no data is available on this tile, we'll be fast
if ( !source->hasData( key ) )
continue;
if ( !layer->isCached(key) )
return false;
}
for( ElevationLayerVector::const_iterator i = elevationLayers().begin(); i != elevationLayers().end(); ++i )
{
const ElevationLayer* layer = i->get();
if (!layer->getEnabled())
continue;
//If we're cache only we should be fast
if (layer->isCacheOnly())
continue;
// no-cache mode? always high-latency.
if (layer->isNoCache())
return false;
osg::ref_ptr< TileSource > source = layer->getTileSource();
if (!source.valid())
continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key ) )
continue;
if ( !source->hasData( key ) )
continue;
if ( !i->get()->isCached( key ) )
return false;
}
return true;
}
示例9: contourLayer
osg::Node*
OSGTileFactory::createPopulatedTile(const MapFrame& mapf,
Terrain* terrain,
const TileKey& key,
bool wrapInPagedLOD,
bool fallback,
bool& validData )
{
const MapInfo& mapInfo = mapf.getMapInfo();
bool isPlateCarre = !mapInfo.isGeocentric() && mapInfo.isGeographicSRS();
typedef std::vector<GeoImageData> GeoImageDataVector;
GeoImageDataVector image_tiles;
// Collect the image layers
bool empty_map = mapf.imageLayers().size() == 0 && mapf.elevationLayers().size() == 0;
// Create the images for the tile
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
GeoImageData imageData;
// Only try to create images if the key is valid
if ( layer->isKeyValid( key ) )
{
imageData._image = layer->createImage( key );
imageData._layerUID = layer->getUID();
imageData._imageTileKey = key;
}
// always push images, even it they are empty, so that the image_tiles vector is one-to-one
// with the imageLayers() vector.
image_tiles.push_back( imageData );
}
bool hasElevation = false;
//Create the heightfield for the tile
osg::ref_ptr<osg::HeightField> hf;
if ( mapf.elevationLayers().size() > 0 )
{
mapf.getHeightField( key, false, hf, 0L, _terrainOptions.elevationInterpolation().value());
}
//If we are on the first LOD and we couldn't get a heightfield tile, just create an empty one. Otherwise you can run into the situation
//where you could have an inset heightfield on one hemisphere and the whole other hemisphere won't show up.
if ( mapInfo.isGeocentric() && key.getLevelOfDetail() <= 1 && !hf.valid())
{
hf = createEmptyHeightField( key );
}
hasElevation = hf.valid();
//Determine if we've created any images
unsigned int numValidImages = 0;
for (unsigned int i = 0; i < image_tiles.size(); ++i)
{
if (image_tiles[i]._image.valid()) numValidImages++;
}
//If we couldn't create any imagery or heightfields, bail out
if (!hf.valid() && (numValidImages == 0) && !empty_map)
{
OE_DEBUG << LC << "Could not create any imagery or heightfields for " << key.str() <<". Not building tile" << std::endl;
validData = false;
//If we're not asked to fallback on previous LOD's and we have no data, return NULL
if (!fallback)
{
return NULL;
}
}
else
{
validData = true;
}
//Try to interpolate any missing image layers from parent tiles
for (unsigned int i = 0; i < mapf.imageLayers().size(); i++ )
{
if (!image_tiles[i]._image.valid())
{
if (mapf.getImageLayerAt(i)->isKeyValid(key))
{
//If the key was valid and we have no image, then something possibly went wrong with the image creation such as a server being busy.
createValidGeoImage(mapf.getImageLayerAt(i), key, image_tiles[i]._image, image_tiles[i]._imageTileKey);
}
//If we still couldn't create an image, either something is really wrong or the key wasn't valid, so just create a transparent placeholder image
if (!image_tiles[i]._image.valid())
{
//If the image is not valid, create an empty texture as a placeholder
image_tiles[i]._image = GeoImage(ImageUtils::createEmptyImage(), key.getExtent());
image_tiles[i]._imageTileKey = key;
}
}
}
//Fill in missing heightfield information from parent tiles
//.........这里部分代码省略.........
示例10: mapf
void
TileBuilder::createTile(const TileKey& key,
bool parallelize,
osg::ref_ptr<Tile>& out_tile,
bool& out_hasRealData,
bool& out_hasLodBlendedLayers )
{
MapFrame mapf( _map, Map::MASKED_TERRAIN_LAYERS );
SourceRepo repo;
// init this to false, then search for real data. "Real data" is data corresponding
// directly to the key, as opposed to fallback data, which is derived from a lower
// LOD key.
out_hasRealData = false;
out_hasLodBlendedLayers = false;
const MapInfo& mapInfo = mapf.getMapInfo();
// If we need more than one layer, fetch them in parallel.
// TODO: change the test based on isKeyValid total.
if ( parallelize && (mapf.imageLayers().size() + mapf.elevationLayers().size() > 1) )
{
// count the valid layers.
int jobCount = 0;
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
if ( i->get()->isKeyValid( key ) )
++jobCount;
if ( i->get()->getImageLayerOptions().lodBlending() == true )
out_hasLodBlendedLayers = true;
}
if ( mapf.elevationLayers().size() > 0 )
++jobCount;
// A thread job monitoring event:
Threading::MultiEvent semaphore( jobCount );
// Start the image layer jobs:
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
if ( layer->isKeyValid(key) )
{
ParallelTask<BuildColorLayer>* j = new ParallelTask<BuildColorLayer>( &semaphore );
j->init( key, layer, mapInfo, _terrainOptions, repo );
j->setPriority( -(float)key.getLevelOfDetail() );
_service->add( j );
}
}
// If we have elevation layers, start an elevation job as well. Otherwise just create an
// empty one while we're waiting for the images to load.
if ( mapf.elevationLayers().size() > 0 )
{
ParallelTask<BuildElevLayer>* ej = new ParallelTask<BuildElevLayer>( &semaphore );
ej->init( key, mapf, _terrainOptions, repo );
ej->setPriority( -(float)key.getLevelOfDetail() );
_service->add( ej );
}
else
{
BuildElevLayer build;
build.init( key, mapf, _terrainOptions, repo );
build.execute();
}
// Wait for all the jobs to finish.
semaphore.wait();
}
// Fetch the image data serially:
else
{
// gather all the image layers serially.
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
//if ( layer->isKeyValid(key) ) // Wrong. no guarantee key is in the same profile.
if ( layer->getEnabled() )
{
BuildColorLayer build;
build.init( key, layer, mapInfo, _terrainOptions, repo );
build.execute();
if ( layer->getImageLayerOptions().lodBlending() == true )
out_hasLodBlendedLayers = true;
}
}
// make an elevation layer.
BuildElevLayer build;
build.init( key, mapf, _terrainOptions, repo );
build.execute();
}
//.........这里部分代码省略.........
示例11: mapConf
Config
EarthFileSerializer2::serialize(const MapNode* input, const std::string& referrer) const
{
Config mapConf("map");
mapConf.set("version", "2");
if ( !input || !input->getMap() )
return mapConf;
const Map* map = input->getMap();
MapFrame mapf( map, Map::ENTIRE_MODEL );
// the map and node options:
Config optionsConf = map->getInitialMapOptions().getConfig();
optionsConf.merge( input->getMapNodeOptions().getConfig() );
mapConf.add( "options", optionsConf );
// the layers
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getImageLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "image", layerConf );
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); ++i )
{
ElevationLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getElevationLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "elevation", layerConf );
}
for( ModelLayerVector::const_iterator i = mapf.modelLayers().begin(); i != mapf.modelLayers().end(); ++i )
{
ModelLayer* layer = i->get();
Config layerConf = layer->getModelLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getModelLayerOptions().driver()->getDriver());
mapConf.add( "model", layerConf );
}
Config ext = input->externalConfig();
if ( !ext.empty() )
{
ext.key() = "extensions";
mapConf.add( ext );
}
#if 1 // removed until it can be debugged.
// Re-write pathnames in the Config so they are relative to the new referrer.
if ( _rewritePaths && !referrer.empty() )
{
RewritePaths rewritePaths( referrer );
rewritePaths.setRewriteAbsolutePaths( _rewriteAbsolutePaths );
rewritePaths.apply( mapConf );
}
#endif
return mapConf;
}
示例12: seed
void CacheSeed::seed( Map* map )
{
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
}
if ( src_max_level > 0 && src_max_level < _maxLevel )
{
_maxLevel = src_max_level;
//.........这里部分代码省略.........
示例13: CustomElevLayer
void
TileBuilder::finalizeJob(TileBuilder::Job* job,
osg::ref_ptr<Tile>& out_tile,
bool& out_hasRealData,
bool& out_hasLodBlending)
{
SourceRepo& repo = job->_repo;
out_hasRealData = false;
out_hasLodBlending = false;
// Bail out now if there's no data to be had.
if ( repo._colorLayers.size() == 0 && !repo._elevLayer.getHFLayer() )
{
return;
}
const TileKey& key = job->_key;
const MapInfo& mapInfo = job->_mapf.getMapInfo();
// OK we are making a tile, so if there's no heightfield yet, make an empty one.
if ( !repo._elevLayer.getHFLayer() )
{
osg::HeightField* hf = HeightFieldUtils::createReferenceHeightField( key.getExtent(), 8, 8 );
osgTerrain::HeightFieldLayer* hfLayer = new osgTerrain::HeightFieldLayer( hf );
hfLayer->setLocator( GeoLocator::createForKey(key, mapInfo) );
repo._elevLayer = CustomElevLayer( hfLayer, true );
}
// Now, if there are any color layers that did not get built, create them with an empty
// image so the shaders have something to draw.
osg::ref_ptr<osg::Image> emptyImage;
osgTerrain::Locator* locator = repo._elevLayer.getHFLayer()->getLocator();
for( ImageLayerVector::const_iterator i = job->_mapf.imageLayers().begin(); i != job->_mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
if ( layer->getEnabled() )
{
if ( !layer->isKeyValid(key) )
{
if ( !emptyImage.valid() )
emptyImage = ImageUtils::createEmptyImage();
repo.add( CustomColorLayer(
i->get(), emptyImage.get(),
locator,
key.getLevelOfDetail(),
key,
true ) );
}
if ( i->get()->getImageLayerOptions().lodBlending() == true )
out_hasLodBlending = true;
}
}
// Ready to create the actual tile.
AssembleTile assemble;
assemble.init( key, mapInfo, _terrainOptions, repo );
assemble.execute();
// Check the results and see if we have any real data.
for( ColorLayersByUID::const_iterator i = repo._colorLayers.begin(); i != repo._colorLayers.end(); ++i )
{
if ( !i->second.isFallbackData() )
{
out_hasRealData = true;
break;
}
}
if ( !out_hasRealData && !repo._elevLayer.isFallbackData() )
{
out_hasRealData = true;
}
out_tile = assemble._tile;
}
示例14: exclusive
void
MPGeometry::renderPrimitiveSets(osg::State& state,
bool usingVBOs) const
{
// check the map frame to see if it's up to date
if ( _frame.needsSync() )
{
// this lock protects a MapFrame sync when we have multiple DRAW threads.
Threading::ScopedMutexLock exclusive( _frameSyncMutex );
if ( _frame.needsSync() && _frame.sync() ) // always double check
{
// This should only happen is the layer ordering changes;
// If layers are added or removed, the Tile gets rebuilt and
// the point is moot.
std::vector<Layer> reordered;
const ImageLayerVector& layers = _frame.imageLayers();
reordered.reserve( layers.size() );
for( ImageLayerVector::const_iterator i = layers.begin(); i != layers.end(); ++i )
{
std::vector<Layer>::iterator j = std::find( _layers.begin(), _layers.end(), i->get()->getUID() );
if ( j != _layers.end() )
reordered.push_back( *j );
}
_layers.swap( reordered );
}
}
unsigned layersDrawn = 0;
osg::ref_ptr<osg::GL2Extensions> ext = osg::GL2Extensions::Get( state.getContextID(), true );
const osg::Program::PerContextProgram* pcp = state.getLastAppliedProgramObject();
GLint opacityLocation;
GLint uidLocation;
GLint orderLocation;
GLint texMatParentLocation;
// yes, it's possible that the PCP is not set up yet.
// TODO: can we optimize this so we don't need to get uni locations every time?
if ( pcp )
{
opacityLocation = pcp->getUniformLocation( _opacityUniform->getNameID() );
uidLocation = pcp->getUniformLocation( _layerUIDUniform->getNameID() );
orderLocation = pcp->getUniformLocation( _layerOrderUniform->getNameID() );
texMatParentLocation = pcp->getUniformLocation( _texMatParentUniform->getNameID() );
}
// activate the tile coordinate set - same for all layers
state.setTexCoordPointer( _imageUnit+1, _tileCoords.get() );
if ( _layers.size() > 0 )
{
float prev_opacity = -1.0f;
float prev_alphaThreshold = -1.0f;
// first bind any shared layers
// TODO: optimize by pre-storing shared indexes
for(unsigned i=0; i<_layers.size(); ++i)
{
const Layer& layer = _layers[i];
// a "shared" layer binds to a secondary texture unit so that other layers
// can see it and use it.
if ( layer._imageLayer->isShared() )
{
int sharedUnit = layer._imageLayer->shareImageUnit().get();
{
state.setActiveTextureUnit( sharedUnit );
state.setTexCoordPointer( sharedUnit, layer._texCoords.get() );
// bind the texture for this layer to the active share unit.
layer._tex->apply( state );
// no texture LOD blending for shared layers for now. maybe later.
}
}
}
// track the active image unit.
int activeImageUnit = -1;
// interate over all the image layers
for(unsigned i=0; i<_layers.size(); ++i)
{
const Layer& layer = _layers[i];
if ( layer._imageLayer->getVisible() )
{
// activate the visible unit if necessary:
if ( activeImageUnit != _imageUnit )
{
state.setActiveTextureUnit( _imageUnit );
activeImageUnit = _imageUnit;
}
// bind the texture for this layer:
layer._tex->apply( state );
// if we're using a parent texture for blending, activate that now
//.........这里部分代码省略.........
示例15: lock
bool
Map::sync( MapFrame& frame ) const
{
bool result = false;
if ( frame._mapDataModelRevision != _dataModelRevision || !frame._initialized )
{
// hold the read lock while copying the layer lists.
Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
if ( frame._parts & IMAGE_LAYERS )
{
if ( !frame._initialized )
frame._imageLayers.reserve( _imageLayers.size() );
frame._imageLayers.clear();
if ( frame._copyValidDataOnly )
{
for( ImageLayerVector::const_iterator i = _imageLayers.begin(); i != _imageLayers.end(); ++i )
if ( i->get()->getProfile() )
frame._imageLayers.push_back( i->get() );
}
else
std::copy( _imageLayers.begin(), _imageLayers.end(), std::back_inserter(frame._imageLayers) );
}
if ( frame._parts & ELEVATION_LAYERS )
{
if ( !frame._initialized )
frame._elevationLayers.reserve( _elevationLayers.size() );
frame._elevationLayers.clear();
if ( frame._copyValidDataOnly )
{
for( ElevationLayerVector::const_iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i )
if ( i->get()->getProfile() )
frame._elevationLayers.push_back( i->get() );
}
else
std::copy( _elevationLayers.begin(), _elevationLayers.end(), std::back_inserter(frame._elevationLayers) );
}
if ( frame._parts & MODEL_LAYERS )
{
if ( !frame._initialized )
frame._modelLayers.reserve( _modelLayers.size() );
frame._modelLayers.clear();
std::copy( _modelLayers.begin(), _modelLayers.end(), std::back_inserter(frame._modelLayers) );
}
if ( frame._parts & MASK_LAYERS )
{
if ( !frame._initialized )
frame._maskLayers.reserve( _terrainMaskLayers.size() );
frame._maskLayers.clear();
std::copy( _terrainMaskLayers.begin(), _terrainMaskLayers.end(), std::back_inserter(frame._maskLayers) );
}
// sync the revision numbers.
frame._initialized = true;
frame._mapDataModelRevision = _dataModelRevision;
result = true;
}
return result;
}