Changeset 584 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
- Timestamp:
- 02/03/06 13:03:35 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r583 r584 305 305 mRoot(NULL), 306 306 mUseAreaForPvs(false), 307 mViewCellsManager(vcm) 307 mViewCellsManager(vcm), 308 mIsCompressed(false) 308 309 { 309 310 environment->GetBoolValue("ViewCells.Visualization.exportMergedViewCells", mExportMergedViewCells); … … 666 667 667 668 668 ViewCell *ViewCellsTree::GetRoot() 669 ViewCell *ViewCellsTree::GetRoot() const 669 670 { 670 671 return mRoot; … … 710 711 int numMergedViewCells = 0; 711 712 712 Debug << "updating active vc: " << viewCells.size() << endl;713 Debug << "updating active vc: " << (int)viewCells.size() << endl; 713 714 // find all already merged view cells and remove them from view cells 714 715 … … 1240 1241 } 1241 1242 1242 1243 1243 void ViewCellsTree::CompressViewCellsPvs() 1244 1244 { 1245 stack<ViewCell *> tstack; 1246 1247 while (!tstack.empty()) 1248 { 1249 ViewCell *viewCell = tstack.top(); 1250 tstack.pop(); 1251 1252 if (!viewCell->IsLeaf()) 1253 { 1254 1255 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(viewCell); 1256 Debug << "compressing " << interior->GetPvs().GetSize() << endl; 1257 ComputeCommonPvs(interior); 1258 Debug << "compressed " << interior->GetPvs().GetSize() << endl; 1259 } 1245 if (!mIsCompressed) 1246 { 1247 mIsCompressed = true; 1248 CompressViewCellsPvs(mRoot); 1249 } 1250 } 1251 1252 void ViewCellsTree::CompressViewCellsPvs(ViewCell *root) 1253 { 1254 if (!root->IsLeaf()) 1255 { 1256 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 1257 1258 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1259 // compress child sets first 1260 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1261 { 1262 CompressViewCellsPvs(*it); 1263 } 1264 1265 PropagateUpVisibility(interior); 1260 1266 } 1261 1267 } … … 1295 1301 1296 1302 1297 void ViewCellsTree:: ComputeCommonPvs(ViewCellInterior *interior)1298 { 1299 Intersectable::NewMail( );1303 void ViewCellsTree::PropagateUpVisibility(ViewCellInterior *interior) 1304 { 1305 Intersectable::NewMail((int)interior->mChildren.size()); 1300 1306 1301 1307 ViewCellContainer::const_iterator cit, cit_end = interior->mChildren.end(); … … 1304 1310 1305 1311 // mail all objects in the leaf sets 1312 // we are interested in the objects which are present in all leaves 1313 // => count how often an object is part of a child set 1306 1314 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 1307 1315 { … … 1312 1320 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1313 1321 { 1314 if (!(*oit).first->Mailed()) 1315 (*oit).first->Mail(); 1322 Intersectable *obj = (*oit).first; 1323 if ((cit == interior->mChildren.begin()) && !obj->Mailed()) 1324 obj->Mail(); 1316 1325 1317 (*oit).first->IncMail();1326 int incm = obj->IncMail(); 1318 1327 } 1319 1328 } 1320 1329 1321 1330 interior->GetPvs().mEntries.clear(); 1322 cit_end = interior->mChildren.end(); 1331 1323 1332 1324 1333 // only the objects which are present in all leaf pvs 1325 1334 // should remain in the parent pvs 1326 1335 // these are the objects which have been mailed in all children 1327 1336 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 1328 1337 { … … 1333 1342 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1334 1343 { 1344 Debug << "mail: " << (*oit).first->mMailbox << endl; 1345 1335 1346 if ((*oit).first->Mailed((int)interior->mChildren.size())) 1336 1347 { 1348 //Debug << "adding sample" << endl; 1337 1349 interior->GetPvs().AddSample((*oit).first, (*oit).second.mSumPdf); 1338 1350 //(*oit)->remove(); … … 1341 1353 } 1342 1354 1343 // delete all the objects from the leaf sets which were moved 1344 // to parent pvs 1355 1356 1357 // delete all the objects from the leaf sets which were moved to parent pvs 1345 1358 ObjectPvsMap::const_iterator oit_end = interior->GetPvs().mEntries.end(); 1346 1359 … … 1349 1362 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 1350 1363 { 1351 (*cit)->GetPvs().RemoveSample((*oit).first, Limits::Infinity); 1352 } 1353 } 1364 if (!(*cit)->GetPvs().RemoveSample((*oit).first, Limits::Infinity)) 1365 Debug << "should not come here!" << endl; 1366 } 1367 } 1368 } 1369 1370 1371 void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const 1372 { 1373 if (mIsCompressed) 1374 { 1375 ObjectPvsMap::const_iterator oit, oit_end = vc->GetPvs().mEntries.end(); 1376 1377 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1378 { 1379 pvs.AddSample((*oit).first, (*oit).second.mSumPdf); 1380 } 1381 1382 if (!vc->IsLeaf()) 1383 { 1384 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1385 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1386 1387 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1388 { 1389 GetPvs(*it, pvs); 1390 } 1391 } 1392 } 1393 else 1394 { 1395 pvs = vc->GetPvs(); 1396 } 1397 } 1398 1399 1400 int ViewCellsTree::GetPvsSize(ViewCell *vc) const 1401 { 1402 int pvsSize = vc->GetPvs().GetSize(); 1403 1404 //Debug << "current size: " << pvsSize << endl; 1405 if (mIsCompressed && !vc->IsLeaf()) 1406 { 1407 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1408 1409 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1410 1411 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1412 { 1413 pvsSize += GetPvsSize(*it); 1414 } 1415 } 1416 1417 return pvsSize; 1418 1419 } 1420 1421 1422 float ViewCellsTree::GetMemoryCost(ViewCell *vc) const 1423 { 1424 const float entrySize = 1425 sizeof(PvsData<Intersectable *>) + sizeof(Intersectable *); 1426 1427 return (float)GetNumPvsEntries(vc) * entrySize; 1428 } 1429 1430 1431 int ViewCellsTree::GetNumPvsEntries(ViewCell *vc) const 1432 { 1433 int pvsSize = vc->GetPvs().GetSize(); 1434 1435 if (!vc->IsLeaf()) 1436 { 1437 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1438 1439 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1440 1441 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1442 { 1443 pvsSize += GetNumPvsEntries(*it); 1444 } 1445 } 1446 1447 return pvsSize; 1448 } 1449 1450 1451 bool ViewCellsTree::IsCompressed() const 1452 { 1453 return mIsCompressed; 1354 1454 } 1355 1455
Note: See TracChangeset
for help on using the changeset viewer.