Changeset 1522


Ignore:
Timestamp:
09/27/06 19:23:51 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
10 edited

Legend:

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

    r1486 r1522  
    489489        const float renderCostDecr = oldRenderCost - newRenderCost; 
    490490 
    491 //#ifdef _DEBUG 
     491#ifdef _DEBUG 
    492492        Debug << "old render cost: " << oldRenderCost << endl; 
    493493        Debug << "new render cost: " << newRenderCost << endl; 
    494494        Debug << "render cost decrease: " << renderCostDecr << endl; 
    495 //#endif 
     495#endif 
    496496        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    497497 
     
    527527                (0 
    528528                || (mBvhStats.Leaves() >= mTermMaxLeaves) 
    529                 || (mBvhStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     529                //|| (mBvhStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    530530                //|| mOutOfMemory  
    531531                ); 
     
    974974 
    975975#ifdef _DEBUG 
    976         Debug << "\n§§§§ eval local cost §§§§" << endl 
     976        Debug << "\n§§§§ bvh eval const decrease §§§§" << endl 
    977977                  << "back pvs: " << (int)objectsBack.size() << " front pvs: " << (int)objectsFront.size() << " total pvs: " << nTotalObjects << endl  
    978978                  << "back p: " << volBack / viewSpaceVol << " front p " << volFront / viewSpaceVol << " p: " << totalVol / viewSpaceVol << endl 
     
    16561656                                                                                                           const ObjectContainer &objects) 
    16571657{ 
    1658         /////////////////////////////////////////////////////////////// 
    1659         //-- note matt: we assume that we have objects sorted by their id =>  
     1658        /////////////////////////////////////// 
     1659        //-- we assume that we have objects sorted by their id =>  
    16601660        //-- we don't have to sort them here and an binary search  
    16611661        //-- for identifying if a object is in a leaf. 
     
    16651665 
    16661666        mBvhStats.nodes = 1; 
    1667          
    1668          
     1667                 
    16691668        // store pointer to this tree 
    16701669        BvhSubdivisionCandidate::sBvHierarchy = this; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1520 r1522  
    12721272   RegisterOption("GvsPreprocessor.epsilon", 
    12731273                 optFloat, 
    1274                  "gvs_epsilon", 
     1274                 "gvs_epsilon=", 
    12751275                 "0.00001"); 
    12761276 
    12771277    RegisterOption("GvsPreprocessor.threshold", 
    12781278                 optFloat, 
    1279                  "gvs_threshold", 
     1279                 "gvs_threshold=", 
    12801280                 "1.5"); 
    12811281 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r1521 r1522  
    88#include "Plane3.h" 
    99#include "RayCaster.h" 
     10#include "Exporter.h" 
    1011 
    1112 
     
    1314{ 
    1415   
     16struct VizStruct 
     17{ 
     18        Polygon3 *enlargedTriangle; 
     19        Triangle3 originalTriangle; 
     20        VssRay *ray; 
     21}; 
     22 
     23static vector<VizStruct> vizContainer; 
    1524 
    1625GvsPreprocessor::GvsPreprocessor(): Preprocessor(), mSamplingType(0) 
     
    5968bool GvsPreprocessor::HandleRay(VssRay *vssRay) 
    6069{ 
    61         if (mViewCellsManager->ComputeSampleContribution(*vssRay, true, false)) 
     70        const int oldContri = vssRay->mPvsContribution; 
     71        mViewCellsManager->ComputeSampleContribution(*vssRay, true, false); 
     72 
     73        if ((vssRay->mPvsContribution - oldContri) > 0) // new contribution 
    6274        { 
    6375                //cout << "h"; 
    6476                mRayQueue.push(vssRay); 
     77                mVssRays.push_back(new VssRay(*vssRay)); 
    6578                return true; 
    6679        } 
     
    159172         
    160173                VssRay *newRay = mRayCaster->CastSingleRay(sray.mOrigin, sray.mDirection, 1, mViewSpaceBox); 
    161                 bool addedToQueue = HandleRay(newRay); 
     174 
     175                if (!newRay) return 0; 
     176                const bool enqueued = HandleRay(newRay); 
    162177                 
    163178                const int s1 = SubdivideEdge(hitTriangle, p1, p, x, *newRay, oldRay); 
     
    165180                return s1 + s2; 
    166181                 
    167                 if (!addedToQueue) 
     182                if (!enqueued) 
    168183                        delete newRay; 
    169184        } 
     
    181196        { 
    182197                hitTriangle = dynamic_cast<TriangleIntersectable *>(tObj)->GetItem(); 
     198                cout << "t: " << hitTriangle << endl << endl; 
     199        } 
     200        else 
     201        { 
     202                cout << "not yet implemented" << endl; 
    183203        } 
    184204 
     
    200220        } 
    201221 
     222        VizStruct dummy; 
     223        dummy.enlargedTriangle = new Polygon3(enlargedTriangle); 
     224        dummy.originalTriangle = hitTriangle; 
     225        //dummy.ray = new VssRay(currentRay); 
     226        vizContainer.push_back(dummy); 
     227 
    202228        // establish visibility 
    203229        VssRayContainer vssRays; 
    204230        CastRays(simpleRays, vssRays, false); 
     231 
    205232        // add to ray queue 
    206233        EnqueueRays(vssRays); 
    207 /* 
     234#if 0 
    208235    // recursivly subdivide each edge 
    209236        for (int i = 0; i < 9; ++ i) 
     
    217244                        currentRay); 
    218245        } 
    219 */ 
     246#endif 
    220247        return (int)vssRays.size(); 
    221248} 
     
    375402        } 
    376403 
     404        Visualize();     
    377405        return true; 
    378406} 
    379407 
    380 } 
     408 
     409void GvsPreprocessor::Visualize() 
     410{ 
     411        Exporter *exporter = Exporter::GetExporter("gvs.wrl"); 
     412 
     413        if (!exporter) 
     414                return; 
     415         
     416        vector<VizStruct>::const_iterator vit, vit_end = vizContainer.end(); 
     417        for (vit = vizContainer.begin(); vit != vit_end; ++ vit) 
     418        { 
     419                cout << "v"; 
     420                exporter->ExportPolygon((*vit).enlargedTriangle); 
     421                //Material m; 
     422                //Polygon3 poly = Polygon3((*vit).originalTriangle); 
     423//              exporter->ExportPolygon(&poly); 
     424        } 
     425 
     426        exporter->ExportRays(mVssRays); 
     427        delete exporter; 
     428} 
     429 
     430} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r1521 r1522  
    100100        void EnqueueRays(VssRayContainer &samples); 
    101101 
    102         /**  
    103                 Hepler function for adaptive border sampling. It finds  
     102        /** Hepler function for adaptive border sampling. It finds  
    104103                new sample points around a triangle in a eps environment 
    105104        */ 
     
    116115                const VssRay &oldRay); 
    117116 
     117        void Visualize(); 
    118118        ////////////////////// 
    119119 
     
    128128        float mEps; 
    129129        float mThreshold; 
     130        VssRayContainer mVssRays; 
    130131}; 
    131132 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1486 r1522  
    243243                ); 
    244244 
    245         if (1 && terminationCriteriaMet) 
     245        if (0 && terminationCriteriaMet) 
    246246        { 
    247247                Debug << "hierarchy global termination criteria met:" << endl; 
     
    331331        cout << "\nstarting view space hierarchy construction ... " << endl; 
    332332 
     333        mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 
     334 
    333335        RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
    334336        SubdivisionCandidate *vsc =  
     
    345347                                                                                                         const ObjectContainer &objects) 
    346348{ 
     349        mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 
     350 
    347351        if (mObjectSpaceSubdivisionType == KD_BASED_OBJ_SUBDIV) 
    348352        { 
     
    407411                // cost ratio of cost decrease / totalCost 
    408412                const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost; 
    409                 Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
     413                //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
    410414         
    411415                if (costRatio < mTermMinGlobalCostRatio) 
     
    606610        cout << "\nresetting bv hierarchy" << endl; 
    607611        mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 
    608         mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses 
     612         
    609613        DEL_PTR(mBvHierarchy); 
    610614        mBvHierarchy = new BvHierarchy(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1521 r1522  
    434434                cout << "loading view cells from " << buf << endl; 
    435435                mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true); 
     436                if (!mViewCellsManager) 
     437                        return false; 
    436438        } 
    437439        else 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r1521 r1522  
    3232        if (!rays.empty()) 
    3333                return rays.back(); 
     34        else 
     35                return NULL; 
    3436} 
    3537 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1520 r1522  
    18301830        { 
    18311831                ViewCell *viewcell = *it; 
    1832  
    1833                 if (viewcell->GetValid()) 
    1834                 { 
    1835                         // if ray not outside of view space 
     1832                 
     1833                if (viewcell->GetValid()) // tests if view cellis in valid view space 
     1834                { 
    18361835                        float contribution; 
    18371836 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1449 r1522  
    562562                // || mOutOfMemory 
    563563                || (mVspStats.Leaves() >= mMaxViewCells) 
    564         || (mVspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance)  
     564      //  || (mVspStats.mGlobalCostMisses >= mTermGlobalCostMissTolerance)  
    565565                ); 
    566566 
     
    571571                Debug << "leaves: " << mVspStats.Leaves() << " " <<  mMaxViewCells << endl; 
    572572        } 
     573 
    573574        return terminationCriteriaMet; 
    574575} 
     
    14821483        const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    14831484 
    1484 //#ifdef _DEBUG 
     1485#ifdef _DEBUG 
    14851486        Debug << "\nvsp render cost decrease" << endl 
    14861487                  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
     
    14881489                  << "old rc: " << normalizedOldRenderCost << " new rc: " << newRenderCost / viewSpaceVol << endl 
    14891490                  << "render cost decrease: " << renderCostDecrease << endl; 
    1490 //#endif 
     1491#endif 
    14911492        return renderCostDecrease; 
    14921493} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1501 r1522  
    164164 
    165165        // parse view cells related options 
    166         preprocessor->PrepareViewCells(); 
     166        if (!preprocessor->PrepareViewCells()) 
     167        { 
     168                Cleanup(); 
     169                exit(1); 
     170        } 
    167171 
    168172        if (0)  
Note: See TracChangeset for help on using the changeset viewer.