- Timestamp:
- 03/16/06 07:06:22 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r694 r703 282 282 } 283 283 284 285 284 286 /************************************************************************/ 285 287 /* class ViewCellsStatistics implementation */ … … 451 453 452 454 mViewCellsManager->CollectMergeCandidates(rays, candidates); 455 453 456 while(!candidates.empty()) 454 457 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r664 r703 545 545 ViewCell *GetRightViewCell() const; 546 546 547 /** Returns leaf view cell initially associated with this merge candidate. 548 */ 547 549 ViewCell *GetInitialLeftViewCell() const; 548 550 ViewCell *GetInitialRightViewCell() const; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r697 r703 544 544 } 545 545 546 /* 547 int ViewCellsManager::ConstructLocalMergeTree(vector<LocalMergeCandidate> candidates) 548 549 { 550 while(!candidates.empty()) 551 { 552 MergeCandidate mc = candidates.back(); 553 candidates.pop_back(); 554 EvalMergeCost(mc); 555 mergeQueue.push(mc); 556 } 557 558 ViewCell::NewMail(); 559 560 561 long startTime = GetTime(); 562 563 mergeStats.candidates = (int)mMergeQueue.size(); 564 565 // passes are needed for statistics, because we don't want to record 566 // every merge 567 int pass = 0; 568 int mergedPerPass = 0; 569 float realExpectedCost = mExpectedCost; 570 float realAvgRenderCost = mAvgRenderCost; 571 int realNumActiveViewCells = mNumActiveViewCells; 572 573 reset. 574 575 int numMergedViewCells = 0; 576 577 environment->GetIntValue("ViewCells.PostProcess.maxMergesPerPass", maxMergesPerPass); 578 environment->GetFloatValue("ViewCells.PostProcess.avgCostMaxDeviation", avgCostMaxDeviation); 579 580 cout << "actual merge starts now ... " << endl; 581 582 //-- use priority queue to merge leaf pairs 583 584 //const float maxAvgCost = 350; 585 while (!mMergeQueue.empty())//NumActiveViewCells > mMergeMinViewCells)) 586 { 587 //-- reset merge queue if the ratio of current expected cost / real expected cost 588 // too small or after a given number of merges 589 if ((mergedPerPass > maxMergesPerPass) || 590 (avgCostMaxDeviation > mAvgRenderCost / realAvgRenderCost)) 591 { 592 // adjust render cost 593 ++ pass; 594 595 mergedPerPass = 0; 596 mExpectedCost = realExpectedCost; 597 598 599 600 // refines the view cells 601 // then priorities are recomputed 602 // and the candidates are put back into merge queue 603 if (mRefineViewCells) 604 RefineViewCells(rays, objects); 605 else 606 ResetMergeQueue(); 607 608 Debug << "Values after reset: " 609 << " erc: " << mExpectedCost 610 << " avg: " << mAvgRenderCost 611 << " dev: " << mDeviation << endl; 612 613 if (mExportMergedViewCells) 614 { 615 ExportMergedViewCells(activeViewCells, objects, numMergedViewCells); 616 } 617 } 618 619 620 MergeCandidate mc = mMergeQueue.top(); 621 mMergeQueue.pop(); 622 623 // both view cells equal 624 // NOTE: do I really still need this? probably cannot happen!! 625 if (mc.mLeftViewCell == mc.mRightViewCell) 626 continue; 627 628 if (mc.IsValid()) 629 { 630 ViewCell::NewMail(); 631 632 //-- update statistical values 633 -- realNumActiveViewCells; 634 ++ mergeStats.merged; 635 ++ mergedPerPass; 636 637 const float renderCostIncr = mc.GetRenderCost(); 638 const float mergeCostIncr = mc.GetMergeCost(); 639 640 totalRenderCost += renderCostIncr; 641 mDeviation += mc.GetDeviationIncr(); 642 643 644 // merge the view cells of leaf1 and leaf2 645 int pvsDiff; 646 ViewCellInterior *mergedVc = 647 MergeViewCells(mc.mLeftViewCell, mc.mRightViewCell, pvsDiff); 648 649 650 // total render cost and deviation has changed 651 // real expected cost will be larger than expected cost used for the 652 // cost heuristics, but cannot recompute costs on each increase of the 653 // expected cost 654 totalPvs += pvsDiff; 655 realExpectedCost = totalRenderCost / (float)realNumActiveViewCells; 656 realAvgRenderCost = (float)totalPvs / (float)realNumActiveViewCells; 657 658 // set merge cost to this node 659 mergedVc->SetMergeCost(totalRenderCost); 660 661 //if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 662 // ++ mergeStats.siblings; 663 mergedVc->SetCost(realExpectedCost); 664 665 if ((mergeStats.merged % statsOut) == 0) 666 cout << "merged " << mergeStats.merged << " view cells" << endl; 667 668 } 669 else 670 { 671 // merge candidate not valid, because one of the leaves was already 672 // merged with another one => validate and reinsert into queue 673 if (ValidateMergeCandidate(mc)) 674 { 675 EvalMergeCost(mc); 676 mMergeQueue.push(mc); 677 } 678 } 679 680 } 681 682 683 // adjust stats and reset queue one final time 684 mExpectedCost = realExpectedCost; 685 mAvgRenderCost = realAvgRenderCost; 686 mNumActiveViewCells = realNumActiveViewCells; 687 688 UpdateActiveViewCells(activeViewCells); 689 690 691 // refine view cells and reset costs 692 if (mRefineViewCells) 693 RefineViewCells(rays, objects); 694 else 695 ResetMergeQueue(); 696 697 // create a root node if the merge was not done till root level, 698 // else take the single node as new root 699 if ((int)activeViewCells.size() > 1) 700 { 701 Debug << "creating root of view cell hierarchy for " 702 << (int)activeViewCells.size() << " view cells" << endl; 703 704 ViewCellInterior *root = mViewCellsManager->MergeViewCells(activeViewCells); 705 root->SetMergeCost(totalRenderCost); 706 // $$JB keep this 0 temporarilly 707 root->SetCost(0.0f); 708 709 mRoot = root; 710 } 711 else if ((int)activeViewCells.size() == 1) 712 { 713 Debug << "setting root of the merge history" << endl; 714 mRoot = activeViewCells[0]; 715 } 716 717 //-- empty merge queue just in case 718 while (!mMergeQueue.empty()) 719 { 720 mMergeQueue.pop(); 721 } 722 723 // TODO delete because makes no sense here 724 mergeStats.expectedRenderCost = realExpectedCost; 725 mergeStats.deviation = mDeviation; 726 727 // we want to optimize this heuristics 728 mergeStats.heuristics = 729 mDeviation * (1.0f - mRenderCostWeight) + 730 mExpectedCost * mRenderCostWeight; 731 732 mergeStats.mergeTime = TimeDiff(startTime, GetTime()); 733 mergeStats.Stop(); 734 Debug << mergeStats << endl << endl; 735 736 // assign colors for the view cells so that at least one is always consistent 737 AssignRandomColors(); 738 739 //TODO: should return sample contributions? 740 return mergeStats.merged; 741 } 742 */ 546 743 547 744 bool ViewCellsManager::CheckValidity(ViewCell *vc, -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r697 r703 64 64 }; 65 65 66 /** 67 Candidate for leaf merging based on priority. 68 */ 69 class LocalMergeCandidate 70 { 71 public: 72 LocalMergeCandidate(ViewCell *l, ViewCell *r); 73 74 /** If this merge pair is still valid. 75 */ 76 //bool IsValid() const; 77 78 friend bool operator<(const LocalMergeCandidate &leafa, const LocalMergeCandidate &leafb) 79 { 80 return leafb.GetMergeCost() < leafa.GetMergeCost(); 81 } 82 83 void SetLeftViewCell(ViewCell *l) {mLeftViewCell = l;} 84 void SetRightViewCell(ViewCell *l) {mRightViewCell = l;} 85 86 ViewCell *GetLeftViewCell() const {return mLeftViewCell;} 87 ViewCell *GetRightViewCell() const { return mRightViewCell;} 88 89 float GetMergeCost() const {return mMergeCost;} 90 void SetMergeCost(const float cost) {mMergeCost = cost;} 91 92 protected: 93 94 /// render cost increase by this merge 95 float mMergeCost; 96 97 ViewCell *mLeftViewCell; 98 ViewCell *mRightViewCell; 99 }; 100 101 66 102 67 103 /// view cell container types -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r694 r703 54 54 static SAXParser::ValSchemes valScheme = SAXParser::Val_Auto; 55 55 56 #define ROTATE_SCENE 156 #define ROTATE_SCENE 0 57 57 58 58 … … 125 125 126 126 mesh->mFaces.push_back(new Face(vc)); 127 //if (ROTATE_SCENE)127 if (ROTATE_SCENE) 128 128 RotateMesh(mesh); 129 129 mesh->Preprocess(); … … 143 143 { 144 144 // HACK 145 //if (ROTATE_SCENE)145 if (ROTATE_SCENE) 146 146 RotateMesh(mCurrentMesh); 147 147 mCurrentMesh->Preprocess();
Note: See TracChangeset
for help on using the changeset viewer.