Ignore:
Timestamp:
01/09/08 10:22:15 (16 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/CombinedPreprocessor.cpp

    r2574 r2580  
    7676  long startTime = GetTime(); 
    7777 
    78   for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) { 
     78  mCurrentSamples = 0; 
     79 
     80  for (mCurrentSamples =0; mCurrentSamples < mTotalSamples; mCurrentSamples += mSamplesPerPass, mPass++) { 
    7981        mRayCaster->InitPass(); 
    8082         
    81         cout<<"Progress :"<<i/1e6f<<"M rays, "<<(100.0f*i)/mTotalSamples<<"%"<<endl; 
     83        cout<<"Progress :"<<mCurrentSamples/1e6f<<"M rays, "<<(100.0f*mCurrentSamples)/mTotalSamples<<"%"<<endl; 
    8284         
    8385        rays.clear(); 
     
    122124        mMixtureDistribution->UpdateDistributions(vssRays); 
    123125         
    124         if (i - lastEvaluation >= mSamplesPerEvaluation) { 
     126        if (mCurrentSamples - lastEvaluation >= mSamplesPerEvaluation) { 
    125127          Real time = TimeDiff(startTime, GetTime()); 
    126128          mViewCellsManager->PrintPvsStatistics(mStats); 
     
    128130                "#Pass\n" <<mPass<<endl<< 
    129131                "#Time\n" << time <<endl<< 
    130                 "#TotalSamples\n" <<i<<endl<< 
     132                "#TotalSamples\n" << mCurrentSamples <<endl<< 
    131133                "#RssSamples\n" <<mTotalRaysCast<<endl; 
    132134 
     
    143145          } 
    144146           
    145           lastEvaluation = i; 
     147          lastEvaluation = mCurrentSamples; 
    146148           
    147149          if (renderer) { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2575 r2580  
    2020#include "VssRay.h" 
    2121#include "IntelRayCaster.h" 
     22#if TODO 
    2223#include "HavranRayCaster.h" 
     24#endif 
    2325#include "InternalRayCaster.h" 
    2426#include "GlobalLinesRenderer.h" 
     
    10591061          //HavranRayCaster *hr = 
    10601062          //  dynamic_cast<HavranRayCaster*>(mRayCaster); 
     1063#if TODO 
    10611064          HavranRayCaster *hr = 
    10621065            reinterpret_cast<HavranRayCaster*>(mRayCaster); 
    10631066          hr->Build(this->mObjects); 
     1067#endif 
    10641068          return true; 
    10651069        }        
     
    11491153        if (rayCastMethod == 2)  
    11501154        { 
    1151           cout << "ray cast method: havran" << endl; 
     1155#if TODO 
     1156                cout << "ray cast method: havran" << endl; 
    11521157          mRayCaster = new HavranRayCaster(*this); 
     1158#endif 
    11531159        } 
    11541160         
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2575 r2580  
    259259 
    260260        int mTotalSamples; 
     261        int mCurrentSamples; 
     262 
    261263        int mTotalTime; 
    262264        int mSamplesPerPass; 
    263265        int mSamplesPerEvaluation; 
    264    
    265   int mTotalRaysCast; 
     266  
     267        int mTotalRaysCast; 
    266268 
    267269        RayCaster *mRayCaster; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.cpp

    r2578 r2580  
    1212 
    1313 
    14 void LogReader::Read(ViewCellHistoryContainer &history) 
     14/*void LogReader::Read(ViewCellHistoryContainer &history) 
    1515{ 
    16         /*std::vector<int>::const_iterator it, it_end = numSamples.end(); 
    17  
    18         for (it = numSamples.begin(); it != it_end; ++ it) 
    19         { 
    20                 int numSamples = *it; 
    21  
    22                 Read(numSamples, infos); 
    23                 }*/ 
    24  
    2516        int numViewCells, numSamples; 
    2617     
     
    4940                src.close(); 
    5041        } 
    51 } 
     42}*/ 
    5243 
    5344 
    54 /*void LogReader::Read(const int numSamples, ViewCellInfoContainer &infos) 
     45void LogReader::Read(const int numSamples, ViewCellInfoContainer &infos) 
    5546{ 
    5647         char filename[64];  
    57          sprintf(filename, "%s %06d", mFilename.c_str(), numSamples); 
     48         //sprintf(filename, "%s %06d", mFilename.c_str(), numSamples); 
    5849         
    5950         // open file 
    60          std::ifstream src(filename); 
     51         std::ifstream src(mFilename.c_str()); 
    6152 
    6253         if (src.is_open()) 
     
    6556                 { 
    6657                         ViewCellInfo info; 
    67  
    6858                         src >> info.mPiercingRays;      
    6959 
     
    7666                 src.close(); 
    7767         } 
    78 }*/ 
     68} 
    7969 
    8070} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogReader.h

    r2578 r2580  
    2121 
    2222typedef std::vector<ViewCellInfo> ViewCellInfoContainer; 
    23 typedef std::map<int, ViewCellInfoContainer *> ViewCellHistoryContainer; 
     23//typedef std::map<int, ViewCellInfoContainer *> ViewCellHistoryContainer; 
    2424 
    25  
    26 /*struct ViewCellHistory; 
    27 { 
    28 }*/ 
    2925 
    3026class LogReader 
     
    3430        /** Reads the info for several #samples. 
    3531        */ 
    36         void Read(ViewCellHistoryContainer &history); 
    37         /** Reads the viewcells info after specific #samples. 
     32        //void Read(ViewCellHistoryContainer &history); 
     33        /** Reads the viewcells info from disc 
    3834        */ 
    3935        void Read(const int numSamples, ViewCellInfoContainer &infos); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.cpp

    r2576 r2580  
    77 
    88 
     9LogWriter::LogWriter() 
     10{ 
     11} 
     12 
     13 
     14LogWriter::LogWriter(const std::string &filename): mFilename(filename) 
     15{ 
     16} 
     17 
     18 
    919void LogWriter::SetFilename(const std::string &filename) 
    1020{ 
     
    1323 
    1424 
    15 void LogWriter::Write(ofstream &myfile, const int numSamples, const ViewCellInfoContainer &infos) 
     25void LogWriter::Write(//ofstream &myfile,  
     26                                          const int numSamples, const ViewCellInfoContainer &infos) 
    1627{ 
     28        ofstream myfile; 
     29        myfile.open(mFilename.c_str()); 
     30 
     31        if (!myfile.is_open()) 
     32                myfile.open(mFilename.c_str()); 
     33 
    1734        ViewCellInfoContainer::const_iterator vit, vit_end = infos.end(); 
    1835 
     
    2542} 
    2643 
    27  
     44/* 
    2845void LogWriter::Write(const ViewCellHistoryContainer &hist) 
    2946{ 
    30         ofstream myfile; 
    31  
     47        //ofstream myfile; 
    3248        //char filename[64];  
    3349        //sprintf(filename, "%s %06d", mFilename.c_str(), numSamples); 
    3450        //myfile.open(filename); 
    35         myfile.open(mFilename.c_str()); 
     51        if (!mFile.is_open()) 
     52                mFile.open(mFilename.c_str()); 
    3653 
    3754        ViewCellHistoryContainer::const_iterator vit, vit_end = hist.end(); 
     
    3956        // number of samples 
    4057        //myfile << "samples: " << numSamples << endl; 
    41         myfile << (int)hist.size() << endl; 
     58        mFile << (int)hist.size() << endl; 
    4259 
    4360        for (vit = hist.begin(); vit != vit_end; ++ vit) 
     
    4764} 
    4865 
     66*/ 
     67 
    4968} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/LogWriter.h

    r2576 r2580  
    1717class LogWriter 
    1818{ 
     19public: 
     20 
     21        LogWriter(); 
     22        LogWriter(const std::string &filename); 
    1923        void SetFilename(const std::string &filename); 
    2024 
    2125        //void Write(const int numSamples, const ViewCellContainer &viewcells); 
    22         void Write(std::ofstream &myfile, const int numSamples, const ViewCellInfoContainer &infos); 
    23         void Write(const ViewCellHistoryContainer &hist); 
     26        void Write(//std::ofstream &myfile,  
     27                                const int numSamples, const ViewCellInfoContainer &infos); 
     28        //void Write(const ViewCellHistoryContainer &hist); 
    2429 
    2530protected: 
    2631 
     32        //std::ofstream mFile; 
    2733        std::string mFilename; 
    2834}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2577 r2580  
    1616#include "Material.h" 
    1717#include "IntersectableWrapper.h" 
     18#include "LogWriter.h" 
    1819 
    1920 
     
    4445QtGlDebuggerWidget *debuggerWidget = NULL; 
    4546 
     47const static int SAMPLES_INCR = 2000000; 
    4648 
    4749static inline bool ilt(Intersectable *obj1, Intersectable *obj2) 
     
    860862        mUseFilter = tmp; 
    861863 
    862         Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", 
    863                 tmp ); 
     864        Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilitySpatialFilter", tmp ); 
    864865        mUseSpatialFilter = tmp; 
     866 
     867        //mLogWriter = new LogWriter("myfile.out"); 
    865868 
    866869        mShowRenderCost = false; 
    867870        mShowPvsSizes = false; 
     871        mShowComparison = false; 
    868872        mShowPiercingRays = false; 
    869873        mShowWeightedRays = false; 
     
    879883        mShowRays = false; 
    880884 
     885        mNextSamples = SAMPLES_INCR; 
    881886        mControlWidget = new QtRendererControlWidget(NULL); 
    882887 
     
    904909        connect(mControlWidget, SIGNAL(SetUseTransparency(bool)), this, SLOT(SetUseTransparency(bool))); 
    905910        connect(mControlWidget, SIGNAL(SetShowPvsSizes(bool)), this, SLOT(SetShowPvsSizes(bool))); 
     911        connect(mControlWidget, SIGNAL(SetShowComparison(bool)), this, SLOT(SetShowComparison(bool))); 
    906912        connect(mControlWidget, SIGNAL(SetTopView(bool)), this, SLOT(SetTopView(bool))); 
    907913        connect(mControlWidget, SIGNAL(SetCutViewCells(bool)), this, SLOT(SetCutViewCells(bool))); 
     
    13411347        int i; 
    13421348 
    1343         mRecordHist = false; 
    1344         //mRecordHist = true; 
     1349        //mRecordHist = false; 
     1350        mRecordHist = true; 
     1351        mNextSamples = 2000000; 
    13451352 
    13461353        ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 
    1347          
    1348         if (mRecordHist && (mSamples > mNextSamples)) 
    1349         { 
    1350                 mNextSamples += 2000000; 
    1351  
    1352                 ViewCellInfoContainer *newContainer = new ViewCellInfoContainer(); 
    1353  
    1354                 FillNewContainer(viewcells, *newContainer); 
    1355                 mCurrentHist[mNextSamples] = newContainer; 
     1354        const int currentSamples = mViewCellsManager->GetPreprocessor()->mCurrentSamples; 
     1355        //cout << "current samples: " << currentSamples << endl; 
     1356 
     1357        if (mRecordHist && (currentSamples > mNextSamples)) 
     1358        { 
     1359                //mNextSamples += SAMPLES_INCR; 
     1360cout<<"************************************************" << 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                cout << "finished writing file" << endl; 
    13561372        } 
    13571373 
     
    14101426                } 
    14111427 
    1412                 if (mAssignImportanceByRelativeValue) 
     1428                if (!mShowComparison)//mAssignImportanceByRelativeValue) 
    14131429                        AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost); 
    14141430                else 
    14151431                { 
    1416                         ViewCellInfoContainer *infos1 = mCurrentHist[mCurrentSamples]; 
    1417                         ViewCellInfoContainer *infos2 = mCompareHist[mCurrentSamples]; 
    1418                         AssignColorByComparison(viewcells, *infos1, *infos2); 
    1419                 } 
    1420  
     1432                        mCurrentInfo.clear(); 
     1433                        FillNewContainer(viewcells, mCurrentInfo); 
     1434 
     1435                        //ViewCellInfoContainer *infos1 = mCurrentHist[mNextSamples]; 
     1436                        //ViewCellInfoContainer *infos2 = mCompareHist[mNextSamples]; 
     1437 
     1438                        //AssignColorByComparison(viewcells, *infos1, *infos2); 
     1439                        AssignColorByComparison(viewcells, //mCurrentInfo,  
     1440                                mCompareInfo); 
     1441                } 
    14211442 
    14221443                glEnable(GL_DEPTH_TEST);         
     
    14871508 
    14881509void QtGlRendererWidget::AssignColorByComparison(const ViewCellContainer &viewcells, 
    1489                                                                                                  const ViewCellInfoContainer &infos1,  
    1490                                                                                                  const ViewCellInfoContainer &infos2) 
    1491 { 
    1492  
    1493         const float maxRatio = 2; 
    1494         const float minRatio = 0.5; 
     1510                                                                                                 //const ViewCellInfoContainer &infos1,  
     1511                                                                                                 const ViewCellInfoContainer &compareInfo) 
     1512{ 
     1513 
     1514        const float maxRatio = 1.0f; 
     1515        const float minRatio = 0.5f; 
    14951516 
    14961517        const float scale = 1.0f / (maxRatio - minRatio); 
     
    15011522                ViewCell *vc = viewcells[i]; 
    15021523 
    1503                 ViewCellInfo vc1Info = infos1[i]; 
    1504                 ViewCellInfo vc2Info = infos2[i]; 
    1505  
    1506                 const float vcRatio = vc1Info.mPiercingRays / vc2Info.mPiercingRays + Limits::Small; 
     1524                //ViewCellInfo vc1Info = infos1[i]; 
     1525                ViewCellInfo vc2Info = compareInfo[i]; 
     1526 
     1527                const float vcRatio = vc->GetNumPiercingRays() / vc2Info.mPiercingRays + Limits::Small; 
    15071528 
    15081529                const float importance = (vcRatio - minRatio) * scale; 
     
    15261547/**********************************************************************/ 
    15271548 
    1528 #if 1 
     1549 
    15291550QGroupBox *QtRendererControlWidget::CreateVisualizationPanel(QWidget *parent) 
    15301551{ 
     
    17071728        cb->setChecked(false); 
    17081729        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRays(bool))); 
     1730         
     1731        cb = new QCheckBox("Show Comparison", hbox); 
     1732        hlayout->addWidget(cb); 
     1733        cb->setChecked(false); 
     1734        connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowComparison(bool))); 
    17091735 
    17101736 
     
    19431969 
    19441970 
    1945 #endif 
    1946  
    19471971 
    19481972/*********************************************************************/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2577 r2580  
    4141struct RenderCostSample; 
    4242 
     43//class LogWriter; 
     44 
     45 
    4346 
    4447class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer 
     
    124127  void SetShowPiercingRays(bool); 
    125128  void SetShowWeightedRays(bool); 
     129   void SetShowComparison(bool); 
    126130  void SetShowWeightedCost(bool); 
    127131  
     
    163167 
    164168        bool mShowPvsSizes; 
     169        bool mShowComparison; 
    165170        float mSpatialFilterSize; 
    166171 
     172        //LogWriter *mLogWriter; 
    167173        Plane3 mSceneCutPlane; 
    168174        float mHidingCost; 
     
    180186 
    181187        /// the current number of samples 
    182         int mSamples; 
     188        //int mCurrentSamples; 
    183189        /// the next number of samples where we record the data 
    184190        int mNextSamples; 
     
    192198        unsigned int mIndexBufferSize; 
    193199 
    194         bool mAssignImportanceByRelativeValue; 
     200        //bool mAssignImportanceByRelativeValue; 
    195201 
    196202        Vector3 mDummyViewPoint; 
     
    202208        int mCurrentSamples; 
    203209 
    204         ViewCellHistoryContainer mCurrentHist; 
    205         ViewCellHistoryContainer mCompareHist; 
    206  
     210        //ViewCellHistoryContainer mCurrentHist; 
     211        //ViewCellHistoryContainer mCompareHist; 
     212 
     213        ViewCellInfoContainer mCurrentInfo; 
     214        ViewCellInfoContainer mCompareInfo; 
    207215 
    208216        QtGlRendererWidget(SceneGraph *sceneGraph, 
    209                 ViewCellsManager *viewcells, 
    210                 KdTree *tree, 
    211                 QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0 
    212                 ); 
     217                               ViewCellsManager *viewcells, 
     218                                           KdTree *tree, 
     219                                           QWidget * parent = 0,  
     220                                           const QGLWidget *shareWidget = 0,  
     221                                           Qt::WFlags f = 0); 
    213222 
    214223        QtGlRendererWidget() {}; 
     
    276285 
    277286        void AssignColorByComparison(const ViewCellContainer &viewcells, 
    278                                                                  const ViewCellInfoContainer &info1,  
    279                                                                  const ViewCellInfoContainer &info2); 
     287                                                                 //const ViewCellInfoContainer &info1,  
     288                                                                 const ViewCellInfoContainer &compareInfo); 
    280289 
    281290 
     
    368377        void SetShowPvsSizes(bool b) { 
    369378                mShowPvsSizes = b; 
     379                updateGL(); 
     380        } 
     381 
     382        void SetShowComparison(bool b) { 
     383                mShowComparison = b; 
    370384                updateGL(); 
    371385        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2575 r2580  
    88#include "RssTree.h" 
    99#include "Mutation.h" 
     10#if TODO 
    1011#include "FilterBasedDistribution.h" 
     12#endif 
    1113#include "DifferenceSampling.h" 
    1214 
     
    726728                                        } else 
    727729                                          if (strcmp(curr, "filter_based")==0) { 
     730#if TODO 
    728731                                                mDistributions.push_back(new FilterBasedDistribution(mPreprocessor)); 
     732#endif 
    729733                                          } 
    730734                                        else if (strcmp(curr, "difference")==0) { 
Note: See TracChangeset for help on using the changeset viewer.