Ignore:
Timestamp:
06/07/06 10:59:55 (18 years ago)
Author:
mattausch
Message:

debug run: fixing memory holes

File:
1 edited

Legend:

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

    r1001 r1002  
    3939}; 
    4040 
    41 //typedef priority_queue<ViewCell *, vector<ViewCell *>, myless<vector<ViewCell *>::value_type> > FilterQueue; 
    42  
    43  
    4441 
    4542ViewCellsManager::ViewCellsManager(Environment *env): 
     
    205202ViewCellsManager::~ViewCellsManager() 
    206203{ 
    207         DEL_PTR(mRenderer); 
     204        //DEL_PTR(mRenderer); 
    208205 
    209206        if (!ViewCellsTreeConstructed()) 
    210207                CLEAR_CONTAINER(mViewCells); 
    211         else 
    212                 DEL_PTR(mViewCellsTree); 
     208        //else 
     209        DEL_PTR(mViewCellsTree); 
    213210} 
    214211 
     
    306303                } 
    307304        } 
    308         Debug << "\nSampled " << i << " new view cells (" << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 
     305        Debug << "\nSampled " << i << " new view cells ("  
     306                  << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 
    309307} 
    310308 
     
    395393                  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    396394 
    397  
     395return 0; 
    398396        // take post processing time 
    399397        startTime = GetTime(); 
    400398 
    401  
    402         // testing the view cell filter functionality    
    403         if (0) TestFilter(preprocessor->mObjects); 
    404  
    405399        // -- stats after contruction 
    406400        ResetViewCells(); 
    407  
    408401        Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 
     402 
    409403 
    410404        if (1) // export initial view cells 
     
    473467 
    474468         
    475  
    476469        //-- post processing 
    477470        VssRayContainer postProcessSamples; 
     
    494487 
    495488 
    496  
    497489        cout << "starting post processing and visualization" << endl; 
    498490 
     
    514506                 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
    515507 
    516         // only for debugging purpose 
    517         if (TEST_EMPTY_VIEW_CELLS) 
    518                 CollectEmptyViewCells(); 
    519          
     508        disposeRays(postProcessSamples, outRays); 
     509 
     510         
     511        //return 1; 
    520512        // evaluation of the paritition, i.e., a number of new samples are cast 
    521513        if (mEvaluateViewCells) 
     
    523515                EvalViewCellPartition(preprocessor); 
    524516        } 
    525          
     517 
     518 
    526519        //-- visualization 
    527520        if (mShowVisualization) 
     
    679672                                                                                         const ObjectContainer &objects) 
    680673{ 
    681         if (!ViewCellsConstructed()) 
     674        if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 
    682675                return false; 
    683676 
     
    764757        sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 
    765758 
    766         //Debug << "********************" << endl; 
    767         //for (int i = 0; i < viewCells.size(); ++ i) 
    768         //      Debug << "pvs: " << mViewCellsTree->GetPvsSize(viewCells[i]) << " "; 
    769         //Debug << "\n"; 
    770759        maxPvs = mViewCellsTree->GetPvsSize(viewCells.back()); 
    771760        minVal = 0; 
     
    844833 
    845834 
     835bool ViewCellsManager::GetExportPvs() const  
     836{ 
     837        return mExportPvs; 
     838} 
     839 
     840 
    846841void ViewCellsManager::EvalViewCellPartition(Preprocessor *preprocessor) 
    847842{ 
     
    862857        Debug << "view cell stats prefix: " << statsPrefix << endl; 
    863858 
    864         //VssRayContainer outRays; 
     859         
    865860        // should directional sampling be used? 
    866861        bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 
     
    932927 
    933928        //-- histogram 
    934  
    935929 
    936930        bool useHisto; 
     
    12071201bool ViewCellsManager::ViewCellsTreeConstructed() const 
    12081202{ 
    1209         return mViewCellsTree->GetRoot(); 
     1203    return (mViewCellsTree && mViewCellsTree->GetRoot()); 
    12101204} 
    12111205 
     
    14191413 
    14201414 
    1421 void ViewCellsManager::DeriveViewCells(const ObjectContainer &objects, 
    1422                                                                            ViewCellContainer &viewCells, 
    1423                                                                            const int maxViewCells) const 
     1415void ViewCellsManager::DeriveViewCellsFromObjects(const ObjectContainer &objects, 
     1416                                                                                                  ViewCellContainer &viewCells, 
     1417                                                                                                  const int maxViewCells) const 
    14241418{ 
    14251419        // maximal max viewcells 
     
    14441438 
    14451439                        Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
    1446  
    1447                         // copy mesh 
    1448                         *mesh = *mi->GetMesh(); 
    1449  
     1440                         
    14501441                        // transform mesh 
    1451                         Matrix4x4 m; 
    1452                         mi->GetWorldTransform(m); 
    1453                         mesh->ApplyTransformation(m); 
     1442                        mi->GetTransformedMesh(*mesh); 
    14541443                         
    14551444                        // create bb + kd tree 
     
    21682157 
    21692158 
     2159void ViewCellsManager::SetScalarPvsSize(ViewCell *vc, const int pvsSize) const 
     2160{ 
     2161        vc->mPvsSize = pvsSize; 
     2162        vc->mPvsSizeValid = true; 
     2163} 
     2164 
     2165 
    21702166/**********************************************************************/ 
    21712167/*                 BspViewCellsManager implementation                 */ 
     
    29642960        { 
    29652961                pvs = root->GetPvs(); 
    2966  
    2967                 root->mPvsSize = pvs.GetSize(); 
    2968                 root->mPvsSizeValid = true; 
    2969  
     2962                SetScalarPvsSize(root, pvs.GetSize()); 
     2963                 
    29702964                return; 
    29712965        } 
     
    30183012        if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 
    30193013        { 
    3020                 interior->mPvs = pvs; 
     3014                interior->SetPvs(pvs); 
    30213015        } 
    30223016         
    30233017        // set new pvs size 
    3024         interior->mPvsSize = pvs.GetSize(); 
    3025         interior->mPvsSizeValid = true; 
     3018    SetScalarPvsSize(interior, pvs.GetSize()); 
    30263019 
    30273020#else 
     
    37813774        Debug << "saved rays: " << (int)savedRays.size() << endl; 
    37823775 
    3783  
    3784         //TODO: remove 
     3776        long startTime; 
     3777 
    37853778        if (1) 
    37863779                mVspBspTree->Construct(constructionRays, &mViewSpaceBox); 
     
    37903783        // collapse invalid regions 
    37913784        cout << "collapsing invalid tree regions ... "; 
    3792         long startTime = GetTime(); 
    3793         int collapsedLeaves = mVspBspTree->CollapseTree(); 
     3785        startTime = GetTime(); 
     3786        const int collapsedLeaves = mVspBspTree->CollapseTree(); 
    37943787        Debug << "collapsed in " << TimeDiff(startTime, GetTime()) * 1e-3  
    37953788                  << " seconds" << endl; 
     
    37973790    cout << "finished" << endl; 
    37983791 
    3799         // -- stats 
     3792        //-- stats 
    38003793        Debug << mVspBspTree->GetStatistics() << endl; 
    38013794 
     
    42114204        { 
    42124205                pvs = root->GetPvs(); 
    4213  
    4214                 root->mPvsSize = root->GetPvs().GetSize(); 
    4215                 root->mPvsSizeValid = true; 
    4216  
     4206                SetScalarPvsSize(root, root->GetPvs().GetSize()); 
     4207                 
    42174208                return; 
    42184209        } 
     
    42664257        if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 
    42674258        { 
    4268                 interior->mPvs = pvs; 
     4259                interior->SetPvs(pvs); 
    42694260        } 
    42704261         
    42714262        // set new pvs size 
    4272         interior->mPvsSize = pvs.GetSize(); 
    4273         interior->mPvsSizeValid = true; 
     4263        SetScalarPvsSize(interior, pvs.GetSize()); 
     4264         
    42744265 
    42754266#else 
     
    43254316        GetRaySets(sampleRays, mVisualizationSamples, visRays); 
    43264317 
    4327          
    4328         if (1) // export view cells 
     4318        //-- export view cells 
     4319        if (1)  
    43294320        {       // hack pvs 
    4330                 int savedColorCode = mColorCode; 
     4321                const int savedColorCode = mColorCode; 
    43314322                mColorCode = 1; 
    43324323         
     
    43674358                mColorCode = savedColorCode; 
    43684359        } 
     4360 
    43694361 
    43704362        if (0) 
     
    50355027  //  AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 
    50365028  //                                      center + Vector3(viewSpaceFilterSize/2)); 
    5037  
    50385029        if (!ViewCellsConstructed()) 
    50395030                return; 
    50405031 
    5041   if (viewSpaceFilterSize >=0.0f) { 
     5032        if (viewSpaceFilterSize >= 0.0f) { 
    50425033 
    50435034  bool usePrVS = false; 
    50445035 
    5045    
    50465036  if (!usePrVS) { 
    50475037        AxisAlignedBox3 box = GetViewCellBox(viewCell); 
     
    50525042         
    50535043  //  cout<<"box="<<box<<endl; 
    5054         ViewCellContainer::const_iterator it=viewCells.begin(), it_end = viewCells.end(); 
     5044        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 
    50555045         
    50565046        int i; 
    5057         for (i=0; it != it_end; ++it, i++) { 
    5058           //    cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
     5047        for (i=0; it != it_end; ++ it, ++ i) { 
     5048                cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
    50595049          pvs.Merge((*it)->GetPvs()); 
    50605050        } 
     
    50705060  } else 
    50715061        pvs = viewCell->GetPvs(); 
    5072    
     5062    
    50735063  if (spatialFilterSize >=0.0f) 
    50745064        ApplySpatialFilter(kdTree, spatialFilterSize, pvs); 
    5075  
     5065   
    50765066} 
    50775067 
     
    50975087   
    50985088  int i; 
    5099   for (i=0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 
     5089  for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
    51005090        ApplyFilter(*it, 
    51015091                                kdTree, 
     
    51075097 
    51085098  // now replace all pvss 
    5109   for (i= 0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 
     5099  for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
     5100             
    51105101        ObjectPvs &pvs = (*it)->GetPvs(); 
    51115102        pvs.Clear(); 
     
    51145105  } 
    51155106   
    5116   delete newPvs; 
     5107  delete [] newPvs; 
    51175108} 
    51185109 
     
    51805171 
    51815172////////////////////////////////// 
    5182 ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 
     5173/*ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 
    51835174{ 
    51845175        //TODO 
    51855176        return NULL;// new VspBspViewCellsManager(); 
    5186 } 
    5187  
    5188  
    5189 } 
     5177}*/ 
     5178 
     5179 
     5180} 
Note: See TracChangeset for help on using the changeset viewer.