Ignore:
Timestamp:
11/07/06 13:56:58 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1717 r1718  
    26282628 
    26292629 
    2630 void 
    2631 ViewCellsManager::UpdatePvsForEvaluation() 
    2632 { 
    2633   ObjectPvs objPvs; 
    2634   UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), objPvs); 
     2630void ViewCellsManager::UpdatePvsForEvaluation() 
     2631{ 
     2632        ObjectPvs objPvs; 
     2633        UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), objPvs); 
    26352634} 
    26362635 
     
    57255724 
    57265725#if 1 
    5727 #if TEST_EVALUATION 
    5728 void VspOspViewCellsManager::EvalViewCellPartition() 
    5729 { 
    5730         const int castSamples = (int)storedRays.size(); 
    5731         char s[64];  
    5732         char statsPrefix[100]; 
    5733  
    5734         Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 
    5735  
    5736         Debug << "view cell stats prefix: " << statsPrefix << endl; 
    5737  
    5738         // should directional sampling be used? 
    5739         const bool dirSamples = (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 
    5740  
    5741         cout << "reseting pvs ... "; 
    5742         const bool startFromZero = true; 
    5743  
    5744         if (startFromZero) 
    5745         { 
    5746                 // reset pvs and start over from zero 
    5747                 mViewCellsTree->ResetPvs(); 
    5748         } 
    5749         else  
    5750         { 
    5751                 // statistics before casting more samples 
    5752                 cout << "compute new statistics ... "; 
    5753                 sprintf(s, "-%09d-eval.log", castSamples); 
    5754                 string fName = string(statsPrefix) + string(s); 
    5755  
    5756                 mViewCellsTree->ExportStats(fName); 
    5757                 cout << "finished" << endl; 
    5758         } 
    5759         cout << "finished" << endl; 
    5760  
    5761     cout << "Evaluating view cell partition ... " << endl; 
    5762  
    5763         VssRayContainer evaluationSamples = storedRays; 
    5764         const int samplingType = mEvaluationSamplingType; 
    5765          
    5766         cout << "computing sample contributions of " << (int)evaluationSamples.size()  << " samples ... "; 
    5767          
    5768         ComputeSampleContributions(evaluationSamples, true, false); 
    5769          
    5770         cout << "finished" << endl; 
    5771          
    5772         cout << "compute new statistics ... "; 
    5773          
    5774         // propagate pvs or pvs size information 
    5775         ObjectPvs pvs; 
    5776         UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
    5777  
    5778  
    5779         ///////////////////// 
    5780         // $§temporary matt: test render cost 
    5781  
    5782         sprintf(s, "-%09d-eval.log", castSamples); 
    5783         string fileName = string(statsPrefix) + string(s); 
    5784  
    5785         ViewCellContainer leaves; 
    5786  
    5787         mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
    5788         float rc = 0; 
    5789  
    5790         ViewCellContainer::const_iterator vit, vit_end = leaves.end(); 
    5791          
    5792         for (vit = leaves.begin(); vit != vit_end; ++ vit) 
    5793         { 
    5794                 ViewCell *vc = *vit; 
    5795                 const float pvsCost = vc->GetPvs().EvalPvsCost(); 
    5796                 const float vol = vc->GetVolume(); 
    5797                 rc += pvsCost * vol; 
    5798         } 
    5799  
    5800         Debug << "\nrendercost hack: " << rc / mViewSpaceBox.GetVolume() << endl; 
    5801         mViewCellsTree->ExportStats(fileName); 
    5802         cout << "finished" << endl; 
    5803  
    5804         disposeRays(evaluationSamples, NULL); 
    5805 } 
    5806  
    5807 #else 
    58085726 
    58095727void VspOspViewCellsManager::EvalViewCellPartition() 
     
    58125730        int numSamples; 
    58135731        int castSamples = 0; 
     5732        int oldSamples = 0; 
     5733        int samplesForStats; 
     5734        char statsPrefix[100]; 
     5735        char suffix[100]; 
    58145736        int splitsStepSize; 
    58155737 
    5816         char str[64];  
    5817          
     5738 
    58185739        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 
     5740        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesForStats", samplesForStats); 
    58195741        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samples", numSamples); 
     5742        Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 
    58205743        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.stepSize", splitsStepSize); 
    5821  
    5822         char statsPrefix[100]; 
    5823         Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 
    5824  
     5744         
     5745        Debug << "step size: " << splitsStepSize << endl; 
    58255746        Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl; 
    58265747        Debug << "view cell evaluation samples: " << numSamples << endl; 
    58275748        Debug << "view cell stats prefix: " << statsPrefix << endl; 
    5828         Debug << "step size: " << splitsStepSize << endl; 
     5749 
     5750        // should directional sampling be used? 
     5751        bool dirSamples =  
     5752                (mEvaluationSamplingType == SamplingStrategy::DIRECTION_BASED_DISTRIBUTION); 
    58295753 
    58305754        cout << "reseting pvs ... "; 
    58315755                 
    5832         const bool startFromZero = true; 
    5833  
    58345756        // reset pvs and start over from zero 
    5835         if (startFromZero) 
    5836         { 
    5837                 mViewCellsTree->ResetPvs(); 
    5838         } 
    5839         else // start from current sampless 
    5840         { 
    5841                 // statistics before casting more samples 
    5842                 cout << "compute new statistics ... "; 
    5843                 sprintf(str, "-%09d-eval.log", castSamples); 
    5844                 string fName = string(statsPrefix) + string(str); 
    5845  
    5846                 mViewCellsTree->ExportStats(fName); 
    5847                 cout << "finished" << endl; 
    5848         } 
    5849  
     5757        mViewCellsTree->ResetPvs(); 
     5758         
    58505759        cout << "finished" << endl; 
    58515760    cout << "Evaluating view cell partition ... " << endl; 
     
    58535762        while (castSamples < numSamples) 
    58545763        {                
    5855                 VssRayContainer evaluationSamples; 
    5856  
    58575764                /////////////// 
    58585765                //-- we have to use uniform sampling strategy for construction rays 
    58595766 
    5860                 //VssRayContainer evaluationSamples; 
     5767                VssRayContainer evaluationSamples; 
    58615768                const int samplingType = mEvaluationSamplingType; 
    58625769 
     
    58715778 
    58725779                Real timeDiff = TimeDiff(startTime, GetTime()); 
    5873                 Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    5874                 cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    5875  
     5780                 
     5781                cout << "finished in " << timeDiff * 1e-3f << " secs" << endl; 
    58765782                cout << "computing sample contributions of " << (int)evaluationSamples.size()  << " samples ... "; 
     5783                 
     5784                Debug << "finished in " << timeDiff * 1e-3f << " secs" << endl; 
    58775785                Debug << "computing sample contributions of " << (int)evaluationSamples.size()  << " samples ... "; 
    58785786 
     
    58855793                Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    58865794 
    5887                 startTime = GetTime(); 
    5888                 cout << "compute new statistics ... " << endl; 
    5889  
    5890                 /////////// 
    5891                 //-- output stats 
    5892  
    5893                 sprintf(str, "-%09d-eval.log", castSamples); 
    5894                 const string splitsFilename = string(statsPrefix) + string(str); 
    5895  
    5896                 ofstream splitsStr(splitsFilename.c_str()); 
    5897                 mHierarchyManager->EvaluateSubdivision2(splitsStr, splitsStepSize); 
    5898  
    5899                 timeDiff = TimeDiff(startTime, GetTime()); 
    5900                 cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    5901                 Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 
    5902          
     5795                if ((castSamples >= samplesForStats + oldSamples) || (castSamples >= numSamples)) 
     5796                { 
     5797                        oldSamples += samplesForStats; 
     5798 
     5799                        /////////// 
     5800                        //-- output stats 
     5801 
     5802                        sprintf(suffix, "-%09d-eval.log", castSamples); 
     5803                        const string filename = string(statsPrefix) + string(suffix); 
     5804 
     5805                        startTime = GetTime(); 
     5806                        cout << "compute new statistics ... " << endl; 
     5807 
     5808                        ofstream ofstr(filename.c_str()); 
     5809                        mHierarchyManager->EvaluateSubdivision2(ofstr, splitsStepSize); 
     5810 
     5811                        timeDiff = TimeDiff(startTime, GetTime()); 
     5812                        cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
     5813                        Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 
     5814 
     5815                        // only for debugging purpose 
     5816                        if (1) 
     5817                        { 
     5818                                ViewCellContainer viewCells; 
     5819                                mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), viewCells); 
     5820 
     5821                                ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
     5822                                int pvsSize = 0; 
     5823 
     5824                                for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
     5825                                { 
     5826                                        pvsSize += (*vit)->GetPvs().GetSize(); 
     5827                                } 
     5828 
     5829                                cout << "debug entries: " << pvsSize << ", memcost: " << (float)pvsSize * ObjectPvs::GetEntrySize() << endl; 
     5830                        } 
     5831                } 
     5832 
    59035833                disposeRays(evaluationSamples, NULL); 
    59045834        } 
     5835         
    59055836} 
    59065837#endif 
    5907 #endif 
    5908 } 
     5838} 
Note: See TracChangeset for help on using the changeset viewer.