Changeset 2115 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
- Timestamp:
- 02/12/07 19:00:37 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r2114 r2115 103 103 , nObjects(0) 104 104 { 105 // pvs objects empty => have to create new ones 106 mCreatePvsObjects = mPvsObjects.empty(); 107 105 // q: can we assume that the objects are sorted? 106 108 107 // sort objects so we can search in them 109 108 //if (!is_sorted(mPvsObjects.begin(), mPvsObjects.end(), ilt)) … … 111 110 112 111 //if (!is_sorted(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt)) 113 sort(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt);112 // sort(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt); 114 113 } 115 114 … … 407 406 408 407 409 void ViewCellsParseHandlers::ReplaceBvhPvs(ViewCell *vc)410 {411 //cout << "exchanging pvs" << endl;412 ObjectPvs newPvs;413 414 ObjectPvsIterator pit = vc->GetPvs().GetIterator();415 416 BvhLeaf *dummyInst = new BvhLeaf(AxisAlignedBox3());417 418 ObjectContainer oldIntersectables;419 420 // output PVS of view cell421 while (pit.HasMoreEntries())422 {423 ObjectPvsEntry entry = pit.Next();424 425 Intersectable *intersect = entry.mObject;426 oldIntersectables.push_back(intersect);427 428 DummyIntersectable *dummyIntersect = static_cast<DummyIntersectable *>(intersect);429 430 const int objId = dummyIntersect->GetItem();431 dummyInst->SetId(objId);432 433 vector<BvhLeaf *>::iterator oit =434 lower_bound(mBvhLeaves.begin(),435 mBvhLeaves.end(),436 dummyInst, ilt);437 438 if ((oit != mBvhLeaves.end()) && ((*oit)->GetId() == objId))439 {440 // $$JB we should store a float a per object which corresponds441 // to sumof pdfs, i.e. its relative visibility442 // temporarily set to 1.0f443 //cout << (*oit)->GetId() << " ";444 445 newPvs.AddSample(*oit, 1.0f);446 }447 else448 {449 Debug << "exchangePvs error: object with id " << objId << " does not exist" << endl;450 }451 }452 453 //newPvs.SimpleSort();454 delete dummyInst;455 vc->SetPvs(newPvs);456 457 CLEAR_CONTAINER(oldIntersectables);458 }459 460 461 void ViewCellsParseHandlers::ReplacePvs()462 {463 // sort the pvs entries464 sort(mPvsObjects.begin(), mPvsObjects.end(), ilt);465 466 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end();467 468 //cout << "viewcells : " << mViewCells.size() << endl;469 for (vit = mViewCells.begin(); vit != vit_end; ++ vit)470 {471 ReplaceBvhPvs(*vit);472 }473 }474 475 476 408 void ViewCellsParseHandlers::StartViewCellHierarchyElement(const std::string &element, 477 409 AttributeList& attributes) … … 513 445 { 514 446 Debug << "\nparsing view space hierarchy" << endl; 515 cout << "\nparsing view space hierarchy" << endl; 447 cout << "\nparsing view space hierarchy" << endl; 448 516 449 mCurrentState = PARSE_VIEWSPACE_HIERARCHY; 517 450 StartViewSpaceHierarchy(attributes); … … 521 454 if (element == "ObjectSpaceHierarchy") 522 455 { 523 cout << "\nparsing object space hierarchy" << endl;456 cout << "\nparsing object space hierarchy" << endl; 524 457 Debug << "\nparsing object space hierarchy" << endl; 525 458 … … 540 473 case PARSE_VIEWSPACE_HIERARCHY: 541 474 if ((++ nViewCells % 1000) == 0) 542 cout <<"\r"<<nViewCells<<" view cells parsed\r";475 cout << "\r" << nViewCells << " view cells parsed\r"; 543 476 544 477 StartViewSpaceHierarchyElement(element, attributes); … … 546 479 case PARSE_OBJECTSPACE_HIERARCHY: 547 480 if ((++ nObjects % 1000) == 0) 548 cout<<"\r"<< nObjects <<" objects parsed\r";481 cout <<"\r" << nObjects << " objects parsed\r"; 549 482 550 483 StartObjectSpaceHierarchyElement(element, attributes); … … 577 510 } 578 511 512 #if 1 579 513 // TODO: 580 514 // 1) find objects and add them to pvs … … 583 517 584 518 vector<int>::const_iterator it, it_end = objIndices.end(); 519 520 pair<ObjectContainer::const_iterator, ObjectContainer::const_iterator> result; 521 585 522 for (it = objIndices.begin(); it != it_end; ++ it) 586 523 { 587 if (mCreatePvsObjects) 588 { 589 // pvs entries will be created => just use dummy proxy 590 pvs.AddSample(new DummyIntersectable(*it), 1); 524 const int objId = *it; 525 dummyInst.SetId(objId); 526 527 // equal indeces possible! 528 result = equal_range(mPvsObjects.begin(), 529 mPvsObjects.end(), 530 (Intersectable *)&dummyInst, 531 ilt); 532 533 ObjectContainer::const_iterator eit = result.first; 534 535 for (; eit != result.second; ++ eit) 536 { 537 pvs.AddSample(*eit, 1.0f); 538 } 539 } 540 541 #else 542 543 // TODO: 544 // 1) find objects and add them to pvs 545 // 2) get view cell with specified id 546 MeshInstance dummyInst(NULL); 547 548 vector<int>::const_iterator it, it_end = objIndices.end(); 549 for (it = objIndices.begin(); it != it_end; ++ it) 550 { 551 const int objId = *it; 552 dummyInst.SetId(objId); 553 554 ObjectContainer::iterator oit = 555 lower_bound(mPvsObjects.begin(), 556 mPvsObjects.end(), 557 (Intersectable *)&dummyInst, ilt); 558 559 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 560 { 561 // $$JB we should store a float a per object which corresponds 562 // to sumof pdfs, i.e. its relative visibility 563 // temporarily set to 1.0f 564 pvs.AddSample(*oit, 1.0f); 591 565 } 592 566 else 593 567 { 594 const int objId = *it; 595 dummyInst.SetId(objId); 596 597 ObjectContainer::iterator oit = 598 lower_bound(mPvsObjects.begin(), 599 mPvsObjects.end(), 600 (Intersectable *)&dummyInst, ilt); 601 602 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 603 { 604 // $$JB we should store a float a per object which corresponds 605 // to sumof pdfs, i.e. its relative visibility 606 // temporarily set to 1.0f 607 pvs.AddSample(*oit, 1.0f); 608 } 609 else 610 { 611 //Debug << "x"; 612 //Debug << "StartViewCellPvs error: object with id " << objId << " does not exist" << endl; 613 } 614 } 615 } 568 Debug << "x"; 569 //Debug << "StartViewCellPvs error: object with id " << objId << " does not exist" << endl; 570 } 571 } 572 #endif 616 573 } 617 574 … … 1287 1244 if (attrName == "objects") 1288 1245 { 1289 StartBvhLeafObjects(objects, ptr); 1246 if (!mPreprocessorObjects.empty()) 1247 StartBvhLeafObjects(objects, ptr); 1290 1248 } 1291 1249 } … … 1298 1256 { 1299 1257 BvhInterior *interior = static_cast<BvhInterior *>(mCurrentBvhNode); 1258 1300 1259 leaf = new BvhLeaf(box, interior, (int)objects.size()); 1301 1260 interior->ReplaceChildLink(NULL, leaf); … … 1309 1268 leaf->mObjects = objects; 1310 1269 BvHierarchy::AssociateObjectsWithLeaf(leaf); 1311 1312 if (mCreatePvsObjects)1313 {1314 // Temp matt: leaves should already have right id1315 if (0) leaf->SetId((int)mBvhLeaves.size());1316 1317 mPvsObjects.push_back(leaf);1318 }1319 1270 } 1320 1271 … … 1336 1287 1337 1288 MeshInstance dummyInst(NULL); 1338 1339 1289 vector<int>::const_iterator it, it_end = objIndices.end(); 1340 1290 … … 1344 1294 dummyInst.SetId(objId); 1345 1295 1346 ObjectContainer:: iterator oit =1347 lower_bound(mP vsObjects.begin(),1348 mP vsObjects.end(),1296 ObjectContainer::const_iterator oit = 1297 lower_bound(mPreprocessorObjects.begin(), 1298 mPreprocessorObjects.end(), 1349 1299 (Intersectable *)&dummyInst, 1350 1300 ilt); 1351 1301 1352 if ((oit != mP vsObjects.end()) && ((*oit)->GetId() == objId))1302 if ((oit != mPreprocessorObjects.end()) && ((*oit)->GetId() == objId)) 1353 1303 { 1354 1304 objects.push_back(*oit);
Note: See TracChangeset
for help on using the changeset viewer.