Changeset 854
- Timestamp:
- 01/22/08 17:56:58
- Files:
-
- trunk/include/vpb/BuildOptions (modified) (2 diffs)
- trunk/include/vpb/DataSet (modified) (1 diff)
- trunk/src/vpb/BuildOptions.cpp (modified) (2 diffs)
- trunk/src/vpb/BuildOptionsIO.cpp (modified) (1 diff)
- trunk/src/vpb/Commandline.cpp (modified) (2 diffs)
- trunk/src/vpb/DataSet.cpp (modified) (7 diffs)
- trunk/src/vpb/TaskManager.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/vpb/BuildOptions
r836 r854 197 197 void setDistributedBuildSplitLevel(unsigned int level) { _distributedBuildSplitLevel = level; } 198 198 unsigned int getDistributedBuildSplitLevel() const { return _distributedBuildSplitLevel; } 199 200 void setDistributedBuildSecondarySplitLevel(unsigned int level) { _distributedBuildSecondarySplitLevel = level; } 201 unsigned int getDistributedBuildSecondarySplitLevel() const { return _distributedBuildSecondarySplitLevel; } 199 202 200 203 void setRecordSubtileFileNamesOnLeafTile(bool recordSubtileFileNamesOnLeafTile) { _recordSubtileFileNamesOnLeafTile = recordSubtileFileNamesOnLeafTile; } … … 277 280 278 281 unsigned int _distributedBuildSplitLevel; 282 unsigned int _distributedBuildSecondarySplitLevel; 283 279 284 bool _recordSubtileFileNamesOnLeafTile; 280 285 bool _generateSubtile; trunk/include/vpb/DataSet
r853 r854 215 215 bool computeOptimumTileSystemDimensions(int& C1, int& R1); 216 216 CompositeDestination* createDestinationTile(int level, int tileX, int tileY); 217 218 bool prepareForDestinationGraphCreation(); 219 220 int computeMaximumLevel(); 217 int computeMaximumLevel(int maxNumLevels); 218 219 bool prepareForDestinationGraphCreation(); 220 221 void selectAppropriateSplitLevels(); 221 222 222 223 osg::ref_ptr<CompositeSource> _sourceGraph; trunk/src/vpb/BuildOptions.cpp
r836 r854 57 57 58 58 _distributedBuildSplitLevel = 0; 59 _distributedBuildSecondarySplitLevel = 0; 59 60 _recordSubtileFileNamesOnLeafTile = false; 60 61 _generateSubtile = false; … … 123 124 _writeNodeBeforeSimplification = rhs._writeNodeBeforeSimplification; 124 125 _distributedBuildSplitLevel = rhs._distributedBuildSplitLevel; 126 _distributedBuildSecondarySplitLevel = rhs._distributedBuildSecondarySplitLevel; 125 127 _recordSubtileFileNamesOnLeafTile = rhs._recordSubtileFileNamesOnLeafTile; 126 128 _generateSubtile = rhs._generateSubtile; trunk/src/vpb/BuildOptionsIO.cpp
r836 r854 199 199 200 200 ADD_UINT_PROPERTY(DistributedBuildSplitLevel); 201 ADD_UINT_PROPERTY(DistributedBuildSecondarySplitLevel); 201 202 ADD_BOOL_PROPERTY(RecordSubtileFileNamesOnLeafTile); 202 203 ADD_BOOL_PROPERTY(GenerateSubtile); trunk/src/vpb/Commandline.cpp
r836 r854 473 473 usage.addCommandLineOption("--record-subtile-on-leaf-tiles","Enable the setting of the subtile file name of the leaf tiles."); 474 474 usage.addCommandLineOption("--split","Set the distributed build split level."); 475 usage.addCommandLineOption("--splits","Set the distributed build primary and secondary split levels."); 475 476 usage.addCommandLineOption("--run-path","Set the path that the build should be run from."); 476 477 usage.addCommandLineOption("--notify-level","Set the notify level when logging messages."); … … 536 537 { 537 538 buildOptions->setDistributedBuildSplitLevel(splitLevel); 539 } 540 541 unsigned int secondarySplitLevel; 542 while(arguments.read("--splits",splitLevel, secondarySplitLevel)) 543 { 544 buildOptions->setDistributedBuildSplitLevel(splitLevel); 545 buildOptions->setDistributedBuildSecondarySplitLevel(secondarySplitLevel); 538 546 } 539 547 trunk/src/vpb/DataSet.cpp
r853 r854 212 212 } 213 213 214 int DataSet::computeMaximumLevel(int maxNumLevels) 215 { 216 int maxLevel = 0; 217 for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) 218 { 219 Source* source = (*itr).get(); 220 221 222 SourceData* sd = (*itr)->getSourceData(); 223 if (!sd) 224 { 225 log(osg::NOTICE,"Skipping source %s as no data loaded from it.",source->getFileName().c_str()); 226 continue; 227 } 228 229 if (source->getType()!=Source::IMAGE && source->getType()!=Source::HEIGHT_FIELD) 230 { 231 // place models and shapefiles into a separate temporary source list and then process these after 232 // the main handling of terrain/imagery sources. 233 continue; 234 235 } 236 237 int k = 0; 238 if (!computeOptimumLevel(source, maxNumLevels-1, k)) continue; 239 240 if (k>maxLevel) 241 { 242 maxLevel = k; 243 } 244 } 245 246 return maxLevel; 247 } 248 214 249 bool DataSet::computeOptimumTileSystemDimensions(int& C1, int& R1) 215 250 { … … 386 421 387 422 _newDestinationGraph = true; 388 389 computeOptimumTileSystemDimensions(_C1,_R1); 390 391 log(osg::NOTICE," C1=%i R1=%i",_C1,_R1); 392 423 393 424 typedef std::list< osg::ref_ptr<Source> > SourceList; 394 425 SourceList modelSources; … … 1120 1151 _numTextureLevels = maxTextureUnit+1; 1121 1152 1153 computeOptimumTileSystemDimensions(_C1,_R1); 1122 1154 1123 1155 log(osg::INFO, "extents = xMin() %f %f",_destinationExtents.xMin(),_destinationExtents.xMax()); … … 1130 1162 { 1131 1163 if (!prepareForDestinationGraphCreation()) return; 1132 1133 #if 01134 if (!_sourceGraph) return;1135 1136 // ensure we have a valid coordinate system1137 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 and1165 _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 01172 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 #endif1185 _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 range1206 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 range1212 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 #endif1252 1164 1253 1165 osg::Timer_t before = osg::Timer::instance()->tick(); … … 2409 2321 } 2410 2322 2323 void DataSet::selectAppropriateSplitLevels() 2324 { 2325 int maxLevel = computeMaximumLevel(getMaximumNumOfLevels()); 2326 log(osg::NOTICE,"Computed maximum source level = %i", maxLevel); 2327 2328 if (getDistributedBuildSplitLevel()==0) 2329 { 2330 if (getDistributedBuildSecondarySplitLevel()==0) 2331 { 2332 // need to compute both primary and secodary split levels 2333 if (maxLevel<10) 2334 { 2335 // just use primary split level 2336 setDistributedBuildSplitLevel((maxLevel * 2) / 5); 2337 } 2338 else 2339 { 2340 setDistributedBuildSplitLevel(maxLevel / 4); 2341 setDistributedBuildSecondarySplitLevel((maxLevel * 5) / 9); 2342 } 2343 } 2344 else 2345 { 2346 // need to compute the primary split level only 2347 setDistributedBuildSplitLevel(getDistributedBuildSecondarySplitLevel()/2); 2348 } 2349 } 2350 else 2351 { 2352 if (maxLevel>=10 && getDistributedBuildSecondarySplitLevel()==0) 2353 { 2354 // need to compute just the seconary split level 2355 setDistributedBuildSecondarySplitLevel( 2356 getDistributedBuildSplitLevel() + 2357 (maxLevel-getDistributedBuildSplitLevel())/2 ); 2358 } 2359 else 2360 { 2361 // primary and secondary split levels fully specified. 2362 } 2363 } 2364 2365 if (getDistributedBuildSplitLevel()>=maxLevel) 2366 { 2367 log(osg::NOTICE,"Warning: primary split level exceed maximum source level, switching off primary split level."); 2368 setDistributedBuildSplitLevel(0); 2369 } 2370 2371 if (getDistributedBuildSecondarySplitLevel()>=maxLevel) 2372 { 2373 log(osg::NOTICE,"Warning: secondary split level exceed maximum source level, switching off secondary split level."); 2374 setDistributedBuildSecondarySplitLevel(0); 2375 } 2376 2377 if (getDistributedBuildSecondarySplitLevel()!=0 && 2378 getDistributedBuildSecondarySplitLevel()<=getDistributedBuildSplitLevel()) 2379 { 2380 log(osg::NOTICE,"Warning: secondary split level is not permited to be lower than or equal to the primary split level, switching off secondary split level."); 2381 setDistributedBuildSecondarySplitLevel(0); 2382 } 2383 2384 2385 if (getDistributedBuildSecondarySplitLevel()==0) 2386 { 2387 log(osg::NOTICE,"Selected single split at %i",getDistributedBuildSplitLevel()); 2388 } 2389 else 2390 { 2391 log(osg::NOTICE,"Selected primary split at %i, secondary split at %i", 2392 getDistributedBuildSplitLevel(), 2393 getDistributedBuildSecondarySplitLevel()); 2394 } 2395 2396 2397 } 2398 2399 2411 2400 bool DataSet::generateTasks_new(TaskManager* taskManager) 2412 2401 { … … 2428 2417 if (!prepareForDestinationGraphCreation()) return false; 2429 2418 2430 computeOptimumTileSystemDimensions(_C1,_R1);2431 log(osg::NOTICE," C1=%i R1=%i",_C1,_R1);2432 2433 2434 2435 2419 log(osg::NOTICE,"OK, OK I now need something to do..."); 2436 2420 2437 log(osg::NOTICE,"First compute the maximum level required"); 2438 log(osg::NOTICE,"Then compute the appropriate split levels"); 2421 selectAppropriateSplitLevels(); 2422 2423 if (getDistributedBuildSplitLevel()==0) return false; 2424 2439 2425 log(osg::NOTICE,"Then generate the root task"); 2440 2426 log(osg::NOTICE,"Then generate the intermediate tasks if any"); … … 2451 2437 bool DataSet::generateTasks_old(TaskManager* taskManager) 2452 2438 { 2439 if (!getLogFileName().empty()) 2440 { 2441 if (!getBuildLog()) setBuildLog(new BuildLog()); 2442 2443 getBuildLog()->openLogFile(getLogFileName()); 2444 } 2445 2446 if (getBuildLog()) 2447 { 2448 pushOperationLog(getBuildLog()); 2449 } 2450 2451 loadSources(); 2452 2453 if (!prepareForDestinationGraphCreation()) return false; 2454 2455 selectAppropriateSplitLevels(); 2456 2453 2457 if (getDistributedBuildSplitLevel()==0) return false; 2454 2458 2455 if (!getLogFileName().empty())2456 {2457 if (!getBuildLog()) setBuildLog(new BuildLog());2458 2459 getBuildLog()->openLogFile(getLogFileName());2460 }2461 2462 if (getBuildLog())2463 {2464 pushOperationLog(getBuildLog());2465 }2466 2467 loadSources();2468 2459 2469 2460 computeDestinationGraphFromSources(getDistributedBuildSplitLevel()+1); trunk/src/vpb/TaskManager.cpp
r833 r854 103 103 while (arguments.read("--build-name",_buildName)) {} 104 104 105 106 DatabaseBuilder* db = dynamic_cast<DatabaseBuilder*>(_terrain->getTerrainTechnique());107 BuildOptions* bo = db->getBuildOptions();108 if (bo)109 {110 if (bo->getDistributedBuildSplitLevel()==0)111 {112 unsigned int maxLevel = bo->getMaximumNumOfLevels();113 unsigned int halfLevel = (maxLevel / 2);114 if (halfLevel>=1)115 {116 bo->setDistributedBuildSplitLevel(osg::minimum(halfLevel,4u));117 }118 }119 }120 121 log(osg::NOTICE,"setDistributedBuildSplitLevel=%d",bo->getDistributedBuildSplitLevel());122 123 105 if (!terrainOutputName.empty()) 124 106 {
