Changeset 1778


Ignore:
Timestamp:
11/21/06 19:41:11 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
4 edited

Legend:

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

    r1774 r1778  
    4040 
    4141 
     42/// sorting operator 
     43inline static bool ilt2(Intersectable *obj1, Intersectable *obj2) 
     44{ 
     45        return obj1->GetBox().SurfaceArea() < obj2->GetBox().SurfaceArea(); 
     46} 
     47 
    4248/***************************************************************/ 
    4349/*              class BvhNode implementation                   */ 
     
    219225        ReadEnvironment(); 
    220226        mSubdivisionCandidates = new SortableEntryContainer; 
    221         for (int i = 0; i < 3; ++ i) 
     227        for (int i = 0; i < 4; ++ i) 
    222228                mSortedObjects[i] = NULL; 
    223229} 
     
    230236 
    231237        // delete the presorted objects 
    232         for (int i = 0; i < 3; ++ i) 
     238        for (int i = 0; i < 4; ++ i) 
    233239        { 
    234240                DEL_PTR(mSortedObjects[i]); 
     
    11941200        ofstream volrStats; 
    11951201 
    1196         const bool printStats = 
    1197                 PrepareOutput(axis, mBvhStats.Leaves(), sumStats, vollStats, volrStats); 
     1202        const bool printStats = PrepareOutput(axis,  
     1203                                                                                  mBvhStats.Leaves(),  
     1204                                                                                  sumStats,  
     1205                                                                                  vollStats,  
     1206                                                                                  volrStats); 
    11981207#endif 
    11991208 
     
    13461355        // collect and mark the view cells as belonging to front pvs 
    13471356        ViewCellContainer viewCells; 
    1348         CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 
    1349          
     1357 
     1358        const int numRays = CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 
     1359        //cout << "here4 " << numRays << endl; 
     1360 
    13501361        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    13511362        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
     
    14431454                sAxis = box.Size().DrivingAxis(); 
    14441455        } 
    1445  
    14461456 
    14471457        // only use a subset of the rays for visibility based heuristics 
     
    17431753 
    17441754                if (onlyMailedRays && !ray->Mailed()) 
     1755                {//if (onlyMailedRays)cout << "u"; 
    17451756                        continue; 
     1757                }//else if (onlyMailedRays) cout << "z"; 
    17461758 
    17471759                //ray->Mail(); 
     
    21392151                } 
    21402152        } 
     2153 
     2154        // create new objects 
     2155        if (!mSortedObjects[3]) 
     2156        { 
     2157                mSortedObjects[3] = new SortableEntryContainer(); 
     2158        } 
     2159/* 
     2160        // last sorted list: by size 
     2161        tData.mSortedObjects[3] = new ObjectContainer(); 
     2162        tData.mSortedObjects[3]->reserve((int)mSortedObjects[i]->size()); 
     2163 
     2164        SortableEntryContainer::const_iterator oit, oit_end = mSortedObjects[i]->end(); 
     2165 
     2166        for (oit = mSortedObjects[3]->begin(); oit != oit_end; ++ oit) 
     2167        { 
     2168                tData.mSortedObjects[3]->push_back((*oit).mObject); 
     2169        } 
     2170*/ 
    21412171} 
    21422172 
     
    24432473 
    24442474 
    2445 void BvHierarchy::InititialSubdivision() 
    2446 { 
    2447 } 
    2448  
    2449  
    2450 void ChooseSplitPlane(BvhLeaf *leaf) 
    2451 {/* 
    2452 std::stable_sort(objects.begin(), objects.end(), ilt); 
    2453          
    2454         // intersected objects 
    2455         MeshInstance sObj(NULL); 
    2456          
    2457         if (sObj.mId >= 0) 
    2458         { 
    2459                         ObjectContainer::iterator oit = 
    2460                                 lower_bound(objects.begin(), objects.end(), &sObj, ilt); 
    2461                         sourceObj = *oit; 
    2462                 } 
    2463 */       
    2464 } 
    2465  
    2466  
    2467 bool BvHierarchy::InitialTerminationCriteriaMet(BvhLeaf *leaf) 
    2468 { 
    2469         /*if (((int)leaf->mObjects.size() < mInititialObjectsSize) || 
    2470                 (leaf->mObjects.end().GetBoundingBox().SurfaceArea() < mMinInitialSuffaceArea)) 
    2471  
    2472         { 
    2473         return true;  
     2475void BvHierarchy::InititialSubdivision(ObjectContainer &objects) 
     2476{ 
     2477        /*std::stable_sort(objects.begin(), objects.end(), ilt2); 
     2478        ObjectContainer::iterator oit; 
     2479 
     2480        stack<BvhLeaf *> tStack; 
     2481 
     2482        while (!tStack.empty()) 
     2483        { 
     2484                BvhLeaf *leaf = tStack.top(); 
     2485 
     2486                if (!InitialTerminationCriteriaMet(leaf)) 
     2487                { 
     2488                        ChooseSplitIndex(objects, oit); 
     2489                        SubdivideLeaf(leaf, oit); 
     2490                } 
    24742491        }*/ 
     2492} 
     2493 
     2494 
     2495void BvHierarchy::ChooseSplitIndex(const ObjectContainer &objects,  
     2496                                                                   ObjectContainer::const_iterator &oit) 
     2497{ 
     2498        ObjectContainer::const_iterator oit2, oit2_end = objects.end(); 
     2499     
     2500        float maxAreaDiff = 0.0f; 
     2501 
     2502        for (oit2 = objects.begin(); oit2 != (objects.end() - 1); ++ oit2) 
     2503        { 
     2504                Intersectable *obj = *oit2; 
     2505                Intersectable *obj2 = *(oit2 + 1); 
     2506                 
     2507                const float areaDiff =  
     2508                        fabs(obj->GetBox().SurfaceArea() - obj2->GetBox().SurfaceArea()); 
     2509 
     2510                if (areaDiff > maxAreaDiff) 
     2511                { 
     2512                        maxAreaDiff = areaDiff; 
     2513                        oit = oit2; 
     2514                } 
     2515        } 
     2516} 
     2517 
     2518 
     2519bool BvHierarchy::InitialTerminationCriteriaMet(BvhLeaf *leaf) const 
     2520{ 
     2521        if (((int)leaf->mObjects.size() < mInititialObjectsSize) || 
     2522                (leaf->mObjects.back()->GetBox().SurfaceArea() < mMinInitialSurfaceArea)) 
     2523 
     2524        { 
     2525                return true;  
     2526        } 
     2527 
    24752528        return false; 
    24762529} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1774 r1778  
    404404                mNumRays(0) 
    405405                { 
    406                         mSortedObjects[0] = mSortedObjects[1] = mSortedObjects[2] = NULL; 
     406                        for (int i = 0; i < 4; ++ i) 
     407                                mSortedObjects[i] = NULL; 
    407408                } 
    408409                 
     
    419420                mNumRays(numRays) 
    420421                { 
    421                         mSortedObjects[0] = mSortedObjects[1] = mSortedObjects[2] = NULL; 
     422                        for (int i = 0; i < 4; ++ i) 
     423                                mSortedObjects[i] = NULL; 
    422424                } 
    423425 
     
    427429                { 
    428430                        DEL_PTR(mNode); 
    429                         DEL_PTR(mSortedObjects[0]); 
    430                         DEL_PTR(mSortedObjects[1]); 
    431                         DEL_PTR(mSortedObjects[2]); 
     431                        for (int i = 0; i < 4; ++ i) 
     432                                DEL_PTR(mSortedObjects[i]); 
    432433                } 
    433434 
     
    447448                int mNumRays; 
    448449                /// the sorted objects for the three dimensions 
    449                 ObjectContainer *mSortedObjects[3];              
     450                ObjectContainer *mSortedObjects[4];              
    450451    }; 
    451452 
     
    895896                some criteria (size, shader) 
    896897        */ 
    897         void InititialSubdivision(); 
    898  
    899         void ChooseSplitPlane(BvhLeaf *leaf); 
    900  
    901         bool InitialTerminationCriteriaMet(BvhLeaf *leaf); 
    902         float mMinInitialSuffaceArea; 
     898        void InititialSubdivision(ObjectContainer &objects); 
     899 
     900        void ChooseSplitIndex(const ObjectContainer &objects,  
     901                                                  ObjectContainer::const_iterator &oit); 
     902 
     903        bool InitialTerminationCriteriaMet(BvhLeaf *leaf) const; 
     904        float mMinInitialSurfaceArea; 
     905int mInititialObjectsSize; 
    903906protected: 
    904907         
     
    987990        bool mUseBboxAreaForSah; 
    988991 
    989         SortableEntryContainer *mSortedObjects[3]; 
     992        SortableEntryContainer *mSortedObjects[4]; 
    990993 
    991994        int mMinRaysForVisibility; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1764 r1778  
    3030 
    3131 
     32 
    3233/*******************************************************************/ 
    3334/*              class HierarchyManager implementation              */ 
     
    18991900                float rc = 0; 
    19001901        ObjectPvs pvs; 
    1901                 mVspTree->mViewCellsTree->GetPvs(vc, pvs); 
    1902  
     1902                 
     1903                //mVspTree->mViewCellsTree->GetPvs(vc, pvs); 
     1904                GetPvsIncrementally(vc, pvs); 
     1905                 
    19031906                vc->SetPvs(pvs); 
    19041907 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1773 r1778  
    129129        { 
    130130                mStrategies.push_back(SamplingStrategy::VIEWSPACE_BORDER_BASED_DISTRIBUTION); 
     131 
     132                // ratio 3:1 
     133                mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 
     134                mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 
    131135                mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 
    132136        } 
     
    405409 
    406410        // cast initial samples 
     411         
     412        // mix of sampling strategies 
     413        vector<int>dummy; 
     414        //dummy.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 
     415        //dummy.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
     416        //dummy.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 
     417 
    407418        CastPassSamples(mInitialSamples, mStrategies, initialSamples); 
    408419 
     
    561572        if (mShowVisualization) 
    562573        { 
    563                 cout << "************************\n*********************\n"; 
    564574                if (0) 
    565575                { 
     
    59986008                Debug << "casting " << samplesPerPass << " samples ... "; 
    59996009 
     6010                vector<int>dummyStrat; 
     6011         
     6012                dummyStrat.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 
     6013                dummyStrat.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
     6014                dummyStrat.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 
     6015                //dummyStrat.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 
     6016 
    60006017                CastPassSamples(samplesPerPass, mStrategies, evaluationSamples); 
    60016018                 
Note: See TracChangeset for help on using the changeset viewer.