Changeset 801


Ignore:
Timestamp:
04/24/06 08:21:10 (18 years ago)
Author:
mattausch
Message:

debug version for testing subdivision

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
8 edited

Legend:

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

    r752 r801  
    20142014                                        "100000"); 
    20152015 
     2016        RegisterOption("VspBspTree.Construction.minBand", 
     2017                                        optFloat, 
     2018                                        "vsp_bsp_construction_min_band=", 
     2019                                        "0.4"); 
     2020 
     2021        RegisterOption("VspBspTree.Construction.maxBand", 
     2022                                        optFloat, 
     2023                                        "vsp_bsp_construction_min_band=", 
     2024                                        "0.6"); 
     2025 
    20162026        RegisterOption("VspBspTree.Construction.epsilon", 
    20172027                                        optFloat, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayInfo.cpp

    r694 r801  
    144144 
    145145        // segment is not intersecting plane: fond out if on front or back side 
    146         if (t >= GetMaxT() - thresh) 
     146        if (t >= (GetMaxT() - thresh)) 
    147147        { 
    148148                return splitPlane.Side(ExtrapOrigin()); 
    149149        } 
    150150                 
    151         if (t <= GetMinT() + thresh) 
     151        if (t <= (GetMinT() + thresh)) 
    152152        { 
    153153                return splitPlane.Side(ExtrapTermination()); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r752 r801  
    262262float ViewCell::GetRenderCost() const 
    263263{ 
    264         return (float)mPvs.GetSize() * GetVolume(); 
     264        //return (float)mPvs.GetSize() * GetVolume(); 
     265        return (float)mPvsSize * GetVolume(); 
    265266} 
    266267 
     
    575576 
    576577        //const float maxAvgCost = 350; 
    577         while (!mMergeQueue.empty())//NumActiveViewCells > mMergeMinViewCells)) 
     578        while (!mMergeQueue.empty())//nmNumActiveViewCells > mMergeMinViewCells)) 
    578579        { 
    579580                //-- reset merge queue if the ratio of current expected cost / real expected cost 
     
    661662                        realAvgRenderCost = (float)totalPvs / (float)realNumActiveViewCells; 
    662663         
    663                         // set merge cost to this node 
    664                         mergedVc->SetMergeCost(totalRenderCost); 
     664                        // set merge cost to this node for priority traversal 
     665                        //mergedVc->SetMergeCost(totalRenderCost); 
     666// HACK 
     667mergedVc->SetMergeCost(1.0f / (float)realNumActiveViewCells); 
    665668 
    666669                        //if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 
     
    736739                mMergeQueue.pop(); 
    737740        } 
    738  
     741//hack!! 
     742//mRoot->GetPvs().Clear(); 
    739743        // TODO delete because makes no sense here 
    740744        mergeStats.expectedRenderCost = realExpectedCost; 
     
    16081612void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const 
    16091613{ 
     1614        // pvs is stored in each cell 
     1615        if (mViewCellsStorage == PVS_IN_INTERIORS) 
     1616        { 
     1617                pvs = vc->GetPvs(); 
     1618                return; 
     1619        } 
     1620 
    16101621        Intersectable::NewMail(); 
    16111622 
    1612         if (mViewCellsStorage == PVS_IN_INTERIORS) 
    1613                 pvs = vc->GetPvs(); 
    16141623 
    16151624        int pvsSize = 0; 
     
    16311640                tstack.pop(); 
    16321641 
     1642                // add new pvs 
    16331643                pvs.AddPvs(vc->GetPvs()); 
    16341644 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r752 r801  
    190190 { 
    191191         return a->GetRenderCost() < b->GetRenderCost(); 
     192 } 
     193 
     194 static bool LargerRenderCost(const ViewCell *a, const ViewCell *b)  
     195 { 
     196         return a->GetRenderCost() > b->GetRenderCost(); 
    192197 } 
    193198 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r752 r801  
    173173        Debug << "export to file: " << mExportViewCells << endl; 
    174174         
    175         Debug << "active: " << mNumActiveViewCells << endl; 
     175        Debug << "active view cells: " << mNumActiveViewCells << endl; 
    176176        Debug << "post process compress: " << mCompressViewCells << endl; 
    177177        Debug << "visualization use clipPlane: " << mUseClipPlaneForViz << endl;  
     
    179179        Debug << "evaluate view cells: " << mEvaluateViewCells << endl; 
    180180        Debug << "sampling type: " << mSamplingType << endl; 
    181         Debug << "render cost evaluation type" << mRenderCostEvaluationType << endl; 
     181        Debug << "render cost evaluation type: " << mRenderCostEvaluationType << endl; 
    182182        Debug << "evaluation sampling type: " << mEvaluationSamplingType << endl; 
    183183        Debug << "show visualization: " << mShowVisualization << endl; 
     
    479479        if (TEST_EMPTY_VIEW_CELLS) 
    480480                CollectEmptyViewCells(); 
    481  
    482  
     481         
     482        // evaluation of the paritition, i.e., a number of new samples are cast 
     483        if (mEvaluateViewCells) 
     484        { 
     485                EvalViewCellPartition(preprocessor); 
     486        } 
     487         
    483488        //-- visualization 
    484489        if (mShowVisualization) 
     
    500505        } 
    501506 
    502         // evaluation of the paritition, i.e., a number of new samples are cast 
    503         if (mEvaluateViewCells) 
    504         { 
    505                 EvalViewCellPartition(preprocessor); 
    506         } 
    507          
    508507        return numSamples; 
    509508} 
     
    696695        bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 
    697696 
    698         cout << "collect leaf view cells and reseting pvs ... "; 
    699  
    700         ViewCellContainer leaves; 
    701         mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
    702         cout << " ... "; 
     697 
     698/*ViewCellContainer leaves; 
     699mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
     700*/       
     701        cout << "reseting pvs ... "; 
     702                 
     703 
    703704        bool startFromZero = true; 
    704705 
     
    744745                cout << "compute new statistics ... "; 
    745746 
    746                 // propagate pvs or pvs size information 
     747/*Debug << "*******+" << endl; 
     748float overall = 0; 
     749stable_sort(leaves.begin(), leaves.end(), ViewCell::SmallerPvs); 
     750        for (int i = 0; i < leaves.size(); ++ i) 
     751        { 
     752                overall += leaves[i]->GetPvs().GetSize(); 
     753                Debug << "i " << i << " !size: " << leaves[i]->GetPvs().GetSize() << " vol: " << leaves[i]->GetVolume() << " overall " << overall << endl; 
     754                 
     755        } 
     756*/ 
     757 
     758                //-- propagate pvs or pvs size information 
    747759                ObjectPvs pvs; 
    748760                UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
    749761 
    750762 
    751                 // output stats 
     763                //-- output stats 
    752764                sprintf(s, "-%09d-eval.log", castSamples); 
    753765                string fileName = string(statsPrefix) + string(s); 
     
    17931805                if (!mOnlyValidViewCells || (*it)->GetValid()) 
    17941806                { 
    1795                         ExportColor(exporter, *it);              
     1807                        ExportColor(exporter, *it);      
     1808 
    17961809                        ExportViewCellGeometry(exporter, *it,  
    17971810                                mUseClipPlaneForViz ? &mClipPlane : NULL); 
     
    21452158 
    21462159                        //exporter->SetWireframe(); 
    2147                         exporter->SetFilled(); 
     2160                        //exporter->SetFilled(); 
     2161                        bool b = mUseClipPlaneForViz; 
     2162                        mUseClipPlaneForViz = false; 
    21482163                        ExportViewCellsForViz(exporter); 
    2149  
     2164                        mUseClipPlaneForViz = b; 
    21502165                        delete exporter; 
    21512166                } 
     
    21682183        // export single view cells 
    21692184        ExportBspPvs(objects); 
    2170 } 
    2171  
    2172  
    2173 inline bool vc_gt(ViewCell *a, ViewCell *b) 
    2174 { 
    2175         return a->GetPvs().GetSize() > b->GetPvs().GetSize(); 
    21762185} 
    21772186 
     
    22192228        // sort view cells to get largest view cells 
    22202229        if (0) 
    2221                 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
     2230                stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 
    22222231 
    22232232        int limit = min(leafOut, (int)mViewCells.size()); 
     
    33293338        case 1: // pvs 
    33303339                { 
    3331                         importance = (float)vc->GetPvs().GetSize() / 
     3340                        importance = (float)mViewCellsTree->GetPvsSize(vc) / 
    33323341                                (float)mCurrentViewCellsStats.maxPvs; 
    33333342                } 
     
    35413550                // compute tree by merging the nodes based on cost heuristics 
    35423551                mViewCellsTree->ConstructMergeTree(rays, objects); 
     3552 
     3553        //cout << "here344" << endl; 
     3554                //ObjectPvs pvs; 
     3555                //UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
    35433556        } 
    35443557        else 
     
    38813894                pvs = root->GetPvs(); 
    38823895 
    3883                 root->mPvsSize = pvs.GetSize(); 
     3896                root->mPvsSize = root->GetPvs().GetSize(); 
    38843897                root->mPvsSizeValid = true; 
    38853898 
     
    38873900        } 
    38883901         
     3902        //-- interior node => propagate pvs up 
    38893903        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 
     3904        interior->GetPvs().Clear(); 
     3905        pvs.Clear(); 
     3906        vector<ObjectPvs> pvsList; 
     3907 
    38903908        ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 
    38913909 
    3892         vector<ObjectPvs> pvsList; 
    3893          
    3894          
    38953910        for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 
    38963911        { 
     
    39053920 
    39063921#if 1 
     3922 
    39073923        Intersectable::NewMail(); 
    39083924 
     
    39333949        { 
    39343950                interior->mPvs = pvs; 
     3951                //cout << "here233" << endl; 
    39353952        } 
    39363953         
     
    39403957 
    39413958#else 
     3959 
    39423960        // really merge cells: slow put sumpdf is correct 
    3943         ViewCellInterior *viewCellInterior = new ViewCellInterior(); 
    3944  
    39453961        viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 
    39463962        viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 
     
    39954011        {       // hack pvs 
    39964012                int savedColorCode = mColorCode; 
    3997                 mColorCode = 0; 
     4013                mColorCode = 1; 
     4014         
    39984015                Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 
    39994016                 
     
    40204037                        } 
    40214038 
     4039                        //exporter->SetFilled(); 
     4040                        bool b = mUseClipPlaneForViz; 
     4041                        mUseClipPlaneForViz = false; 
    40224042                        ExportViewCellsForViz(exporter); 
     4043                        mUseClipPlaneForViz = b; 
     4044                 
    40234045                        delete exporter; 
    40244046                        cout << "finished" << endl; 
     
    41484170 
    41494171        const bool sortViewCells = true; 
     4172         
    41504173 
    41514174        // sort view cells to visualize the largest view cells 
    41524175        if (sortViewCells) 
    4153                 stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
    4154          
     4176        { 
     4177                //stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 
     4178                stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
     4179        } 
     4180 
    41554181        int limit = min(leafOut, (int)mViewCells.size()); 
    41564182 
     
    41684194                else 
    41694195                        vc = mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 
     4196 
     4197                ObjectPvs pvs; 
     4198                mViewCellsTree->GetPvs(vc, pvs); 
    41704199 
    41714200                //bspLeaves[j]->Mail(); 
     
    41754204                Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 
    41764205 
     4206                //-- export the sample rays 
    41774207                if (1 || mExportRays) 
    41784208                { 
     
    42124242                                                vcRays.push_back(*rit); 
    42134243                                } 
     4244 
    42144245                                //-- export rays piercing this view cell 
    42154246                                exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 
     
    42214252                                VssRayContainer vcRays; 
    42224253                                raysOut = min((int)rays.size(), mVisualizationSamples); 
     4254 
    42234255                                // check whether we can add the current ray to the output rays 
    42244256                                for (int k = 0; k < raysOut; ++ k) 
     
    42514283                exporter->SetFilled(); 
    42524284 
    4253  
     4285                //-- export pvs 
    42544286                if (1) 
    42554287                { 
    42564288                        ObjectPvsMap::const_iterator oit, 
    4257                                 oit_end = vc->GetPvs().mEntries.end(); 
    4258  
    4259  
    4260                         exporter->SetFilled(); 
     4289                                oit_end = pvs.mEntries.end(); 
    42614290 
    42624291                        Intersectable::NewMail(); 
    4263          
     4292 
    42644293                        // output PVS of view cell 
    4265                         for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     4294                        for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 
    42664295                        {                
    42674296                                Intersectable *intersect = (*oit).first; 
     
    42774306                        } 
    42784307                } 
    4279                 else 
    4280                 { 
     4308                 
     4309                if (0) 
     4310                {   // export scene geometry 
    42814311                        m.mDiffuseColor = RgbColor(1, 0, 0); 
    42824312                        exporter->SetForcedMaterial(m); 
     
    43384368        case 1: // pvs 
    43394369                { 
    4340                         importance = (float)vc->GetPvs().GetSize() / 
     4370                        importance = (float)mViewCellsTree->GetPvsSize(vc) / 
    43414371#if 1 // hack for result                         
    43424372                                (float)mCurrentViewCellsStats.maxPvs; 
     
    43774407                                                                                                        const Plane3 *clipPlane) const 
    43784408{ 
    4379         if (vc->GetMesh()) 
    4380         { 
    4381                 exporter->ExportMesh(vc->GetMesh()); 
    4382          
    4383                 return; 
    4384         } 
    4385  
    4386          
    43874409        if (clipPlane) 
    43884410        { 
     
    44184440                                //Debug << "geo size: " << geom.Size() << endl; 
    44194441                                //Debug << "size b: " << back.Size() << " f: " << front.Size() << endl; 
     4442 
    44204443                                if (back.Valid()) 
    44214444                                { 
     
    44274450        else 
    44284451        { 
    4429                 BspNodeGeometry geom; 
    4430                 mVspBspTree->ConstructGeometry(vc, geom); 
    4431                          
    4432                 exporter->ExportPolygons(geom.GetPolys()); 
     4452                // export mesh if available 
     4453        /*      if (vc->GetMesh()) 
     4454                { 
     4455                        exporter->ExportMesh(vc->GetMesh()); 
     4456                } 
     4457                else 
     4458                {*/ 
     4459                        BspNodeGeometry geom; 
     4460                        mVspBspTree->ConstructGeometry(vc, geom); 
     4461                        exporter->ExportPolygons(geom.GetPolys()); 
     4462                //} 
    44334463        } 
    44344464} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r752 r801  
    118118        environment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 
    119119        environment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 
    120         environment->GetBoolValue("VspBspTree.simulateOctree", mSimulateOctree); 
     120        environment->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 
    121121        environment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 
    122122        environment->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 
     
    127127        environment->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 
    128128        mSubdivisionStats.open(subdivisionStatsLog); 
     129 
     130        environment->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 
     131        environment->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 
    129132 
    130133        //-- debug output 
     
    156159        Debug << "priority queue type: " << mNodePriorityQueueType << endl; 
    157160        Debug << "empty view cells merge: " << mEmptyViewCellsMergeAllowed << endl; 
    158         Debug << "octree: " << mSimulateOctree << endl; 
     161        Debug << "octree: " << mCirculatingAxis << endl; 
     162        Debug << "minband: " << mMinBand << endl; 
     163        Debug << "maxband: " << mMaxBand << endl; 
     164         
    159165 
    160166        Debug << "Split plane strategy: "; 
     
    12151221        const float sizeBox = maxBox - minBox; 
    12161222 
    1217         const float minBand = minBox + 0.1f * sizeBox; 
    1218         const float maxBand = minBox + 0.9f * sizeBox; 
     1223        const float minBand = minBox + mMinBand * sizeBox; 
     1224        const float maxBand = minBox + mMaxBand * sizeBox; 
    12191225 
    12201226        SortSplitCandidates(rays, axis, minBand, maxBand); 
     
    14071413 
    14081414        int sAxis = 0; 
    1409  
    1410         bool useSpecialAxis = mOnlyDrivingAxis || mUseRandomAxis || mSimulateOctree; 
     1415        bool maxDepthForDrivingAxis = 0; 
     1416 
     1417        const bool useSpecialAxis = mOnlyDrivingAxis || mUseRandomAxis ||  
     1418                mCirculatingAxis || (tData.mDepth < maxDepthForDrivingAxis); 
     1419 
    14111420 
    14121421        // use some kind of specialised fixed axis 
    1413         if (mOnlyDrivingAxis) 
     1422        if (mUseRandomAxis) 
     1423                sAxis = Random(3); 
     1424        else if (mCirculatingAxis) 
     1425                sAxis = (tData.mAxis + 1) % 3; 
     1426        else if (mOnlyDrivingAxis || (tData.mDepth < maxDepthForDrivingAxis)) 
    14141427                sAxis = box.Size().DrivingAxis(); 
    1415         else if (mUseRandomAxis) 
    1416                 sAxis = Random(3); 
    1417         else if (mSimulateOctree) 
    1418                 sAxis = (tData.mAxis + 1) % 3; 
     1428 
    14191429                 
    14201430        //Debug << "use special axis: " << useSpecialAxis << endl; 
     
    15191529                                                         int &splitAxis) 
    15201530{ 
     1531        // hack 
     1532        if (data.mDepth < 0)     
     1533        { 
     1534                cout << "d: " << data.mDepth << endl; 
     1535                // return axis aligned split 
     1536                AxisAlignedBox3 box; 
     1537                box.Initialize(); 
     1538         
     1539                // create bounding box of region 
     1540                data.mGeometry->GetBoundingBox(box); 
     1541         
     1542                const int axis = box.Size().DrivingAxis(); 
     1543                const Vector3 position = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 
     1544 
     1545                Vector3 norm(0,0,0); norm[axis] = 1.0f; 
     1546                bestPlane = Plane3(norm, position); 
     1547                splitAxis = axis; 
     1548                return true; 
     1549        } 
     1550 
    15211551        // simplest strategy: just take next polygon 
    15221552        if (mSplitPlaneStrategy & RANDOM_POLYGON) 
     
    16231653        } 
    16241654     
    1625  
    1626 //      if (lowestCost > 10) 
    1627 //              Debug << "warning!! lowest cost: " << lowestCost << endl; 
    1628          
    16291655#ifdef _DEBUG 
    16301656        Debug << "plane lowest cost: " << lowestCost << endl; 
    16311657#endif 
    16321658 
     1659        // exeeded relative max cost ratio 
    16331660        if (lowestCost > mTermMaxCostRatio) 
    16341661        { 
     
    20522079 
    20532080        //-- compute heurstics 
    2054         //  we take simplified computation for mid split 
     2081        //-- we take simplified computation for mid split 
    20552082                 
    20562083        pOverall = data.mProbability; 
     
    27762803        BspNodeGeometry nodeGeom; 
    27772804        ConstructGeometry(n, nodeGeom); 
     2805//      const float eps = 0.5f; 
    27782806        const float eps = 0.01f; 
    2779  
    27802807        // split planes from the root to this node 
    27812808        // needed to verify that we found neighbor leaf 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r735 r801  
    795795        int mTotalPvsSize; 
    796796 
     797        float mMinBand; 
     798        float mMaxBand; 
     799 
    797800        //int mSplits; 
    798801        /// subdivision stats output file 
     
    807810        int mCreatedViewCells; 
    808811        /// if vsp bsp tree should simulate octree 
    809         bool mSimulateOctree; 
     812        bool mCirculatingAxis; 
    810813 
    811814        /// if we should use breath first priority for the splits 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h

    r752 r801  
    9292  MeshDefinitions mMeshDefinitions; 
    9393 
     94  // TODO: for storing meshes 
     95  MeshContainer *mMeshes; 
    9496  bool mIsMeshDefinition; 
    9597  // Handlers for X3D 
Note: See TracChangeset for help on using the changeset viewer.