Changeset 853

Show
Ignore:
Timestamp:
01/22/08 15:15:11
Author:
robert
Message:

Introduced optional code paths for new multiple split level support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/vpb/DataSet

    r843 r853  
    165165        bool generateTasks(TaskManager* taskManager); 
    166166 
     167        bool generateTasks_new(TaskManager* taskManager); 
     168        bool generateTasks_old(TaskManager* taskManager); 
     169 
     170 
    167171        int run(); 
    168172 
     
    211215        bool computeOptimumTileSystemDimensions(int& C1, int& R1); 
    212216        CompositeDestination* createDestinationTile(int level, int tileX, int tileY); 
     217         
     218        bool prepareForDestinationGraphCreation(); 
     219      
     220        int computeMaximumLevel(); 
    213221 
    214222        osg::ref_ptr<CompositeSource>               _sourceGraph; 
  • trunk/src/vpb/DataSet.cpp

    r849 r853  
    427427        } 
    428428 
    429         double source_xRange = sp._extents.xMax()-sp._extents.xMin(); 
    430         double source_yRange = sp._extents.yMax()-sp._extents.yMin(); 
    431          
    432         int level = 0; 
    433429         
    434430        if (source->getType()!=Source::IMAGE && source->getType()!=Source::HEIGHT_FIELD) 
     
    10091005} 
    10101006 
    1011 void DataSet::computeDestinationGraphFromSources(unsigned int numLevels
    1012 { 
    1013     if (!_sourceGraph) return
     1007bool DataSet::prepareForDestinationGraphCreation(
     1008{ 
     1009    if (!_sourceGraph) return false
    10141010 
    10151011    // ensure we have a valid coordinate system 
     
    11281124    log(osg::INFO, "          yMin() %f %f",_destinationExtents.yMin(),_destinationExtents.yMax()); 
    11291125 
     1126    return true; 
     1127} 
     1128 
     1129void DataSet::computeDestinationGraphFromSources(unsigned int numLevels) 
     1130{ 
     1131    if (!prepareForDestinationGraphCreation()) return; 
     1132 
     1133#if 0 
     1134    if (!_sourceGraph) return; 
     1135 
     1136    // ensure we have a valid coordinate system 
     1137    if (_destinationCoordinateSystemString.empty()&& !getConvertFromGeographicToGeocentric()) 
     1138    { 
     1139        for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) 
     1140        { 
     1141            SourceData* sd = (*itr)->getSourceData(); 
     1142            if (sd) 
     1143            { 
     1144                if (sd->_cs.valid()) 
     1145                { 
     1146                    _destinationCoordinateSystem = sd->_cs; 
     1147                    log(osg::INFO,"Setting coordinate system to %s",_destinationCoordinateSystem->getCoordinateSystem().c_str()); 
     1148                    break; 
     1149                } 
     1150            } 
     1151        } 
     1152    } 
     1153     
     1154     
     1155    assignIntermediateCoordinateSystem(); 
     1156 
     1157    CoordinateSystemType destinateCoordSytemType = getCoordinateSystemType(_destinationCoordinateSystem.get()); 
     1158    if (destinateCoordSytemType==GEOGRAPHIC && !getConvertFromGeographicToGeocentric()) 
     1159    { 
     1160        // convert elevation into degrees. 
     1161        setVerticalScale(1.0f/111319.0f); 
     1162    } 
     1163 
     1164    // get the extents of the sources and 
     1165    _destinationExtents = _extents; 
     1166    _destinationExtents._isGeographic = destinateCoordSytemType==GEOGRAPHIC; 
     1167 
     1168    // sort the sources so that the lowest res tiles are drawn first. 
     1169    { 
     1170     
     1171#if 0     
     1172        for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) 
     1173        { 
     1174            Source* source = itr->get(); 
     1175            if (source) 
     1176            { 
     1177                source->setSortValueFromSourceDataResolution(_intermediateCoordinateSystem.get()); 
     1178                log(osg::INFO, "sort %s value %f",source->getFileName().c_str(),source->getSortValue()); 
     1179            } 
     1180             
     1181        } 
     1182         
     1183        // sort them so highest sortValue is first. 
     1184#endif 
     1185        _sourceGraph->setSortValueFromSourceDataResolution(_intermediateCoordinateSystem.get()); 
     1186        _sourceGraph->sort(); 
     1187    } 
     1188 
     1189    if (!_destinationExtents.valid())  
     1190    { 
     1191        for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) 
     1192        { 
     1193            SourceData* sd = (*itr)->getSourceData(); 
     1194            if (sd) 
     1195            { 
     1196                GeospatialExtents local_extents(sd->getExtents(_intermediateCoordinateSystem.get())); 
     1197                log(osg::INFO, "local_extents = xMin() %f %f",local_extents.xMin(),local_extents.xMax()); 
     1198                log(osg::INFO, "                yMin() %f %f",local_extents.yMin(),local_extents.yMax()); 
     1199                 
     1200                if (destinateCoordSytemType==GEOGRAPHIC) 
     1201                { 
     1202                    // need to clamp within -180 and 180 range. 
     1203                    if (local_extents.xMin()>180.0)  
     1204                    { 
     1205                        // shift back to -180 to 180 range 
     1206                        local_extents.xMin() -= 360.0; 
     1207                        local_extents.xMax() -= 360.0; 
     1208                    } 
     1209                    else if (local_extents.xMin()<-180.0)  
     1210                    { 
     1211                        // shift back to -180 to 180 range 
     1212                        local_extents.xMin() += 360.0; 
     1213                        local_extents.xMax() += 360.0; 
     1214                    } 
     1215                } 
     1216 
     1217                _destinationExtents.expandBy(local_extents); 
     1218            } 
     1219        } 
     1220    } 
     1221     
     1222 
     1223    if (destinateCoordSytemType==GEOGRAPHIC) 
     1224    { 
     1225        double xRange = _destinationExtents.xMax() - _destinationExtents.xMin(); 
     1226        if (xRange>360.0)  
     1227        { 
     1228            // clamp to proper 360 range. 
     1229            _destinationExtents.xMin() = -180.0; 
     1230            _destinationExtents.xMax() = 180.0; 
     1231        } 
     1232    } 
     1233     
     1234 
     1235    // compute the number of texture layers required. 
     1236    unsigned int maxTextureUnit = 0; 
     1237    for(CompositeSource::source_iterator sitr(_sourceGraph.get());sitr.valid();++sitr) 
     1238    { 
     1239        Source* source = sitr->get(); 
     1240        if (source)  
     1241        { 
     1242            if (maxTextureUnit<source->getLayer()) maxTextureUnit = source->getLayer(); 
     1243        } 
     1244    } 
     1245    _numTextureLevels = maxTextureUnit+1; 
     1246 
     1247 
     1248    log(osg::INFO, "extents = xMin() %f %f",_destinationExtents.xMin(),_destinationExtents.xMax()); 
     1249    log(osg::INFO, "          yMin() %f %f",_destinationExtents.yMin(),_destinationExtents.yMax()); 
     1250 
     1251#endif 
    11301252 
    11311253    osg::Timer_t before = osg::Timer::instance()->tick(); 
    11321254 
    11331255    // then create the destination graph accordingly. 
    1134     if (getBuildOptionsString() != "new") 
     1256    if (getBuildOptionsString().find("new")!=std::string::npos) 
     1257    { 
     1258        createNewDestinationGraph(_intermediateCoordinateSystem.get(), 
     1259                                  _destinationExtents, 
     1260                                  _maximumTileImageSize, 
     1261                                  _maximumTileTerrainSize, 
     1262                                  numLevels); 
     1263    } 
     1264    else 
    11351265    { 
    11361266        _destinationGraph = createDestinationGraph(0, 
     
    11431273                                                   0, 
    11441274                                                   numLevels); 
    1145     } 
    1146     else 
    1147     { 
    1148         createNewDestinationGraph(_intermediateCoordinateSystem.get(), 
    1149                                   _destinationExtents, 
    1150                                   _maximumTileImageSize, 
    1151                                   _maximumTileTerrainSize, 
    1152                                   numLevels); 
    11531275    } 
    11541276                                                                
     
    22772399bool DataSet::generateTasks(TaskManager* taskManager) 
    22782400{ 
     2401    if (getBuildOptionsString().find("tm")!=std::string::npos) 
     2402    { 
     2403        return generateTasks_new(taskManager); 
     2404    } 
     2405    else 
     2406    { 
     2407        return generateTasks_old(taskManager); 
     2408    } 
     2409} 
     2410 
     2411bool DataSet::generateTasks_new(TaskManager* taskManager) 
     2412{ 
     2413    log(osg::NOTICE,"DataSet::generateTasks_new"); 
     2414    if (!getLogFileName().empty()) 
     2415    { 
     2416        if (!getBuildLog()) setBuildLog(new BuildLog()); 
     2417     
     2418        getBuildLog()->openLogFile(getLogFileName()); 
     2419    } 
     2420 
     2421    if (getBuildLog()) 
     2422    { 
     2423        pushOperationLog(getBuildLog()); 
     2424    } 
     2425     
     2426    loadSources(); 
     2427 
     2428    if (!prepareForDestinationGraphCreation()) return false; 
     2429 
     2430    computeOptimumTileSystemDimensions(_C1,_R1); 
     2431    log(osg::NOTICE,"      C1=%i R1=%i",_C1,_R1); 
     2432 
     2433 
     2434 
     2435    log(osg::NOTICE,"OK, OK I now need something to do..."); 
     2436     
     2437    log(osg::NOTICE,"First compute the maximum level required"); 
     2438    log(osg::NOTICE,"Then compute the appropriate split levels"); 
     2439    log(osg::NOTICE,"Then generate the root task"); 
     2440    log(osg::NOTICE,"Then generate the intermediate tasks if any"); 
     2441    log(osg::NOTICE,"Then generate the leaf tasks if any"); 
     2442 
     2443    if (getBuildLog()) 
     2444    { 
     2445        popOperationLog(); 
     2446    } 
     2447 
     2448    return false; 
     2449} 
     2450 
     2451bool DataSet::generateTasks_old(TaskManager* taskManager) 
     2452{ 
    22792453    if (getDistributedBuildSplitLevel()==0) return false; 
    22802454