Ignore:
Timestamp:
03/15/06 08:59:33 (18 years ago)
Author:
mattausch
Message:

added means for rotating scene

File:
1 edited

Legend:

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

    r693 r694  
    1717 
    1818#define SAMPLE_AFTER_SUBDIVISION 1 
    19  
     19#define TEST_EMPTY_VIEW_CELLS 0 
    2020 
    2121ViewCellsManager::ViewCellsManager(): 
     
    145145 
    146146        cout << "collecting empty view cells" << endl; 
    147         int i = 0; 
     147         
    148148        for (it = leaves.begin(); it != it_end; ++ it) 
    149149        { 
    150150                if ((*it)->GetPvs().Empty()) 
    151151                { 
    152                         ++ i; 
    153152                        mEmptyViewCells.push_back(*it); 
    154153                } 
    155154        } 
    156         cout << "view cells found: " << i << endl; 
    157 } 
    158  
    159  
    160 void ViewCellsManager::TestEmptyViewCells() 
    161 { 
    162         mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), mEmptyViewCells); 
    163  
     155        Debug << "empty view cells found: " << (int)mEmptyViewCells.size() << endl; 
     156} 
     157 
     158 
     159void ViewCellsManager::TestEmptyViewCells(const ObjectContainer &obj) 
     160{ 
    164161        ViewCellContainer::const_iterator it, it_end = mEmptyViewCells.end(); 
    165162 
     
    170167                if (!(*it)->GetPvs().Empty()) 
    171168                { 
    172                         sprintf(buf, "empty-viewcells-%09d.x3d", (*it)->GetId()); 
     169                        sprintf(buf, "empty-viewcells-%09d.x3d", i/*(*it)->GetId()*/); 
    173170                        Exporter *exporter = Exporter::GetExporter(buf); 
    174171                         
    175172                        if (exporter && i < 20) 
    176173                        { 
    177                                 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << endl; 
     174                                Ray *pray = (*it)->mPiercingRays[0]; 
     175                                Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << " " << pray->intersections.size() << endl; 
     176 
     177                                exporter->ExportRays((*it)->mPiercingRays); 
     178                                                         
     179                                exporter->SetFilled(); 
     180                                exporter->SetForcedMaterial(RgbColor(0,0,1)); 
     181 
     182                                for (int j = 0; j < (int)pray->intersections.size(); ++ j) 
     183                                { 
     184                                        if (pray->intersections[j].mObject) 
     185                                                exporter->ExportIntersectable(pray->intersections[j].mObject); 
     186                                } 
     187 
     188                                //exporter->SetWireframe(); 
     189                                exporter->SetForcedMaterial(RgbColor(0,1,0)); 
     190                                exporter->ExportGeometry(obj); 
     191 
     192                                exporter->SetFilled(); 
     193 
     194                                exporter->SetForcedMaterial(RgbColor(1,0,0)); 
    178195                                ExportViewCellGeometry(exporter, *it); 
     196 
     197                                delete exporter;                 
    179198                        } 
    180199 
     200                 
    181201                        ++ i; 
    182202                } 
    183203        } 
    184         Debug << "\nfound " << i << " new view cells (" << " of " << mEmptyViewCells.size() << ")" << endl << endl; 
     204        Debug << "\nSampled " << i << " new view cells (" << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 
    185205} 
    186206 
     
    289309 
    290310        // should we use directional samples? 
    291         bool dirSamples = mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION; 
     311        bool dirSamples = (mSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 
    292312 
    293313        while (numSamples < n) 
     
    296316                VssRayContainer constructionSamples; 
    297317 
    298                 const int samplingType = 
    299                         dirSamples ?  
     318                const int samplingType = mSamplingType; 
     319                        /*dirSamples ?  
    300320                                                Preprocessor::DIRECTION_BASED_DISTRIBUTION : 
    301                                                 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 
     321                                                Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;*/ 
    302322 
    303323                if (0) 
     
    327347        VssRayContainer postProcessSamples; 
    328348 
    329         //-- construction rays => we use uniform samples for this 
     349        //-- construction rays  
    330350        CastPassSamples(mPostProcessSamples, 
    331                                     Preprocessor::DIRECTION_BASED_DISTRIBUTION,  
     351                                        mSamplingType,  
    332352                                        postProcessSamples); 
    333353 
     
    359379 
    360380        // only for testing 
    361         CollectEmptyViewCells(); 
     381        if (TEST_EMPTY_VIEW_CELLS) 
     382                CollectEmptyViewCells(); 
    362383 
    363384 
     
    495516 
    496517        // find empty view cells bug 
    497         TestEmptyViewCells(); 
     518        if (TEST_EMPTY_VIEW_CELLS) 
     519                TestEmptyViewCells(preprocessor->mObjects); 
    498520} 
    499521 
     
    10831105        { 
    10841106                ViewCell *viewcell = *it; 
     1107 
    10851108                if (viewcell->GetValid())  
    10861109                { 
     1110                        // HACK 
     1111                        if (TEST_EMPTY_VIEW_CELLS) 
     1112                                for (int i = 0; i < mEmptyViewCells.size(); ++i) 
     1113                                { 
     1114                                        if (viewcell == mEmptyViewCells[i]) 
     1115                                        { 
     1116                                                viewcell->mPiercingRays.push_back(new Ray(ray)); 
     1117                                                Debug << "empty view cell ray found: " << ray.mOriginObject << ", " << ray.mTerminationObject << endl; 
     1118                                        } 
     1119                                } 
     1120 
    10871121                        // if ray not outside of view space 
    10881122                        float contribution; 
     
    17731807                newVol += lVol; 
    17741808                subdivVol += (*it)->GetVolume(); 
     1809 
     1810                float thres = 0.9; 
     1811                if ((lVol < ((*it)->GetVolume() * thres)) || 
     1812                        (lVol * thres > ((*it)->GetVolume()))) 
     1813                        Debug << "warning: " << lVol << " " << (*it)->GetVolume() << endl; 
    17751814        } 
    17761815         
     
    30323071        MergeViewCells(postProcessRays, objects); 
    30333072         
    3034  
    3035         Debug << "here4" << endl; 
    30363073        // only for testing 
    30373074        TestSubdivision(); 
     
    33413378        Debug << "\nOutput view cells: " << endl; 
    33423379 
     3380        const bool sortViewCells = true; 
     3381 
    33433382        // sort view cells to visualize the largest view cells 
    3344         if (0) 
     3383        if (sortViewCells) 
    33453384                stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
    33463385         
     
    33543393                cout << "creating output for view cell " << i << " ... "; 
    33553394 
    3356          
    33573395                ViewCell *vc; 
    33583396         
    3359                 if (0) // largest view cell pvs first 
     3397                if (sortViewCells) // largest view cell pvs first 
    33603398                        vc = mViewCells[i]; 
    33613399                else 
     
    33703408                if (1 || mExportRays) 
    33713409                { 
     3410                        // output rays stored with the view cells during subdivision 
    33723411                        if (0) 
    33733412                        { 
     
    34083447                        } 
    34093448                 
    3410  
     3449                        // associate new rays with output view cell 
    34113450                        if (1) 
    34123451                        { 
     
    35983637                                                                   0.00000001f); 
    35993638         
    3600                                 //Debug << "here geo size: " << geom.Size() << endl; 
    3601                                 //Debug << "here size b: " << back.Size() << " f: " << front.Size() << endl; 
     3639                                //Debug << "geo size: " << geom.Size() << endl; 
     3640                                //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 
    36023641                                if (back.Valid()) 
    36033642                                { 
    36043643                                        exporter->ExportPolygons(back.GetPolys()); 
    36053644                                } 
    3606                                 //else Debug << "here2 size: " << back.Size() << endl; 
     3645                         
    36073646                        } 
    36083647                } 
Note: See TracChangeset for help on using the changeset viewer.