当前位置: 首页>>代码示例>>C++>>正文


C++ MapFrame::populateHeightField方法代码示例

本文整理汇总了C++中MapFrame::populateHeightField方法的典型用法代码示例。如果您正苦于以下问题:C++ MapFrame::populateHeightField方法的具体用法?C++ MapFrame::populateHeightField怎么用?C++ MapFrame::populateHeightField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapFrame的用法示例。


在下文中一共展示了MapFrame::populateHeightField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

bool
HeightFieldCache::getOrCreateHeightField(const MapFrame&                 frame,
                                         const TileKey&                  key,
                                         const osg::HeightField*         parent_hf,
                                         osg::ref_ptr<osg::HeightField>& out_hf,
                                         bool&                           out_isFallback,
                                         ElevationSamplePolicy           samplePolicy,
                                         ElevationInterpolation          interp,
                                         ProgressCallback*               progress )
{
    // default
    out_isFallback = false;
    
    // check the quick cache.
    HFKey cachekey;
    cachekey._key          = key;
    cachekey._revision     = frame.getRevision();
    cachekey._samplePolicy = samplePolicy;

    if (progress)
        progress->stats()["hfcache_try_count"] += 1;

    LRUCache<HFKey,HFValue>::Record rec;
    if ( _enabled && _cache.get(cachekey, rec) )
    {
        // Found it in the cache.
        out_hf         = rec.value()._hf.get();
        out_isFallback = rec.value()._isFallback;

        if (progress)
        {
            progress->stats()["hfcache_hit_count"] += 1;
            progress->stats()["hfcache_hit_rate"] = progress->stats()["hfcache_hit_count"]/progress->stats()["hfcache_try_count"];
        }
    }

    else
    {
        // Not in the cache, so we need to create a HF.
        TileKey parentKey = key.createParentKey();

        // Elevation "smoothing" uses the parent HF as the starting point for building
        // a new tile. This will cause lower-resolution data to propagate down the tree
        // and fill in any gaps in higher-resolution data. The result will be an elevation
        // grid that is "smoother" but not necessarily as accurate.
        if ( _useParentAsReferenceHF && parent_hf && parentKey.valid() )
        {
            out_hf = HeightFieldUtils::createSubSample(
                parent_hf,
                parentKey.getExtent(),
                key.getExtent(),
                interp );
        }

        // If we are not smoothing, or we have no parent data, start with a basic
        // MSL=0 reference heightfield instead.
        if ( !out_hf.valid() )
        {
            out_hf = HeightFieldUtils::createReferenceHeightField( key.getExtent(), _tileSize, _tileSize, 0u );
        }

        // Next, populate it with data from the Map. The map will overwrite our starting
        // data with real data from the elevation stack.
        bool populated = frame.populateHeightField(
            out_hf,
            key,
            true, // convertToHAE
            progress );

        // Check for cancelation before writing to a cache
        if (progress && progress->isCanceled())
        {
            if (out_hf.valid())
            {
                OE_DEBUG << LC << "Cancelation with a valid HF; this would cache bad data." << std::endl;
            }
            return false;
        }

        // If the map failed to provide any suitable data sources at all, replace the
        // heightfield with data from its parent (if available). 
        if ( !populated )
        {
            if ( parentKey.valid() && parent_hf )
            {        
                out_hf = HeightFieldUtils::createSubSample(
                    parent_hf,
                    parentKey.getExtent(),
                    key.getExtent(),
                    interp );
            }

            if ( !out_hf.valid() )
            {
                // NOTE: This is probably no longer be possible, but check anyway for completeness.
                return false;
            }
        }

        // ONLY cache the new heightfield if a parent HF existed. Otherwise the new HF
//.........这里部分代码省略.........
开发者ID:emminizer,项目名称:osgearth,代码行数:101,代码来源:HeightFieldCache.cpp


注:本文中的MapFrame::populateHeightField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。