Ignore:
Timestamp:
09/21/06 12:16:04 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ... "; 
Note: See TracChangeset for help on using the changeset viewer.