Changeset 2048


Ignore:
Timestamp:
01/24/07 01:33:39 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
22 edited

Legend:

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

    r2017 r2048  
    21142114                BvhLeaf *leaf = static_cast<BvhLeaf *>(node); 
    21152115                const AxisAlignedBox3 box = leaf->GetBoundingBox(); 
    2116                 stream << "<Leaf" 
     2116                stream << "<Leaf id=\"" << node->GetId() << "\"" 
    21172117                           << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    21182118                           << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\"" 
     
    21302130                const AxisAlignedBox3 box = interior->GetBoundingBox(); 
    21312131 
    2132                 stream << "<Interior" 
     2132                stream << "<Interior id=\"" << node->GetId() << "\"" 
    21332133                           << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    21342134                           << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z 
  • GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp

    r2046 r2048  
    7474   
    7575  long startTime = GetTime(); 
     76 
    7677  for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) { 
    7778        mRayCaster->InitPass(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r2046 r2048  
    12961296                 "1000000"); 
    12971297    
    1298    RegisterOption("GvsPreprocessor.samplesPerPass", 
     1298   RegisterOption("GvsPreprocessor.gvsSamplesPerPass", 
    12991299                 optInt, 
    13001300                 "gvs_samples_per_pass=", 
     
    16111611                "view_cells_compress_objects=",  
    16121612                "false"); 
    1613  
    16141613         
    16151614        RegisterOption("ViewCells.useKdPvs", 
     
    16181617                "false"); 
    16191618 
    1620          
    16211619        RegisterOption("ViewCells.useKdPvsAfterFiltering", 
    16221620                                   optBool,  
     
    16241622                                   "false"); 
    16251623 
    1626  
    1627          
     1624        RegisterOption("ViewCells.importRandomViewCells", 
     1625                                   optBool,  
     1626                                   "view_cells_import_random_viewcells=",  
     1627                                   "false"); 
     1628 
     1629        RegisterOption("ViewCells.exportRandomViewCells", 
     1630                                   optBool,  
     1631                                   "view_cells_export_random_viewcells=",  
     1632                                   "false"); 
     1633 
     1634 
    16281635 
    16291636        /****************************************************************************/ 
     
    17841791        RegisterOption("BspTree.Factor.pvs", optFloat, "bsp_factor_pvs=", "1.0"); 
    17851792 
    1786         /************************************************************************************/ 
    1787         /*                         Preprocessor related options                             */ 
    1788         /************************************************************************************/ 
     1793 
     1794 
     1795 
     1796        /**********************************************************************/ 
     1797        /*                     Preprocessor related options                   */ 
     1798        /**********************************************************************/ 
    17891799 
    17901800        RegisterOption("Preprocessor.type", 
     
    18631873                                   "false"); 
    18641874         
     1875        RegisterOption("Preprocessor.evaluatePixelError", 
     1876                                   optBool, 
     1877                                   "preprocessor_evaluatePixelError", 
     1878                                   "false"); 
     1879 
    18651880        RegisterOption("Preprocessor.applyVisibilitySpatialFilter", 
    18661881                                   optBool, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2023 r2048  
    860860GlRendererBuffer::EvalPvsStat() 
    861861{ 
    862 cout<<"here15"<<endl; 
    863   MakeCurrent(); 
    864  
    865   GlRenderer::EvalPvsStat(); 
    866    
    867   DoneCurrent(); 
    868   cout<<"here185"<<endl; 
     862        MakeCurrent(); 
     863 
     864        GlRenderer::EvalPvsStat(); 
     865 
     866        DoneCurrent(); 
    869867  //  mRenderingFinished.wakeAll(); 
     868} 
     869 
     870 
     871void GlRendererBuffer::EvalPvsStat(const SimpleRayContainer &viewPoints) 
     872{ 
     873        MakeCurrent(); 
     874 
     875        GlRenderer::EvalPvsStat(viewPoints); 
     876   
     877        DoneCurrent(); 
    870878} 
    871879 
     
    12911299 
    12921300bool GlRendererBuffer::ValidViewPoint() 
    1293 {       cout << "here49" << endl; 
    1294         /*MakeCurrent(); 
     1301{        
     1302        MakeCurrent(); 
     1303 
     1304        SetupProjection(GetWidth(), GetHeight()); 
    12951305 
    12961306        bool result = GlRenderer::ValidViewPoint(); 
     1307 
    12971308        DoneCurrent(); 
    1298 */bool result = true; 
     1309         
    12991310        return result; 
    13001311} 
     
    13041315GlRenderer::EvalPvsStat() 
    13051316{ 
    1306 cout <<"here3399"<<endl; 
    13071317  mPvsStat.Reset(); 
    13081318  halton.Reset(); 
     
    13721382} 
    13731383 
     1384 
     1385void GlRenderer::EvalPvsStat(const SimpleRayContainer &viewPoints) 
     1386{ 
     1387        ClearErrorBuffer(); 
     1388 
     1389        mPvsStat.Reset(); 
     1390        halton.Reset(); 
     1391 
     1392        SetupProjection(GetWidth(), GetHeight()); 
     1393 
     1394        cout << "mPvsStatFrames=" << mPvsStatFrames << endl; 
     1395 
     1396        SimpleRayContainer::const_iterator sit, sit_end = viewPoints.end(); 
     1397        int i = 0; 
     1398 
     1399        for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i)  
     1400        { 
     1401                //cout << "view point: " << (*sit) << endl;; 
     1402                SimpleRay sray = *sit; 
     1403 
     1404                float err; 
     1405 
     1406                // set frame id for saving the error buffer 
     1407                mFrame = i; 
     1408                mViewPoint = sray.mOrigin; 
     1409                mViewDirection = sray.mDirection; 
     1410 
     1411                if (0 && (mPvsErrorBuffer[i].mError == 1.0f)) 
     1412                { 
     1413                        // check if the view point is valid 
     1414                        if (!ValidViewPoint()) 
     1415                        { 
     1416                                cout << "error: " << " view point invalid" << endl; 
     1417                                mPvsErrorBuffer[i].mError = -1.0f; 
     1418                        } 
     1419                        else 
     1420                        { 
     1421                                cout << "view point valid" << endl; 
     1422                        } 
     1423                } 
     1424 
     1425                if (mPvsErrorBuffer[i].mError > 0.0f)  
     1426                { 
     1427                        int pvsSize; 
     1428 
     1429                        // compute the pixel error 
     1430                        float error = GetPixelError(pvsSize); 
     1431 
     1432                        mPvsErrorBuffer[i].mError = error; 
     1433                        mPvsErrorBuffer[i].mPvsSize = pvsSize; 
     1434 
     1435                        cout << "(" << i << "," << mPvsErrorBuffer[i].mError <<")"; 
     1436                } 
     1437 
     1438                err = mPvsErrorBuffer[i].mError; 
     1439 
     1440                if (err >= 0.0f)  
     1441                { 
     1442                        if (err > mPvsStat.maxError) 
     1443                                mPvsStat.maxError = err; 
     1444 
     1445                        mPvsStat.sumError += err; 
     1446                        mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
     1447 
     1448                        if (err == 0.0f) 
     1449                                ++ mPvsStat.errorFreeFrames; 
     1450 
     1451                        ++ mPvsStat.frames; 
     1452                } 
     1453        } 
     1454 
     1455        glFinish(); 
     1456        cout << endl << flush; 
     1457} 
     1458 
     1459 
     1460 
    13741461bool 
    13751462GlRenderer::ValidViewPoint() 
    13761463{ 
    1377   if (!mDetectEmptyViewSpace) 
    1378         return true; 
     1464   //cout<<"VV4 "; 
     1465        if (!mDetectEmptyViewSpace) 
     1466                return true; 
     1467        //cout << "vp: " << mViewPoint << " dir: " << mViewDirection << endl; 
    13791468 
    13801469  OcclusionQuery *query = mOcclusionQueries[0]; 
     
    14151504  //  cout<<"VV4 "; 
    14161505   
     1506          //cout<<"count: " << pixelCount<<endl; 
     1507   
    14171508  if (pixelCount > 0) 
    1418   {cout<<"count: " << pixelCount<<endl; 
     1509  { 
    14191510        return false; // backfacing polygon found -> not a valid viewspace sample 
    14201511  } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2023 r2048  
    2626class TriangleIntersectable; 
    2727 class BvhNode; 
    28    
     28  class SimpleRayContainer; 
     29 
    2930struct VssRayContainer; 
    3031 
     
    152153  virtual void 
    153154  EvalPvsStat(); 
     155 
     156  virtual void EvalPvsStat(const SimpleRayContainer &viewPoints); 
    154157 
    155158  virtual void InitGL(); 
     
    272275        virtual void EvalPvsStat(); 
    273276 
     277        virtual void EvalPvsStat(const SimpleRayContainer &viewPoints); 
    274278 
    275279        virtual int GetWidth() const = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2017 r2048  
    2525}; 
    2626 
     27 
    2728static const float MIN_DIST = 0.001f; 
    2829 
     
    3738        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); 
    3839        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.initialSamples", mInitialSamples); 
    39         Environment::GetSingleton()->GetIntValue("GvsPreprocessor.samplesPerPass", mSamplesPerPass); 
     40        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.gvsSamplesPerPass", mGvsSamplesPerPass); 
    4041        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.minContribution", mMinContribution); 
    4142        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.epsilon", mEps); 
     
    4445        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.maxViewCells", mMaxViewCells); 
    4546 
     47        Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError", mEvaluatePixelError); 
     48 
    4649        char gvsStatsLog[100]; 
    4750        Environment::GetSingleton()->GetStringValue("GvsPreprocessor.stats", gvsStatsLog); 
     
    5154        Debug << "number of total samples: " << mTotalSamples << endl; 
    5255        Debug << "number of initial samples: " << mInitialSamples << endl; 
    53         Debug << "number of samples per pass: " << mSamplesPerPass << endl; 
     56        cout << "number of gvs samples per pass: " << mGvsSamplesPerPass << endl; 
     57        cout << "number of samples per pass: " << mSamplesPerPass << endl; 
    5458        Debug << "threshold: " << mThreshold << endl; 
    5559        Debug << "epsilon: " << mEps << endl; 
     
    8387                mRayQueue.pop(); 
    8488 
    85                 delete ray; 
     89                //delete ray; 
    8690        } 
    8791} 
     
    141145                if (!HandleRay(newRay)) 
    142146                { 
    143                         delete newRay; 
    144                 } 
    145                  
    146  
     147                        //delete newRay; 
     148                } 
     149                 
    147150                return 1; 
    148151        } 
     
    286289                                                                   const VssRay &ray2, 
    287290                                                                   const VssRay &oldRay) 
    288 {//cout <<"x"<<Magnitude(p1 - p2) << " "; 
     291{ 
     292        //cout <<"y"<<Magnitude(p1 - p2) << " "; 
    289293        int castRays = 0; 
    290294 
     
    320324 
    321325        // this ray will not be further processed 
    322         if (!enqueued) 
    323                 delete newRay; 
     326        //if (!enqueued) delete newRay; 
    324327 
    325328        return castRays; 
     
    339342        else 
    340343        { 
    341                 cout << "not yet implemented" << endl; 
     344                cout << "border sampling: " << tObj->Type() << " not yet implemented" << endl; 
    342345        } 
    343346 
     
    427430 
    428431        CLEAR_CONTAINER(invalidSamples); 
    429 //cout << "***********"<< endl; 
     432         
     433        //cout << "cast rays: " << castRays << endl; 
    430434        return castRays; 
    431435} 
     
    495499        // other types not implemented yet 
    496500        if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE) 
     501        { 
    497502                occluder = static_cast<TriangleIntersectable *>(tObj)->GetItem(); 
     503        } 
    498504        else 
    499                 cout << "not yet implemented" << endl; 
    500          
     505        { 
     506                cout << "reverse sampling: " << tObj->Type() << " not yet implemented" << endl; 
     507        } 
    501508        // get a point which is passing just outside of the occluder 
    502509    Vector3 newPoint; 
     
    603610        ++ mGvsStats.mGvsPass; 
    604611 
    605         while (!mRayQueue.empty()  
    606                 )//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) ) 
     612        while (!mRayQueue.empty())//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) ) 
    607613        { 
    608614                // handle next ray 
     
    614620                castSamples += newSamples; 
    615621 
    616                 //cout << "new samples: " << newSamples << " " << "queue: "  << (int)mRayQueue.size() << endl; 
    617                 delete ray; 
     622                //delete ray; 
     623        } 
     624 
     625        // HACK 
     626        if (mRayCaster->mVssRayPool.mIndex > mSamplesPerPass) 
     627        { 
     628                cout << "warning: new samples: " << castSamples << " " << "queue: "  << (int)mRayQueue.size() << endl; 
     629                Debug << "warning: new samples: " << castSamples << " " << "queue: "  << (int)mRayQueue.size() << endl; 
    618630        } 
    619631 
     
    753765{ 
    754766        //Intersectable::NewMail(); 
     767 
    755768        // compute direct intersections with view cell 
    756769        IntersectWithViewCell(); 
     
    763776        while (1)  
    764777        { 
     778                mRayCaster->InitPass(); 
     779 
    765780                // Ray queue empty =>  
    766781                // cast a number of uniform samples to fill ray queue 
     
    773788                mGvsStats.mPerViewCellSamples += newSamples; 
    774789                 
    775  
    776                 if (passSamples >= mSamplesPerPass) 
     790                if (passSamples >= mGvsSamplesPerPass) 
    777791                { 
    778792                        ++ mPass; 
    779  
    780793                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 
    781794 
     
    805818void GvsPreprocessor::CompileViewCellsList() 
    806819{ 
     820        vector<ViewCellPoints *> *vcPoints = mViewCellsManager->GetViewCellPoints(); 
     821 
     822        if (!vcPoints->empty()) 
     823        { 
     824                vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end(); 
     825 
     826                for (vit = vcPoints->begin(); vit != vit_end; ++ vit) 
     827                { 
     828                        mViewCells.push_back((*vit)->first); 
     829                } 
     830 
     831                return; 
     832        } 
     833 
    807834        while ((int)mViewCells.size() < mMaxViewCells) 
    808835    { 
     
    886913                (*oit)->mCounter = 0; 
    887914        } 
    888         long lastTime = GetTime(); 
    889  
    890         while (NextViewCell()) 
    891         { 
     915//int dummy = 0; 
     916        while (NextViewCell())// && (dummy < 3)) 
     917        {//++ dummy; 
     918                long startTime = GetTime(); 
    892919                cout << "\n***********************\n"  
    893920                         << "processing view cell " << mProcessedViewCells  
     
    907934                GetObjectPvs(objectPvs); 
    908935 
    909                 cout << "triangle pvs of " << (int)mTrianglePvs.size() << " was converted to object pvs of " << (int)objectPvs.size() << endl; 
     936                cout << "triangle pvs of " << (int)mTrianglePvs.size()  
     937                         << " was converted to object pvs of " << (int)objectPvs.size() << endl; 
    910938 
    911939                //////// 
     
    922950                const long currentTime = GetTime(); 
    923951         
    924                 mGvsStats.mTimePerViewCell = TimeDiff(lastTime, currentTime) * 1e-3f; 
     952                mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f; 
    925953                mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 
    926954 
    927                 lastTime = currentTime; 
     955                //lastTime = currentTime; 
    928956 
    929957                mGvsStats.Stop(); 
     
    940968 
    941969                // is this really necessary? 
    942                 ClearRayQueue(); 
     970                //ClearRayQueue(); 
     971 
     972                if (mEvaluatePixelError || mExportVisibility) 
     973                { 
     974                        StorePvs(objectPvs); 
     975                } 
     976        } 
     977} 
     978 
     979 
     980void GvsPreprocessor::StorePvs(const ObjectContainer &objectPvs) 
     981{ 
     982        ObjectContainer::const_iterator oit, oit_end = objectPvs.end(); 
     983 
     984        for (oit = objectPvs.begin(); oit != oit_end; ++ oit) 
     985        { 
     986                mCurrentViewCell->GetPvs().AddSample(*oit, 1); 
     987        } 
     988} 
     989 
     990 
     991void GvsPreprocessor::ComputeRenderError() 
     992{ 
     993        cout << "computing gvs render error" << endl; 
     994        vector<ViewCellPoints *> *vcPoints = mViewCellsManager->GetViewCellPoints(); 
     995 
     996        vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end(); 
     997 
     998        for (vit = vcPoints->begin(); vit != vit_end; ++ vit) 
     999        { 
     1000                ViewCellPoints *vcPoints = *vit; 
     1001                 
     1002                renderer->EvalPvsStat(vcPoints->second); 
     1003 
     1004                mStats << 
     1005                        "#ViewCell\n" << vcPoints->first->GetId() << endl << 
     1006                        "#AvgPvsRenderError\n" <<renderer->mPvsStat.GetAvgError() << endl << 
     1007                        "#AvgPixelError\n" << renderer->GetAvgPixelError() << endl << 
     1008                        "#MaxPixelError\n" << renderer->GetMaxPixelError() << endl << 
     1009                        "#MaxPvsRenderError\n" << renderer->mPvsStat.GetMaxError() << endl << 
     1010                        "#ErrorFreeFrames\n" << renderer->mPvsStat.GetErrorFreeFrames() << endl << 
     1011                        "#AvgRenderPvs\n" << renderer->mPvsStat.GetAvgPvs() << endl; 
    9431012        } 
    9441013} 
     
    10071076        while (mGvsStats.mTotalSamples < mTotalSamples)  
    10081077        { 
     1078                mRayCaster->InitPass(); 
    10091079                // Ray queue empty =>  
    10101080                // cast a number of uniform samples to fill ray queue 
     
    10171087                mGvsStats.mTotalSamples += newSamples; 
    10181088 
    1019                 if (passSamples % (mSamplesPerPass + 1) == mSamplesPerPass) 
     1089                if (passSamples % (mGvsSamplesPerPass + 1) == mGvsSamplesPerPass) 
    10201090                { 
    10211091                        ++ mPass; 
     
    10751145                // list of view cells to compute 
    10761146                CompileViewCellsList(); 
    1077  
    10781147                PerViewCellComputation(); 
     1148 
     1149                if (mEvaluatePixelError) 
     1150                { 
     1151                        ComputeRenderError(); 
     1152                } 
    10791153        } 
    10801154        else 
     
    10901164                CLEAR_CONTAINER(mVssRays); 
    10911165        } 
     1166         
     1167        // export the preprocessed information to a file 
     1168        if (0 && mExportVisibility) 
     1169        { 
     1170                ExportPreprocessedData(mVisibilityFileName); 
     1171        } 
    10921172 
    10931173        return true; 
     1174} 
     1175 
     1176 
     1177void GvsPreprocessor::DeterminePvsObjects(VssRayContainer &rays) 
     1178{ 
     1179        mViewCellsManager->DeterminePvsObjects(rays, true); 
    10941180} 
    10951181 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2003 r2048  
    215215        void IntersectWithViewCell(); 
    216216 
     217        void DeterminePvsObjects(VssRayContainer &rays); 
     218 
     219        virtual void ComputeRenderError(); 
     220 
     221        void StorePvs(const ObjectContainer &objectPvs); 
     222 
     223 
    217224        ////////////////////// 
    218225 
    219  
    220         int mSamplesPerPass; 
    221         int mTotalSamples; 
     226        //int mSamplesPerPass; 
     227        //int mTotalSamples; 
    222228        int mInitialSamples; 
    223229 
     
    230236        VssRayContainer mVssRays; 
    231237         
     238 
     239 
    232240        /////////// 
    233241        // stats 
     
    250258 
    251259        ObjectContainer mTrianglePvs; 
     260 
     261        // HACK 
     262        int mGvsSamplesPerPass; 
     263 
     264        bool mComputeRenderError; 
     265 
     266        bool mEvaluatePixelError; 
    252267}; 
    253268 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1999 r2048  
    6464                 BVH_INTERSECTABLE, 
    6565                 TRIANGLE_INTERSECTABLE, 
    66                  OBJECTS_INTERSECTABLE 
     66                 OBJECTS_INTERSECTABLE, 
     67                 DUMMY_INTERSECTABLE 
    6768                }; 
    6869   
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r1999 r2048  
    188188{ 
    189189public: 
    190         TriangleIntersectable(Triangle3 item): 
     190        TriangleIntersectable(const Triangle3 &item): 
    191191        IntersectableWrapper<Triangle3>(item) {} 
    192192 
     
    220220 
    221221 
     222class DummyIntersectable: public IntersectableWrapper<int> 
     223{ 
     224public: 
     225  DummyIntersectable(const int item): 
     226        IntersectableWrapper<int>(item) {} 
     227 
     228        int Type() const 
     229        { 
     230                return Intersectable::DUMMY_INTERSECTABLE; 
     231        } 
     232}; 
     233 
    222234} 
    223235 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp

    r2035 r2048  
    712712  sray = SimpleRay(origin, direction, MUTATION_BASED_DISTRIBUTION, pdf); 
    713713  sray.mGeneratorId = index; 
     714 
     715  return true; 
    714716} 
    715717 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2047 r2048  
    155155        Environment::GetSingleton()->GetStringValue("Preprocessor.stats",  buffer); 
    156156        mStats.open(buffer); 
    157          
    158          
     157                 
    159158        Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilityFilter", mApplyVisibilityFilter); 
    160159        Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", 
     
    182181        Debug << "export obj: " << mExportObj << endl; 
    183182        Debug << "use view space box: " << mUseViewSpaceBox << endl; 
     183 
     184        cout << "samples per pass " << mSamplesPerPass << endl; 
    184185} 
    185186 
     
    262263} 
    263264 
    264 #define POWERPLANT_HACK 1 
    265265 
    266266bool Preprocessor::LoadBinaryObj(const string filename, 
     
    12041204         
    12051205        // reserve constant block of rays 
    1206         mRayCaster->ReserveVssRayPool(2*mSamplesPerPass); 
     1206        cout << "======================" << endl; 
     1207        cout << "reserving " << 2 * mSamplesPerPass << " rays " << endl; 
     1208        mRayCaster->ReserveVssRayPool(2 * mSamplesPerPass); 
    12071209         
    12081210        return true; 
     
    13111313        } 
    13121314 
    1313         mViewCellsManager->DeterminePvsObjects(vssRays 
    1314                                                                                    ); 
    1315          
     1315        DeterminePvsObjects(vssRays); 
    13161316} 
    13171317 
     
    15301530} 
    15311531 
    1532 } 
     1532 
     1533void Preprocessor::DeterminePvsObjects(VssRayContainer &rays) 
     1534{ 
     1535        mViewCellsManager->DeterminePvsObjects(rays, false); 
     1536} 
     1537 
     1538 
     1539} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2046 r2048  
    129129                           ); 
    130130 
    131   bool 
    132   ExportRayAnimation(const char *filename, 
    133                                          const vector<VssRayContainer> &vssRays 
    134                                          ); 
    135  
    136         virtual int 
    137                 GenerateRays(const int number, 
    138                 SamplingStrategy &strategy, 
    139                 SimpleRayContainer &rays); 
     131        bool ExportRayAnimation(const char *filename, 
     132                                                        const vector<VssRayContainer> &vssRays); 
     133 
     134        virtual int     GenerateRays(const int number, 
     135                                                         SamplingStrategy &strategy, 
     136                                                         SimpleRayContainer &rays); 
    140137 
    141138        virtual int GenerateRays(const int number, 
    142                 const int raysType, 
    143                 SimpleRayContainer &rays); 
     139                                                         const int raysType, 
     140                                                         SimpleRayContainer &rays); 
    144141 
    145142        bool GenerateRayBundle(SimpleRayContainer &rayBundle, 
    146                 const SimpleRay &mainRay, 
    147                 const int number, 
    148                 const int shuffleType) const; 
     143                                                   const SimpleRay &mainRay, 
     144                                                   const int number, 
     145                                                   const int shuffleType) const; 
    149146 
    150147        virtual void CastRays(SimpleRayContainer &rays, 
     
    153150                                                  const bool pruneInvalidRays = true); 
    154151 
    155         /** Compute pixel error of the current PVS solution by sampling given number of viewpoints */ 
     152        /** Compute pixel error of the current PVS solution by sampling given number of viewpoints . 
     153        */ 
    156154        virtual void ComputeRenderError(); 
    157155 
     
    179177        PreprocessorThread *GetThread() const; 
    180178 
    181          
    182179        Intersectable *GetObjectById(const int id); 
    183180 
    184181        void PrepareHwGlobalLines(); 
     182 
     183        virtual void DeterminePvsObjects(VssRayContainer &rays); 
     184 
     185 
    185186        //////////////////////////////////////////////// 
    186187 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2023 r2048  
    221221                                OptimizeForProcessor="3" 
    222222                                OptimizeForWindowsApplication="TRUE" 
    223                                 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(CG_INC_PATH)&quot;" 
    224                                 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT;USE_CG" 
     223                                AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(CG_INC_PATH)&quot;;Timer" 
     224                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT" 
    225225                                ExceptionHandling="TRUE" 
    226226                                RuntimeLibrary="2" 
     
    377377                        </File> 
    378378                        <File 
     379                                RelativePath=".\Timer\BenchTimer.cpp"> 
     380                        </File> 
     381                        <File 
     382                                RelativePath=".\Timer\BenchTimer.h"> 
     383                        </File> 
     384                        <File 
    379385                                RelativePath="..\src\BoostPreprocessorThread.cpp"> 
    380386                        </File> 
     
    527533                        </File> 
    528534                        <File 
     535                                RelativePath=".\Timer\merror.cpp"> 
     536                        </File> 
     537                        <File 
     538                                RelativePath=".\Timer\merror.h"> 
     539                        </File> 
     540                        <File 
    529541                                RelativePath="..\src\Mesh.cpp"> 
    530542                        </File> 
     
    539551                        </File> 
    540552                        <File 
     553                                RelativePath=".\Timer\mstring.h"> 
     554                        </File> 
     555                        <File 
     556                                RelativePath=".\Mutation.cpp"> 
     557                        </File> 
     558                        <File 
     559                                RelativePath=".\Mutation.h"> 
     560                        </File> 
     561                        <File 
    541562                                RelativePath="..\src\MutualVisibility.cpp"> 
    542563                        </File> 
     
    572593                        </File> 
    573594                        <File 
     595                                RelativePath=".\Timer\PerfTimer.h"> 
     596                        </File> 
     597                        <File 
     598                                RelativePath=".\Timer\PerfTimerSkeleton.h"> 
     599                        </File> 
     600                        <File 
    574601                                RelativePath="..\src\Plane3.cpp"> 
    575602                        </File> 
     
    738765                        <File 
    739766                                RelativePath="..\src\RayInfo.h"> 
     767                        </File> 
     768                        <File 
     769                                RelativePath=".\Timer\RDTSCTimer.cpp"> 
     770                        </File> 
     771                        <File 
     772                                RelativePath=".\Timer\RDTSCTimer.h"> 
    740773                        </File> 
    741774                        <File 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2008 r2048  
    166166   
    167167   
    168   if (mSnapErrorFrames && pErrorPixels > 0.01f) { 
     168  if (mSnapErrorFrames && pErrorPixels >= 0.01f) { 
    169169         
    170170        char filename[256]; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r2014 r2048  
    6969  // pool of vss rays to be used in one pass of the sampling 
    7070  struct VssRayPool { 
    71         VssRayPool():mRays(NULL), mIndex(0) {} 
     71        VssRayPool():mRays(NULL), mIndex(0), mNumber(0) {} 
    7272        ~VssRayPool() { 
    7373          if (mRays) 
     
    7979                delete mRays; 
    8080          mRays = new VssRay[number]; 
     81          mNumber = number; 
    8182        } 
    8283         
     
    8586        } 
    8687        VssRay *Alloc() { 
     88                // reset pool 
     89                if (mIndex == mNumber) 
     90                        mIndex = 0; 
    8791          return mRays + mIndex++; 
    8892        } 
     
    9094        VssRay *mRays; 
    9195        int mIndex; 
     96        int mNumber; 
    9297  }; 
    9398 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2044 r2048  
    669669                                  } else 
    670670                                        if (strcmp(curr, "mutation")==0) { 
    671                                           // temp matt: still no mutationstrategy! 
    672                                           mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
     671                                         mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
    673672                                        } 
    674673         
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r2023 r2048  
    209209                                Name="VCLinkerTool" 
    210210                                AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib RTScene.lib RTWorld.lib QtCore4.lib qtmain.lib cg.lib cgGL.lib QtOpenGL4.lib Qt3Support4.lib QtTest4.lib QtGui4.lib QtInterface.lib" 
    211                                 OutputFile="../bin/release/Preprocessor.exe" 
     211                                OutputFile="../bin/release/Preprocessor2.exe" 
    212212                                LinkIncremental="1" 
    213213                                AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release;&quot;$(QTDIR)\lib&quot;;.\QtInterface\Release;&quot;$(CG_LIB_PATH)&quot;" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2043 r2048  
    352352 
    353353 
    354 bool ViewCellsManager::GenerateRandomViewCells(vector<ViewCellPoints *> &viewCells, 
     354/*bool ViewCellsManager::GenerateRandomViewCells(vector<ViewCellPoints *> &viewCells, 
    355355                                                                                           const int nViewCells, 
    356356                                                                                           const int nViewPoints) 
     
    369369        ViewCellContainer::const_iterator vit, vit_end = rViewCells.end(); 
    370370     
    371         for (vit = rViewCells.begin(); vit != vit_end; ++ vit) 
     371        int i = 0; 
     372    for (vit = rViewCells.begin(); vit != vit_end; ++ vit, ++ i) 
    372373        { 
    373374                ViewCell *vc = *vit; 
     
    379380 
    380381                SimpleRayContainer viewPoints; 
     382                cout << "processing view cell " << i << endl; 
    381383                // generate random view points 
    382384                GenerateViewPoints(vc, nViewPoints, viewPoints); 
     
    388390                        vcPts->second.push_back(*pit);   
    389391                } 
     392        } 
     393 
     394        return true; 
     395}*/ 
     396 
     397 
     398bool ViewCellsManager::GenerateRandomViewCells(vector<ViewCellPoints *> &viewCells, 
     399                                                                                           const int nViewCells, 
     400                                                                                           const int nViewPoints) 
     401{ 
     402        ViewCellContainer rViewCells; 
     403 
     404        cout << "generating " << nViewCells << " random view cells" << endl; 
     405        ///GenerateRandomViewCells(rViewCells, nViewCells); 
     406 
     407        //cout << "finished" << endl; 
     408 
     409        //for (int i = 0; i < viewCells.size(); ++ i) 
     410        //      cout << "vc " << i << ": " << viewCells[i]->GetId() << endl; 
     411 
     412        cout << "generating " << nViewPoints << " view points per view cell" << endl; 
     413             
     414        int generatedViewCells = 0; 
     415        int i = 0; 
     416    while (generatedViewCells < nViewCells) 
     417        { 
     418                ++ i; 
     419                 
     420                const int idx = (int)RandomValue(0.0f, (float)mViewCells.size() - 0.5f); 
     421                         
     422                ViewCell *viewCell = GetViewCell(idx); 
     423                 
     424                cout << "testing view cell: " << viewCell->GetId() << endl; 
     425 
     426                if (!viewCell->Mailed()) 
     427                { 
     428                        viewCell->Mail(); 
     429 
     430                        SimpleRayContainer viewPoints; 
     431                        cout<<"here18"<<endl; 
     432                        // generate random view points 
     433                        if (IsValidViewSpace(viewCell) &&  
     434                                GenerateViewPoints(viewCell, nViewPoints, viewPoints)) 
     435                        {cout << "here99" << endl; 
     436                                Debug << "vc: " << viewCell->GetId() << endl; 
     437 
     438                                ViewCellPoints *vcPts = new ViewCellPoints(); 
     439                                viewCells.push_back(vcPts); 
     440 
     441                                // valid view cell found 
     442                                vcPts->first = viewCell; 
     443 
     444                                // generate view points 
     445                                ++ generatedViewCells; 
     446 
     447                                SimpleRayContainer::const_iterator pit, pit_end = viewPoints.end(); 
     448 
     449                                for (pit = viewPoints.begin(); pit != pit_end; ++ pit) 
     450                                { 
     451                                        Debug << "vp: " << (*pit) << endl; 
     452                                        vcPts->second.push_back(*pit);   
     453                                } 
     454                                cout << "view cell " << generatedViewCells << " generated: " << viewCell->GetId() << endl;       
     455                        } 
     456                        else 
     457                        { 
     458                                cout << "error: invalid view cell " << generatedViewCells << " with id " << viewCell->GetId() << endl;   
     459                        } 
     460                } 
     461 
     462                if (i > nViewCells * 1000000) // safety 
     463                { 
     464                        cout << "big error" << endl; 
     465                        break; 
     466                } 
     467                cout << "processd view cells " << generatedViewCells << " of " << nViewCells << endl << endl; 
    390468        } 
    391469 
     
    437515 
    438516 
     517bool ViewCellsManager::ImportRandomViewCells(const string &filename) 
     518{ 
     519        return ImportRandomViewCells(filename, mViewCellPoints); 
     520} 
     521 
     522 
    439523bool ViewCellsManager::GenerateViewPoints(ViewCell *viewCell,  
    440524                                                                                  const int numViewPoints, 
     
    445529        int i = 0; 
    446530 
     531        cout << "generating view points for view cell " << viewCell->GetId() << endl; 
     532 
    447533        while (generatedPts < numViewPoints) 
    448534        { 
     
    450536 
    451537                if (GenerateViewPoint(viewCell, pt)) 
    452                 { 
     538                {cout<<"here4"<<endl; 
    453539                        ++ generatedPts; 
     540                        cout << "generated view point " << generatedPts << endl; 
    454541                        viewPoints.push_back(pt); 
    455542                } 
    456543 
    457544                // savety criterium 
    458                 if (++ i > numViewPoints + 100000) 
     545                if (++ i > numViewPoints * 3) 
    459546                { 
    460547                        return false; 
     
    462549        } 
    463550         
     551        cout << "view point generation finished" << endl; 
     552 
    464553        return true; 
     554} 
     555 
     556 
     557bool ViewCellsManager::ExportRandomViewCells(const string &filename) 
     558{ 
     559        const int numViewCells = 100; 
     560        const int numViewPoints = 10; 
     561 
     562        preprocessor->mViewCellsManager-> 
     563                GenerateRandomViewCells(mViewCellPoints, numViewCells, numViewPoints); 
     564 
     565        //cout << "exporting random view cells" << endl; 
     566        return preprocessor->mViewCellsManager->ExportRandomViewCells(filename,  mViewCellPoints); 
    465567} 
    466568 
     
    473575        int tries = 0; 
    474576        Vector3 viewPoint, direction; 
    475         const int maxTries = 100; 
     577        const int maxTries = 10; 
    476578 
    477579        while (1)  
     
    499601                //halton.GenerateNext(); 
    500602 
    501                 //cout << "vp: " << viewPoint << endl; 
    502                 //cout << "dir: " << direction << endl; 
    503  
    504603                ViewCell *v = GetViewCell(viewPoint); 
    505604 
    506605                if (v && v->GetValid()) 
    507606                { 
    508                         //cout << "validating view point" << endl; 
    509  
    510607                        mPreprocessor->GetRenderer()->mViewPoint = viewPoint; 
    511608                        mPreprocessor->GetRenderer()->mViewDirection = direction; 
    512                         //preprocessor->renderer->EvalPvsStat(); 
    513 cout<<"*********hgere55"<<endl; 
    514                         if (preprocessor->renderer->ValidViewPoint()) 
     609                        //mPreprocessor->GetRenderer()->EvalPvsStat(); 
     610 
     611                        if (mPreprocessor->GetRenderer()->ValidViewPoint()) 
    515612                        { 
    516                                 cout << "view point valid" << endl; 
     613                                cout << "view point valid " << viewPoint << " " << direction << endl; 
    517614                                break; 
    518615                        } 
    519                         cout<<"here33"<<endl; 
     616                         
    520617                } 
    521618 
     
    526623                //      cout << "error!" << endl; 
    527624                if (++ tries > maxTries) 
     625                { 
     626                        cerr << "error: no view point computed" << endl; 
    528627                        return false; 
     628                } 
    529629        } 
    530630 
     
    584684                                else 
    585685                                { 
    586                                         cout << "error: invalid view cell " << generatedViewCells << " generated: " << viewCell->GetId() << endl;        
     686                                        cout << "error: invalid view cell " << generatedViewCells << " with id " << viewCell->GetId() << endl;   
    587687                                } 
    588688                        } 
     
    615715 
    616716        DEL_PTR(mMixtureDistribution); 
     717         
     718        CLEAR_CONTAINER(mViewCellPoints); 
    617719} 
    618720 
     
    10051107                        vm->FinalizeViewCells(true); 
    10061108                        // vm->mViewCellsTree->AssignRandomColors(); 
     1109                } 
     1110 
     1111                if (0) 
     1112                { 
     1113                        cout << "=============== " << vm->GetViewCellById(5318)->GetPvs().GetSize() << "========" << endl; 
    10071114                } 
    10081115 
     
    26092716 
    26102717 
    2611  
    2612  
    26132718int ViewCellsManager::GetNumViewCells() const 
    26142719{ 
     
    35403645} 
    35413646 
     3647 
    35423648void ViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 
    35433649{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2021 r2048  
    541541                                                           vector<ViewCellPoints *> &viewCells); 
    542542 
     543        bool ImportRandomViewCells(const string &filename); 
    543544 
    544545        bool ExportRandomViewCells(const string &filename, 
    545546                                                           const vector<ViewCellPoints *> &viewCells); 
    546547 
     548        bool ExportRandomViewCells(const string &filename); 
     549 
    547550        bool GenerateViewPoint(ViewCell *viewCell, SimpleRay &ray); 
    548551 
    549552        bool IsValidViewSpace(ViewCell *vc); 
     553 
    550554 
    551555        ////////////// 
     
    558562                @param objects the scene objects 
    559563                @param finalizeViewCells if the view cells should be post processed, i.e. 
    560                         a mesh is created representing the geometry 
     564                           a mesh is created representing the geometry 
    561565                @param bconverter a conversion routine working with the similarities of bounding 
    562                         boxes: if there is a certain similarity of overlap between  
    563                         bounding boxes, two tested 
    564                 candidate objects are considered to be the same objects 
     566                           boxes: if there is a certain similarity of overlap between  
     567                           bounding boxes, two tested candidate objects are considered  
     568                          to be the same objects 
    565569                @returns the view cells manager if loading was successful, false otherwise 
    566570        */ 
     
    575579 
    576580        // TODO: write own visibiltiy filter class 
    577   void ApplyFilter(KdTree *kdTree, 
    578                                    const float viewSpaceFilterSize, 
    579                                    const float spatialFilterSize); 
    580  
    581   // new adaptive version of the filter 
    582   PvsFilterStatistics  
    583   ApplyFilter2(ViewCell *viewCell, 
    584                            const bool useViewSpaceFilter, 
    585                            const float filterSize, 
    586                            ObjectPvs &pvs, 
    587                            vector<AxisAlignedBox3> *filteredBoxes = NULL); 
     581        void ApplyFilter(KdTree *kdTree, 
     582                                         const float viewSpaceFilterSize, 
     583                                         const float spatialFilterSize); 
     584 
     585        // new adaptive version of the filter 
     586        PvsFilterStatistics ApplyFilter2(ViewCell *viewCell, 
     587                                                                         const bool useViewSpaceFilter, 
     588                                                                         const float filterSize, 
     589                                                                         ObjectPvs &pvs, 
     590                                                                         vector<AxisAlignedBox3> *filteredBoxes = NULL); 
    588591 
    589592        void ApplySpatialFilter(KdTree *kdTree, 
     
    606609 
    607610        ////////////////////////////////////////////////////////////////// 
     611 
    608612 
    609613        /** If true, the kd nodes are stored instead of the object pvs. 
     
    635639 
    636640 
    637         void ViewCellsManager::ResetPvs(); 
     641        void ResetPvs(); 
    638642 
    639643        Preprocessor *GetPreprocessor() const { 
     
    643647        void SetPreprocessor(Preprocessor *p) { 
    644648                mPreprocessor = p; 
     649        } 
     650 
     651        vector<ViewCellPoints *> *GetViewCellPoints() 
     652        { 
     653                return &mViewCellPoints; 
    645654        } 
    646655 
     
    741750        void ExportMergedViewCells(const ObjectContainer &objects); 
    742751 
     752 
    743753        /////////////////////// 
    744754 
     
    746756        */ 
    747757        virtual float GetViewSpaceVolume(); 
     758 
    748759        /** Prepares the view cells for sampling after loading them from disc. 
    749760        */ 
    750761        virtual void PrepareLoadedViewCells() {}; 
     762         
    751763        /** Constructs local view cell merge hierarchy. 
    752764        */ 
     
    755767 
    756768        /** Constructs local view cell merge hierarchy based solely on similarity with the 
    757         current viewcell 
     769                current viewcell 
    758770        */ 
    759771        ViewCell *ConstructLocalMergeTree2(ViewCell *currentViewCell,  
     
    766778        virtual void ExportStats(const string &mergeStats); 
    767779 
    768    
     780 
    769781        //////////////////////////////////////////////// 
     782 
    770783 
    771784        Preprocessor *mPreprocessor; 
     
    816829        bool mCompressViewCells; 
    817830 
     831        vector<ViewCellPoints *> mViewCellPoints; 
     832 
    818833        /// holds the current view cell statistics 
    819834        ViewCellsStatistics mCurrentViewCellsStats; 
     835 
    820836        /// the scene bounding box 
    821837        AxisAlignedBox3 mViewSpaceBox; 
     
    845861 
    846862        MixtureDistribution *mMixtureDistribution; 
     863 
    847864 
    848865        ////////////////// 
     
    13061323        ///////////////////////////////////////// 
    13071324 
    1308  
    13091325        bool mCompressObjects; 
    13101326 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r2017 r2048  
    6464static SAXParser::ValSchemes    valScheme       = SAXParser::Val_Auto; 
    6565 
    66  
     66#define PVS_HACK 1 
    6767 
    6868inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 
     
    393393 
    394394 
     395void ViewCellsParseHandlers::ExchangePvs(ViewCell *vc) 
     396{ 
     397        //cout << "exchanging pvs" << endl; 
     398 
     399        sort(mBvhLeaves.begin(), mBvhLeaves.end(), ilt); 
     400        ObjectPvs newPvs; 
     401 
     402        ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 
     403 
     404        BvhLeaf *dummyInst = new BvhLeaf(AxisAlignedBox3()); 
     405 
     406        ObjectContainer oldIntersectables; 
     407        // output PVS of view cell 
     408        while (pit.HasMoreEntries()) 
     409        {                
     410                ObjectPvsEntry entry = pit.Next(); 
     411 
     412                Intersectable *intersect = entry.mObject; 
     413                oldIntersectables.push_back(intersect); 
     414 
     415                DummyIntersectable *dummyIntersect = static_cast<DummyIntersectable *>(intersect); 
     416 
     417                const int objId = dummyIntersect->GetItem();     
     418                dummyInst->SetId(objId); 
     419 
     420                vector<BvhLeaf *>::iterator oit = 
     421                        lower_bound(mBvhLeaves.begin(),  
     422                                                mBvhLeaves.end(),  
     423                                                dummyInst, ilt);         
     424 
     425                if ((oit != mBvhLeaves.end()) && ((*oit)->GetId() == objId)) 
     426                { 
     427                        // $$JB we should store a float a per object which corresponds 
     428                        // to sumof pdfs, i.e. its relative visibility 
     429                        // temporarily set to 1.0f 
     430                        //cout << (*oit)->GetId() << " "; 
     431                         
     432                        newPvs.AddSample(*oit, 1.0f); 
     433                } 
     434                else 
     435                { 
     436                        Debug << "error: object with id " << objId << " does not exist" << endl; 
     437                } 
     438        } 
     439 
     440        //newPvs.SimpleSort(); 
     441        delete dummyInst; 
     442        vc->SetPvs(newPvs); 
     443 
     444        CLEAR_CONTAINER(oldIntersectables); 
     445} 
     446 
     447 
     448void ViewCellsParseHandlers::ExchangeElements() 
     449{ 
     450        ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
     451 
     452        for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 
     453        {//cout << "j"; 
     454                ExchangePvs(*vit); 
     455        } 
     456} 
     457 
     458 
    395459void ViewCellsParseHandlers::StartViewCellHierarchyElement(const std::string &element, 
    396460                                                                                                                   AttributeList& attributes) 
     
    500564        for (it = objIndices.begin(); it != it_end; ++ it) 
    501565        { 
     566#if PVS_HACK 
     567                //cout << "u"; 
     568                pvs.AddSample(new DummyIntersectable(*it), 1); 
     569#else 
    502570                const int objId = *it;   
    503571                dummyInst.SetId(objId); 
     
    513581                        // to sumof pdfs, i.e. its relative visibility 
    514582                        // temporarily set to 1.0f 
    515                         pvs.AddSample(*oit, 1.0f);                               
     583                        //cout << "r"; 
     584 
     585                        pvs.AddSample(*oit, 1.0f); 
    516586                } 
    517587                else 
     
    519589                        Debug << "error: object with id " << objId << " does not exist" << endl; 
    520590                } 
     591#endif 
    521592        } 
    522593} 
     
    839910                } 
    840911                if (attrName == "pvs")  
    841                 { 
     912                {//cout <<"e"; 
    842913                        StrX attrValue(attributes.getValue(i)); 
    843914                        const char *ptr = attrValue.LocalForm(); 
     
    846917                        // otherwise view cell is undefined 
    847918 
    848                         StartViewCellPvs(viewCell->GetPvs(), ptr); // assume that view cell comes before pvs 
     919                        // hack: assume that view cell comes before pvs 
     920                        StartViewCellPvs(viewCell->GetPvs(), ptr);  
    849921                        //StartViewCellPvs(pvs, ptr); 
    850922                } 
     
    12441316 
    12451317        leaf->mObjects = objects; 
    1246         BvHierarchy::AssociateObjectsWithLeaf(leaf);     
     1318        BvHierarchy::AssociateObjectsWithLeaf(leaf); 
     1319         
     1320        if (PVS_HACK) 
     1321        { 
     1322                if (1) // Temp matt: should HAVE right id 
     1323                { 
     1324                        leaf->SetId((int)mBvhLeaves.size()); 
     1325                } 
     1326                mBvhLeaves.push_back(leaf);      
     1327                                 
     1328                //cout << "i"; 
     1329        } 
    12471330} 
    12481331 
     
    12631346        } 
    12641347 
    1265         //TODO: find objects and add them to pvs 
    1266         // TODO: get view cell with specified id 
    12671348        MeshInstance dummyInst(NULL); 
    12681349 
     
    14241505#else 
    14251506        parser->parse(filename.c_str()); 
     1507 
    14261508#endif 
     1509 
     1510        if (PVS_HACK) 
     1511                handler.ExchangeElements(); 
    14271512 
    14281513        const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r2005 r2048  
    7474  void CreateViewCellsManager(/*const char *name*/); 
    7575 
     76  void ExchangeElements(); 
     77  void ExchangePvs(ViewCell *vc); 
     78 
    7679 
    7780  ///////////////////////// 
     
    9497  VspNode *mVspRoot; 
    9598  ViewCell *mViewCellRoot; 
    96  
    97  // typedef map<int, ViewCell *> ViewCellsMap; 
     99int mUniqueObjectId; 
     100  vector<BvhLeaf *> mBvhLeaves; 
     101  //typedef map<int, ViewCell *> ViewCellsMap; 
    98102  //ViewCellsMap mViewCells; 
    99103  ViewCellContainer mViewCells; 
     
    119123  int mViewSpaceHierarchyType; 
    120124  int mObjectSpaceHierarchyType; 
    121 int nViewCells; 
    122 int nObjects; 
     125  int nViewCells; 
     126  int nObjects; 
     127   
     128   
    123129  //////////////////////////////// 
    124130 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r2032 r2048  
    285285        } 
    286286 
    287         string viewCellsFile = ReplaceSuffix(filename, ".obj", ".vc"); 
    288         //viewCellsFile = ReplaceSuffix(filename, ".dat", ".vc"); 
    289  
    290         const int numViewCells = 5; 
    291         const int numViewPoints = 20; 
     287        string viewCellPointsFile; 
     288 
     289        if (strstr(filename.c_str(), ".obj")) 
     290                viewCellPointsFile = ReplaceSuffix(filename, ".obj", ".vc"); 
     291        else if (strstr(filename.c_str(), ".dat")) 
     292                viewCellPointsFile = ReplaceSuffix(filename, ".dat", ".vc"); 
     293        else if (strstr(filename.c_str(), ".x3d")) 
     294                viewCellPointsFile = ReplaceSuffix(filename, ".x3d", ".vc"); 
     295 
     296        bool importRandomViewCells; 
     297        Environment::GetSingleton()->GetBoolValue("ViewCells.importRandomViewCells", 
     298                                                                                           importRandomViewCells); 
     299 
     300        if (importRandomViewCells) 
     301        { 
     302                cout << "importing random view cells" << endl; 
     303                preprocessor->mViewCellsManager->ImportRandomViewCells(viewCellPointsFile); 
     304                cout << "finished" << endl; 
     305        } 
    292306 
    293307        bool useHwGlobalLines; 
     
    377391                } 
    378392 
    379                 vector<ViewCellPoints *> myViewCells; 
    380  
    381                 preprocessor->mViewCellsManager->GenerateRandomViewCells(myViewCells, numViewCells, numViewPoints); 
    382                 cout << "exporting random view cells" << endl; 
    383                 preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellsFile, myViewCells); 
    384  
    385                 //preprocessor->mViewCellsManager->ImportRandomViewCells(viewCellsFile, myViewCells); 
    386                 CLEAR_CONTAINER(myViewCells); 
    387  
    388                 //preprocessor->renderer->EvalPvsStat(); 
     393                bool exportRandomViewCells; 
     394                Environment::GetSingleton()->GetBoolValue("ViewCells.exportRandomViewCells", 
     395                                                                                                  exportRandomViewCells); 
     396 
     397                if (exportRandomViewCells) 
     398                { 
     399                        cout << "exporting random view cells" << endl; 
     400                        preprocessor->mViewCellsManager->ExportRandomViewCells(viewCellPointsFile); 
     401                        cout << "finished" << endl; 
     402                } 
     403 
     404                /*bool evaluatePixelError; 
     405                Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError",  evaluatePixelError); 
     406 
     407                if (evaluatePixelError) 
     408                { 
     409                        cout << "evaluating pixel error" << endl; 
     410                        preprocessor->ComputeRenderError(); 
     411                }*/ 
    389412 
    390413                qApp->exec(); 
Note: See TracChangeset for help on using the changeset viewer.