Changeset 650 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
- Timestamp:
- 02/17/06 20:41:22 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r649 r650 249 249 250 250 251 void ViewCellInterior::SetupChildLink(ViewCell * l)252 { 253 mChildren.push_back( l);254 l->mParent = this;251 void ViewCellInterior::SetupChildLink(ViewCell *vc) 252 { 253 mChildren.push_back(vc); 254 vc->mParent = this; 255 255 } 256 256 … … 333 333 334 334 MergeCandidate::sRenderCostWeight = mRenderCostWeight; 335 336 mStats.open("mergeStats.log");337 335 } 338 336 … … 473 471 474 472 // frequency stats are updated 475 const int statsOut = 1;473 const int statsOut = 500; 476 474 477 475 // passes are needed for statistics, because we don't want to record … … 493 491 494 492 cout << "actual merge starts now ... " << endl; 495 496 mStats << "#Pass\n" << pass << endl497 << "#Merged\n" << mergeStats.merged << endl498 << "#ViewCells\n" << realNumActiveViewCells << endl499 << "#RenderCostIncrease\n" << 0 << endl500 << "#TotalRenderCost\n" << totalRenderCost << endl501 << "#CurrentPvs\n" << 0 << endl502 << "#ExpectedCost\n" << realExpectedCost << endl503 << "#AvgRenderCost\n" << realAvgRenderCost << endl504 << "#Deviation\n" << mDeviation << endl505 << "#TotalPvs\n" << totalPvs << endl506 << "#PvsSizeDecrease\n0" << endl507 << "#Volume\n0" << endl508 //<< "#Siblings\n" << mergeStats.siblings << endl509 << endl;510 493 511 494 //-- use priority queue to merge leaf pairs … … 604 587 mergedVc->SetCost(realExpectedCost); 605 588 606 if (((mergeStats.merged % statsOut) == 0) || 607 (realNumActiveViewCells == mMergeMinViewCells)) 608 { 589 if ((mergeStats.merged % statsOut) == 0) 609 590 cout << "merged " << mergeStats.merged << " view cells" << endl; 610 591 611 mStats612 << "#Pass\n" << pass << endl613 << "#Merged\n" << mergeStats.merged << endl614 << "#ViewCells\n" << realNumActiveViewCells << endl615 << "#RenderCostIncrease\n" << renderCostIncr << endl616 << "#TotalRenderCost\n" << totalRenderCost << endl617 << "#CurrentPvs\n" << mergedVc->GetPvs().GetSize() << endl618 << "#ExpectedCost\n" << realExpectedCost << endl619 << "#AvgRenderCost\n" << realAvgRenderCost << endl620 << "#Deviation\n" << mDeviation << endl621 << "#TotalPvs\n" << totalPvs << endl622 << "#PvsSizeDecrease\n" << -pvsDiff << endl623 << "#Volume\n" << mergedVc->GetVolume() << endl624 << endl;625 626 }627 592 } 628 593 else … … 663 628 // $$JB keep this 0 temporarilly 664 629 root->SetCost(0.0f); 665 666 mStats667 << "#Pass\n" << pass << endl668 << "#Merged\n" << mergeStats.merged << endl669 << "#ViewCells\n" << realNumActiveViewCells << endl670 << "#RenderCostIncrease\n" << 0 << endl // TODO671 << "#TotalRenderCost\n" << totalRenderCost << endl672 << "#CurrentPvs\n" << root->GetPvs().GetSize() << endl673 << "#ExpectedCost\n" << realExpectedCost << endl674 << "#AvgRenderCost\n" << realAvgRenderCost << endl675 << "#Deviation\n" << mDeviation << endl676 << "#TotalPvs\n" << totalPvs << endl677 << "#PvsSizeDecrease\n" << 0 << endl // TODO678 << "#Volume\n" << root->GetVolume() << endl679 << endl;680 630 681 631 mRoot = root; … … 705 655 mergeStats.mergeTime = TimeDiff(startTime, GetTime()); 706 656 mergeStats.Stop(); 707 708 657 Debug << mergeStats << endl << endl; 709 658 … … 1302 1251 1303 1252 1253 void ViewCellsTree::ExportStats() 1254 { 1255 TraversalQueue tqueue; 1256 1257 tqueue.push(mRoot); 1258 int numViewCells = 1; 1259 1260 const AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox(); 1261 const float vol = box.GetVolume(); 1262 1263 int totalPvs; 1264 float totalRenderCost, float avgRenderCost, float expectedCost; 1265 1266 float deviation = 0; 1267 totalPvs = (int)mRoot->GetPvs().GetSize(); 1268 totalRenderCost = avgRenderCost = expectedCost = (float)mRoot->GetPvs().GetSize(); 1269 1270 ofstream stats; 1271 stats.open("mergeStats.log"); 1272 1273 Debug << "here343" << endl; 1274 1275 stats 1276 << "#Pass\n" << 0 << endl 1277 //<< "#Merged\n" << mergeStats.merged << endl 1278 << "#ViewCells\n" << numViewCells << endl 1279 << "#RenderCostDecrease\n" << 0 << endl // TODO 1280 << "#TotalRenderCost\n" << totalRenderCost << endl 1281 << "#CurrentPvs\n" << mRoot->GetPvs().GetSize() << endl 1282 << "#ExpectedCost\n" << expectedCost << endl 1283 << "#AvgRenderCost\n" << avgRenderCost << endl 1284 << "#Deviation\n" << deviation << endl 1285 << "#TotalPvs\n" << totalPvs << endl 1286 << "#PvsSizeDecrease\n" << 0 << endl // TODO 1287 << "#Volume\n" << mRoot->GetVolume() << endl 1288 << endl; 1289 1290 1291 while (!tqueue.empty()) 1292 { 1293 ViewCell *vc = tqueue.top(); 1294 tqueue.pop(); 1295 1296 if (!vc->IsLeaf()) 1297 { 1298 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1299 1300 const int parentPvs = interior->GetPvs().GetSize(); 1301 const float parentCost = (float)parentPvs * interior->GetVolume(); 1302 float childCost = 0; 1303 int childPvs = 0; 1304 1305 -- numViewCells; 1306 1307 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1308 1309 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1310 { 1311 childCost += (float)(*it)->GetPvs().GetSize() * (*it)->GetVolume(); 1312 childPvs += (*it)->GetPvs().GetSize(); 1313 1314 tqueue.push(*it); 1315 ++ numViewCells; 1316 } 1317 1318 1319 const float costDecr = (parentCost - childCost) / vol; 1320 1321 totalRenderCost -= costDecr; 1322 totalPvs += childPvs - parentPvs; 1323 1324 expectedCost = totalRenderCost / (float)numViewCells; 1325 avgRenderCost = (float)totalPvs / (float)numViewCells; 1326 1327 stats 1328 << "#Pass\n" << 0 << endl 1329 //<< "#Merged\n" << mergeStats.merged << endl 1330 << "#ViewCells\n" << numViewCells << endl 1331 << "#RenderCostDecrease\n" << costDecr << endl // TODO 1332 << "#TotalRenderCost\n" << totalRenderCost << endl 1333 << "#CurrentPvs\n" << vc->GetPvs().GetSize() << endl 1334 << "#ExpectedCost\n" << expectedCost << endl 1335 << "#AvgRenderCost\n" << avgRenderCost << endl 1336 << "#Deviation\n" << deviation << endl 1337 << "#TotalPvs\n" << totalPvs << endl 1338 << "#PvsSizeDecrease\n" << childPvs - parentPvs << endl // TODO 1339 << "#Volume\n" << vc->GetVolume() << endl 1340 << endl; 1341 1342 } 1343 } 1344 1345 stats.close(); 1346 } 1347 1348 1349 /*float ViewCellsTree::ComputeVolume(ViewCell *vc) 1350 { 1351 if (vc->IsLeaf()) 1352 { 1353 return vc->GetVolume(); 1354 } 1355 else 1356 { 1357 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1358 1359 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1360 1361 float volume = 0; 1362 1363 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1364 { 1365 volume += ComputeVolume(*it); 1366 } 1367 1368 interior->SetVolume(volume); 1369 return volume; 1370 } 1371 }*/ 1372 1373 1374 void ViewCellsTree::SetRoot(ViewCell *root) 1375 { 1376 mRoot = root; 1377 } 1378 1304 1379 void ViewCellsTree::CollectBestViewCellSet(ViewCellContainer &viewCells, 1305 1380 const int numViewCells) … … 1311 1386 { 1312 1387 ViewCell *vc = tqueue.top(); 1313 1388 tqueue.pop(); 1389 1314 1390 // save the view cells if it is a leaf or if enough view cells have already been traversed 1315 1391 // because of the priority queue, this will be the optimal set of v 1316 if (vc->IsLeaf() || ((viewCells.size() + tqueue.size() ) >= numViewCells))1392 if (vc->IsLeaf() || ((viewCells.size() + tqueue.size() + 1) >= numViewCells)) 1317 1393 { 1318 1394 // todo: should be done with a function taking the active flag and some … … 1333 1409 } 1334 1410 } 1335 1336 tqueue.pop();1337 1411 } 1338 1412 } … … 1411 1485 1412 1486 1413 void ViewCellsTree::ExportStats()1414 {1415 1416 }1417 1418 1487 void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const 1419 1488 { … … 1562 1631 1563 1632 1564 void 1565 ViewCellsTree::AssignRandomColors() 1633 void ViewCellsTree::AssignRandomColors() 1566 1634 { 1567 1635 TraversalQueue tqueue; … … 1571 1639 { 1572 1640 ViewCell *vc = tqueue.top(); 1573 1641 tqueue.pop(); 1642 1574 1643 // save the view cells if it is a leaf or if enough view cells have already been traversed 1575 1644 // because of the priority queue, this will be the optimal set of v … … 1593 1662 1594 1663 } 1595 1596 tqueue.pop(); 1664 1597 1665 } 1598 1666 } … … 1606 1674 while (!tqueue.empty()) { 1607 1675 ViewCell *vc = tqueue.top(); 1608 1676 tqueue.pop(); 1609 1677 // save the view cells if it is a leaf or if enough view cells have already been traversed 1610 1678 // because of the priority queue, this will be the optimal set of v … … 1620 1688 1621 1689 } 1622 1623 tqueue.pop();1624 1690 } 1625 1691 }
Note: See TracChangeset
for help on using the changeset viewer.