Changeset 1444


Ignore:
Timestamp:
09/21/06 12:16:04 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
6 edited

Legend:

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

    r1421 r1444  
    529529                ); 
    530530 
    531         if (0 && terminationCriteriaMet) 
     531        if (1 && terminationCriteriaMet) 
    532532        { 
    533533                Debug << "bvh global termination criteria met:" << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1421 r1444  
    16701670        RegisterOption("Preprocessor.pvsRenderErrorSamples", 
    16711671                                   optInt, 
    1672                                    "pvsRenderErrorSamples=", 
     1672                                   "preprocessor_pvs_rendererror_samples=", 
    16731673                                   "10000"); 
    16741674         
     
    24272427                                        optFloat, 
    24282428                                        "hierarchy_term_min_global_cost_ratio=", 
    2429                                         "0.9"); 
     2429                                        "0.000000001"); 
    24302430 
    24312431        RegisterOption("Hierarchy.Termination.globalCostMissTolerance", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1422 r1444  
    234234                (0 
    235235                || (mHierarchyStats.Leaves() >= mTermMaxLeaves)  
    236                 //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     236                || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    237237                ||(candidate->GlobalTerminationCriteriaMet()) 
    238238                ); 
    239239 
    240         if (0 && terminationCriteriaMet) 
     240        if (1 && terminationCriteriaMet) 
    241241        { 
    242242                Debug << "hierarchy global termination criteria met:" << endl; 
     
    382382        const bool vspSplit = (sc->Type() == SubdivisionCandidate::VIEW_SPACE); 
    383383 
     384        if (!globalTerminationCriteriaMet) 
     385        { 
     386                // cost ratio of cost decrease / totalCost 
     387                const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost; 
     388                Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
     389         
     390                if (costRatio < mTermMinGlobalCostRatio) 
     391                { 
     392                        ++ mGlobalCostMisses; 
     393                } 
     394 
     395                mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); 
     396        } 
     397 
    384398        if (vspSplit) 
    385399        { 
     
    481495        { 
    482496                mCurrentCandidate = NextSubdivisionCandidate();     
    483                 mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); 
    484  
    485                 // cost ratio of cost decrease / totalCost 
    486                 const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost; 
    487  
    488                 //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
    489                 if (costRatio < mTermMinGlobalCostRatio) 
    490                 { 
    491                         ++ mGlobalCostMisses; 
    492                 } 
    493                  
     497                         
    494498                /////////////////// 
    495499                //-- subdivide leaf node 
     
    498502                { 
    499503                        cout << mCurrentCandidate->Type() << " "; 
    500                         if (0) cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 
     504                        if (0) cout << "subdividing candidate " << ++ i << " of type "  
     505                                                << mCurrentCandidate->Type() << endl; 
    501506                        mHierarchyStats.nodes += 2; 
    502507 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r1415 r1444  
    537537{ 
    538538        // matt: TODO 
    539         return ( 
    540                 (mOspStats.Leaves() >= mTermMaxLeaves) 
    541                 //mOutOfMemory ||  
    542                 //(mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     539        return (0 
     540                || (mOspStats.Leaves() >= mTermMaxLeaves)  
     541                //|| mOutOfMemory 
     542                || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    543543                ); 
    544544} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1421 r1444  
    348348                  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    349349 
    350  
    351         /////////////////////////////////////////// 
    352         //-- Initial hierarchy construction finished 
     350        // collect view cells and compute statistics 
     351        ResetViewCells(); 
     352 
     353 
     354        /////////////////// 
     355        //-- Initial hierarchy construction finished. 
    353356        //-- We can do some stats and visualization 
    354357         
    355         ResetViewCells(); 
    356                  
    357         if (0) //-- optionally export initial view cell partition 
    358         { 
    359         Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 
     358        if (0) 
     359        { 
     360                //-- export initial view cell partition 
     361                Debug << "\nView cells after initial sampling:\n"  
     362                          << mCurrentViewCellsStats << endl; 
    360363 
    361364                const string filename("viewcells.wrl"); 
     
    400403 
    401404                const int samplingType = mSamplingType; 
    402                         /*dirSamples ?  
    403                                                 Preprocessor::DIRECTION_BASED_DISTRIBUTION : 
    404                                                 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;*/ 
     405                        //dirSamples ? Preprocessor::DIRECTION_BASED_DISTRIBUTION :     Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 
    405406 
    406407                if (0) dirSamples = !dirSamples; // toggle sampling method 
     
    445446        //-- post processing of the initial construction 
    446447        //-- We can bottom-up merge the view cells in this step 
    447  
    448  
    449         // we can additionally cast some post processing sample rays. 
    450         // These rays can be used to store the view cells with the rays 
     448        //-- We can additionally cast some post processing sample rays. 
     449        //-- These rays can be used to store the view cells with the rays 
     450 
    451451        VssRayContainer postProcessSamples; 
    452452        cout << "casting " << mPostProcessSamples << " post processing samples ... "; 
     
    457457        cout << "starting post processing and visualization" << endl; 
    458458 
    459         // store view cells for post processing? 
     459        // store view cells with rays for post processing? 
    460460        const bool storeViewCells = true; 
    461461 
     
    480480                EvalViewCellPartition(); 
    481481        } 
    482  
    483482         
    484483        ///////////////// 
     
    497496                        ComputeSampleContributions(visualizationSamples, true, storeViewCells); 
    498497 
    499                 // different visualizations 
     498                // various visualizations 
    500499                Visualize(preprocessor->mObjects, visualizationSamples); 
    501500 
    502501                disposeRays(visualizationSamples, outRays); 
    503502        } 
     503 
     504        // recalculate view cells 
     505        EvaluateViewCellsStats(); 
    504506 
    505507        return numSamples; 
     
    614616                long startTime = GetTime(); 
    615617 
    616                 //vm->PrepareLoadedViewCells(); 
    617618                vm->ResetViewCells(); 
    618619 
     
    620621                vm->mMaxPvsSize = (int)objects->size(); 
    621622 
    622                 // create the meshes and compute volumes 
    623623                if (finalizeViewCells) 
    624624                { 
     625                        // create the meshes and compute volumes 
    625626                        vm->FinalizeViewCells(true); 
    626627                        vm->mViewCellsTree->AssignRandomColors(); 
     
    901902                startTime = GetTime(); 
    902903 
    903                 cout << "compute new statistics ... "; 
    904                 Debug << "compute new statistics ... "; 
    905  
     904                cout << "compute new statistics ... " << endl; 
     905         
    906906                //-- propagate pvs or pvs size information 
    907907                ObjectPvs pvs; 
     
    916916                timeDiff = TimeDiff(startTime, GetTime()); 
    917917                cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    918                 Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
     918                Debug << "statistis compted in " << timeDiff * 1e-3 << " secs" << endl; 
    919919         
    920920                disposeRays(evaluationSamples, NULL); 
     
    922922         
    923923 
     924        ////////////7 
    924925        //-- histogram 
    925926 
     
    12861287bool ViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
    12871288{ 
    1288   if (!ViewCellsConstructed()) 
    1289           return mViewSpaceBox.IsInside(viewPoint); 
    1290   else  
    1291   { 
    1292           if (!mViewSpaceBox.IsInside(viewPoint)) 
    1293                   return false; 
    1294            
    1295           ViewCell *viewcell = GetViewCell(viewPoint); 
    1296            
    1297           if (!viewcell || !viewcell->GetValid()) 
    1298                   return false; 
    1299   } 
    1300  
    1301   return true; 
    1302 } 
    1303  
    1304  
    1305 float 
    1306 ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 
    1307                                                                                          const bool addRays,                                                                     
    1308                                                                                          const bool storeViewCells 
    1309                                                                                          ) 
    1310 { 
    1311   // view cells not yet constructed 
    1312   if (!ViewCellsConstructed()) 
    1313         return 0.0f; 
    1314  
    1315   VssRayContainer::const_iterator it, it_end = rays.end(); 
    1316  
    1317   float sum = 0.0f; 
    1318  
    1319   for (it = rays.begin(); it != it_end; ++ it)  
    1320   { 
    1321           sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 
    1322   } 
    1323  
    1324   return sum; 
     1289        if (!ViewCellsConstructed()) 
     1290        { 
     1291                return mViewSpaceBox.IsInside(viewPoint); 
     1292        } 
     1293        else  
     1294        { 
     1295                if (!mViewSpaceBox.IsInside(viewPoint)) 
     1296                        return false; 
     1297 
     1298                ViewCell *viewcell = GetViewCell(viewPoint); 
     1299 
     1300                if (!viewcell || !viewcell->GetValid()) 
     1301                        return false; 
     1302        } 
     1303 
     1304        return true; 
     1305} 
     1306 
     1307 
     1308float ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 
     1309                                                                                                   const bool addRays,                                                                   
     1310                                                                                                   const bool storeViewCells) 
     1311{ 
     1312        // view cells not yet constructed 
     1313        if (!ViewCellsConstructed()) 
     1314                return 0.0f; 
     1315         
     1316        float sum = 0.0f; 
     1317 
     1318        VssRayContainer::const_iterator it, it_end = rays.end(); 
     1319         
     1320        for (it = rays.begin(); it != it_end; ++ it)  
     1321        { 
     1322                sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 
     1323        } 
     1324 
     1325        return sum; 
    13251326} 
    13261327 
     
    13451346                                                                                                float &avgRenderCost) 
    13461347{ 
    1347         ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    1348  
     1348        //////////// 
    13491349        //-- compute expected value 
     1350 
    13501351        totalRenderCost = 0; 
    13511352        totalPvs = 0; 
     1353 
     1354        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    13521355 
    13531356        for (it = mViewCells.begin(); it != it_end; ++ it) 
     
    13641367 
    13651368 
     1369        /////////// 
    13661370        //-- compute standard defiation 
     1371 
    13671372        variance = 0; 
    13681373        deviation = 0; 
     
    17271732        CollectViewCells(); 
    17281733         
    1729          
    17301734        // stats are computed once more 
    1731         mCurrentViewCellsStats.Reset(); 
    17321735        EvaluateViewCellsStats(); 
    17331736 
     
    25542557 
    25552558        Debug << mBspTree->GetStatistics() << endl; 
    2556  
    2557         //EvaluateViewCellsStats(); 
    25582559        Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 
    25592560 
     
    26302631    int vcSize = 0; 
    26312632        int pvsSize = 0; 
    2632  
    2633          
    2634         /////////////////////// 
     2633         
     2634 
     2635        ////////////////// 
    26352636        //-- merge leaves of the view cell hierarchy     
    26362637         
     
    26682669         
    26692670        //////////////////////// 
    2670         //-- visualization and statistics 
    2671  
    2672         // export statistics after merge 
     2671        //-- visualization and statistics after merge 
     2672 
    26732673        if (1) 
    26742674        { 
     
    26862686        if (1) // export merged view cells 
    26872687        { 
    2688                 mColorCode = 0; // hack color code 
     2688                mColorCode = 0; // use random colors 
    26892689                Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 
    26902690                 
    2691  
    26922691                cout << "exporting view cells after merge ... "; 
    26932692 
     
    32413240        // create the view cells 
    32423241        mKdTree->CreateAndCollectViewCells(mViewCells); 
    3243  
    32443242        // cast rays 
    32453243        ComputeSampleContributions(rays, true, false); 
     
    36233621    cout << "finished" << endl; 
    36243622 
     3623        ///////////////// 
    36253624        //-- stats after construction 
    36263625 
     
    36313630 
    36323631 
     3632        ////////////////////// 
     3633        //-- recast rest of rays 
    36333634        startTime = GetTime(); 
    36343635 
    36353636        cout << "Computing remaining ray contributions ... "; 
    36363637 
    3637         // recast rest of rays 
    36383638        if (SAMPLE_AFTER_SUBDIVISION) 
    36393639                ComputeSampleContributions(savedRays, true, false); 
     
    36463646        cout << "construction finished" << endl; 
    36473647 
    3648          
    36493648        if (0) 
    36503649        { 
     
    36963695        } 
    36973696 
    3698         //-- stats and visualizations 
    3699         cout << "finished merging" << endl; 
    37003697        cout << "merged view cells in " 
    37013698                 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
     
    37043701                  << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 
    37053702         
     3703 
     3704        ////////////////// 
     3705        //-- stats and visualizations 
    37063706 
    37073707        int savedColorCode = mColorCode; 
     
    37103710        ResetViewCells(); 
    37113711        Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 
    3712  
    3713         //BspLeaf::NewMail(); 
     3712         
    37143713        if (1) // export merged view cells 
    37153714        { 
     
    38923891        if (0) FinalizeViewCells(false); 
    38933892                 
    3894         ////////////////// 
     3893        ////////// 
    38953894        //-- merge the individual view cells 
    38963895        MergeViewCells(postProcessRays, objects); 
    38973896         
    3898         ///////////////////////////////// 
    3899         //-- refines the merged view cells 
     3897        // refines the merged view cells 
    39003898        if (0) RefineViewCells(postProcessRays, objects); 
    39013899 
    3902         ////////////////// 
     3900 
     3901        /////////// 
    39033902        //-- render simulation after merge + refine 
    39043903 
     
    39343933        // compute final meshes and volume / area 
    39353934        if (1) FinalizeViewCells(true); 
    3936 cout << "here09*******************" << endl; 
     3935 
    39373936        // write view cells to disc 
    39383937        if (0 && mExportViewCells) 
    3939         {cout << "here77*******************" << endl; 
     3938        { 
    39403939                char filename[100]; 
    39413940                Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); 
     
    47934792        } 
    47944793 
    4795         // print subdivision statistics 
     4794        //////////// 
     4795        //-- print satistics for subdivision and view cells 
     4796 
    47964797        Debug << endl << endl << *mHierarchyManager << endl; 
    4797         //mHierarchyManager->PrintHierarchyStatistics(Debug); 
     4798 
     4799        ResetViewCells(); 
     4800        Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 
    47984801 
    47994802        if (0) 
     
    48034806        }        
    48044807 
    4805         // print view cell statistics 
    4806         ResetViewCells(); 
    4807         Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 
    4808  
    4809  
     4808 
     4809        ////////// 
     4810        //-- recast rest of rays 
     4811         
    48104812        const long startTime = GetTime(); 
    48114813        cout << "Computing remaining ray contributions ... "; 
    48124814 
    4813         // recast rest of rays 
    48144815        if (SAMPLE_AFTER_SUBDIVISION) 
    48154816                ComputeSampleContributions(savedRays, true, false); 
     
    54875488 
    54885489                        // for directional sampling it is important to count only contributions 
    5489                         // made in one direction!!! 
    5490                         // the other contributions of this sample will be counted for the oposite ray! 
     5490                        // made in one direction! 
     5491                        // the other contributions of this sample will be counted for the opposite ray! 
    54915492#if SAMPLE_ORIGIN_OBJECTS 
    54925493                        if (ray.mOriginObject &&  
     
    55905591                mViewCellsTree->ResetPvs(); 
    55915592        } 
    5592         else // start from current sampless 
    5593         { 
     5593        else  
     5594        { 
     5595                // start from current sampless 
    55945596                // statistics before casting more samples 
    55955597                cout << "compute new statistics ... "; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1421 r1444  
    6262{ 
    6363        MailablePvsData *vdata = obj->mViewCellPvs.Find(vc); 
    64 //return false; 
     64 
    6565        if (vdata) 
    6666        { 
     
    128128 
    129129        app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 
    130         //app << "#N_PVS: " << pvs << endl; 
    131  
    132         //app << "#N_MAXOBJECTREFS  ( Max number of object refs / leaf )\n" << maxObjectRefs << "\n"; 
     130         
    133131 
    134132        app << "========== END OF VspTree statistics ==========\n"; 
     
    202200        mTreeValid = v; 
    203201} 
     202 
    204203 
    205204 
     
    372371mHierarchyManager(NULL) 
    373372{ 
     373        mLocalSubdivisionCandidates = new vector<SortableEntry>; 
     374 
    374375        bool randomize = false; 
    375376        Environment::GetSingleton()->GetBoolValue("VspTree.Construction.randomize", randomize); 
     
    377378                Randomize(); // initialise random generator for heuristics 
    378379 
     380        char subdivisionStatsLog[100]; 
     381        Environment::GetSingleton()->GetStringValue("VspTree.subdivisionStats", subdivisionStatsLog); 
     382        mSubdivisionStats.open(subdivisionStatsLog); 
     383 
     384        ///////////// 
    379385        //-- termination criteria for autopartition 
     386 
    380387        Environment::GetSingleton()->GetIntValue("VspTree.Termination.maxDepth", mTermMaxDepth); 
    381388        Environment::GetSingleton()->GetIntValue("VspTree.Termination.minPvs", mTermMinPvs); 
     
    386393        Environment::GetSingleton()->GetIntValue("VspTree.Termination.missTolerance", mTermMissTolerance); 
    387394        Environment::GetSingleton()->GetIntValue("VspTree.Termination.maxViewCells", mMaxViewCells); 
    388  
    389         //-- max cost ratio for early tree termination 
     395        // max cost ratio for early tree termination 
    390396        Environment::GetSingleton()->GetFloatValue("VspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    391397 
     
    393399        Environment::GetSingleton()->GetIntValue("VspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
    394400 
     401        Environment::GetSingleton()->GetFloatValue("VspTree.maxStaticMemory", mMaxMemory); 
     402 
     403 
     404        ////////////// 
    395405        //-- factors for bsp tree split plane heuristics 
     406 
    396407        Environment::GetSingleton()->GetFloatValue("VspTree.Termination.ct_div_ci", mCtDivCi); 
    397  
    398         //-- partition criteria 
    399408        Environment::GetSingleton()->GetFloatValue("VspTree.Construction.epsilon", mEpsilon); 
     409        Environment::GetSingleton()->GetFloatValue("VspTree.Construction.minBand", mMinBand); 
     410        Environment::GetSingleton()->GetFloatValue("VspTree.Construction.maxBand", mMaxBand); 
     411        Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests); 
     412 
    400413        Environment::GetSingleton()->GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    401  
     414         
    402415        // if only the driving axis is used for axis aligned split 
    403416        Environment::GetSingleton()->GetBoolValue("VspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    404          
    405         Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests); 
    406         Environment::GetSingleton()->GetFloatValue("VspTree.maxStaticMemory", mMaxMemory); 
    407  
    408417        Environment::GetSingleton()->GetBoolValue("VspTree.useCostHeuristics", mUseCostHeuristics); 
    409418        Environment::GetSingleton()->GetBoolValue("VspTree.simulateOctree", mCirculatingAxis); 
    410          
    411         //Environment::GetSingleton()->GetBoolValue("VspTree.useKdPvsForHeuristics", mUseKdPvsForHeuristics); 
    412  
    413         char subdivisionStatsLog[100]; 
    414         Environment::GetSingleton()->GetStringValue("VspTree.subdivisionStats", subdivisionStatsLog); 
    415         mSubdivisionStats.open(subdivisionStatsLog); 
    416  
    417         Environment::GetSingleton()->GetFloatValue("VspTree.Construction.minBand", mMinBand); 
    418         Environment::GetSingleton()->GetFloatValue("VspTree.Construction.maxBand", mMaxBand); 
    419          
    420  
     419 
     420 
     421        ////////////// 
    421422        //-- debug output 
    422423 
     
    445446        Debug << "maxband: " << mMaxBand << endl; 
    446447 
    447         mLocalSubdivisionCandidates = new vector<SortableEntry>; 
    448  
    449448        Debug << endl; 
    450449} 
     
    565564                ); 
    566565 
    567         if (0 && terminationCriteriaMet) 
     566        if (1 && terminationCriteriaMet) 
    568567        { 
    569568                Debug << "vsp global termination criteria met:" << endl; 
Note: See TracChangeset for help on using the changeset viewer.