Changeset 584 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 02/03/06 13:03:35 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 3 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 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r582 r584 285 285 int RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects); 286 286 287 /** Compresses the pvs of the view cells. 287 288 289 /** Returns optimal set of view cells for a given number of view cells. 290 */ 291 void CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells); 292 293 /** Root of view cells tree. 294 */ 295 ViewCell *GetRoot() const; 296 297 /** Returns pvs of view cell. 298 @note pvs is returned per reference if tree is not compressed, 299 per copy else. 300 */ 301 void GetPvs(ViewCell *vc, ObjectPvs &pvs) const; 302 303 /** Returns pvs size of view cell. 304 */ 305 int GetPvsSize(ViewCell *vc) const; 306 307 /** Returns actual number of object in this pvs and the children. 308 */ 309 int GetNumPvsEntries(ViewCell *vc) const; 310 311 /** Returns memory cost of this view cell. 312 */ 313 float GetMemoryCost(ViewCell *vc) const; 314 315 /** Compresses the pvs of the view cells from the root. 288 316 */ 289 317 void CompressViewCellsPvs(); 290 318 291 /** Returns optimal set of view cells for a given number of view cells. 292 */ 293 void CollectBestViewCellSet(ViewCellContainer &viewCells, const int numViewCells); 294 295 /** Root of view cells tree. 296 */ 297 ViewCell *GetRoot(); 319 /** If view cells in this tree have compressed pvs. 320 */ 321 bool IsCompressed() const; 298 322 299 323 protected: … … 365 389 int UpdateActiveViewCells(ViewCellContainer &viewCells); 366 390 367 void ComputeCommonPvs(ViewCellInterior *interior); 368 391 void PropagateUpVisibility(ViewCellInterior *interior); 392 393 void CompressViewCellsPvs(ViewCell *root); 369 394 370 395 /** Returns memory usage of view cells. … … 373 398 374 399 375 400 /// if the view cell tree hold compressed pvs 401 bool mIsCompressed; 376 402 377 403 ViewCellsManager *mViewCellsManager; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r583 r584 1244 1244 } 1245 1245 1246 Debug << i << ": pvs size=" << (int) vc->GetPvs().GetSize()1246 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) 1247 1247 << ", piercing rays=" << (int)vcRays.size() << endl; 1248 1248 // << ", leaves=" << (int)vc->mLeaves.size() << endl; … … 2066 2066 2067 2067 2068 void VspKdViewCellsManager::CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates) 2068 void VspKdViewCellsManager::CollectMergeCandidates(const VssRayContainer &rays, 2069 vector<MergeCandidate> &candidates) 2069 2070 { 2070 2071 // TODO … … 2365 2366 RefineViewCells(postProcessRays, objects); 2366 2367 2368 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 2369 2370 int pvsSize = 0; 2371 int numPvsEntries = 0; 2372 2373 int vidx = 0; 2374 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 2375 { 2376 const int vcPvs = mViewCellsTree->GetPvsSize(*vit); 2377 const int pvsEntries = mViewCellsTree->GetNumPvsEntries(*vit); 2378 2379 pvsSize += vcPvs; 2380 numPvsEntries += pvsEntries; 2381 Debug << "Viewcell " << vidx ++ << ": " << vcPvs << endl; 2382 } 2383 2384 Debug << "pvs size before compress: " << pvsSize << endl; 2385 Debug << "number of entries before compress: " << numPvsEntries << endl; 2386 2367 2387 mViewCellsTree->CompressViewCellsPvs(); 2388 2389 pvsSize = numPvsEntries = vidx = 0; 2390 2391 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 2392 { 2393 const int vcPvs = mViewCellsTree->GetPvsSize(*vit); 2394 const int pvsEntries = mViewCellsTree->GetNumPvsEntries(*vit); 2395 2396 pvsSize += vcPvs; 2397 numPvsEntries += pvsEntries; 2398 Debug << "Viewcell " << vidx ++ << ": " << vcPvs << endl; 2399 } 2400 2401 Debug << "pvs size after compress: " << pvsSize << endl; 2402 Debug << "number of entries after compress: " << numPvsEntries << endl; 2368 2403 2369 2404 if (1)
Note: See TracChangeset
for help on using the changeset viewer.