Changeset 1696 for GTP/trunk/Lib


Ignore:
Timestamp:
10/29/06 18:17:38 (18 years ago)
Author:
mattausch
Message:

removed memory leaks

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/data/graz/terrain.x3d

    r257 r1696  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"   "http://www.web3d.org/specifications/x3d-3.0.dtd"> 
    32<X3D profile="Full"> 
    43  <head> 
  • GTP/trunk/Lib/Vis/Preprocessing/data/graz/terrain_walls.x3d

    r257 r1696  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"   "http://www.web3d.org/specifications/x3d-3.0.dtd"> 
    32<X3D profile="Full"> 
    43  <head> 
  • GTP/trunk/Lib/Vis/Preprocessing/data/graz/walls.x3d

    r257 r1696  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"   "http://www.web3d.org/specifications/x3d-3.0.dtd"> 
    32<X3D profile="Full"> 
    43  <head> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1693 r1696  
    214214BvHierarchy::~BvHierarchy() 
    215215{ 
    216         // delete kd intersectables 
     216        // delete bvh intersectables 
    217217        BvhIntersectableMap::iterator it, it_end = mBvhIntersectables.end(); 
    218218 
     
    222222        } 
    223223 
     224        // delete the local subdivision candidates 
    224225        DEL_PTR(mSubdivisionCandidates); 
    225226 
     227        // delete the presorted objects 
    226228        for (int i = 0; i < 3; ++ i) 
    227229        { 
    228230                DEL_PTR(mSortedObjects[i]); 
    229231        } 
    230         mSubdivisionStats.close(); 
     232         
     233        // delete the tree 
     234        DEL_PTR(mRoot); 
    231235} 
    232236 
     
    329333        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    330334        { 
    331                 nRays += (int)(*oit)->mVssRays.size(); 
     335                nRays += (int)(*oit)->GetOrCreateRays()->size(); 
    332336        } 
    333337 
     
    13361340                if (ray->mTerminationObject) 
    13371341                { 
    1338                         ray->mTerminationObject->mVssRays.push_back(ray); 
     1342                        ray->mTerminationObject->GetOrCreateRays()->push_back(ray); 
    13391343                        if (!ray->Mailed()) 
    13401344                        { 
     
    13461350                if (ray->mOriginObject) 
    13471351                { 
    1348                         ray->mOriginObject->mVssRays.push_back(ray); 
     1352                        ray->mOriginObject->GetOrCreateRays()->push_back(ray); 
    13491353 
    13501354                        if (!ray->Mailed()) 
     
    13851389        { 
    13861390                Intersectable *obj = *oit; 
    1387                 VssRayContainer::const_iterator rit, rit_end = obj->mVssRays.end(); 
    1388  
    1389                 for (rit = obj->mVssRays.begin(); rit < rit_end; ++ rit) 
     1391                VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 
     1392 
     1393                for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 
    13901394                { 
    13911395                        VssRay *ray = (*rit); 
     
    15141518                                                                   const bool setCounter) const 
    15151519{ 
    1516         VssRayContainer::const_iterator rit, rit_end = obj->mVssRays.end(); 
    1517  
    1518         for (rit = obj->mVssRays.begin(); rit < rit_end; ++ rit) 
     1520        VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 
     1521 
     1522        for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 
    15191523        { 
    15201524                VssRay *ray = (*rit); 
     
    15571561        int result = 0; 
    15581562         
    1559         VssRayContainer::const_iterator rit, rit_end = obj->mVssRays.end(); 
    1560  
    1561         for (rit = obj->mVssRays.begin(); rit < rit_end; ++ rit) 
     1563        VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 
     1564 
     1565        for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 
    15621566        { 
    15631567                VssRay *ray = (*rit); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r1595 r1696  
    9696                        { 
    9797                                VssRay *nray = new VssRay(*vssRay); 
    98                                 (*vit)->mVssRays.push_back(nray);                                
     98                                (*vit)->GetOrCreateRays()->push_back(nray);                              
    9999                        } 
    100100                } 
     
    480480                for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 
    481481                { 
    482                         CLEAR_CONTAINER((*vit)->mVssRays); 
     482                        (*vit)->DelRayRefs(); 
    483483                } 
    484484 
    485                 CLEAR_CONTAINER(mVssRays); 
     485                //CLEAR_CONTAINER(mVssRays); 
    486486                // ComputeRenderError(); 
    487487                ++ mPass; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1692 r1696  
    389389        SplitQueue viewSpaceQueue; 
    390390 
    391         int vspSteps, ospSteps; 
     391        int vspSteps = 0, ospSteps = 0; 
    392392 
    393393        // use sah for evaluating osp tree construction  
     
    451451        // then optimizate view space partition for the current osp 
    452452        // and vice versa until iteration depth is reached. 
     453 
    453454        bool lastSplitWasOsp = true; 
    454455 
     
    948949                SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue);  
    949950                 
    950                 float rc = (float)sc->GetRenderCostDecrease() / (mInitialRenderCost - mHierarchyStats.mTotalCost + 1.0f); 
    951                 float mc = (float)sc->GetPvsEntriesIncr() / (float)mHierarchyStats.mPvsEntries;  
    952  
     951                const float priority = sc->GetPriority(); 
     952                 
     953                //float rc = (float)sc->GetRenderCostDecrease() / (mInitialRenderCost - mHierarchyStats.mTotalCost + 1.0f); 
     954                //float mc = (float)sc->GetPvsEntriesIncr() / (float)mHierarchyStats.mPvsEntries;        
    953955                //cout << "dRc: " << sc->GetRenderCostDecrease() << " dMem: " << sc->GetPvsEntriesIncr() << " ratio1 " << rc << " ratio2 " << mc << " const: " << 1.0f - GetMemoryConst() << endl; 
    954  
    955                 // minimum slope reached 
    956                 if ((steps > maxSteps) ||  
    957                         ((sc->GetPriority() < threshold) && !(steps < minSteps))) 
    958                 { 
    959                         cout << "\n**************** breaking on " << sc->GetPriority() << " smaller than " << threshold << endl; 
    960                         break; 
    961                 } 
    962956 
    963957                //////// 
     
    969963                if (success) 
    970964                { 
    971                         sc->CollectDirtyCandidates(dirtyCandidates, true); 
     965                        //sc->CollectDirtyCandidates(dirtyCandidates, true); 
    972966                        ++ steps; 
    973967                } 
     968 
     969                DEL_PTR(sc); 
     970 
     971                // minimum slope reached 
     972                if ((steps >= maxSteps) ||  
     973                        ((priority < threshold) && !(steps < minSteps))) 
     974                { 
     975                        cout << "\n**************** breaking on " << priority << " smaller than " << threshold << endl; 
     976                        break; 
     977                } 
     978 
    974979        } 
    975980 
     
    11561161                                                                                  AxisAlignedBox3 *forcedViewSpace) 
    11571162{ 
    1158         // assume object space subdivision constructed 
    1159         //mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
    1160  
    11611163        const long startTime = GetTime(); 
    11621164        const int limit = mNumMultiLevels; 
     
    15381540        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    15391541        { 
    1540                 (*oit)->mVssRays.clear(); 
     1542                (*oit)->DelRayRefs(); 
    15411543        } 
    15421544} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1687 r1696  
    4848  BvhLeaf *mBvhLeaf; 
    4949//BvhNode *mBvhLeaf; 
    50   /// some rays piercing this intersectable 
    51   VssRayContainer mVssRays; 
    52  
     50   
    5351  /// # of references to this instance 
    5452  int mReferences; 
    5553 
    5654  ////////////////// 
    57   // note matt: delete these, they are only taking memory+ 
     55  // note matt: delete these, they are only taking memory 
    5856 
    5957 
     
    7775                }; 
    7876   
    79   Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0) {} 
     77  Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0), mVssRays(NULL) {} 
    8078 
    8179  virtual Intersectable::~Intersectable() {}; 
     
    114112 
    115113  virtual int GetRandomVisibleSurfacePoint(Vector3 &point, 
    116           Vector3 &normal, 
    117           const Vector3 &viewpoint, 
    118           const int maxTries) = 0; 
     114                                                                                   Vector3 &normal, 
     115                                                                                   const Vector3 &viewpoint, 
     116                                           const int maxTries) = 0; 
    119117 
    120118  virtual ostream &Describe(ostream &s) = 0; 
     
    160158  } 
    161159 
    162   /** returns normal from the face with the specified index. 
    163   PROBLEM: Does not fit to all intersectable types (e.g., spheres) 
     160  /** Returns normal from the face with the specified index. 
     161          PROBLEM: Does not fit to all intersectable types (e.g., spheres) 
    164162  */ 
    165163  virtual Vector3 GetNormal(const int idx) const { return Vector3(0, 0, 0); } 
     164 
     165  VssRayContainer *GetOrCreateRays()  
     166  {  
     167          if (!mVssRays) 
     168                mVssRays = new VssRayContainer(); 
     169          return mVssRays; 
     170  } 
     171 
     172  void DelRayRefs() 
     173  { 
     174          DEL_PTR(mVssRays); 
     175  } 
     176 
     177protected: 
     178 
     179  /// some rays piercing this intersectable 
     180  VssRayContainer *mVssRays; 
    166181}; 
    167182 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1695 r1696  
    772772                Environment::GetSingleton()->GetStringValue("Hierarchy.type", buf);      
    773773 
    774                 HierarchyManager *mHierarchyManager = CreateHierarchyManager(buf); 
     774                mHierarchyManager = CreateHierarchyManager(buf); 
    775775                mViewCellsManager = new VspOspViewCellsManager(vcTree, mHierarchyManager); 
    776776        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r1633 r1696  
    428428                        <File 
    429429                                RelativePath="..\src\MutualVisibility.h"> 
     430                        </File> 
     431                        <File 
     432                                RelativePath=".\ObjExporter.cpp"> 
     433                        </File> 
     434                        <File 
     435                                RelativePath=".\ObjExporter.h"> 
    430436                        </File> 
    431437                        <File 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1695 r1696  
    244244        { 
    245245                CLEAR_CONTAINER(mViewCells); 
     246        } 
     247        else 
     248        { 
     249                DEL_PTR(mViewCellsTree); 
    246250        } 
    247251} 
     
    30413045                        {        
    30423046                                // prepare some rays for output 
    3043                                 VssRayContainer::const_iterator rit, rit_end = (*vit)->mVssRays.end(); 
    3044                                 for (rit = (*vit)->mVssRays.begin(); rit != rit_end; ++ rit) 
     3047                                VssRayContainer::const_iterator rit, rit_end = (*vit)->GetOrCreateRays()->end(); 
     3048                                for (rit = (*vit)->GetOrCreateRays()->begin(); rit != rit_end; ++ rit) 
    30453049                                { 
    30463050                                        collectRays.push_back(*rit); 
     
    49684972 
    49694973 
    4970         // should maybe be done here to allow merge working with area or volume 
    4971         // and to correct the rendering statistics 
    4972         if (0) FinalizeViewCells(false); 
    4973                  
    49744974        // compute tree by merging the nodes of the spatial hierarchy 
    49754975        ViewCell *root = ConstructSpatialMergeTree(mHierarchyManager->GetVspTree()->GetRoot()); 
    49764976        mViewCellsTree->SetRoot(root); 
    49774977 
    4978  
    49794978        ////////////////////////// 
    4980         //-- update pvs in the whole hierarchy 
     4979        //-- update pvs up to the root of the hierarchy 
     4980 
    49814981        ObjectPvs pvs; 
    49824982        UpdatePvsForEvaluation(root, pvs); 
     
    50105010        //-- some tasks still to do on the view cells: 
    50115011        //-- Compute meshes from view cell geometry, evaluate volume and / or area 
     5012 
    50125013        if (1) FinalizeViewCells(true); 
    50135014 
    50145015        // write out view cells (this moved to preprocessor) 
    5015         if (1 && mExportViewCells) 
     5016        if (mExportViewCells) 
    50165017        { 
    50175018                char filename[100]; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1692 r1696  
    345345 
    346346VspLeaf::VspLeaf():  
    347 mViewCell(NULL), mPvs(NULL), mSubdivisionCandidate(NULL) 
     347mViewCell(NULL), mSubdivisionCandidate(NULL) 
     348//, mPvs(NULL) 
    348349{ 
    349350} 
     
    352353VspLeaf::~VspLeaf() 
    353354{ 
    354         DEL_PTR(mPvs); 
    355  
    356355        VssRayContainer::const_iterator vit, vit_end = mVssRays.end(); 
    357356        for (vit = mVssRays.begin(); vit != vit_end; ++ vit) 
     
    380379 
    381380VspLeaf::VspLeaf(VspInterior *parent):  
    382 VspNode(parent), mViewCell(NULL), mPvs(NULL) 
     381VspNode(parent), mViewCell(NULL) 
     382//, mPvs(NULL) 
    383383{} 
    384384 
    385385 
    386386VspLeaf::VspLeaf(VspInterior *parent, ViewCellLeaf *viewCell):  
    387 VspNode(parent), mViewCell(viewCell), mPvs(NULL) 
     387VspNode(parent), mViewCell(viewCell) 
     388//, mPvs(NULL) 
    388389{ 
    389390} 
     
    963964        backData.mNode = backLeaf; 
    964965 
    965         // explicitely create front and back view cell 
     966        // create front and back view cell for the new leaves 
    966967        CreateViewCell(frontData, false); 
    967968        CreateViewCell(backData, false); 
     
    28462847        // set view cell values 
    28472848        viewCell->mLeaves.push_back(leaf); 
    2848  
    28492849        viewCell->SetVolume(mBoundingBox.GetVolume()); 
    2850     leaf->mProbability = mBoundingBox.GetVolume(); 
     2850 
     2851        leaf->mProbability = mBoundingBox.GetVolume(); 
    28512852} 
    28522853 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1695 r1696  
    334334         
    335335        /// leaf pvs 
    336         ObjectPvs *mPvs; 
     336        //ObjectPvs *mPvs; 
    337337 
    338338        /// Probability that the view point lies in this leaf 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1695 r1696  
    160160        //be ignored. Use it as you will! 
    161161        //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 
    162 #if 0 
     162#if 1 
    163163  _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 
    164164  _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 
     
    325325          preprocessor->mUseGlDebugger = false; 
    326326        } 
    327          
     327 
    328328        if (!(preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger)) { 
    329           // just call the mail method -> will be executed in the main thread 
    330           pt->Main(); 
    331         } 
    332          
     329                // just call the mail method -> will be executed in the main thread 
     330                pt->Main(); 
     331        }        
     332 
    333333        // release memory 
    334334        Cleanup(); 
Note: See TracChangeset for help on using the changeset viewer.