Ignore:
Timestamp:
04/24/06 08:21:10 (18 years ago)
Author:
mattausch
Message:

debug version for testing subdivision

File:
1 edited

Legend:

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

    r752 r801  
    173173        Debug << "export to file: " << mExportViewCells << endl; 
    174174         
    175         Debug << "active: " << mNumActiveViewCells << endl; 
     175        Debug << "active view cells: " << mNumActiveViewCells << endl; 
    176176        Debug << "post process compress: " << mCompressViewCells << endl; 
    177177        Debug << "visualization use clipPlane: " << mUseClipPlaneForViz << endl;  
     
    179179        Debug << "evaluate view cells: " << mEvaluateViewCells << endl; 
    180180        Debug << "sampling type: " << mSamplingType << endl; 
    181         Debug << "render cost evaluation type" << mRenderCostEvaluationType << endl; 
     181        Debug << "render cost evaluation type: " << mRenderCostEvaluationType << endl; 
    182182        Debug << "evaluation sampling type: " << mEvaluationSamplingType << endl; 
    183183        Debug << "show visualization: " << mShowVisualization << endl; 
     
    479479        if (TEST_EMPTY_VIEW_CELLS) 
    480480                CollectEmptyViewCells(); 
    481  
    482  
     481         
     482        // evaluation of the paritition, i.e., a number of new samples are cast 
     483        if (mEvaluateViewCells) 
     484        { 
     485                EvalViewCellPartition(preprocessor); 
     486        } 
     487         
    483488        //-- visualization 
    484489        if (mShowVisualization) 
     
    500505        } 
    501506 
    502         // evaluation of the paritition, i.e., a number of new samples are cast 
    503         if (mEvaluateViewCells) 
    504         { 
    505                 EvalViewCellPartition(preprocessor); 
    506         } 
    507          
    508507        return numSamples; 
    509508} 
     
    696695        bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 
    697696 
    698         cout << "collect leaf view cells and reseting pvs ... "; 
    699  
    700         ViewCellContainer leaves; 
    701         mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
    702         cout << " ... "; 
     697 
     698/*ViewCellContainer leaves; 
     699mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
     700*/       
     701        cout << "reseting pvs ... "; 
     702                 
     703 
    703704        bool startFromZero = true; 
    704705 
     
    744745                cout << "compute new statistics ... "; 
    745746 
    746                 // propagate pvs or pvs size information 
     747/*Debug << "*******+" << endl; 
     748float overall = 0; 
     749stable_sort(leaves.begin(), leaves.end(), ViewCell::SmallerPvs); 
     750        for (int i = 0; i < leaves.size(); ++ i) 
     751        { 
     752                overall += leaves[i]->GetPvs().GetSize(); 
     753                Debug << "i " << i << " !size: " << leaves[i]->GetPvs().GetSize() << " vol: " << leaves[i]->GetVolume() << " overall " << overall << endl; 
     754                 
     755        } 
     756*/ 
     757 
     758                //-- propagate pvs or pvs size information 
    747759                ObjectPvs pvs; 
    748760                UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
    749761 
    750762 
    751                 // output stats 
     763                //-- output stats 
    752764                sprintf(s, "-%09d-eval.log", castSamples); 
    753765                string fileName = string(statsPrefix) + string(s); 
     
    17931805                if (!mOnlyValidViewCells || (*it)->GetValid()) 
    17941806                { 
    1795                         ExportColor(exporter, *it);              
     1807                        ExportColor(exporter, *it);      
     1808 
    17961809                        ExportViewCellGeometry(exporter, *it,  
    17971810                                mUseClipPlaneForViz ? &mClipPlane : NULL); 
     
    21452158 
    21462159                        //exporter->SetWireframe(); 
    2147                         exporter->SetFilled(); 
     2160                        //exporter->SetFilled(); 
     2161                        bool b = mUseClipPlaneForViz; 
     2162                        mUseClipPlaneForViz = false; 
    21482163                        ExportViewCellsForViz(exporter); 
    2149  
     2164                        mUseClipPlaneForViz = b; 
    21502165                        delete exporter; 
    21512166                } 
     
    21682183        // export single view cells 
    21692184        ExportBspPvs(objects); 
    2170 } 
    2171  
    2172  
    2173 inline bool vc_gt(ViewCell *a, ViewCell *b) 
    2174 { 
    2175         return a->GetPvs().GetSize() > b->GetPvs().GetSize(); 
    21762185} 
    21772186 
     
    22192228        // sort view cells to get largest view cells 
    22202229        if (0) 
    2221                 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
     2230                stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 
    22222231 
    22232232        int limit = min(leafOut, (int)mViewCells.size()); 
     
    33293338        case 1: // pvs 
    33303339                { 
    3331                         importance = (float)vc->GetPvs().GetSize() / 
     3340                        importance = (float)mViewCellsTree->GetPvsSize(vc) / 
    33323341                                (float)mCurrentViewCellsStats.maxPvs; 
    33333342                } 
     
    35413550                // compute tree by merging the nodes based on cost heuristics 
    35423551                mViewCellsTree->ConstructMergeTree(rays, objects); 
     3552 
     3553        //cout << "here344" << endl; 
     3554                //ObjectPvs pvs; 
     3555                //UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
    35433556        } 
    35443557        else 
     
    38813894                pvs = root->GetPvs(); 
    38823895 
    3883                 root->mPvsSize = pvs.GetSize(); 
     3896                root->mPvsSize = root->GetPvs().GetSize(); 
    38843897                root->mPvsSizeValid = true; 
    38853898 
     
    38873900        } 
    38883901         
     3902        //-- interior node => propagate pvs up 
    38893903        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 
     3904        interior->GetPvs().Clear(); 
     3905        pvs.Clear(); 
     3906        vector<ObjectPvs> pvsList; 
     3907 
    38903908        ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 
    38913909 
    3892         vector<ObjectPvs> pvsList; 
    3893          
    3894          
    38953910        for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 
    38963911        { 
     
    39053920 
    39063921#if 1 
     3922 
    39073923        Intersectable::NewMail(); 
    39083924 
     
    39333949        { 
    39343950                interior->mPvs = pvs; 
     3951                //cout << "here233" << endl; 
    39353952        } 
    39363953         
     
    39403957 
    39413958#else 
     3959 
    39423960        // really merge cells: slow put sumpdf is correct 
    3943         ViewCellInterior *viewCellInterior = new ViewCellInterior(); 
    3944  
    39453961        viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 
    39463962        viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 
     
    39954011        {       // hack pvs 
    39964012                int savedColorCode = mColorCode; 
    3997                 mColorCode = 0; 
     4013                mColorCode = 1; 
     4014         
    39984015                Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 
    39994016                 
     
    40204037                        } 
    40214038 
     4039                        //exporter->SetFilled(); 
     4040                        bool b = mUseClipPlaneForViz; 
     4041                        mUseClipPlaneForViz = false; 
    40224042                        ExportViewCellsForViz(exporter); 
     4043                        mUseClipPlaneForViz = b; 
     4044                 
    40234045                        delete exporter; 
    40244046                        cout << "finished" << endl; 
     
    41484170 
    41494171        const bool sortViewCells = true; 
     4172         
    41504173 
    41514174        // sort view cells to visualize the largest view cells 
    41524175        if (sortViewCells) 
    4153                 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
    4154          
     4176        { 
     4177                //stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 
     4178                stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
     4179        } 
     4180 
    41554181        int limit = min(leafOut, (int)mViewCells.size()); 
    41564182 
     
    41684194                else 
    41694195                        vc = mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 
     4196 
     4197                ObjectPvs pvs; 
     4198                mViewCellsTree->GetPvs(vc, pvs); 
    41704199 
    41714200                //bspLeaves[j]->Mail(); 
     
    41754204                Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 
    41764205 
     4206                //-- export the sample rays 
    41774207                if (1 || mExportRays) 
    41784208                { 
     
    42124242                                                vcRays.push_back(*rit); 
    42134243                                } 
     4244 
    42144245                                //-- export rays piercing this view cell 
    42154246                                exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 
     
    42214252                                VssRayContainer vcRays; 
    42224253                                raysOut = min((int)rays.size(), mVisualizationSamples); 
     4254 
    42234255                                // check whether we can add the current ray to the output rays 
    42244256                                for (int k = 0; k < raysOut; ++ k) 
     
    42514283                exporter->SetFilled(); 
    42524284 
    4253  
     4285                //-- export pvs 
    42544286                if (1) 
    42554287                { 
    42564288                        ObjectPvsMap::const_iterator oit, 
    4257                                 oit_end = vc->GetPvs().mEntries.end(); 
    4258  
    4259  
    4260                         exporter->SetFilled(); 
     4289                                oit_end = pvs.mEntries.end(); 
    42614290 
    42624291                        Intersectable::NewMail(); 
    4263          
     4292 
    42644293                        // output PVS of view cell 
    4265                         for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     4294                        for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 
    42664295                        {                
    42674296                                Intersectable *intersect = (*oit).first; 
     
    42774306                        } 
    42784307                } 
    4279                 else 
    4280                 { 
     4308                 
     4309                if (0) 
     4310                {   // export scene geometry 
    42814311                        m.mDiffuseColor = RgbColor(1, 0, 0); 
    42824312                        exporter->SetForcedMaterial(m); 
     
    43384368        case 1: // pvs 
    43394369                { 
    4340                         importance = (float)vc->GetPvs().GetSize() / 
     4370                        importance = (float)mViewCellsTree->GetPvsSize(vc) / 
    43414371#if 1 // hack for result                         
    43424372                                (float)mCurrentViewCellsStats.maxPvs; 
     
    43774407                                                                                                        const Plane3 *clipPlane) const 
    43784408{ 
    4379         if (vc->GetMesh()) 
    4380         { 
    4381                 exporter->ExportMesh(vc->GetMesh()); 
    4382          
    4383                 return; 
    4384         } 
    4385  
    4386          
    43874409        if (clipPlane) 
    43884410        { 
     
    44184440                                //Debug << "geo size: " << geom.Size() << endl; 
    44194441                                //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 
     4442 
    44204443                                if (back.Valid()) 
    44214444                                { 
     
    44274450        else 
    44284451        { 
    4429                 BspNodeGeometry geom; 
    4430                 mVspBspTree->ConstructGeometry(vc, geom); 
    4431                          
    4432                 exporter->ExportPolygons(geom.GetPolys()); 
     4452                // export mesh if available 
     4453        /*      if (vc->GetMesh()) 
     4454                { 
     4455                        exporter->ExportMesh(vc->GetMesh()); 
     4456                } 
     4457                else 
     4458                {*/ 
     4459                        BspNodeGeometry geom; 
     4460                        mVspBspTree->ConstructGeometry(vc, geom); 
     4461                        exporter->ExportPolygons(geom.GetPolys()); 
     4462                //} 
    44334463        } 
    44344464} 
Note: See TracChangeset for help on using the changeset viewer.