Changeset 660


Ignore:
Timestamp:
02/21/06 17:42:39 (18 years ago)
Author:
mattausch
Message:

adding function for testing purpose

Location:
GTP/trunk/Lib/Vis
Files:
13 edited

Legend:

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

    r633 r660  
    1515                        OutputDirectory="..\lib\$(ConfigurationName)" 
    1616                        IntermediateDirectory="..\obj\$(ConfigurationName)" 
    17                         ConfigurationType="4" 
     17                        ConfigurationType="1" 
    1818                        CharacterSet="2"> 
    1919                        <Tool 
    2020                                Name="VCCLCompilerTool" 
    2121                                Optimization="0" 
    22                                 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include;&quot;$(QTDIR)&quot;\includ&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;..\src;&quot;$(CG_INC_PATH)&quot;;&quot;$(GTPDIR)\NonGTP\Xerces&quot;;&quot;$(GTPDIR)\NonGTP\Devil&quot;;" 
     22                                AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include..\support;&quot;..\include  ..\support&quot;;..\include;&quot;$(GTPDIR)\NonGTP\Devil\include&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(GTPDIR)\NonGTP\Xerces&quot;;&quot;$(CG_INC_PATH)&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(GTPDIR)\NonGTP\Zlib\include&quot;" 
    2323                                PreprocessorDefinitions="WIN32;_DEBUG;_LIB" 
    2424                                MinimalRebuild="TRUE" 
     
    3333                                Name="VCCustomBuildTool"/> 
    3434                        <Tool 
    35                                 Name="VCLibrarianTool" 
    36                                 OutputFile="$(OutDir)/GtpVisibility.lib"/> 
     35                                Name="VCLinkerTool" 
     36                                AdditionalDependencies="xerces-c_2D.lib zdll.lib zziplibd.lib devil.lib qtmain.lib QtOpenGLd4.lib QtCored4.lib QtGuid4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 
     37                                AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;&quot;$(QTDIR)\lib&quot;;..\include;..\src\GL;&quot;$(CG_LIB_PATH)&quot;;&quot;$(GTPDIR)\NonGTP\Xerces&quot;;&quot;$(GTPDIR)\NonGTP\Xerces\xercesc\lib&quot;;&quot;$(GTPDIR)\NonGTP\zlib\lib&quot;;&quot;$(GTPDIR)\NonGTP\Devil\lib&quot;"/> 
    3738                        <Tool 
    3839                                Name="VCMIDLTool"/> 
     
    4950                        <Tool 
    5051                                Name="VCXMLDataGeneratorTool"/> 
     52                        <Tool 
     53                                Name="VCWebDeploymentTool"/> 
    5154                        <Tool 
    5255                                Name="VCManagedWrapperGeneratorTool"/> 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env

    r658 r660  
    203203        pruneEmptyViewCells false 
    204204        processOnlyValidViewCells false 
    205          
     205 
     206        stats viewCellStats.log 
     207 
     208        samplingType directional 
     209 
    206210        PostProcess { 
    207211                # how much samples are used for post processing 
     
    216220                compress false 
    217221                merge true 
     222                statsPrefix ../scripts/viewCells 
    218223        } 
    219224 
     
    314319        maxStaticMemory 50 
    315320         
     321        subdivisionStats ../subDivisionStats.log 
     322 
    316323        # factors for evaluating split plane costs 
    317324        Factor { 
     
    405412        maxTests 10000 
    406413         
     414        subdivisionStats ../subDivisionStats.log 
     415 
    407416        # factors for evaluating split plane costs 
    408417        Factor { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r658 r660  
    12061206                        "bspTree"); 
    12071207 
     1208        RegisterOption("ViewCells.stats", 
     1209                                        optString, 
     1210                                        "view_cells_stats=", 
     1211                                        "viewCellsStats.log"); 
     1212 
     1213        RegisterOption("ViewCells.PostProcess.statsPrefix", 
     1214                                        optString, 
     1215                                        "view_cells_stats_prefix=", 
     1216                                        "viewCells"); 
     1217 
     1218 
     1219        RegisterOption("ViewCells.active", 
     1220                                        optInt, 
     1221                                        "1000"); 
     1222         
    12081223        RegisterOption("ViewCells.active", 
    12091224                                        optInt, 
     
    12141229                                        "view_cells_construction_samples=", 
    12151230                                        "5000000"); 
     1231 
     1232        RegisterOption("ViewCells.Evaluation.samples", 
     1233                                        optInt, 
     1234                                        "view_cells_evaluation_samples=", 
     1235                                        "8000000"); 
     1236 
     1237        RegisterOption("ViewCells.Evaluation.samplesPerPass", 
     1238                                        optInt, 
     1239                                        "view_cells_evaluation_samples_per_oass=", 
     1240                                        "300000"); 
    12161241 
    12171242        RegisterOption("ViewCells.Construction.samplesPerPass", 
     
    12801305                "-view_cells_delayed_construction", 
    12811306                "false"); 
    1282  
    12831307         
    12841308 
     
    12971321                "-view_cells_process_only_valid_view_cells", 
    12981322                "false"); 
    1299          
     1323 
    13001324         
    13011325        RegisterOption("ViewCells.PostProcess.maxCostRatio", 
     
    13031327                        "-view_cells_post_process_max_cost_ratio=", 
    13041328                        "0.9"); 
    1305  
    13061329         
    13071330        RegisterOption("ViewCells.PostProcess.renderCostWeight", 
     
    13091332                        "-view_cells_post_process_render_cost_weight", 
    13101333                        "0.5"); 
    1311  
    13121334         
    13131335        RegisterOption("ViewCells.PostProcess.avgCostMaxDeviation", 
     
    13461368                "8.0"); 
    13471369 
    1348         RegisterOption("ViewCells.Visualization.useCuttingPlane", 
     1370        RegisterOption("ViewCells.Visualization.useClipPlane", 
    13491371                optBool,  
    1350                 "view_cells_viz_use_cutting_plane=",  
     1372                "view_cells_viz_use_clip_plane=",  
    13511373                "false"); 
    1352  
    13531374         
    1354         RegisterOption("ViewCells.Visualization.cuttingPlaneAxis", 
     1375        RegisterOption("ViewCells.Visualization.clipPlaneAxis", 
    13551376                optInt,  
    1356                 "view_cells_viz_cutting_plane_axis=",  
     1377                "view_cells_viz_clip_plane_axis=",  
    13571378                "0"); 
    13581379 
     
    13901411                "bsp_construction_input=", 
    13911412                "fromViewCells"); 
     1413 
     1414        RegisterOption("BspTree.subdivisionStats", 
     1415                                        optString, 
     1416                                        "vsp_bsp_subdivision_stats=", 
     1417                                        "bspSubdivisionStats.log"); 
    13921418 
    13931419        RegisterOption("BspTree.Construction.samples", 
     
    18401866                                        "vsp_bsp_term_min_pvs=", 
    18411867                                        "20"); 
     1868 
    18421869        RegisterOption("VspBspTree.Termination.minProbability", 
    18431870                                        optFloat, 
    18441871                                        "vsp_bsp_term_min_probability=", 
    18451872                                        "0.001"); 
     1873 
     1874        RegisterOption("VspBspTree.subdivisionStats", 
     1875                                        optString, 
     1876                                        "vsp_bsp_subdivision_stats=", 
     1877                                        "vspBspSubdivisionStats.log"); 
    18461878 
    18471879        RegisterOption("VspBspTree.Termination.maxRayContribution", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r651 r660  
    3030int ViewCell::sMailId = 21843194198; 
    3131int ViewCell::sReservedMailboxes = 1; 
     32int ViewCell::sLastUpdated = 0; 
    3233 
    3334//int upperPvsLimit = 120; 
     
    117118mParent(NULL), 
    118119mMergeCost(0), 
    119 mIsActive(false) 
     120mIsActive(false), 
     121mLastUpdated(sLastUpdated) 
    120122{ 
    121123} 
     
    216218} 
    217219 
     220 
     221void ViewCell::SetActive() 
     222{ 
     223        mIsActive = true; 
     224        mLastUpdated = sLastUpdated; 
     225} 
     226 
     227 
     228bool ViewCell::IsActive() const 
     229{ 
     230        return mIsActive  && (mLastUpdated == sLastUpdated); 
     231} 
    218232 
    219233 
     
    12511265 
    12521266 
    1253 void ViewCellsTree::ExportStats() 
     1267void ViewCellsTree::ExportStats(const string &mergeStats) 
    12541268{ 
    12551269        TraversalQueue tqueue; 
     
    12691283 
    12701284        ofstream stats; 
    1271         stats.open("mergeStats.log"); 
     1285        stats.open(mergeStats.c_str()); 
    12721286 
    12731287        stats  
     
    13761390} 
    13771391 
     1392 
     1393 
    13781394void ViewCellsTree::CollectBestViewCellSet(ViewCellContainer &viewCells,  
    13791395                                                                                   const int numViewCells) 
     
    13911407                if (vc->IsLeaf() || ((viewCells.size() + tqueue.size() + 1) >= numViewCells)) 
    13921408                { 
    1393                         // todo: should be done with a function taking the active flag and some  
    1394                         // time stamp so I don't have to reset view cells, this also means that  
    1395                         // the leaf view cells can be set active fist 
    1396                         vc->mIsActive = true;  
    13971409                        viewCells.push_back(vc); 
    13981410                } 
     
    16111623ViewCell *ViewCellsTree::GetActiveViewCell(ViewCell *vc) const 
    16121624{ 
    1613         while (vc->GetParent() && !vc->mIsActive) 
     1625        while (vc->GetParent() && !vc->IsActive()) 
    16141626        { 
    16151627                vc = vc->GetParent(); 
     
    16221634void ViewCellsTree::PropagatePvs(ViewCell *vc) 
    16231635{ 
     1636        // propagate pvs up 
    16241637        while (vc->GetParent()) 
    16251638        { 
     
    16311644                return; 
    16321645 
     1646        // propagate pvs to the leaves 
    16331647        stack<ViewCell *> tstack; 
    1634  
    16351648        tstack.push(vc); 
    16361649 
     
    17911804                stream << "<Leaf "; 
    17921805                stream << "id=\"" << viewCell->GetId() << "\" "; 
    1793                 stream << "active=\"" << viewCell->mIsActive << "\" "; 
     1806                stream << "active=\"" << viewCell->IsActive() << "\" "; 
    17941807                stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 
    17951808                stream << "pvs=\""; 
     
    18101823                stream << "<Interior "; 
    18111824                stream << "id=\"" << viewCell->GetId() << "\" "; 
    1812                 stream << "active=\"" << viewCell->mIsActive << "\" "; 
     1825                stream << "active=\"" << viewCell->IsActive() << "\" "; 
    18131826                stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 
    18141827                stream << "pvs=\""; 
     
    18341847 
    18351848 
     1849void ViewCellsTree::ResetPvs() 
     1850{ 
     1851        stack<ViewCell *> tstack; 
     1852 
     1853        tstack.push(mRoot); 
     1854 
     1855        while (!tstack.empty()) 
     1856        { 
     1857                ViewCell *vc = tstack.top(); 
     1858                tstack.pop(); 
     1859 
     1860                vc->GetPvs().mEntries.clear(); 
     1861 
     1862                if (!vc->IsLeaf()) 
     1863                { 
     1864                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1865                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1866                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     1867                        { 
     1868                                tstack.push(*it); 
     1869                        } 
     1870                } 
     1871        } 
     1872} 
     1873 
     1874 
     1875void ViewCellsTree::SetActiveSetToLeaves() 
     1876{ 
     1877} 
    18361878 
    18371879/**************************************************************************/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r651 r660  
    191191 
    192192 
    193                                                   
     193        /** Sets this view cell to be an active view cell. 
     194        */ 
     195        void SetActive(); 
     196        /** Returns if this view cell is active. 
     197        */ 
     198        bool IsActive() const; 
     199 
    194200        // last mail id -> warning not thread safe! 
    195201        // both mailId and mailbox should be unique for each thread!!! 
    196202        static int sMailId; 
    197203        static int sReservedMailboxes; 
    198          
    199         bool mIsActive; 
    200  
     204 
     205        static int sLastUpdated; 
    201206         
    202207protected: 
     
    212217        bool mValid; 
    213218 
    214   /** color used for consistent visualization */ 
    215   RgbColor mColor; 
     219        int mLastUpdated; 
     220        bool mIsActive; 
     221        /** color used for consistent visualization */ 
     222        RgbColor mColor; 
    216223}; 
    217224 
     
    350357        bool IsCompressed() const; 
    351358 
     359        /** Returns active view cell that is in the path of this view cell. 
     360        */ 
    352361        ViewCell *GetActiveViewCell(ViewCell *vc) const; 
    353362 
     363        /** Sets the leaves to be the currently active view cells. 
     364        */ 
     365    void SetActiveSetToLeaves(); 
     366 
    354367        /** Propagates pvs up the tree to the root and downwards the tree. 
    355368        */ 
     
    360373        /** Export statistics of this view cell tree. 
    361374        */ 
    362         void ExportStats(); 
     375        void ExportStats(const string &mergeStats); 
    363376 
    364377        /** Sets root of hierarchy. 
     
    372385        void CreateUniqueViewCellsIds(); 
    373386 
     387        /** Resets pvs of whole tree. 
     388        */ 
     389        void ResetPvs(); 
    374390 
    375391protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r650 r660  
    264264        environment->GetFloatValue("BspTree.Construction.epsilon", mEpsilon); 
    265265 
    266         mSubdivisionStats.open("subdivisionStats.log"); 
     266        char subdivisionStatsLog[100]; 
     267        environment->GetStringValue("BspTree.subdivisionStats", subdivisionStatsLog); 
     268        mSubdivisionStats.open(subdivisionStatsLog); 
    267269 
    268270    Debug << "BSP max depth: " << mTermMaxDepth << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r658 r660  
    6161        environment->GetIntValue("ViewCells.active", mNumActiveViewCells); 
    6262        environment->GetBoolValue("ViewCells.PostProcess.compress", mCompressViewCells); 
    63         environment->GetBoolValue("ViewCells.Visualization.useCuttingPlane", mUseCuttingPlaneForViz); 
     63        environment->GetBoolValue("ViewCells.Visualization.useClipPlane", mUseClipPlaneForViz); 
    6464 
    6565        environment->GetBoolValue("ViewCells.PostProcess.merge", mMergeViewCells); 
     66 
     67        char samplingBuf[50]; 
     68        environment->GetStringValue("ViewCells.samplingType", samplingBuf); 
     69         
     70        if (strcmp(samplingBuf, "box") == 0) 
     71                mSamplingType = Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 
     72        else if (strcmp(samplingBuf, "directional") == 0) 
     73                mSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION; 
     74 
     75#if 0 
     76 
     77                char viewCellsStatsLog[100]; 
     78                environment->GetStringValue("ViewCells.stats", viewCellsStats); 
     79                mViewCellsStats.open(viewCellsStatsLog); 
     80#endif 
    6681 
    6782        mMinPvsSize = emptyViewCells ? 1 : 0; 
     
    157172        //-- construction rays => we use uniform samples for this 
    158173        CastPassSamples(mInitialSamples,  
    159                                         //Preprocessor::DIRECTION_BASED_DISTRIBUTION, 
    160                                         Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION,  
     174                                        mSamplingType, 
    161175                                        initialSamples); 
    162176         
    163177        cout << "finished" << endl; 
    164178 
     179         
    165180        // construct view cells 
    166181        const int numInitialSamples =  
     
    172187        disposeRays(initialSamples, outRays); 
    173188         
     189 
     190        // -- stats after contruction 
     191        ResetViewCells(); 
     192        Debug << "\nView cells after initial sampling: " << mCurrentViewCellsStats << endl; 
     193 
     194        if (0) // export initial view cells 
     195        { 
     196                cout << "exporting initial view cells (=leaves) ... "; 
     197                Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 
     198 
     199                if (exporter) 
     200                { 
     201                        if (mExportGeometry) 
     202                                exporter->ExportGeometry(preprocessor->mObjects); 
     203 
     204                        ExportViewCellsForViz(exporter); 
     205 
     206                        delete exporter; 
     207                } 
     208                cout << "finished" << endl; 
     209        } 
     210 
    174211 
    175212        //-- guided rays are used for further sampling 
     
    191228                dirSamples = !dirSamples; // toggle sampling method 
    192229                numSamples += CastPassSamples(mSamplesPerPass,  
    193                                                                           samplingType, 
     230                                                                          mSamplingType, 
    194231                                                                          constructionSamples); 
    195232 
     
    217254                                    Preprocessor::DIRECTION_BASED_DISTRIBUTION,  
    218255                                        postProcessSamples); 
    219          
     256 
     257 
     258        // stats before post processing (i.e., merge) 
     259        EvaluateViewCellsStats(); 
     260        Debug << "\noriginal view cell partition before post process:\n" << mCurrentViewCellsStats << endl; 
     261 
     262        mRenderer->RenderScene(); 
     263        SimulationStatistics ss; 
     264        dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
     265 
     266    Debug << ss << endl; 
     267 
     268 
     269 
    220270        cout << "starting post processing and visualization" << endl; 
     271 
    221272 
    222273        // store viewCells for postprocessing 
    223274        const bool storeViewCells = true; 
     275 
    224276 
    225277        if (SAMPLE_AFTER_SUBDIVISION) 
     
    240292                ComputeSampleContributions(visualizationSamples, true, storeViewCells); 
    241293 
    242         //Debug << "visualizationsamples: " << mVisualizationSamples << " " << visualizationSamples.size() << endl; 
    243294        // different visualizations 
    244295        Visualize(preprocessor->mObjects, visualizationSamples); 
     
    247298 
    248299        return numSamples; 
     300} 
     301 
     302 
     303void ViewCellsManager::EvalViewCellPartition() 
     304{ 
     305        int samplesPerPass; 
     306        int numSamples; 
     307        int castSamples = 0; 
     308 
     309        environment->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 
     310        environment->GetIntValue("ViewCells.Evaluation.samples", numSamples); 
     311 
     312        while (castSamples < numSamples) 
     313        { 
     314        } 
     315        //char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 
    249316} 
    250317 
     
    385452void ViewCellsManager::EvaluateViewCellsStats() 
    386453{ 
    387         mViewCellsStats.Reset(); 
     454        mCurrentViewCellsStats.Reset(); 
    388455 
    389456        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     
    391458        for (it = mViewCells.begin(); it != it_end; ++ it) 
    392459        { 
    393                 mViewCellsTree->UpdateViewCellsStats(*it, mViewCellsStats); 
     460                mViewCellsTree->UpdateViewCellsStats(*it, mCurrentViewCellsStats); 
    394461        } 
    395462} 
     
    698765        mViewSpaceBox = box; 
    699766 
    700         CreateCuttingPlane(); 
     767        CreateClipPlane(); 
    701768         
    702769        mTotalAreaValid = false; 
     
    704771 
    705772 
    706 void ViewCellsManager::CreateCuttingPlane() 
     773void ViewCellsManager::CreateClipPlane() 
    707774{ 
    708775        int axis = 0; 
    709776 
    710         const float factor = 0.65; 
     777        const float factor = 0.65f; 
    711778        Vector3 point = mViewSpaceBox.Min() +  mViewSpaceBox.Size() * factor; 
    712779 
    713         if (mUseCuttingPlaneForViz) 
    714         environment->GetIntValue("ViewCells.Visualization.cuttingPlaneAxis", axis); 
     780        if (mUseClipPlaneForViz) 
     781        environment->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis); 
    715782 
    716783        Vector3 normal(0,0,0); 
    717784        normal[axis] = 1; 
    718785 
    719         mCuttingPlane = Plane3(normal, point); 
     786        mClipPlane = Plane3(normal, point); 
    720787} 
    721788 
     
    733800        CollectViewCells(); 
    734801         
    735         mViewCellsStats.Reset(); 
     802        mCurrentViewCellsStats.Reset(); 
    736803        EvaluateViewCellsStats(); 
    737804 
     
    813880 
    814881        CastLineSegment(origin, termination, viewcells); 
    815         //Debug << "constribution: " << (int)viewcells.size() << endl; 
    816  
     882         
    817883        // copy viewcells memory efficiently 
    818884        //const bool storeViewcells = !addRays; 
     
    902968void ViewCellsManager::PrintStatistics(ostream &s) const 
    903969{ 
    904         s << mViewCellsStats << endl; 
     970        s << mCurrentViewCellsStats << endl; 
    905971} 
    906972 
     
    926992                        ExportColor(exporter, *it);              
    927993                        ExportViewCellGeometry(exporter, *it,  
    928                                 mUseCuttingPlaneForViz ? &mCuttingPlane : NULL); 
     994                                mUseClipPlaneForViz ? &mClipPlane : NULL); 
    929995                } 
    930996        } 
     
    9601026 
    9611027 
     1028void ViewCellsManager::SetViewCellsActive() 
     1029{ 
     1030        ++ ViewCell::sLastUpdated; 
     1031        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     1032        for (it = mViewCells.begin(); it != it_end; ++ it) 
     1033        { 
     1034                (*it)->SetActive(); 
     1035        } 
     1036} 
    9621037 
    9631038/**********************************************************************/ 
     
    10321107 
    10331108        //EvaluateViewCellsStats(); 
    1034         Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 
     1109        Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 
    10351110 
    10361111        // recast rest of the rays 
    10371112        if (SAMPLE_AFTER_SUBDIVISION) 
    10381113                ComputeSampleContributions(savedRays, true, false); 
    1039  
    1040  
    1041         ResetViewCells(); 
    1042      
    1043         Debug << "\nView cells after " << (int)savedRays.size()  
    1044                   << " samples:\n" << mViewCellsStats << endl; 
    1045  
    1046         if (1) // export initial view cells 
    1047         { 
    1048                 cout << "exporting initial view cells (=leaves) ... "; 
    1049                 Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 
    1050  
    1051                 if (exporter) 
    1052                 { 
    1053                         if (0 && mExportRays) 
    1054                                 exporter->ExportRays(rays, RgbColor(1, 1, 1)); 
    1055                          
    1056                         if (mExportGeometry) 
    1057                                 exporter->ExportGeometry(objects); 
    1058  
    1059                         //exporter->SetWireframe(); 
    1060                         exporter->SetFilled(); 
    1061                         ExportViewCellsForViz(exporter); 
    1062  
    1063  
    1064                         delete exporter; 
    1065                 } 
    1066                 cout << "finished" << endl; 
    1067         } 
    1068  
    10691114 
    10701115        return sampleContributions; 
     
    11151160                return 0; 
    11161161        } 
    1117  
    11181162         
    11191163        // view cells already finished before post processing step (i.e. because they were loaded) 
     
    11301174    int vcSize = 0; 
    11311175        int pvsSize = 0; 
    1132  
    1133         EvaluateViewCellsStats(); 
    1134         Debug << "\noriginal view cell partition:\n" << mViewCellsStats << endl; 
    1135  
    1136         mRenderer->RenderScene(); 
    1137         SimulationStatistics ss; 
    1138         dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
    1139  
    1140     Debug << ss << endl; 
    1141  
    1142          
    11431176 
    11441177        //-- merge view cells 
     
    11511184        if (mMergeViewCells) 
    11521185        { 
    1153                 Debug << "constructing visibility based merge tree" << endl; 
     1186                cout << "constructing visibility based merge tree" << endl; 
    11541187                mViewCellsTree->ConstructMergeTree(rays, objects); 
    11551188        } 
    11561189        else 
    11571190        { 
    1158                 Debug << "constructing spatial merge tree" << endl; 
     1191                cout << "constructing spatial merge tree" << endl; 
    11591192                // create spatial merge hierarchy 
    11601193                mViewCellsTree->SetRoot(ConstructSpatialMergeTree(mBspTree->GetRoot())); 
    11611194        } 
    11621195 
    1163         mViewCellsTree->ExportStats(); 
     1196        // export statistics after merge 
     1197        if (0) 
     1198                mViewCellsTree->ExportStats("mergeStats.log"); 
    11641199 
    11651200        //-- stats and visualizations 
     
    11721207         
    11731208 
     1209        //-- visualization and statistics 
    11741210    // reset view cells and stats 
    11751211        ResetViewCells(); 
    1176         Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 
     1212        Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 
     1213 
    11771214 
    11781215        int savedColorCode  = mColorCode; 
     
    14681505                { 
    14691506                        importance = (float)vc->GetPvs().GetSize() / 
    1470                                 (float)mViewCellsStats.maxPvs; 
     1507                                (float)mCurrentViewCellsStats.maxPvs; 
    14711508 
    14721509                } 
     
    14751512                { 
    14761513            int lSize = mViewCellsTree->GetSize(vc); 
    1477                         importance = (float)lSize / (float)mViewCellsStats.maxLeaves; 
     1514                        importance = (float)lSize / (float)mCurrentViewCellsStats.maxLeaves; 
    14781515                } 
    14791516                //break; 
     
    15021539void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    15031540                                                                                                 ViewCell *vc, 
    1504                                                                                                  const Plane3 *cuttingPlane) const 
     1541                                                                                                 const Plane3 *clipPlane) const 
    15051542{ 
    15061543        if (vc->GetMesh()) 
     
    15131550        mBspTree->ConstructGeometry(vc, geom); 
    15141551 
    1515  
    1516         if (cuttingPlane) 
     1552        if (clipPlane) 
    15171553        { 
    15181554                BspNodeGeometry front; 
     
    15211557                geom.SplitGeometry(front, 
    15221558                                                   back, 
    1523                                                    *cuttingPlane, 
     1559                                                   *clipPlane, 
    15241560                                                   mViewSpaceBox,  
    15251561                                                   0.0001f); 
     
    17751811 
    17761812        EvaluateViewCellsStats(); 
    1777         Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 
     1813        Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 
    17781814 
    17791815        return 0; 
     
    19782014void KdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    19792015                                                                                                ViewCell *vc, 
    1980                                                                                                 const Plane3 *cuttingPlane) const 
     2016                                                                                                const Plane3 *clipPlane) const 
    19812017{ 
    19822018        ViewCellContainer leaves; 
     
    20982134        ResetViewCells(); 
    20992135 
    2100         Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 
     2136        Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 
    21012137 
    21022138        long startTime = GetTime(); 
     2139 
    21032140        // recast rest of rays 
    21042141        ComputeSampleContributions(savedRays, true, false); 
     
    23282365                { 
    23292366                        importance = (float)vc->GetPvs().GetSize() / 
    2330                                 (float)mViewCellsStats.maxPvs; 
     2367                                (float)mCurrentViewCellsStats.maxPvs; 
    23312368                } 
    23322369                break; 
     
    23352372                int lSize = mViewCellsTree->GetSize(vc); 
    23362373                        importance = (float)lSize / 
    2337                                 (float)mViewCellsStats.maxLeaves; 
     2374                                (float)mCurrentViewCellsStats.maxLeaves; 
    23382375                } 
    23392376                break; 
     
    23592396void VspKdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    23602397                                                                                                   ViewCell *vc, 
    2361                                                                                                    const Plane3 *cuttingPlane) const 
     2398                                                                                                   const Plane3 *clipPlane) const 
    23622399{ 
    23632400        VspKdViewCell *kdVc = dynamic_cast<VspKdViewCell *>(vc); 
     
    24502487 
    24512488 
    2452 /*void VspBspViewCellsManager::CollectNodes(ViewCell *vc, vector<BspNode *>nodes) 
    2453 { 
    2454         void ViewCellsTree::CollectLeaves(ViewCell *vc, vector<BspNode *> &nodes) const 
    2455          
    2456         if (vc->IsLeaf()) 
    2457         { 
    2458                 BspViewCell *bvc = dynamic_cast<BspViewCell *>(vc); 
    2459                 nodes->push_back(bvc->mLeaf); 
    2460         } 
    2461         else 
    2462         { 
    2463                 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    2464  
    2465                 for (it = interior->mChildren.begin; it != it_end; ++ it) 
    2466                 { 
    2467                         vector<BspNode *> mynodes; 
    2468                         CollectNodes(*it, mynodes); 
    2469  
    2470                         if (mynodes[0]->GetParent() && (mynodes[0]->GetParent() == mynodes[1]->GetParent())) 
    2471                         { 
    2472                                 nodes.push_back(nodes[0]->GetParent()); 
    2473                         } 
    2474  
    2475                 } 
    2476         } 
    2477 }*/ 
    2478  
    2479  
    24802489int VspBspViewCellsManager::ConstructSubdivision(const ObjectContainer &objects, 
    24812490                                                                                                 const VssRayContainer &rays) 
     
    24852494                return 0; 
    24862495 
    2487         Debug << "Constructing bsp view cells" << endl; 
    2488  
    24892496        int sampleContributions = 0; 
    24902497 
     
    24962503        VssRayContainer savedRays; 
    24972504 
    2498         Debug << "samples used for subdivision: " << mInitialSamples  
     2505        Debug << "samples used for vsp bsp subdivision: " << mInitialSamples  
    24992506                  << " rays: " << (int)rays.size() << endl; 
    25002507 
     
    25072514 
    25082515        mVspBspTree->Construct(constructionRays, &mViewSpaceBox); 
    2509  
    2510         Debug << mVspBspTree->GetStatistics() << endl; 
    25112516 
    25122517        // collapse invalid regions 
     
    25192524    cout << "finished" << endl; 
    25202525 
    2521         cout << "reseting view cell stats ... "; 
     2526        // -- stats 
     2527        Debug << mVspBspTree->GetStatistics() << endl; 
     2528 
    25222529        ResetViewCells(); 
    2523         cout << "finished" << endl; 
    2524  
    2525         Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 
    2526  
    2527         if (0) // export initial view cells 
    2528         { 
    2529                 cout << "exporting initial view cells (=leaves) ... "; 
    2530                 Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 
    2531  
    2532                 if (exporter) 
    2533                 { 
    2534                         if (0 && mExportRays) 
    2535                                 exporter->ExportRays(rays, RgbColor(1, 1, 1)); 
    2536  
    2537                         if (mExportGeometry) 
    2538                                 exporter->ExportGeometry(objects); 
    2539  
    2540                         //exporter->SetWireframe(); 
    2541                         exporter->SetFilled(); 
    2542                         ExportViewCellsForViz(exporter); 
    2543  
    2544                         delete exporter; 
    2545                 } 
    2546                 cout << "finished" << endl; 
    2547         } 
     2530        Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 
     2531 
    25482532 
    25492533        startTime = GetTime(); 
    2550  
    2551         // reset view cells and stats 
    2552         ResetViewCells(); 
    25532534 
    25542535        cout << "Computing remaining ray contributions ... "; 
     
    25752556        int pvsSize = 0; 
    25762557 
    2577         mRenderer->RenderScene(); 
    2578         SimulationStatistics ss; 
    2579         dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
    2580     Debug << ss << endl; 
    2581  
    25822558        //-- merge view cells 
    25832559         
     
    25882564        if (mMergeViewCells) 
    25892565        { 
    2590                 Debug << "merging view cells" << endl; 
    25912566                // TODO: should be done BEFORE the ray casting 
    25922567                mViewCellsTree->ConstructMergeTree(rays, objects); 
     
    25942569        else 
    25952570        { 
    2596                 Debug << "spatial merge" << endl; 
    25972571                mViewCellsTree->SetRoot(ConstructSpatialMergeTree(mVspBspTree->GetRoot())); 
    25982572        } 
    25992573 
    2600         mViewCellsTree->ExportStats(); 
     2574        if (0) 
     2575                mViewCellsTree->ExportStats("mergeStats.log"); 
    26012576 
    26022577        //-- stats and visualizations 
     
    26112586        int savedColorCode = mColorCode; 
    26122587         
     2588        // get currently active view cell set 
     2589        ResetViewCells(); 
     2590        Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 
     2591 
    26132592        //BspLeaf::NewMail(); 
    26142593        if (0) // export merged view cells 
    26152594        { 
    26162595                mColorCode = 0; 
    2617                 cout << "reseting view cells ... "; 
    2618                 ResetViewCells(); 
    2619  
    2620                 cout << "finished" << endl; 
    2621  
    26222596                Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 
    2623                 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 
    2624  
     2597                 
    26252598                cout << "exporting view cells after merge ... "; 
    26262599 
     
    27752748        mVspBspTree->ValidateTree(); 
    27762749 
    2777         // recompute view cell statistics 
    2778         mViewCellsStats.Reset(); 
    2779         EvaluateViewCellsStats(); 
    2780  
    27812750        // has to be recomputed 
    27822751        mTotalAreaValid = false; 
    2783  
    2784  
    27852752        VssRayContainer postProcessRays; 
    2786  
    27872753        GetRaySets(rays, mPostProcessSamples, postProcessRays); 
    27882754 
    27892755        Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 
    27902756 
    2791         Debug << "\nview cell partition after sampling:\n" << mViewCellsStats << endl << endl; 
    27922757 
    27932758        // should maybe be done here to allow merge working with area or volume 
     
    28062771                RefineViewCells(postProcessRays, objects); 
    28072772 
    2808         //-- render simulation after merge 
     2773 
     2774        //-- render simulation after merge + refine 
     2775         
    28092776        cout << "\nevaluating bsp view cells render time before compress ... "; 
    28102777        dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 
     
    28312798                Debug << "number of entries after compress: " << pvsEntries << endl; 
    28322799        } 
     2800 
    28332801 
    28342802        // collapse sibling leaves that share the same view cell 
     
    32883256                { 
    32893257                        importance = (float)vc->GetPvs().GetSize() / 
    3290                                 (float)mViewCellsStats.maxPvs; 
     3258                                (float)mCurrentViewCellsStats.maxPvs; 
    32913259 
    32923260                } 
     
    32953263                { 
    32963264            int lSize = mViewCellsTree->GetSize(vc); 
    3297                         importance = (float)lSize / (float)mViewCellsStats.maxLeaves; 
     3265                        importance = (float)lSize / (float)mCurrentViewCellsStats.maxLeaves; 
    32983266                } 
    32993267                break; 
     
    33213289void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    33223290                                                    ViewCell *vc, 
    3323                                                                                                         const Plane3 *cuttingPlane) const 
     3291                                                                                                        const Plane3 *clipPlane) const 
    33243292{ 
    33253293        if (vc->GetMesh()) 
     
    33313299 
    33323300         
    3333         if (cuttingPlane) 
     3301        if (clipPlane) 
    33343302        { 
    33353303                ViewCellContainer leaves; 
     
    33513319                        geom.SplitGeometry(front, 
    33523320                                                           back, 
    3353                                                            *cuttingPlane, 
     3321                                                           *clipPlane, 
    33543322                                                           mViewSpaceBox,  
    33553323                                                           0.0001f); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r651 r660  
    320320        virtual void ExportViewCellGeometry(Exporter *exporter,  
    321321                                                                                ViewCell *vc, 
    322                                                                                 const Plane3 *cuttingPlane = NULL) const = 0; 
     322                                                                                const Plane3 *clipPlane = NULL) const = 0; 
    323323 
    324324        virtual void FinalizeViewCells(const bool createMesh); 
     
    352352        void CollectViewCells(const int n); 
    353353 
     354        /** Returns true if this (logical) view cell is equal to a spatial node. 
     355        */ 
    354356        virtual bool EqualToSpatialNode(ViewCell *viewCell) const { return false;} 
    355357 
     358        /** Sets current view cells set to active, i.e., the sampling is done in this view cell set. 
     359        */ 
     360        void SetViewCellsActive(); 
     361 
     362        /** Evaluates worth of current view cell hierarchy. 
     363        */ 
     364        void EvalViewCellPartition(); 
    356365 
    357366protected: 
     
    407416        void CreateViewCellMeshes(); 
    408417 
    409  
    410418        /** Takes different measures to prepares the view cells after loading them from disc. 
    411419        */ 
    412420        virtual void PrepareLoadedViewCells() {}; 
    413421 
    414  
    415         void CreateCuttingPlane(); 
    416  
    417         Plane3 mCuttingPlane; 
    418         bool mUseCuttingPlaneForViz; 
     422        /** Creates clip plane for visualization. 
     423        */ 
     424        void CreateClipPlane(); 
     425 
     426        Plane3 mClipPlane; 
     427        bool mUseClipPlaneForViz; 
    419428 
    420429 
     
    441450        float mMaxPvsRatio; 
    442451 
     452        int mSamplingType; 
    443453        int mNumActiveViewCells; 
    444454        bool mCompressViewCells; 
    445455 
    446         ViewCellsStatistics mViewCellsStats; 
     456        ViewCellsStatistics mCurrentViewCellsStats; 
    447457        /// the scene bounding box 
    448458        AxisAlignedBox3 mViewSpaceBox; 
     
    517527        void ExportViewCellGeometry(Exporter *exporter,  
    518528                                                                ViewCell *vc,  
    519                                                                 const Plane3 *cuttingPlane = NULL) const; 
     529                                                                const Plane3 *clipPlane = NULL) const; 
    520530         
    521531        void CollectMergeCandidates(const VssRayContainer &rays,  
     
    600610        void ExportViewCellGeometry(Exporter *exporter,  
    601611                                                                ViewCell *vc, 
    602                                                                 const Plane3 *cuttingPlane = NULL) const; 
     612                                                                const Plane3 *clipPlane = NULL) const; 
    603613 
    604614        void CollectMergeCandidates(const VssRayContainer &rays,  
     
    666676        void ExportViewCellGeometry(Exporter *exporter,  
    667677                                                                ViewCell *vc, 
    668                                                                 const Plane3 *cuttingPlane = NULL) const; 
     678                                                                const Plane3 *clipPlane = NULL) const; 
    669679 
    670680        void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 
     
    735745        void ExportViewCellGeometry(Exporter *exporter,  
    736746                                                                ViewCell *vc, 
    737                                                                 const Plane3 *cuttingPlane = NULL) const; 
     747                                                                const Plane3 *clipPlane = NULL) const; 
    738748 
    739749        //float GetVolume(ViewCell *viewCell) const; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r654 r660  
    329329                        const bool isActive = (bool)strtol(ptr, &endptr, 10); 
    330330 
    331                         viewCell->mIsActive = isActive; 
     331                        if (isActive) 
     332                                viewCell->SetActive(); 
    332333                } 
    333334                else if (attrName == "mergecost") 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r656 r660  
    129129        environment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 
    130130        environment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 
     131 
     132        char subdivisionStatsLog[100]; 
     133        environment->GetStringValue("BspTree.subdivisionStats", subdivisionStatsLog); 
     134        mSubdivisionStats.open(subdivisionStatsLog); 
    131135 
    132136 
     
    556560                                                          geom); 
    557561 
     562        // compute first split candidate 
    558563        VspBspSplitCandidate splitCandidate; 
    559  
    560  
    561564        EvalSplitCandidate(tData, splitCandidate); 
    562565 
     
    820823                VspBspTraversalData tBackData; 
    821824 
    822 #if OCTREE_HACK 
    823                 //Debug << "new axis:" << (tData.mAxis + 1) % 3 << endl; 
    824                 tFrontData.mAxis = (tData.mAxis + 1) % 3; 
    825                 tBackData.mAxis = (tData.mAxis + 1) % 3; 
    826 #endif 
    827825                //-- continue subdivision 
    828826                // create new interior node and two leaf node 
     
    831829                newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData, coincident); 
    832830                 
    833 #if 0 // TODO 
     831                const int splitAxis = splitCandidate.mSplitAxis; 
     832                const int maxCostMisses = splitCandidate.mMaxCostMisses; 
     833 
    834834                if (splitAxis < 3) 
    835835                        ++ mBspStats.splits[splitAxis]; 
     
    838838 
    839839                tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && splitAxis < 3); 
     840                 
    840841                // how often was max cost ratio missed in this branch? 
    841842                tFrontData.mMaxCostMisses = maxCostMisses; 
    842843                tBackData.mMaxCostMisses = maxCostMisses; 
    843  
    844 #endif 
     844                 
     845 
    845846                if (1) 
    846847                { 
     
    936937 
    937938        // compute locally best split plane 
    938         SelectPlane(splitData.mSplitPlane, leaf, tData, frontData, backData, splitAxis); 
     939        bool success = SelectPlane(splitData.mSplitPlane, leaf, tData, frontData, backData, splitAxis); 
    939940 
    940941        // TODO: reuse 
     
    945946        splitData.mRenderCost = EvalRenderCostDecrease(splitData.mSplitPlane, tData); 
    946947        splitData.mParentData = tData; 
     948        splitData.mMaxCostMisses = success ? tData.mMaxCostMisses : tData.mMaxCostMisses + 1; 
    947949} 
    948950 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r655 r660  
    167167                /// the current node 
    168168                Plane3 mSplitPlane; 
    169                  
     169                /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) 
     170                int mSplitAxis; 
     171                /// the number of misses of max cost ratio until this split 
     172                int mMaxCostMisses; 
     173 
    170174                // parent data 
    171175                VspBspTraversalData mParentData; 
    172  
     176                // cost of applying this split 
    173177                float mRenderCost; 
    174178 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r658 r660  
    9999                        Mesh *mesh = new Mesh(); 
    100100 
     101                        VertexIndexContainer vc; 
     102 
    101103                        // add vertices 
    102104                        for (int i = 0; i < (int)(*it).size(); ++ i) 
    103105                        { 
    104106                                mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]); 
    105                                  
     107                                vc.push_back(i); 
    106108                        } 
    107109                         
    108                         mesh->mFaces.push_back(new Face(0,1,2)); 
     110                        mesh->mFaces.push_back(new Face(vc)); 
    109111                        mesh->Preprocess(); 
    110112                        // make an instance of this mesh 
Note: See TracChangeset for help on using the changeset viewer.