Changeset 1027


Ignore:
Timestamp:
06/21/06 09:44:39 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
12 edited

Legend:

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

    r1023 r1027  
    20892089 
    20902090 
    2091 /************************************************************************************/ 
    2092 /*                 View space partition tree related options                        */ 
    2093 /************************************************************************************/ 
     2091/***************************************************************************/ 
     2092/*                 View space partition tree related options               */ 
     2093/***************************************************************************/ 
    20942094 
    20952095         
     2096        RegisterOption("VspTree.Construction.samples", 
     2097                                        optInt, 
     2098                                        "vsp_construction_samples=", 
     2099                                        "10000"); 
     2100 
    20962101        RegisterOption("VspTree.Termination.maxDepth", 
    20972102                                        optInt, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1004 r1027  
    490490          box.SetMin(0, box.Min(0) + s); 
    491491          box.SetMax(0, box.Max(0) + s); 
     492          
    492493          mViewCellsManager->SetViewSpaceBox(box); 
    493494        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1010 r1027  
    381381        Debug << "max memory: " << mMaxMemory << endl; 
    382382        Debug << "refining view cells: " << mRefineViewCells << endl; 
    383         Debug << "============= view cell tree options ================\n"; 
     383        Debug << "=========== end view cell tree options ===============\n"; 
    384384 
    385385        MergeCandidate::sRenderCostWeight = mRenderCostWeight; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1016 r1027  
    6060 
    6161 
    62 bool BspNode::IsRoot() const  
    63 { 
    64         return mParent == NULL; 
    65 } 
    66  
    67  
    68 BspInterior *BspNode::GetParent()  
    69 {  
    70         return mParent;  
    71 } 
    72  
    73  
    74 void BspNode::SetParent(BspInterior *parent) 
    75 { 
    76         mParent = parent; 
    77 } 
    78  
    79  
    8062bool BspNode::IsSibling(BspNode *n) const 
    8163{ 
     
    127109} 
    128110 
    129 bool BspInterior::IsLeaf() const 
    130 {  
    131         return false;  
    132 } 
    133  
    134 BspNode *BspInterior::GetBack()  
    135 { 
    136         return mBack; 
    137 } 
    138  
    139 BspNode *BspInterior::GetFront()  
    140 { 
    141         return mFront; 
    142 } 
    143  
    144 Plane3 BspInterior::GetPlane() const 
    145 { 
    146         return mPlane; 
    147 } 
    148  
    149 void BspInterior::ReplaceChildLink(BspNode *oldChild, BspNode *newChild)  
    150 { 
    151         if (mBack == oldChild) 
    152                 mBack = newChild; 
    153         else 
    154                 mFront = newChild; 
    155 } 
    156111 
    157112void BspInterior::SetupChildLinks(BspNode *b, BspNode *f)  
     
    193148BspNode(parent), mViewCell(viewCell), mPvs(NULL) 
    194149{ 
    195 } 
    196  
    197 ViewCellLeaf *BspLeaf::GetViewCell() const 
    198 { 
    199         return mViewCell; 
    200 } 
    201  
    202 void BspLeaf::SetViewCell(ViewCellLeaf *viewCell) 
    203 { 
    204         mViewCell = viewCell; 
    205 } 
    206  
    207  
    208 bool BspLeaf::IsLeaf() const  
    209 {  
    210         return true;  
    211150} 
    212151 
     
    1010949                // generate new view cell for each leaf 
    1011950                if (mGenerateViewCells) 
     951                { 
    1012952                        viewCell = new BspViewCell(); 
     953                } 
    1013954                else 
     955                { 
    1014956                        // add view cell to leaf 
    1015957                        viewCell = dynamic_cast<BspViewCell *>(tData.mViewCell); 
    1016                  
     958                } 
     959 
    1017960                leaf->SetViewCell(viewCell); 
    1018961                viewCell->mLeaf = leaf; 
     
    1036979                } 
    1037980 
    1038                 EvaluateLeafStats(tData); 
     981                if (1) 
     982                        EvaluateLeafStats(tData); 
    1039983                 
    1040984                //-- clean up 
     
    1045989                CLEAR_CONTAINER(*tData.mRays); 
    1046990 
    1047                 DEL_PTR(tData.mPolygons); 
    1048                 DEL_PTR(tData.mRays); 
    1049                 DEL_PTR(tData.mGeometry); 
     991                delete tData.mPolygons; 
     992                delete tData.mRays; 
     993                delete tData.mGeometry; 
    1050994 
    1051995                return leaf; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r1012 r1027  
    278278 
    279279        /** Determines whether this node is a root 
    280         @return true if root 
    281         */ 
    282         virtual bool IsRoot() const; 
     280                @return true if root 
     281        */ 
     282        virtual bool IsRoot() const 
     283        { 
     284                return mParent == NULL; 
     285        } 
    283286 
    284287        /** Returns parent node. 
    285288        */ 
    286         BspInterior *GetParent(); 
     289        inline BspInterior *GetParent() 
     290        {  
     291                return mParent;  
     292        } 
    287293 
    288294        /** Sets parent node. 
    289295        */ 
    290         void SetParent(BspInterior *parent); 
     296        inline void BspNode::SetParent(BspInterior *parent) 
     297        { 
     298                mParent = parent; 
     299        } 
     300 
    291301 
    292302        /** Returns true if this node is a sibling of node n. 
     
    334344        BspInterior(const Plane3 &plane); 
    335345        ~BspInterior(); 
     346 
    336347        /** @return false since it is an interior node  
    337348        */ 
    338         bool IsLeaf() const; 
    339  
    340         BspNode *GetBack(); 
    341         BspNode *GetFront(); 
    342  
     349        bool IsLeaf() const 
     350        {  
     351                return false;  
     352        } 
     353        BspNode *GetBack()  
     354        { 
     355                return mBack; 
     356        } 
     357 
     358        BspNode *GetFront()  
     359        { 
     360                return mFront; 
     361        } 
     362         
    343363        /** Returns split plane. 
    344364        */ 
    345         Plane3 GetPlane() const; 
     365        Plane3 BspInterior::GetPlane() const 
     366        { 
     367                return mPlane; 
     368        } 
    346369 
    347370        /** Replace front or back child with new child. 
    348371        */ 
    349         void ReplaceChildLink(BspNode *oldChild, BspNode *newChild); 
     372        inline void ReplaceChildLink(BspNode *oldChild, BspNode *newChild) 
     373        { 
     374                if (mBack == oldChild) 
     375                        mBack = newChild; 
     376                else 
     377                        mFront = newChild; 
     378        } 
     379 
    350380        /** Replace front and back child. 
    351381        */ 
     
    383413        ~BspLeaf(); 
    384414 
     415        /** Returns pointer of view cell. 
     416        */ 
     417        inline ViewCellLeaf *GetViewCell() const 
     418        { 
     419                return mViewCell; 
     420        } 
     421 
     422        /** Sets pointer to view cell. 
     423        */ 
     424        inline void SetViewCell(ViewCellLeaf *viewCell) 
     425        { 
     426                mViewCell = viewCell; 
     427        } 
     428 
    385429        /** @return true since it is an interior node  
    386430        */ 
    387         bool IsLeaf() const; 
    388          
    389         /** Returns pointer of view cell. 
    390         */ 
    391         ViewCellLeaf *GetViewCell() const; 
    392  
    393         /** Sets pointer to view cell. 
    394         */ 
    395         void SetViewCell(ViewCellLeaf *viewCell); 
     431        bool BspLeaf::IsLeaf() const  
     432        {  
     433                return true;  
     434        } 
     435         
    396436 
    397437        /// Rays piercing this leaf. 
     
    403443        /// Probability that the view point lies in this leaf 
    404444        float mProbability; 
     445 
    405446 
    406447protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1022 r1027  
    181181 
    182182 
    183         Debug << "***********View Cells options ****************" << endl; 
     183        Debug << "************ View Cells options ***************" << endl; 
    184184        Debug << "color code: " << mColorCode << endl; 
    185185 
     
    417417                  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    418418 
    419 //return 0; 
     419 
    420420        // take post processing time 
    421421        startTime = GetTime(); 
     
    17271727{ 
    17281728        mViewSpaceBox = box; 
    1729  
     1729        Debug << "here111 " << mViewSpaceBox << endl; 
     1730        // hack: create clip plane relative to new view space box 
    17301731        CreateClipPlane(); 
    1731          
     1732        // the total area of the view space has changed 
    17321733        mTotalAreaValid = false; 
    17331734} 
     
    29282929                                                                                                 const Plane3 *clipPlane) const 
    29292930{ 
     2931        // export mesh if available 
    29302932        if (vc->GetMesh()) 
    29312933        { 
    29322934                exporter->ExportMesh(vc->GetMesh()); 
    2933          
    29342935                return; 
    29352936        } 
    2936  
    2937          
     2937        // otherwise construct from leaves 
    29382938        if (clipPlane) 
    29392939        { 
     
    47874787ViewCellsManager(), mVspTree(vspTree), mOspTree(ospTree) 
    47884788{ 
    4789         Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", mInitialSamples); 
     4789        mHierarchyManager = new HierarchyManager(*vspTree, *ospTree); 
     4790        Environment::GetSingleton()->GetIntValue("VspTree.Construction.samples", mInitialSamples); 
    47904791        mVspTree->SetViewCellsManager(this); 
    47914792        mVspTree->mViewCellsTree = mViewCellsTree; 
     
    47954796VspOspViewCellsManager::~VspOspViewCellsManager() 
    47964797{ 
     4798        DEL_PTR(mHierarchyManager); 
    47974799} 
    47984800 
     
    48354837        mMaxPvsSize = (int)(mMaxPvsRatio * (float)objects.size()); 
    48364838 
     4839        Debug << "here125 view space box " << mViewSpaceBox << endl; 
     4840 
    48374841        // if view cells were already constructed 
    48384842        if (ViewCellsConstructed()) 
     
    48584862        long startTime; 
    48594863 
    4860 #if TODO 
    4861         if (1) 
    4862                 mVspTree->Construct(constructionRays, &mViewSpaceBox); 
    4863         else 
    4864                 mVspTree->Construct(rays, &mViewSpaceBox); 
    4865 #endif 
    4866         // collapse invalid regions 
    4867         cout << "collapsing invalid tree regions ... "; 
    4868         startTime = GetTime(); 
    4869         const int collapsedLeaves = mVspTree->CollapseTree(); 
    4870         Debug << "collapsed in " << TimeDiff(startTime, GetTime()) * 1e-3  
    4871                   << " seconds" << endl; 
    4872  
    4873     cout << "finished" << endl; 
    4874  
     4864        mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 
     4865 
     4866         
    48754867        //-- stats 
    48764868        Debug << mVspTree->GetStatistics() << endl; 
     
    49174909 
    49184910 
    4919         // view cells already finished before post processing step  
    4920         // (i.e. because they were loaded) 
     4911        // take this step only if  
     4912        // view cells already constructed before post processing step  
     4913        // (e.g., because they were loaded) 
    49214914        if (mViewCellsFinished) 
    49224915        { 
     
    51545147 
    51555148 
     5149void VspOspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
     5150                                                                                                        ViewCell *vc, 
     5151                                                                                                        const Plane3 *clipPlane) const 
     5152{ 
     5153        ViewCellContainer leaves; 
     5154 
     5155        mViewCellsTree->CollectLeaves(vc, leaves); 
     5156        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     5157 
     5158        for (it = leaves.begin(); it != it_end; ++ it) 
     5159        { 
     5160                VspViewCell *vspVc = dynamic_cast<VspViewCell *>(*it); 
     5161                VspLeaf *l = vspVc->mLeaf; 
     5162 
     5163                const AxisAlignedBox3 box = mVspTree->GetBBox(vspVc->mLeaf); 
     5164 
     5165                if (!clipPlane || !box.Side(*clipPlane)) 
     5166                        exporter->ExportBox(box); 
     5167        } 
     5168} 
     5169 
     5170 
    51565171bool VspOspViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 
    51575172{ 
     
    51615176 
    51625177  //    return mViewSpaceBox.IsInside(viewPoint) && 
    5163   //               mVspBspTree->ViewPointValid(viewPoint); 
     5178  //               mVspTree->ViewPointValid(viewPoint); 
    51645179} 
    51655180 
     
    51705185        if (!ViewCellsConstructed()) 
    51715186                return; 
    5172 #if TODO 
     5187 
    51735188        VssRayContainer visRays; 
    51745189        GetRaySets(sampleRays, mVisualizationSamples, visRays); 
     
    52085223 
    52095224                        // HACK: export without clip plane 
    5210                         const bool b = mUseClipPlaneForViz; 
    5211                         mUseClipPlaneForViz = false; 
     5225                        //const bool b = mUseClipPlaneForViz; 
     5226                        //mUseClipPlaneForViz = false; 
    52125227 
    52135228                        ExportViewCellsForViz(exporter); 
    52145229                         
    5215                         mUseClipPlaneForViz = b; 
     5230                        //mUseClipPlaneForViz = b; 
    52165231                        delete exporter; 
    52175232 
     
    52205235 
    52215236                mColorCode = savedColorCode; 
    5222         } 
    5223  
    5224  
    5225         if (0) 
    5226         { 
    5227                 cout << "exporting depth map ... "; 
    5228  
    5229                 Exporter *exporter = Exporter::GetExporter("depth_map.x3d"); 
    5230                 if (exporter) 
    5231                 { 
    5232                         if (1) 
    5233                         { 
    5234                                 exporter->SetWireframe(); 
    5235                                 exporter->ExportBox(mViewSpaceBox); 
    5236                                 exporter->SetFilled(); 
    5237                         } 
    5238  
    5239                         if (mExportGeometry) 
    5240                         { 
    5241                                 exporter->ExportGeometry(objects); 
    5242                         } 
    5243  
    5244                         const int maxDepth = mVspBspTree->mBspStats.maxDepth; 
    5245  
    5246                         ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 
    5247  
    5248                         for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 
    5249                         { 
    5250                                 ViewCell *vc = *vit; 
    5251  
    5252                                 ViewCellContainer leaves; 
    5253                                 mViewCellsTree->CollectLeaves(vc, leaves); 
    5254  
    5255                                 ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
    5256  
    5257                                 for (lit = leaves.begin(); lit != lit_end; ++ lit) 
    5258                                 { 
    5259                                         BspLeaf *leaf = dynamic_cast<BspViewCell *>(*lit)->mLeaf; 
    5260  
    5261                                         Material m;  
    5262  
    5263                                         float relDepth = (float)leaf->GetDepth() / (float)maxDepth; 
    5264                                         m.mDiffuseColor.r = relDepth; 
    5265                                         m.mDiffuseColor.g = 0.0f; 
    5266                                         m.mDiffuseColor.b = 1.0f - relDepth; 
    5267  
    5268                     exporter->SetForcedMaterial(m); 
    5269                                  
    5270  
    5271                                         BspNodeGeometry geom; 
    5272                                         mVspBspTree->ConstructGeometry(leaf, geom); 
    5273                                         exporter->ExportPolygons(geom.GetPolys()); 
    5274                                 } 
    5275                         } 
    5276  
    5277                         delete exporter; 
    5278                 } 
    5279  
    5280  
    5281                 cout << "finished" << endl; 
    5282         } 
    5283  
    5284         //-- visualization of the BSP splits 
    5285  
    5286         bool exportSplits = false; 
    5287         Environment::GetSingleton()->GetBoolValue("VspBspTree.Visualization.exportSplits", exportSplits); 
    5288  
    5289         if (exportSplits) 
    5290         { 
    5291                 cout << "exporting splits ... "; 
    5292                 ExportSplits(objects, visRays); 
    5293                 cout << "finished" << endl; 
    52945237        } 
    52955238 
    52965239        //-- export single view cells 
    52975240        ExportBspPvs(objects, visRays); 
    5298 #endif 
    52995241} 
    53005242 
     
    54825424 
    54835425 
    5484 void VspOspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    5485                                                     ViewCell *vc, 
    5486                                                                                                         const Plane3 *clipPlane) const 
    5487 { 
    5488         // matt: TODO 
    5489 } 
    5490  
    5491  
    54925426bool VspOspViewCellsManager::ExportViewCells(const string filename,  
    54935427                                                                                         const bool exportPvs,  
     
    55375471 
    55385472        //-- export the view cells and the pvs 
    5539         stream << "<HierarchyType name=\"vspBspTree\" />" << endl; 
     5473        stream << "<HierarchyType name=\"vspTree\" />" << endl; 
    55405474 
    55415475        const int numViewCells = mCurrentViewCellsStats.viewCells; 
     
    55665500 
    55675501 
    5568 ViewCell *VspOspViewCellsManager::GetViewCell(const Vector3 &point, const bool active) const 
     5502ViewCell *VspOspViewCellsManager::GetViewCell(const Vector3 &point,  
     5503                                                                                          const bool active) const 
    55695504{ 
    55705505        if (!ViewCellsConstructed()) 
     
    55825517        // matt: TODO 
    55835518        Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
     5519 
     5520        ViewCellContainer leaves; 
     5521        mViewCellsTree->CollectLeaves(vc, leaves); 
     5522 
     5523        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     5524 
     5525    for (it = leaves.begin(); it != it_end; ++ it) 
     5526        { 
     5527                VspLeaf *leaf = dynamic_cast<VspViewCell *>(*it)->mLeaf; 
     5528                const AxisAlignedBox3 box = mVspTree->GetBBox(leaf); 
     5529 
     5530        IncludeBoxInMesh(box, *mesh); 
     5531        } 
     5532 
    55845533        vc->SetMesh(mesh); 
    55855534} 
     
    55965545                                                                          const bool createMesh) 
    55975546{ 
    5598 #if TODO 
    55995547        float area = 0; 
    56005548        float volume = 0; 
     
    56075555    for (it = leaves.begin(); it != it_end; ++ it) 
    56085556        { 
    5609                 BspNodeGeometry geom; 
    5610                 BspLeaf *leaf = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
    5611                 mVspBspTree->ConstructGeometry(leaf, geom); 
    5612  
    5613                 const float lVol = geom.GetVolume(); 
    5614                 const float lArea = geom.GetArea(); 
     5557                VspLeaf *leaf = dynamic_cast<VspViewCell *>(*it)->mLeaf; 
     5558                 
     5559                const AxisAlignedBox3 box = mVspTree->GetBBox(leaf); 
     5560 
     5561                const float lVol = box.GetVolume(); 
     5562                const float lArea = box.SurfaceArea(); 
    56155563 
    56165564                //(*it)->SetVolume(vol); 
     
    56255573        viewCell->SetVolume(volume); 
    56265574        viewCell->SetArea(area); 
    5627 #endif 
    56285575} 
    56295576         
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1022 r1027  
    3535class OspTree; 
    3636class VspNode; 
    37  
     37class HierarchyManager; 
    3838 
    3939struct BspRay; 
     
    298298        /** Writes view cells to disc. 
    299299        */ 
    300         virtual bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 
     300        virtual bool ExportViewCells(const string filename,  
     301                                                                 const bool exportPvs,  
     302                                                                 const ObjectContainer &objects); 
    301303 
    302304        /** Casts beam to collect view cells. 
     
    983985        void CreateMesh(ViewCell *vc); 
    984986 
    985         bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 
     987        bool ExportViewCells(const string filename,  
     988                                                 const bool exportPvs,  
     989                                                 const ObjectContainer &objects); 
    986990 
    987991        int CastBeam(Beam &beam); 
    988992 
     993        void Finalize(ViewCell *viewCell, const bool createMesh); 
     994 
     995 
     996protected: 
     997 
     998         
     999        /** Exports view cell geometry. 
     1000        */ 
    9891001        void ExportViewCellGeometry(Exporter *exporter,  
    9901002                                                                ViewCell *vc, 
    9911003                                                                const Plane3 *clipPlane = NULL) const; 
    9921004 
    993         void Finalize(ViewCell *viewCell, const bool createMesh); 
    994  
    995  
    996 protected: 
    997  
    9981005        int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const; 
    9991006         
     
    10201027        VspTree *mVspTree; 
    10211028        OspTree *mOspTree; 
     1029 
     1030        HierarchyManager *mHierarchyManager; 
    10221031}; 
    10231032 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1023 r1027  
    197197        Debug << endl; 
    198198} 
    199 /* 
    200 VspBspTree::VspBspTree(): 
    201 mRoot(NULL), 
    202 mUseAreaForPvs(false), 
    203 mCostNormalizer(Limits::Small), 
    204 mViewCellsManager(NULL), 
    205 mOutOfBoundsCell(NULL), 
    206 mStoreRays(false), 
    207 mRenderCostWeight(0.5), 
    208 mUseRandomAxis(false), 
    209 mTimeStamp(1), 
    210 mEpsilon(1e-6f) 
    211 { 
    212 }*/ 
     199 
    213200 
    214201BspViewCell *VspBspTree::GetOutOfBoundsCell() 
     
    343330 
    344331 
     332void VspBspTree::ComputeBoundingBox(const VssRayContainer &sampleRays, 
     333                                                                        AxisAlignedBox3 *forcedBoundingBox)  
     334{ 
     335        if (forcedBoundingBox) 
     336        { 
     337                mBox = *forcedBoundingBox; 
     338        } 
     339        else // compute vsp tree bounding box 
     340        { 
     341                mBox.Initialize(); 
     342 
     343                VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
     344 
     345                //-- compute bounding box 
     346        for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
     347                { 
     348                        VssRay *ray = *rit; 
     349 
     350                        // compute bounding box of view space 
     351                        mBox.Include(ray->GetTermination()); 
     352                        mBox.Include(ray->GetOrigin()); 
     353                } 
     354        } 
     355} 
     356 
     357 
    345358void VspBspTree::Construct(const VssRayContainer &sampleRays, 
    346359                                                   AxisAlignedBox3 *forcedBoundingBox) 
    347360{ 
    348         mBspStats.nodes = 1; 
    349         mBox.Initialize();      // initialise BSP tree bounding box 
    350  
    351         if (forcedBoundingBox) 
    352                 mBox = *forcedBoundingBox; 
     361        // Compute the bounding box from the rays 
     362        ComputeBoundingBox(sampleRays, forcedBoundingBox); 
    353363         
    354364        PolygonContainer polys; 
    355365        RayInfoContainer *rays = new RayInfoContainer(); 
    356366 
     367        //-- extract polygons from rays if there are polygon candidates 
     368        if (mMaxPolyCandidates)  
     369        { 
     370                int numObj = 0; 
     371 
     372                Intersectable::NewMail(); 
     373 
     374        cout << "Extracting polygons from rays ... "; 
     375 
     376                long startTime = GetTime(); 
     377 
     378        VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
     379 
     380                //-- extract polygons intersected by the rays 
     381                for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
     382                { 
     383                        VssRay *ray = *rit; 
     384                        Intersectable *obj = ray->mTerminationObject; 
     385 
     386                        if ((mBox.IsInside(ray->mTermination) || !forcedBoundingBox) && 
     387                                obj && !obj->Mailed()) 
     388                        { 
     389                                obj->Mail(); 
     390 
     391                                // transformed mesh instance and mesh instance handle mesh differently 
     392                                if (obj->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 
     393                                { 
     394                                        Mesh mesh; 
     395                                 
     396                                        TransformedMeshInstance *tmobj =  
     397                                                dynamic_cast<TransformedMeshInstance *>(obj); 
     398                                 
     399                                        tmobj->GetTransformedMesh(mesh); 
     400                                        AddMeshToPolygons(&mesh, polys, tmobj); 
     401                                } 
     402                                else // MeshInstance 
     403                                { 
     404                                        MeshInstance *mobj = dynamic_cast<MeshInstance *>(obj); 
     405                                        AddMeshToPolygons(mobj->GetMesh(), polys, mobj); 
     406                                } 
     407 
     408                                ++ numObj; 
     409 
     410                                //-- compute bounding box 
     411                                if (!forcedBoundingBox) 
     412                                        mBox.Include(ray->mTermination); 
     413                        } 
     414 
     415                        if ((mBox.IsInside(ray->mOrigin) || !forcedBoundingBox) && 
     416                                ray->mOriginObject &&  
     417                                !ray->mOriginObject->Mailed()) 
     418                        {                
     419                                ray->mOriginObject->Mail(); 
     420                                MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->mOriginObject); 
     421                                AddMeshToPolygons(obj->GetMesh(), polys, obj); 
     422                                 
     423                                ++ numObj; 
     424                        } 
     425                } 
     426 
     427                // throw out unnecessary polygons 
     428                PreprocessPolygons(polys); 
     429 
     430                cout << "finished" << endl; 
     431 
     432                Debug << "\n" << (int)polys.size() << " polys extracted from " 
     433                  << (int)sampleRays.size() << " rays in " 
     434                  << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl << endl; 
     435        } 
     436         
     437        Debug << "maximal pvs (i.e., pvs still considered as valid): "  
     438                  << mViewCellsManager->GetMaxPvsSize() << endl; 
     439 
    357440        VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
    358  
    359         long startTime = GetTime(); 
    360  
    361         cout << "Extracting polygons from rays ... "; 
    362  
    363         Intersectable::NewMail(); 
    364  
    365         int numObj = 0; 
    366  
    367         //-- extract polygons intersected by the rays 
    368         for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
    369         { 
    370                 VssRay *ray = *rit; 
    371                 Intersectable *obj = ray->mTerminationObject; 
    372  
    373                 if ((mBox.IsInside(ray->mTermination) || !forcedBoundingBox) && 
    374                         obj && !obj->Mailed()) 
    375                 { 
    376                         obj->Mail(); 
    377  
    378                         // transformed mesh instance and mesh instance handle mesh differently 
    379                         if (obj->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 
    380                         { 
    381                                 Mesh mesh; 
    382                                  
    383                                 TransformedMeshInstance *tmobj =  
    384                                         dynamic_cast<TransformedMeshInstance *>(obj); 
    385                                  
    386                                 tmobj->GetTransformedMesh(mesh); 
    387                                 AddMeshToPolygons(&mesh, polys, tmobj); 
    388                         } 
    389                         else // MeshInstance 
    390                         { 
    391                                 MeshInstance *mobj = dynamic_cast<MeshInstance *>(obj); 
    392                                 AddMeshToPolygons(mobj->GetMesh(), polys, mobj); 
    393                         } 
    394  
    395                         ++ numObj; 
    396  
    397                         //-- compute bounding box 
    398                         if (!forcedBoundingBox) 
    399                                 mBox.Include(ray->mTermination); 
    400                 } 
    401  
    402                 if ((mBox.IsInside(ray->mOrigin) || !forcedBoundingBox) && 
    403                         ray->mOriginObject &&  
    404                         !ray->mOriginObject->Mailed()) 
    405                 { 
    406                         ray->mOriginObject->Mail(); 
    407                         MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->mOriginObject); 
    408                         AddMeshToPolygons(obj->GetMesh(), polys, obj); 
    409                         ++ numObj; 
    410  
    411                         //-- compute bounding box 
    412                         if (!forcedBoundingBox) 
    413                                 mBox.Include(ray->mOrigin); 
    414                 } 
    415         } 
    416          
    417         Debug << "maximal pvs (i.e., pvs still considered as valid) : "  
    418                   << mViewCellsManager->GetMaxPvsSize() << endl; 
    419441 
    420442        //-- store rays 
     
    446468                mTermMinProbability *= mBox.GetVolume(); 
    447469 
    448         // throw out unnecessary polygons 
    449         PreprocessPolygons(polys); 
    450  
     470 
     471        mBspStats.nodes = 1; 
    451472        mBspStats.polys = (int)polys.size(); 
    452473        mGlobalCostMisses = 0; 
    453474 
    454         cout << "finished" << endl; 
    455  
    456         Debug << "\nPolygon extraction: " << (int)polys.size() << " polys extracted from " 
    457                   << (int)sampleRays.size() << " rays in " 
    458                   << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl << endl; 
    459475 
    460476        // use split cost priority queue 
     
    684700                { 
    685701                        nViewCells += 500; 
    686  
    687702                        cout << "generated " << mCreatedViewCells << " viewcells" << endl; 
    688703                } 
     
    847862 
    848863                // should I check here? 
    849                 if (0 && !mViewCellsManager->CheckValidity(viewCell, 0, mViewCellsManager->GetMaxPvsSize())) 
     864                if (0 && !mViewCellsManager->CheckValidity(viewCell, 0,  
     865                        mViewCellsManager->GetMaxPvsSize())) 
    850866                { 
    851867                        viewCell->SetValid(false); 
     
    866882 
    867883                // finally evaluate stats until this leaf 
    868                 EvaluateLeafStats(tData);                
     884                if (0) 
     885                        EvaluateLeafStats(tData);                
    869886        } 
    870887 
     
    875892} 
    876893 
    877 // subdivide using a split plane queue 
     894 
     895// subdivide node using a split plane queue 
    878896BspNode *VspBspTree::Subdivide(VspBspSplitQueue &tQueue, 
    879897                                                           VspBspSplitCandidate &splitCandidate) 
     
    9901008 
    9911009                // finally evaluate stats until this leaf 
    992                 EvaluateLeafStats(tData);                
     1010                if (0) 
     1011                        EvaluateLeafStats(tData);                
    9931012        } 
    9941013 
     
    10311050 
    10321051        // TODO: reuse 
    1033         DEL_PTR(frontData.mGeometry); 
    1034         DEL_PTR(backData.mGeometry); 
     1052        delete frontData.mGeometry; 
     1053        delete backData.mGeometry; 
    10351054         
    10361055        // compute global decrease in render cost 
     
    19101929 
    19111930                // something is wrong with the volume 
    1912                 if ((pFront < 0.0) || (pBack < 0.0)) 
     1931                if (0 && ((pFront < 0.0) || (pBack < 0.0))) 
    19131932                { 
    19141933                        Debug << "ERROR in volume:\n" 
     
    20252044                { 
    20262045                        //Debug << "error f: " << pFront << " b: " << pBack << endl; 
    2027                         // high penalty for this split 
     2046 
     2047                        // high penalty for degenerated / wrong split 
    20282048                        return 99999.9f; 
    20292049                } 
     
    23822402                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
    23832403                  << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 
    2384           //              << "Area: " << data.mProbability << " (min: " << mTermMinProbability << "), " 
    2385                   << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    2386                   << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "=, " 
     2404                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
     2405                  << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "), " 
    23872406                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    23882407#endif 
     
    26602679        // preprocess: throw out polygons coincident to the view space box (not needed) 
    26612680        PolygonContainer boxPolys; 
    2662         /*mBox.ExtractPolys(boxPolys); 
     2681         
     2682        mBox.ExtractPolys(boxPolys); 
    26632683        vector<Plane3> boxPlanes; 
    26642684 
     
    26992719                        polys.pop_back(); 
    27002720                } 
    2701         }*/ 
     2721        } 
    27022722} 
    27032723 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r1020 r1027  
    227227        /** Returns box which bounds the whole tree. 
    228228        */ 
    229         AxisAlignedBox3 GetBoundingBox()const; 
     229        AxisAlignedBox3 GetBoundingBox() const; 
    230230 
    231231        /** Returns root of BSP tree. 
     
    389389                } 
    390390        }; 
     391 
     392        void ComputeBoundingBox(const VssRayContainer &sampleRays,  
     393                                                        AxisAlignedBox3 *forcedBoundingBox); 
    391394 
    392395        /** faster evaluation of split plane cost for kd axis aligned cells. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1023 r1027  
    5353void VspTreeStatistics::Print(ostream &app) const 
    5454{ 
    55 #if TODO 
    56         app << "===== BspTree statistics ===============\n"; 
     55        app << "===== VspTree statistics ===============\n"; 
    5756 
    5857        app << setprecision(4); 
     
    6564 
    6665        app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 
    67  
    68         app << "#N_POLYSPLITS ( Number of polygon splits )\n" << polySplits << "\n"; 
    6966 
    7067        app << "#AXIS_ALIGNED_SPLITS (number of axis aligned splits)\n" << splits[0] + splits[1] + splits[2] << endl; 
     
    10097        app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl; 
    10198 
    102         app << "#N_INPUTPOLYGONS (number of input polygons )\n" << polys << endl; 
    103  
    10499        app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 
    105100 
     
    107102        //app << "#N_PVS: " << pvs << endl; 
    108103 
    109         app << "#N_ROUTPUT_INPUT_POLYGONS ( ratio polygons after subdivision / input polygons )\n" << 
    110                  (polys + polySplits) / (double)polys << endl; 
    111          
    112         app << "===== END OF BspTree statistics ==========\n"; 
    113 #endif 
     104        app << "===== END OF VspTree statistics ==========\n"; 
    114105} 
    115106 
     
    267258        return Interior; 
    268259} 
     260 
     261 
    269262 
    270263/****************************************************************/ 
     
    449442{ 
    450443        mVspStats.nodes = 1; 
    451         mBoundingBox.Initialize();      // initialise vsp tree bounding box 
    452  
     444         
    453445        if (forcedBoundingBox) 
     446        { 
    454447                mBoundingBox = *forcedBoundingBox; 
    455          
    456         VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
    457  
    458         Intersectable::NewMail(); 
    459  
    460         //-- compute bounding box 
    461         for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
    462         { 
    463                 VssRay *ray = *rit; 
    464  
    465                 // compute bounding box of view space 
    466                 if (!forcedBoundingBox) 
    467                 { 
     448        } 
     449        else // compute vsp tree bounding box 
     450        { 
     451                mBoundingBox.Initialize(); 
     452 
     453                VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
     454 
     455                //-- compute bounding box 
     456        for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
     457                { 
     458                        VssRay *ray = *rit; 
     459 
     460                        // compute bounding box of view space 
    468461                        mBoundingBox.Include(ray->GetTermination()); 
    469462                        mBoundingBox.Include(ray->GetOrigin()); 
    470463                } 
    471         } 
    472  
    473         mTermMinProbability *= mBoundingBox.GetVolume(); 
    474         mGlobalCostMisses = 0; 
     464 
     465                mTermMinProbability *= mBoundingBox.GetVolume(); 
     466                mGlobalCostMisses = 0; 
     467        } 
    475468} 
    476469 
     
    480473                                                                  const float splitCandidateCost, 
    481474                                                                  const float totalRenderCost, 
    482                                                                         const float avgRenderCost) 
     475                                                                  const float avgRenderCost) 
    483476{ 
    484477        mSubdivisionStats  
     
    507500{ 
    508501        return 
     502#if TODO 
    509503                (((int)data.mRays->size() <= mTermMinRays) || 
    510504                 (data.mPvs <= mTermMinPvs)   || 
     
    512506                 (data.GetAvgRayContribution() > mTermMaxRayContribution) || 
    513507                 (data.mDepth >= mTermMaxDepth)); 
     508#else 
     509                false; 
     510#endif 
    514511} 
    515512 
     
    518515{ 
    519516        return 
     517#if TODO 
    520518                (mOutOfMemory ||  
    521519                (mVspStats.Leaves() >= mMaxViewCells) ||  
    522520                (mGlobalCostMisses >= mTermGlobalCostMissTolerance)); 
     521#else 
     522                (mVspStats.Leaves() >= mMaxViewCells) ;          
     523#endif 
    523524} 
    524525 
     
    633634 
    634635void VspTree::EvalSplitCandidate(VspTraversalData &tData, 
    635                                                                  VspSplitCandidate &splitData) 
     636                                                                 VspSplitCandidate &splitCandidate) 
    636637{ 
    637638        float frontProb; 
    638         float backtProb; 
     639        float backProb; 
    639640         
    640641        VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 
     
    642643        // compute locally best split plane 
    643644        const bool success =  
    644                 SelectPlane(tData, splitData.mSplitPlane, 
    645                                         frontProb, backtProb); 
    646  
    647         //TODO 
     645                SelectSplitPlane(tData, splitCandidate.mSplitPlane,     frontProb, backProb); 
     646 
    648647        // compute global decrease in render cost 
    649         splitData.mPriority = EvalRenderCostDecrease(splitData.mSplitPlane, tData); 
    650         splitData.mParentData = tData; 
    651         splitData.mMaxCostMisses = success ? tData.mMaxCostMisses : tData.mMaxCostMisses + 1; 
     648        splitCandidate.mPriority = EvalRenderCostDecrease(splitCandidate.mSplitPlane, tData); 
     649        splitCandidate.mParentData = tData; 
     650        splitCandidate.mMaxCostMisses = success ? tData.mMaxCostMisses : tData.mMaxCostMisses + 1; 
     651 
     652        Debug << "p: " << tData.mNode << " depth: " << tData.mDepth << endl; 
    652653} 
    653654 
     
    673674                          *backData.mRays); 
    674675 
     676        Debug << "f: " << frontData.mRays->size() << " b: " << backData.mRays->size() << "d: " << tData.mRays->size() << endl; 
    675677        //-- compute pvs 
    676678        frontData.mPvs = ComputePvsSize(*frontData.mRays); 
     
    831833 
    832834 
    833 float VspTree::BestCostRatioHeuristics(const RayInfoContainer &rays, 
    834                                                                                   const AxisAlignedBox3 &box, 
    835                                                                                   const int pvsSize, 
    836                                                                                   const int axis, 
    837                                           float &position) 
     835float VspTree::EvalLocalCostHeuristics(const RayInfoContainer &rays, 
     836                                                                           const AxisAlignedBox3 &box, 
     837                                                                           const int pvsSize, 
     838                                                                           const int axis, 
     839                                                                           float &position) 
    838840{ 
    839841        const float minBox = box.Min(axis); 
     
    10031005 
    10041006 
    1005 float VspTree::SelectPlane(const VspTraversalData &tData, 
    1006                                                    AxisAlignedPlane &plane, 
    1007                                                    float &pFront, 
    1008                                                    float &pBack) 
     1007float VspTree::SelectSplitPlane(const VspTraversalData &tData, 
     1008                                                                AxisAlignedPlane &plane, 
     1009                                                                float &pFront, 
     1010                                                                float &pBack) 
    10091011{ 
    10101012        float nPosition[3]; 
     
    10191021        int bestAxis = -1; 
    10201022 
    1021  
    10221023        // if we use some kind of specialised fixed axis 
    10231024    const bool useSpecialAxis =  
    10241025                mOnlyDrivingAxis || mCirculatingAxis; 
    10251026 
     1027        int parentAxis = 0; 
     1028        VspNode *parent = tData.mNode->GetParent(); 
     1029 
     1030        if (parent) 
     1031                parentAxis = dynamic_cast<VspInterior *>(parent)->GetAxis(); 
     1032 
    10261033        if (mCirculatingAxis) 
    1027                 sAxis = (tData.mAxis + 1) % 3; 
     1034                sAxis = (parentAxis + 1) % 3; 
    10281035        else if (mOnlyDrivingAxis) 
    10291036                sAxis = box.Size().DrivingAxis(); 
     
    10391046                        { 
    10401047                                nCostRatio[axis] = 
    1041                                         BestCostRatioHeuristics(*tData.mRays, 
    1042                                                                                     box, 
     1048                                        EvalLocalCostHeuristics(*tData.mRays, 
     1049                                                                                        box, 
    10431050                                                                                        tData.mPvs, 
    10441051                                                                                        axis, 
     
    10491056                                nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 
    10501057 
    1051                                 nCostRatio[axis] = EvalSplitCost(tData, 
    1052                                                                                                 box, 
    1053                                                                                                 axis, 
    1054                                                                                                 nPosition[axis], 
    1055                                                                                                 nProbFront[axis],  
    1056                                                                                                 nProbBack[axis]); 
     1058                                nCostRatio[axis] = EvalLocalSplitCost(tData, 
     1059                                                                                                          box, 
     1060                                                                                                          axis, 
     1061                                                                                                          nPosition[axis], 
     1062                                                                                                          nProbFront[axis],  
     1063                                                                                                          nProbBack[axis]); 
    10571064                        } 
    10581065                                                 
     
    10911098                                                                          const VspTraversalData &data) const 
    10921099{ 
     1100#if 1 
     1101        return -data.mDepth; 
     1102#endif 
    10931103        float pvsFront = 0; 
    10941104        float pvsBack = 0; 
     
    11121122                float t; 
    11131123                VssRay *ray = rayInf.mRay; 
     1124 
    11141125                const int cf =  
    11151126                        rayInf.ComputeRayIntersection(candidatePlane.mAxis,  
     
    11201131                AddObjToPvs(ray->mOriginObject, cf, pvsFront, pvsBack, totalPvs); 
    11211132        } 
     1133 
    11221134 
    11231135        AxisAlignedBox3 frontBox; 
     
    11451157        const float renderCostDecrease = (oldRenderCost - newRenderCost) / mBoundingBox.GetVolume(); 
    11461158         
    1147  
    1148 #if 1 
    11491159        // take render cost of node into account  
    11501160        // otherwise danger of being stuck in a local minimum!! 
     1161        const float factor = 0.99f; 
     1162 
    11511163        const float normalizedOldRenderCost = oldRenderCost / mBoundingBox.GetVolume(); 
    1152         return 0.99f * renderCostDecrease + 0.01f * normalizedOldRenderCost; 
    1153 #else 
    1154         return renderCostDecrease; 
    1155 #endif 
    1156 } 
    1157  
    1158  
    1159 float VspTree::EvalSplitCost(const VspTraversalData &data, 
    1160                                                          const AxisAlignedBox3 &box, 
    1161                                                          const int axis, 
    1162                                                          const float &position,                                                                            
    1163                                                          float &pFront, 
    1164                                                          float &pBack) const 
     1164        return factor * renderCostDecrease + (1.0f - factor) * normalizedOldRenderCost; 
     1165} 
     1166 
     1167 
     1168float VspTree::EvalLocalSplitCost(const VspTraversalData &data, 
     1169                                                                  const AxisAlignedBox3 &box, 
     1170                                                                  const int axis, 
     1171                                                                  const float &position, 
     1172                                                                  float &pFront, 
     1173                                                                  float &pBack) const 
    11651174{ 
    11661175        float pvsTotal = 0; 
     
    11901199 
    11911200        //-- compute heurstics 
    1192         //-- we take simplified computation for mid split 
    1193                  
     1201         
    11941202        pOverall = data.mProbability; 
     1203        // we take simplified computation for mid split 
    11951204        pBack = pFront = pOverall * 0.5f; 
    11961205         
     
    12101219 
    12111220void VspTree::AddObjToPvs(Intersectable *obj, 
    1212                                                         const int cf, 
    1213                                                         float &frontPvs, 
    1214                                                         float &backPvs, 
    1215                                                         float &totalPvs) const 
     1221                                                  const int cf, 
     1222                                                  float &frontPvs, 
     1223                                                  float &backPvs, 
     1224                                                  float &totalPvs) const 
    12161225{ 
    12171226        if (!obj) 
     
    13521361        ++ mCreatedViewCells; 
    13531362 
    1354 #ifdef _DEBUG 
     1363//#ifdef _DEBUG 
    13551364        Debug << "BSP stats: " 
    13561365                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
    13571366                  << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 
    1358           //              << "Area: " << data.mProbability << " (min: " << mTermMinProbability << "), " 
    13591367                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    1360                   << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "=, " 
     1368                  << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "), " 
    13611369                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    1362 #endif 
     1370//#endif 
    13631371} 
    13641372 
     
    16051613                         
    16061614                        if (GetBBox(interior->GetBack()).Side(plane) < 0) 
     1615                        { 
    16071616                                next = interior->GetFront(); 
     1617                        } 
    16081618            else 
     1619                        { 
    16091620                                if (GetBBox(interior->GetFront()).Side(plane) < 0) 
     1621                                { 
    16101622                                        next = interior->GetBack(); 
     1623                                } 
    16111624                                else  
    16121625                                { 
     
    16181631                                        mask = mask >> 1; 
    16191632                                } 
    1620  
    1621                                 nodeStack.push(next); 
     1633                        } 
     1634                         
     1635                        nodeStack.push(next); 
    16221636                } 
    16231637        } 
     
    17041718 
    17051719int VspTree::CastLineSegment(const Vector3 &origin, 
    1706                                                                 const Vector3 &termination, 
    1707                                                                 ViewCellContainer &viewcells) 
     1720                                                         const Vector3 &termination, 
     1721                             ViewCellContainer &viewcells) 
    17081722{ 
    17091723        int hits = 0; 
     
    17221736        VspNode *node = mRoot; 
    17231737        VspNode *farChild; 
     1738 
     1739        float position; 
     1740        int axis; 
     1741 
     1742        while (1) 
     1743        { 
     1744                if (!node->IsLeaf()) 
     1745                { 
     1746                        VspInterior *in = dynamic_cast<VspInterior *>(node); 
     1747                        position = in->GetPosition(); 
     1748                        axis = in->GetAxis(); 
     1749 
     1750                        if (entp[axis] <= position) 
     1751                        { 
     1752                                if (extp[axis] <= position) 
     1753                                { 
     1754                                        node = in->GetFront(); 
     1755                                        // cases N1,N2,N3,P5,Z2,Z3 
     1756                                        continue; 
     1757                                } else 
     1758                                { 
     1759                                        // case N4 
     1760                                        node = in->GetFront(); 
     1761                                        farChild = in->GetBack(); 
     1762                                } 
     1763                        } 
     1764                        else 
     1765                        { 
     1766                                if (position <= extp[axis]) 
     1767                                { 
     1768                                        node = in->GetBack(); 
     1769                                        // cases P1,P2,P3,N5,Z1 
     1770                                        continue; 
     1771                                } 
     1772                                else 
     1773                                { 
     1774                                        node = in->GetBack(); 
     1775                                        farChild = in->GetFront(); 
     1776                                        // case P4 
     1777                                } 
     1778                        } 
     1779 
     1780                        // $$ modification 3.5.2004 - hints from Kamil Ghais 
     1781                        // case N4 or P4 
     1782                        const float tdist = (position - origin[axis]) / dir[axis]; 
     1783                        tStack.push(LineTraversalData(farChild, extp, maxt)); //TODO 
     1784 
     1785                        extp = origin + dir * tdist; 
     1786                        maxt = tdist; 
     1787                } 
     1788                else 
     1789                { 
     1790                        // compute intersection with all objects in this leaf 
     1791                        VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
     1792                        ViewCell *vc = leaf->GetViewCell(); 
     1793 
     1794                        if (!vc->Mailed()) 
     1795                        { 
     1796                                vc->Mail(); 
     1797                                viewcells.push_back(vc); 
     1798                                ++ hits; 
     1799                        } 
     1800#if 0 
     1801                        leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 
     1802#endif 
     1803                        // get the next node from the stack 
     1804                        if (tStack.empty()) 
     1805                                break; 
     1806 
     1807                        entp = extp; 
     1808                        mint = maxt; 
     1809                         
     1810                        LineTraversalData &s  = tStack.top(); 
     1811                        node = s.mNode; 
     1812                        extp = s.mExitPoint; 
     1813                        maxt = s.mMaxT; 
     1814                        tStack.pop(); 
     1815                } 
     1816        } 
     1817 
     1818        return hits; 
     1819} 
     1820 
     1821 
     1822int VspTree::CastRay(Ray &ray) 
     1823{ 
     1824        int hits = 0; 
     1825 
     1826        stack<LineTraversalData> tStack; 
     1827        const Vector3 dir = ray.GetDir(); 
     1828 
     1829        float maxt, mint; 
     1830 
     1831        if (!mBoundingBox.GetRaySegment(ray, mint, maxt)) 
     1832                return 0; 
     1833 
     1834        Intersectable::NewMail(); 
     1835        ViewCell::NewMail(); 
     1836 
     1837        Vector3 entp = ray.Extrap(mint); 
     1838        Vector3 extp = ray.Extrap(maxt); 
     1839 
     1840        const Vector3 origin = entp; 
     1841 
     1842        VspNode *node = mRoot; 
     1843        VspNode *farChild = NULL; 
    17241844 
    17251845        float position; 
     
    17411861                                        // cases N1,N2,N3,P5,Z2,Z3 
    17421862                                        continue; 
    1743                                 } else 
     1863                                }  
     1864                                else 
    17441865                                { 
    17451866                                        // case N4 
     
    17681889                        const float tdist = (position - origin[axis]) / dir[axis]; 
    17691890                        tStack.push(LineTraversalData(farChild, extp, maxt)); //TODO 
    1770  
    17711891                        extp = origin + dir * tdist; 
    17721892                        maxt = tdist; 
     
    17811901                        { 
    17821902                                vc->Mail(); 
    1783                                 viewcells.push_back(vc); 
     1903                                // todo: add view cells to ray 
    17841904                                ++ hits; 
    17851905                        } 
     
    18041924        return hits; 
    18051925} 
    1806  
    1807  
    1808 int VspTree::CastRay(Ray &ray) 
    1809 { 
    1810         int hits = 0; 
    1811  
    1812         stack<LineTraversalData> tStack; 
    1813         const Vector3 dir = ray.GetDir(); 
    1814  
    1815         float maxt, mint; 
    1816  
    1817         if (!mBoundingBox.GetRaySegment(ray, mint, maxt)) 
    1818                 return 0; 
    1819  
    1820         Intersectable::NewMail(); 
    1821         ViewCell::NewMail(); 
    1822  
    1823         Vector3 entp = ray.Extrap(mint); 
    1824         Vector3 extp = ray.Extrap(maxt); 
    1825  
    1826         const Vector3 origin = entp; 
    1827  
    1828         VspNode *node = mRoot; 
    1829         VspNode *farChild = NULL; 
    1830  
    1831         float position; 
    1832         int axis; 
    1833  
    1834         while (1) 
    1835         { 
    1836                 if (!node->IsLeaf()) 
    1837                 { 
    1838                         VspInterior *in = dynamic_cast<VspInterior *>(node); 
    1839                         position = in->GetPosition(); 
    1840                         axis = in->GetAxis(); 
    1841  
    1842                         if (entp[axis] <= position) 
    1843                         { 
    1844                                 if (extp[axis] <= position) 
    1845                                 { 
    1846                                         node = in->GetBack(); 
    1847                                         // cases N1,N2,N3,P5,Z2,Z3 
    1848                                         continue; 
    1849                                 }  
    1850                                 else 
    1851                                 { 
    1852                                         // case N4 
    1853                                         node = in->GetBack(); 
    1854                                         farChild = in->GetFront(); 
    1855                                 } 
    1856                         } 
    1857                         else 
    1858                         { 
    1859                                 if (position <= extp[axis]) 
    1860                                 { 
    1861                                         node = in->GetFront(); 
    1862                                         // cases P1,P2,P3,N5,Z1 
    1863                                         continue; 
    1864                                 } 
    1865                                 else 
    1866                                 { 
    1867                                         node = in->GetFront(); 
    1868                                         farChild = in->GetBack(); 
    1869                                         // case P4 
    1870                                 } 
    1871                         } 
    1872  
    1873                         // $$ modification 3.5.2004 - hints from Kamil Ghais 
    1874                         // case N4 or P4 
    1875                         const float tdist = (position - origin[axis]) / dir[axis]; 
    1876                         tStack.push(LineTraversalData(farChild, extp, maxt)); //TODO 
    1877                         extp = origin + dir * tdist; 
    1878                         maxt = tdist; 
    1879                 } 
    1880                 else 
    1881                 { 
    1882                         // compute intersection with all objects in this leaf 
    1883                         VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    1884                         ViewCell *vc = leaf->GetViewCell(); 
    1885  
    1886                         if (!vc->Mailed()) 
    1887                         { 
    1888                                 vc->Mail(); 
    1889                                 // todo: add view cells to ray 
    1890                                 ++ hits; 
    1891                         } 
    1892 #if 0 
    1893                         leaf->mRays.push_back(RayInfo(new VssRay(origin, termination, NULL, NULL, 0))); 
    1894 #endif 
    1895                         // get the next node from the stack 
    1896                         if (tStack.empty()) 
    1897                                 break; 
    1898  
    1899                         entp = extp; 
    1900                         mint = maxt; 
    1901                          
    1902                         LineTraversalData &s  = tStack.top(); 
    1903                         node = s.mNode; 
    1904                         extp = s.mExitPoint; 
    1905                         maxt = s.mMaxT; 
    1906                         tStack.pop(); 
    1907                 } 
    1908         } 
    1909  
    1910         return hits; 
    1911 } 
    1912  
    1913  
    1914 VspNode *VspTree::CollapseTree(VspNode *node, int &collapsed) 
    1915 { 
    1916 // TODO 
    1917 #if HAS_TO_BE_REDONE 
    1918         if (node->IsLeaf()) 
    1919                 return node; 
    1920  
    1921         VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    1922  
    1923         VspNode *front = CollapseTree(interior->GetFront(), collapsed); 
    1924         VspNode *back = CollapseTree(interior->GetBack(), collapsed); 
    1925  
    1926         if (front->IsLeaf() && back->IsLeaf()) 
    1927         { 
    1928                 VspLeaf *frontLeaf = dynamic_cast<VspLeaf *>(front); 
    1929                 VspLeaf *backLeaf = dynamic_cast<VspLeaf *>(back); 
    1930  
    1931                 //-- collapse tree 
    1932                 if (frontLeaf->GetViewCell() == backLeaf->GetViewCell()) 
    1933                 { 
    1934                         BspViewCell *vc = frontLeaf->GetViewCell(); 
    1935  
    1936                         VspLeaf *leaf = new VspLeaf(interior->GetParent(), vc); 
    1937                         leaf->SetTreeValid(frontLeaf->TreeValid()); 
    1938  
    1939                         // replace a link from node's parent 
    1940                         if (leaf->GetParent()) 
    1941                                 leaf->GetParent()->ReplaceChildLink(node, leaf); 
    1942                         else 
    1943                                 mRoot = leaf; 
    1944  
    1945                         ++ collapsed; 
    1946                         delete interior; 
    1947  
    1948                         return leaf; 
    1949                 } 
    1950         } 
    1951 #endif 
    1952         return node; 
    1953 } 
    1954  
    1955  
    1956 int VspTree::CollapseTree() 
    1957 { 
    1958         int collapsed = 0; 
    1959  
    1960         (void)CollapseTree(mRoot, collapsed); 
    1961         // revalidate leaves 
    1962         RepairViewCellsLeafLists(); 
    1963  
    1964         return collapsed; 
    1965 } 
    1966  
    1967  
    1968 void VspTree::RepairViewCellsLeafLists() 
    1969 { 
    1970 // TODO 
    1971 #if HAS_TO_BE_REDONE 
    1972         // list not valid anymore => clear 
    1973         stack<VspNode *> nodeStack; 
    1974         nodeStack.push(mRoot); 
    1975  
    1976         ViewCell::NewMail(); 
    1977  
    1978         while (!nodeStack.empty()) 
    1979         { 
    1980                 VspNode *node = nodeStack.top(); 
    1981                 nodeStack.pop(); 
    1982  
    1983                 if (node->IsLeaf()) 
    1984                 { 
    1985                         VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
    1986  
    1987                         BspViewCell *viewCell = leaf->GetViewCell(); 
    1988  
    1989                         if (!viewCell->Mailed()) 
    1990                         { 
    1991                                 viewCell->mLeaves.clear(); 
    1992                                 viewCell->Mail(); 
    1993                         } 
    1994          
    1995                         viewCell->mLeaves.push_back(leaf); 
    1996  
    1997                 } 
    1998                 else 
    1999                 { 
    2000                         VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    2001  
    2002                         nodeStack.push(interior->GetFront()); 
    2003                         nodeStack.push(interior->GetBack()); 
    2004                 } 
    2005         } 
    2006 // TODO 
    2007 #endif 
    2008 } 
    2009  
    20101926 
    20111927 
     
    21712087                //-- test if start point behind or in front of plane 
    21722088                const int side = plane.ComputeRayIntersection(bRay, t); 
    2173  
     2089#if 1 
    21742090                if (side == 0) 
    21752091                { 
     
    21952111                        backRays.push_back(bRay); 
    21962112                } 
    2197  
     2113#else 
     2114                if (side == 0) 
     2115                { 
     2116                        ++ splits; 
     2117 
     2118                        if (ray->HasPosDir(plane.mAxis)) 
     2119                        { 
     2120                                backRays.push_back(RayInfo(ray, bRay.GetMaxT(), t)); 
     2121                                frontRays.push_back(RayInfo(ray, t, bRay.GetMinT())); 
     2122                        } 
     2123                        else 
     2124                        { 
     2125                                frontRays.push_back(RayInfo(ray, bRay.GetMaxT(), t)); 
     2126                                backRays.push_back(RayInfo(ray, t, bRay.GetMinT())); 
     2127                        } 
     2128                } 
     2129                else if (side == 1) 
     2130                { 
     2131                        backRays.push_back(bRay); 
     2132                } 
     2133                else 
     2134                { 
     2135                        frontRays.push_back(bRay); 
     2136                         
     2137                } 
     2138#endif 
    21982139        } 
    21992140 
     
    22162157        AxisAlignedBox3 box(parent->GetBoundingBox()); 
    22172158 
    2218         if (parent->GetFront() == node) 
     2159        if (parent->GetBack() == node) 
    22192160                box.SetMin(parent->GetAxis(), parent->GetPosition()); 
    22202161        else 
     
    22302171                                                                         ViewCellContainer &viewCells) const 
    22312172{ 
    2232 #if TODO 
    2233         stack<bspNodePair> nodeStack; 
    2234         BspNodeGeometry *rgeom = new BspNodeGeometry(); 
    2235  
    2236         ConstructGeometry(mRoot, *rgeom); 
    2237  
    2238         nodeStack.push(bspNodePair(mRoot, rgeom)); 
    2239    
     2173        stack<VspNode *> nodeStack; 
     2174  
    22402175        ViewCell::NewMail(); 
    22412176 
    22422177        while (!nodeStack.empty())  
    22432178        { 
    2244                 BspNode *node = nodeStack.top().first; 
    2245                 BspNodeGeometry *geom = nodeStack.top().second; 
     2179                VspNode *node = nodeStack.top(); 
    22462180                nodeStack.pop(); 
    22472181 
    2248                 const int side = geom->ComputeIntersection(box); 
    2249                  
    2250                 switch (side) 
    2251                 { 
    2252                 case -1: 
     2182                const AxisAlignedBox3 bbox = GetBBox(node); 
     2183 
     2184                if (bbox.Includes(box)) 
     2185                { 
    22532186                        // node geometry is contained in box 
    22542187                        CollectViewCells(node, true, viewCells, true); 
    2255                         break; 
    2256  
    2257                 case 0: 
     2188                } 
     2189                else if (Overlap(bbox, box)) 
     2190                { 
    22582191                        if (node->IsLeaf()) 
    22592192                        { 
     
    22682201                        else  
    22692202                        { 
    2270                                 BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     2203                                VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    22712204                         
    2272                                 BspNode *first = interior->GetFront(); 
    2273                                 BspNode *second = interior->GetBack(); 
     2205                                VspNode *first = interior->GetFront(); 
     2206                                VspNode *second = interior->GetBack(); 
    22742207             
    2275                                 BspNodeGeometry *firstGeom = new BspNodeGeometry(); 
    2276                                 BspNodeGeometry *secondGeom = new BspNodeGeometry(); 
    2277  
    2278                                 geom->SplitGeometry(*firstGeom, 
    2279                                                                         *secondGeom, 
    2280                                                                         interior->GetPlane(), 
    2281                                                                         mBox, 
    2282                                                                         //0.0000001f); 
    2283                                                                         mEpsilon); 
    2284  
    2285                                 nodeStack.push(bspNodePair(first, firstGeom)); 
    2286                                 nodeStack.push(bspNodePair(second, secondGeom)); 
    2287                         } 
    2288                          
    2289                         break; 
    2290                 default: 
    2291                         // default: cull 
    2292                         break; 
    2293                 } 
    2294                 DEL_PTR(geom); 
    2295         } 
    2296  
    2297 #endif 
     2208                                nodeStack.push(first); 
     2209                                nodeStack.push(second); 
     2210                        } 
     2211                }        
     2212                // default: cull 
     2213        } 
     2214 
    22982215        return (int)viewCells.size(); 
    22992216} 
     
    23042221/*                class OspTree implementation                   */ 
    23052222/*****************************************************************/ 
     2223 
    23062224 
    23072225OspTree::OspTree(): 
     
    24992417                // create new interior node and two leaf node 
    25002418                const AxisAlignedPlane splitPlane = splitCandidate.mSplitPlane; 
     2419                 
    25012420                newNode = SubdivideNode(dynamic_cast<KdLeaf *>(newNode),  
    25022421                                                                splitPlane,  
     
    26352554          //              << "Area: " << data.mProbability << " (min: " << mTermMinProbability << "), " 
    26362555                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    2637                   << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "=, " 
     2556                  << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "), " 
    26382557                  << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 
    26392558#endif 
     
    26472566/*********************************************************************/ 
    26482567 
    2649 HierarchyManager::HierarchyManager() 
     2568HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree): 
     2569mVspTree(vspTree), mOspTree(ospTree) 
    26502570{ 
    26512571} 
     
    26552575{ 
    26562576        SplitCandidate *splitCandidate = mTQueue.top(); 
     2577        Debug << "priority: " << splitCandidate->GetPriority() << endl; 
    26572578        mTQueue.pop(); 
    26582579 
     
    26622583 
    26632584void HierarchyManager::PrepareConstruction(const VssRayContainer &sampleRays, 
     2585                                                                                   const ObjectContainer &objects, 
    26642586                                                                                   AxisAlignedBox3 *forcedViewSpace, 
    26652587                                                                                   RayInfoContainer &rays) 
    26662588{ 
     2589        mVspTree.PrepareConstruction(sampleRays, forcedViewSpace); 
     2590 
     2591        long startTime = GetTime(); 
     2592 
     2593        cout << "storing rays ... "; 
     2594 
     2595        Intersectable::NewMail(); 
     2596 
    26672597        VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
    2668  
    2669         long startTime = GetTime(); 
    2670  
    2671         cout << "storing rays ... "; 
    2672  
    2673         Intersectable::NewMail(); 
    2674  
    2675         mVspTree->PrepareConstruction(sampleRays, forcedViewSpace); 
    26762598 
    26772599        //-- store rays 
     
    26842606                static Ray hray; 
    26852607                hray.Init(*ray); 
    2686  
     2608                 
    26872609                // TODO: not very efficient to implictly cast between rays types 
    2688                 if (mBoundingBox.GetRaySegment(hray, minT, maxT)) 
     2610                if (mVspTree.GetBoundingBox().GetRaySegment(hray, minT, maxT)) 
    26892611                { 
    26902612                        float len = ray->Length(); 
     
    26972619        } 
    26982620 
    2699         cout << "finished" << endl; 
     2621        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     2622 
     2623        /// add first candidate for view space partition 
     2624        mVspTree.mRoot = new VspLeaf(); 
     2625        const float prop = mVspTree.mBoundingBox.GetVolume(); 
     2626 
     2627        /// first traversal data 
     2628        VspTree::VspTraversalData tData(mVspTree.mRoot, 
     2629                                                                        0, 
     2630                                                                        &rays, 
     2631                                                                        (int)objects.size(), 
     2632                                                                        //mVspTree.ComputePvsSize(rays), 
     2633                                                                        prop, 
     2634                                                                        mVspTree.mBoundingBox); 
     2635 
     2636        // compute first split candidate 
     2637        VspTree::VspSplitCandidate *splitCandidate = new VspTree::VspSplitCandidate(); 
     2638    mVspTree.EvalSplitCandidate(tData, *splitCandidate); 
     2639 
     2640        mTQueue.push(splitCandidate); 
    27002641 
    27012642        //mOspTree->PrepareConstruction(sampleRays, forcedViewSpace, rays); 
     
    27102651                        dynamic_cast<VspTree::VspSplitCandidate *>(candidate); 
    27112652                 
    2712                 return mVspTree->GlobalTerminationCriteriaMet(sc->mParentData); 
     2653                return mVspTree.GlobalTerminationCriteriaMet(sc->mParentData); 
    27132654        } 
    27142655 
     
    27242665         
    27252666        // prepare vsp and osp trees for traversal 
    2726         PrepareConstruction(sampleRays, forcedViewSpace, *rays); 
    2727  
    2728         mVspTree->mVspStats.Start(); 
     2667        PrepareConstruction(sampleRays, objects, forcedViewSpace, *rays); 
     2668 
     2669        mVspTree.mVspStats.Reset(); 
     2670        mVspTree.mVspStats.Start(); 
    27292671 
    27302672        cout << "Constructing view space / object space tree ... \n"; 
     
    27382680                        GlobalTerminationCriteriaMet(splitCandidate); 
    27392681 
     2682                Debug << "cost: " << splitCandidate->GetPriority(); 
     2683 
    27402684                // cost ratio of cost decrease / totalCost 
    27412685                const float costRatio = splitCandidate->GetPriority() / mTotalCost; 
     
    27442688                if (costRatio < mTermMinGlobalCostRatio) 
    27452689                        ++ mGlobalCostMisses; 
    2746          
     2690 
    27472691                //-- subdivide leaf node 
    27482692                //-- either a object space or view space split 
     
    27522696                                dynamic_cast<VspTree::VspSplitCandidate *>(splitCandidate); 
    27532697 
    2754                         VspNode *r = mVspTree->Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 
     2698                        VspNode *r = mVspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 
    27552699                } 
    27562700                else // object space split 
    27572701                { 
    27582702#if TODO 
    2759                         KdNode *r = mKdtree->Subdivide(tOspQueue, dynamic_cast<OspSplitCandidate<(splitCandidate)); 
     2703                        KdNode *r = mKdtree.Subdivide(tOspQueue, dynamic_cast<OspSplitCandidate<(splitCandidate)); 
    27602704#endif 
    27612705                } 
     
    27662710        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << "secs" << endl; 
    27672711 
    2768         mVspTree->mVspStats.Stop(); 
     2712        mVspTree.mVspStats.Stop(); 
    27692713} 
    27702714 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1023 r1027  
    3434class KdTreeStatistics; 
    3535 
     36template <typename T> class GtPriority 
     37{ 
     38public: 
     39        bool operator() (const T c1, const T c2) const 
     40        { 
     41                //return false; 
     42                return c1->GetPriority() < c2->GetPriority(); 
     43        } 
     44}; 
     45 
    3646/** A definition for an axis aligned plane. 
    3747*/ 
     
    8494        float GetPriority() const 
    8595        { 
    86 #if 1 
    8796                return mPriority; 
    88 #else 
    89                 return (float) (-mDepth); // for kd tree 
    90 #endif 
    9197        } 
    9298 
    93         friend bool operator<(const SplitCandidate &a, const SplitCandidate &b) 
     99        /*friend bool operator<(const SplitCandidate &a, const SplitCandidate &b) 
    94100        { 
    95101                return a.GetPriority() < b.GetPriority(); 
    96         } 
     102        }*/ 
    97103}; 
    98104 
     
    461467 
    462468 
    463 typedef std::priority_queue<SplitCandidate *> SplitQueue; 
    464  
     469typedef std::priority_queue<SplitCandidate *,  
     470                                                        std::vector<SplitCandidate *>,  
     471                                                        GtPriority<std::vector<SplitCandidate *>::value_type> > SplitQueue; 
    465472 
    466473#if TODO 
     
    511518                /// how often this branch has missed the max-cost ratio 
    512519                int mMaxCostMisses; 
    513                 // current axis 
    514                 int mAxis; 
    515520                // current priority 
    516521                float mPriority; 
     
    532537                mProbability(0.0), 
    533538                mMaxCostMisses(0),  
    534                 mPriority(0), 
    535                 mAxis(0) 
     539                mPriority(0) 
    536540                {} 
    537541                 
     
    549553                mBoundingBox(box), 
    550554                mMaxCostMisses(0), 
    551                 mPriority(0), 
    552                 mAxis(0) 
     555                mPriority(0) 
    553556                {} 
    554557 
     
    562565                mProbability(0), 
    563566                mMaxCostMisses(0), 
    564                 mAxis(0), 
    565567                mBoundingBox(box) 
    566568                {} 
     
    698700        */ 
    699701        void SetViewCellsManager(ViewCellsManager *vcm); 
    700  
    701  
    702         /** Collapses the tree with respect to the view cell partition. 
    703                 @returns number of collapsed nodes 
    704         */ 
    705         int CollapseTree(); 
    706702 
    707703        /** Returns view cell the current point is located in. 
     
    785781                } 
    786782                 
    787                 friend bool operator<(const SortableEntry &a, const SortableEntry &b)  
     783                friend bool operator<(const SortableEntry &a, const SortableEntry &b) 
    788784                { 
    789785                        return a.value < b.value; 
     
    793789        /** faster evaluation of split plane cost for kd axis aligned cells. 
    794790        */ 
    795         float EvalSplitCost(const VspTraversalData &data, 
    796                                                 const AxisAlignedBox3 &box, 
    797                                                 const int axis, 
    798                                                 const float &position, 
    799                                                 float &pFront, 
    800                                                 float &pBack) const; 
     791        float EvalLocalSplitCost(const VspTraversalData &data, 
     792                                                         const AxisAlignedBox3 &box, 
     793                                                         const int axis, 
     794                                                         const float &position, 
     795                                                         float &pFront, 
     796                                                         float &pBack) const; 
    801797 
    802798        void PrepareConstruction(const VssRayContainer &sampleRays, 
     
    806802        */ 
    807803        void EvalSplitCandidate(VspTraversalData &tData, VspSplitCandidate &splitData); 
    808  
    809         /** Computes priority of the traversal data and stores it in tData. 
    810         */ 
    811         void EvalPriority(VspTraversalData &tData) const; 
    812804 
    813805        /** Evaluates render cost decrease of next split. 
     
    882874                @returns cost for this split 
    883875        */ 
    884         float SelectPlane(const VspTraversalData &tData, 
    885                                           AxisAlignedPlane &plane, 
    886                                           float &pFront, 
    887                                           float &pBack); 
     876        float SelectSplitPlane(const VspTraversalData &tData, 
     877                                                   AxisAlignedPlane &plane, 
     878                                                   float &pFront, 
     879                                                   float &pBack); 
    888880 
    889881        /** Sorts split candidates for surface area heuristics for axis aligned splits. 
     
    899891        /** Computes best cost for axis aligned planes. 
    900892        */ 
    901         float BestCostRatioHeuristics(const RayInfoContainer &rays, 
     893        float EvalLocalCostHeuristics(const RayInfoContainer &rays, 
    902894                                                                  const AxisAlignedBox3 &box, 
    903895                                                                  const int pvsSize, 
     
    13391331        /** faster evaluation of split plane cost for kd axis aligned cells. 
    13401332        */ 
    1341         float EvalSplitCost(const OspTraversalData &data, 
    1342                                                 const AxisAlignedBox3 &box, 
    1343                                                 const int axis, 
    1344                                                 const float &position, 
    1345                                                 float &pFront, 
    1346                                                 float &pBack) const; 
     1333        float EvalLocalSplitCost(const OspTraversalData &data, 
     1334                                                         const AxisAlignedBox3 &box, 
     1335                                                         const int axis, 
     1336                                                         const float &position, 
     1337                                                         float &pFront, 
     1338                                                         float &pBack) const; 
    13471339 
    13481340        /** Evaluates candidate for splitting. 
     
    14291421        /** Computes best cost for axis aligned planes. 
    14301422        */ 
    1431         float BestCostRatioHeuristics(const RayInfoContainer &rays, 
     1423        float EvalLocalCostHeuristics(const RayInfoContainer &rays, 
    14321424                                                                  const AxisAlignedBox3 &box, 
    14331425                                                                  const int pvsSize, 
     
    16221614class HierarchyManager 
    16231615{ 
    1624         /** Default constructor. 
    1625         */ 
    1626         HierarchyManager(); 
     1616public: 
     1617        /** Constructor taking an object space partition and a view space partition tree. 
     1618        */ 
     1619        HierarchyManager(VspTree &vspTree, OspTree &ospTree); 
    16271620 
    16281621        /** Constructs the view space and object space subdivision from a given set of rays 
     
    16361629 
    16371630public: 
    1638         VspTree *mVspTree; 
    1639         OspTree *mOspTree; 
     1631        VspTree &mVspTree; 
     1632        OspTree &mOspTree; 
    16401633 
    16411634protected: 
     
    16441637 
    16451638        void PrepareConstruction(const VssRayContainer &sampleRays, 
     1639                                                         const ObjectContainer &objects, 
    16461640                                                         AxisAlignedBox3 *forcedViewSpace, 
    16471641                                                         RayInfoContainer &rays); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r1004 r1027  
    616616  if (!mLoadViewCells) 
    617617  { 
     618           Debug << "here923 " << vbox << endl; 
    618619          mViewCellsManager->SetViewSpaceBox(vbox); 
    619620          // construct view cells using it's own set of samples 
Note: See TracChangeset for help on using the changeset viewer.