Ignore:
Timestamp:
01/09/08 15:22:12 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2560 r2584  
    125125                                OptimizeForProcessor="2" 
    126126                                OptimizeForWindowsApplication="TRUE" 
    127                                 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(CG_INC_PATH)";Timer;..\src\sparsehash\src\google\sparsehash;..\src\sparsehash\src\windows;..\src\sparsehash\src\google;..\src\sparsehash\src;..\src\ootl\;..\src\ootl\src\;..\src\ootl\src\cpp;..\src\ootl\src\cpp\include\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;..\src\ootl\src\cpp\include\ootl\mswin" 
     127                                AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(CG_INC_PATH)";Timer;..\src\sparsehash\src\google\sparsehash;..\src\sparsehash\src\windows;..\src\sparsehash\src\google;..\src\sparsehash\src;..\src\ootl\;..\src\ootl\src\;..\src\ootl\src\cpp;..\src\ootl\src\cpp\include\;..\src\ootl\src\include\ootl;..\src\ootl\src\include\ootl\sandbox;..\src\ootl\src\cpp\include\ootl\mswin;..\src\havran" 
    128128                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GTP_INTERNAL;USE_QT;USE_VERBOSE_PVS;USE_CG" 
    129129                                StringPooling="TRUE" 
     
    10531053                        </File> 
    10541054                        <File 
     1055                                RelativePath=".\sparsehash\src\windows\hash_fun.h"> 
     1056                        </File> 
     1057                        <File 
    10551058                                RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h"> 
    1056                         </File> 
    1057                         <File 
    1058                                 RelativePath=".\sparsehash\src\windows\hash_fun.h"> 
    10591059                        </File> 
    10601060                        <File 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp

    r2580 r2584  
    1212 
    1313 
    14 /*void LogReader::Read(ViewCellHistoryContainer &history) 
     14void LogReader::Read(int &numSamples, ViewCellInfoContainer &infos) 
    1515{ 
    16         int numViewCells, numSamples; 
    17      
    18         // open file 
    19         std::ifstream src(mFilename.c_str()); 
    20  
    21         if (src.is_open()) 
    22         { 
    23                 src >> numViewCells; 
    24                 src >> numSamples; 
    25  
    26                 while (!src.eof()) 
    27                 { 
    28                         ViewCellInfoContainer *infos = new ViewCellInfoContainer(); 
    29  
    30                         for (size_t i = 0; i << numViewCells; ++ i) 
    31                         { 
    32                                 ViewCellInfo info; 
    33                                 src >> info.mPiercingRays;       
    34                                 infos->push_back(info); 
    35                         } 
    36  
    37                         history[numSamples] = infos; 
    38                 } 
    39  
    40                 src.close(); 
    41         } 
    42 }*/ 
    43  
    44  
    45 void LogReader::Read(const int numSamples, ViewCellInfoContainer &infos) 
    46 { 
    47          char filename[64];  
     16         //char filename[64];  
    4817         //sprintf(filename, "%s %06d", mFilename.c_str(), numSamples); 
    49          
    5018         // open file 
    5119         std::ifstream src(mFilename.c_str()); 
     
    5321         if (src.is_open()) 
    5422         { 
    55                  while (!src.eof()) 
     23                 src >> numSamples; 
     24 
     25                 while (1) 
    5626                 { 
    5727                         ViewCellInfo info; 
    58                          src >> info.mPiercingRays;      
    59  
     28                         src >> info.mPiercingRays;     src >> info.mPvsSize; 
     29                          
     30                         if (src.eof()) break; 
     31                          
    6032                         infos.push_back(info); 
    6133                 } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h

    r2581 r2584  
    2727class LogReader 
    2828{ 
     29public: 
    2930        void SetFilename(const std::string &filename); 
    3031 
     
    3435        /** Reads the viewcells info from disc 
    3536        */ 
    36         void Read(const int numSamples, ViewCellInfoContainer &infos); 
     37        void Read(int &numSamples, ViewCellInfoContainer &infos); 
    3738 
    3839 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp

    r2581 r2584  
    2323 
    2424 
    25 void LogWriter::Write(//ofstream &myfile,  
    26                                           const int numSamples, const ViewCellInfoContainer &infos) 
     25void LogWriter::Write(const int numSamples, const ViewCellContainer &viewCells) 
    2726{ 
    2827        ofstream myfile; 
     
    3231                myfile.open(mFilename.c_str()); 
    3332 
    34         ViewCellInfoContainer::const_iterator vit, vit_end = infos.end(); 
     33        ViewCellContainer::const_iterator vit, vit_end =viewCells.end(); 
    3534 
    3635        myfile << numSamples << endl; 
    3736 
    38         for (vit = infos.begin(); vit != vit_end; ++ vit) 
     37        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    3938        { 
    40                 myfile << (*vit).mPiercingRays << " " << (*vit).mPvsSize << endl; 
    41                 //myfile << (*vit); 
    42                 //ViewCell *vc = *vit; 
    43                 //myfile << "vc: " << vc->GetPvs().GetSize() << " " << vc->GetNumPiercingRays(); 
     39                myfile << (*vit)->GetNumPiercingRays() << " " << (*vit)->GetPvs().GetSize() << endl; 
    4440        } 
    4541} 
    4642 
    47 /* 
    48 void LogWriter::Write(const ViewCellHistoryContainer &hist) 
    49 { 
    50         //ofstream myfile; 
    51         //char filename[64];  
    52         //sprintf(filename, "%s %06d", mFilename.c_str(), numSamples); 
    53         //myfile.open(filename); 
    54         if (!mFile.is_open()) 
    55                 mFile.open(mFilename.c_str()); 
    56  
    57         ViewCellHistoryContainer::const_iterator vit, vit_end = hist.end(); 
    58  
    59         // number of samples 
    60         //myfile << "samples: " << numSamples << endl; 
    61         mFile << (int)hist.size() << endl; 
    62  
    63         for (vit = hist.begin(); vit != vit_end; ++ vit) 
    64         { 
    65                 Write(myfile, (*vit).first, *(*vit).second); 
    66         } 
    6743} 
    68  
    69 */ 
    70  
    71 } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h

    r2580 r2584  
    2323        void SetFilename(const std::string &filename); 
    2424 
    25         //void Write(const int numSamples, const ViewCellContainer &viewcells); 
    26         void Write(//std::ofstream &myfile,  
    27                                 const int numSamples, const ViewCellInfoContainer &infos); 
    28         //void Write(const ViewCellHistoryContainer &hist); 
     25        void Write(const int numSamples, const ViewCellContainer &viewcells); 
     26         
    2927 
    3028protected: 
    3129 
    32         //std::ofstream mFile; 
    3330        std::string mFilename; 
    3431}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2581 r2584  
    846846        mRenderVisibilityEstimates = false; 
    847847 
    848         mHistRecorded = false; 
    849  
    850848        mHideByCost = false; 
    851849        mUseTransparency = false; 
     
    885883        mShowRays = false; 
    886884 
    887         mNextSamples = SAMPLES_INCR; 
    888885        mControlWidget = new QtRendererControlWidget(NULL); 
    889886 
    890887        connect(mControlWidget, SIGNAL(SetViewCellGranularity(int)), this, SLOT(SetViewCellGranularity(int))); 
    891         connect(mControlWidget, 
    892                 SIGNAL(SetTransferFunction(int)), 
    893                 this, 
    894                 SLOT(SetTransferFunction(int))); 
     888        connect(mControlWidget, SIGNAL(SetTransferFunction(int)), this, SLOT(SetTransferFunction(int))); 
     889 
    895890        connect(mControlWidget, SIGNAL(UpdateAllPvs()), this, SLOT(UpdateAllPvs())); 
    896891        connect(mControlWidget, SIGNAL(ComputeVisibility()), this, SLOT(ComputeVisibility())); 
    897892        connect(mControlWidget, SIGNAL(StopComputation()), this, SLOT(StopComputation())); 
    898         connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this, 
    899                 SLOT(SetRandomViewPoint())); 
     893        connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this,     SLOT(SetRandomViewPoint())); 
     894        connect(mControlWidget, SIGNAL(StoreStatistics(void)), this, SLOT(StoreStatistics(void))); 
    900895 
    901896        connect(mControlWidget, SIGNAL(SetSceneCut(int)), this, SLOT(SetSceneCut(int))); 
     
    965960QtGlRendererWidget::SetRandomViewPoint() 
    966961{ 
    967         cerr<<"stop computation called!\n"<<endl; 
     962        cerr<<"setting random view point!\n"<<endl; 
    968963        mViewCellsManager->GetViewPoint(mViewPoint); 
     964        updateGL(); 
     965} 
     966 
     967 
     968void QtGlRendererWidget::StoreStatistics() 
     969{ 
     970        cerr<<"storing statistics!\n"<<endl; 
     971        const int currentSamples = mViewCellsManager->GetPreprocessor()->mCurrentSamples; 
     972 
     973        cout<<"**********************************************" << endl; 
     974        cout << "reached " << currentSamples << " samples " << " => writing file" << endl; 
     975                 
     976        LogWriter writer; 
     977        writer.SetFilename("compare.log"); 
     978        writer.Write(currentSamples, mViewCellsManager->GetViewCells()); 
     979        cout << "finished writing file" << endl; 
     980        mCompareInfo.clear(); 
    969981        updateGL(); 
    970982} 
     
    13061318 
    13071319 
    1308  
    1309 void QtGlRendererWidget::FillNewContainer(const ViewCellContainer &viewCells, ViewCellInfoContainer &infos) 
    1310 { 
    1311         ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    1312  
    1313         for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    1314         { 
    1315         ViewCell *vc = *vit; 
    1316                 ViewCellInfo info; 
    1317  
    1318                 info.mPiercingRays = vc->GetNumPiercingRays(); 
    1319  
    1320                 infos.push_back(info); 
    1321                 //myfile << "vc: " << vc->GetPvs().GetSize() << " " << vc->GetNumPiercingRays(); 
    1322         } 
    1323 } 
    1324  
    1325  
    1326  
    13271320void QtGlRendererWidget::RenderViewCells() 
    13281321{ 
     
    13471340        } 
    13481341 
    1349         mNextSamples = 200000; 
    1350  
    13511342        ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 
    1352         const int currentSamples = mViewCellsManager->GetPreprocessor()->mCurrentSamples; 
    1353         //cout << "current samples: " << currentSamples << endl; 
    1354  
    1355         if (!mHistRecorded && (currentSamples > mNextSamples)) 
    1356         { 
    1357                 mHistRecorded = true; 
    1358  
    1359                 //mNextSamples += SAMPLES_INCR; 
    1360                 cout<<"************************************************" << endl; 
    1361                 cout << "reached " << currentSamples << " samples " << " => writing file" << endl; 
    1362                 //ViewCellInfoContainer newContainer; 
    1363  
    1364                 mCurrentInfo.clear(); 
    1365                 FillNewContainer(viewcells, mCurrentInfo); 
    1366                 //mCurrentHist[mNextSamples] = newContainer; 
    1367                  
    1368                 LogWriter writer; 
    1369                 writer.SetFilename("compare.log"); 
    1370                 writer.Write(mNextSamples, mCurrentInfo); 
    1371  
    1372                 cout << "finished writing file" << endl; 
    1373         } 
    1374  
     1343         
    13751344        int maxPvs, maxPiercingRays; 
    13761345        float maxRelativeRays, maxRcCost; 
     
    14281397                } 
    14291398 
    1430                 if (!mShowComparison)//mAssignImportanceByRelativeValue) 
     1399                if (!mShowComparison) 
    14311400                        AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost); 
    14321401                else 
    14331402                { 
    1434                         mCurrentInfo.clear(); 
    1435                         FillNewContainer(viewcells, mCurrentInfo); 
    1436  
    1437                         //ViewCellInfoContainer *infos1 = mCurrentHist[mNextSamples]; 
    1438                         //ViewCellInfoContainer *infos2 = mCompareHist[mNextSamples]; 
    1439  
    1440                         //AssignColorByComparison(viewcells, *infos1, *infos2); 
    1441                         AssignColorByComparison(viewcells, //mCurrentInfo,  
    1442                                 mCompareInfo); 
     1403                        if (mCompareInfo.empty()) 
     1404                        { 
     1405                                LogReader reader; 
     1406                                reader.SetFilename("compare.log"); 
     1407                                int samples; 
     1408                                reader.Read(samples, mCompareInfo); 
     1409                        } 
     1410 
     1411                        AssignColorByComparison(viewcells, mCompareInfo); 
    14431412                } 
    14441413 
     
    15131482                                                                                                 const ViewCellInfoContainer &compareInfo) 
    15141483{ 
    1515  
    1516         const float maxRatio = 1.0f; 
    1517         const float minRatio = 0.5f; 
     1484        //cout << "comparing " << viewcells.size() << " view cells to " << compareInfo.size() << " values" << endl; 
     1485 
     1486        if (viewcells.size() > compareInfo.size()) 
     1487        { 
     1488                cerr << "loaded size (" << compareInfo.size() << ") does not fit to view cells size (" << viewcells.size() << ")" << endl; 
     1489                return; 
     1490        } 
     1491 
     1492        //const float maxRatio = 1.0f; 
     1493        const float maxRatio = 2.0f; 
     1494        const float minRatio = 0.0f; 
    15181495 
    15191496        const float scale = 1.0f / (maxRatio - minRatio); 
     
    15271504                ViewCellInfo vc2Info = compareInfo[i]; 
    15281505 
    1529                 const float vcRatio = vc->GetNumPiercingRays() / vc2Info.mPiercingRays + Limits::Small; 
     1506                //const float vcRatio = vc->GetNumPiercingRays() / vc2Info.mPiercingRays + Limits::Small; 
     1507                float vcRatio = 1.0f;//maxRatio; 
     1508                 
     1509                if (vc2Info.mPvsSize > Limits::Small)  
     1510                        vcRatio = (float)vc->GetPvs().GetSize() / vc2Info.mPvsSize; 
     1511 
     1512                // truncate here 
     1513                if (vcRatio > maxRatio) vcRatio = 1.0f; 
    15301514 
    15311515                const float importance = (vcRatio - minRatio) * scale; 
     1516         
     1517                if (i < 20) 
     1518                { 
     1519                        cout << "pvs1: " << vc->GetPvs().GetSize() << " pvs2: " << compareInfo[i].mPvsSize << " importance: " << importance << endl; 
     1520                } 
    15321521 
    15331522                // c = RgbColor(importance, 1.0f - importance, 0.0f); 
     
    17441733 
    17451734        myBox->setLayout(vh); 
    1746  
    17471735        vl->addWidget(myBox, 0, 0); 
    17481736 
    17491737        QGroupBox *groupBox = CreateVisualizationPanel(hbox); 
    1750  
    17511738        vh->addWidget(groupBox, 0, 0); 
    17521739 
    17531740        QGroupBox *groupBox2 = CreateRenderCostPanel(hbox); 
    1754  
    17551741        vh->addWidget(groupBox2, 0, 0); 
    17561742 
     
    19001886 
    19011887 
    1902         vbox = new QGroupBox("PVS Errors", this); 
     1888        /*vbox = new QGroupBox("PVS Errors", this); 
    19031889        layout()->addWidget(vbox); 
    19041890 
     
    19161902        button = new QPushButton("Set Random View Point", vbox); 
    19171903        vbox->layout()->addWidget(button); 
    1918         connect(button, SIGNAL(clicked()), SLOT(SetRandomViewPoint())); 
    1919  
    1920  
     1904        connect(button, SIGNAL(clicked()), SLOT(SetRandomViewPoint()));*/ 
     1905 
     1906        button = new QPushButton("Store statistics", vbox); 
     1907        vbox->layout()->addWidget(button); 
     1908        connect(button, SIGNAL(clicked()), SIGNAL(StoreStatistics())); 
     1909 
     1910        /*cb = new QCheckBox("Stats", vbox); 
     1911        vbox->layout()->addWidget(cb); 
     1912        cb->setChecked(false); 
     1913        connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics())); 
     1914*/ 
    19211915        if (0)  
    19221916        { 
     
    19401934        } 
    19411935         
     1936        //connect(button, SIGNAL(clicked(void)), SLOT(StoreStatistics(void))); 
    19421937        //mHidingCost = 0.1f; 
    19431938 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2581 r2584  
    105105  void StopComputation(); 
    106106  void SetRandomViewPoint(); 
     107  void StoreStatistics(); 
    107108  void UpdateAllPvs(); 
    108109  void SetViewCellGranularity(int); 
     
    185186        bool mShowWeightedTriangles; 
    186187 
    187         /// the current number of samples 
    188         //int mCurrentSamples; 
    189         /// the next number of samples where we record the data 
    190         int mNextSamples; 
    191         bool mHistRecorded; 
    192  
    193188        // some statistics 
    194189        int mPvsSize; 
     
    198193        unsigned int mIndexBufferSize; 
    199194 
    200         //bool mAssignImportanceByRelativeValue; 
    201  
    202195        Vector3 mDummyViewPoint; 
    203196 
     
    206199        QtPreprocessorThread *mPreprocessorThread; 
    207200 
    208         int mCurrentSamples; 
    209  
    210         //ViewCellHistoryContainer mCurrentHist; 
    211         //ViewCellHistoryContainer mCompareHist; 
    212  
    213         ViewCellInfoContainer mCurrentInfo; 
    214201        ViewCellInfoContainer mCompareInfo; 
    215202 
     
    223210        QtGlRendererWidget() {}; 
    224211 
    225         void FillNewContainer(const ViewCellContainer &viewCells, ViewCellInfoContainer &infos); 
    226  
    227  
    228         void SetThread(QtPreprocessorThread *t) { 
     212        void SetThread(QtPreprocessorThread *t) 
     213        { 
    229214                mPreprocessorThread = t; 
    230215        } 
     
    288273                                                                 const ViewCellInfoContainer &compareInfo); 
    289274 
     275        void WriteViewCellInfos(); 
     276 
    290277 
    291278        ///////// 
     
    300287        void StopComputation(); 
    301288        void SetRandomViewPoint(); 
     289        void StoreStatistics(); 
    302290 
    303291        void SetRenderErrors(bool b) { 
     
    452440 
    453441        float ComputeRenderCost(ViewCell *vc); 
     442 
     443 
    454444 
    455445        ///////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ReverseGvs.cpp

    r2582 r2584  
    380380        // mlrtaTraverseGroupASEye4(&box.Min().x, &box.Max().x, hit_triangles, dist); 
    381381        assert(preprocessor->mRayCaster); 
    382         preprocessor->mRayCaster->CastRaysPacket4(&box.Min(), &box.Max(), origs, 
     382        preprocessor->mRayCaster->CastRaysPacket4(box.Min(), box.Max(), origs, 
    383383                                                  dirs, hit_triangles, dist); 
    384384         
Note: See TracChangeset for help on using the changeset viewer.