Changeset 1101


Ignore:
Timestamp:
07/07/06 16:28:17 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
2 edited

Legend:

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

    r1099 r1101  
    750750                        Intersectable *object = (*oit).first; 
    751751                        // HACK: make sure that the view cell is removed from the pvs 
    752                         const float high_contri = 99999999999; 
    753                         object->mViewCellPvs.RemoveSample(parent, 999999); 
     752                        const float high_contri = 9999999; 
     753                        object->mViewCellPvs.RemoveSample(parent, high_contri); 
    754754                } 
    755755        } 
     
    34543454 
    34553455 
    3456 void HierarchyManager::Construct(const VssRayContainer &sampleRays, 
     3456void HierarchyManager::Construct2(const VssRayContainer &sampleRays, 
    34573457                                                                 const ObjectContainer &objects, 
    34583458                                                                 AxisAlignedBox3 *forcedViewSpace) 
    34593459{ 
    34603460        RayInfoContainer *rays = new RayInfoContainer(); 
    3461          
    3462         // prepare vsp and osp trees for traversal 
    3463         PrepareConstruction(sampleRays, objects, forcedViewSpace, *rays); 
    3464  
    3465         mVspTree.mVspStats.Reset(); 
    3466         mVspTree.mVspStats.Start(); 
    3467  
    3468         cout << "Constructing view space / object space tree ... \n"; 
    3469         const long startTime = GetTime();        
    3470          
     3461 
     3462        mVspTree.PrepareConstruction(sampleRays, forcedViewSpace); 
     3463 
     3464        long startTime = GetTime(); 
     3465 
     3466        cout << "storing rays ... "; 
     3467 
     3468        Intersectable::NewMail(); 
     3469 
     3470        VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
     3471 
     3472        //-- store rays 
     3473        for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 
     3474        { 
     3475                VssRay *ray = *rit; 
     3476 
     3477                float minT, maxT; 
     3478 
     3479                static Ray hray; 
     3480                hray.Init(*ray); 
     3481                 
     3482                // TODO: not very efficient to implictly cast between rays types 
     3483                if (mVspTree.GetBoundingBox().GetRaySegment(hray, minT, maxT)) 
     3484                { 
     3485                        float len = ray->Length(); 
     3486 
     3487                        if (!len) 
     3488                                len = Limits::Small; 
     3489 
     3490                        rays->push_back(RayInfo(ray, minT / len, maxT / len)); 
     3491                } 
     3492        } 
     3493 
     3494        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     3495 
     3496 
     3497        const int pvsSize = mVspTree.ComputePvsSize(*rays); 
     3498 
     3499 
     3500        // -- prepare view space partition 
     3501 
     3502        // add first candidate for view space partition 
     3503        mVspTree.mRoot = new VspLeaf(); 
     3504        const float prop = mVspTree.mBoundingBox.GetVolume(); 
     3505 
     3506        // first vsp traversal data 
     3507        VspTree::VspTraversalData vData(mVspTree.mRoot, 
     3508                                                                        0, 
     3509                                                                        rays, 
     3510                                                                        pvsSize,         
     3511                                                                        prop, 
     3512                                                                        mVspTree.mBoundingBox); 
     3513 
     3514 
     3515        //-- compute first split candidate 
     3516        VspTree::VspSplitCandidate *splitCandidate = new VspTree::VspSplitCandidate(vData); 
     3517    mVspTree.EvalSplitCandidate(*splitCandidate); 
     3518 
     3519        mTQueue.Push(splitCandidate); 
     3520 
    34713521        int i = 0; 
     3522 
    34723523        while (!FinishedConstruction()) 
    34733524        { 
     
    34873538 
    34883539                //-- subdivide leaf node 
    3489                 //-- we have either a object space or view space split 
     3540 
     3541                // we have either a object space or view space split 
     3542                VspTree::VspSplitCandidate *sc =  
     3543                        dynamic_cast<VspTree::VspSplitCandidate *>(splitCandidate); 
     3544 
     3545                VspNode *r = mVspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 
     3546         
     3547                DEL_PTR(splitCandidate); 
     3548        } 
     3549 
     3550        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
     3551 
     3552        mVspTree.mVspStats.Stop(); 
     3553 
     3554 
     3555 
     3556        //-- object space partition 
     3557 
     3558        mOspTree.PrepareConstruction(objects, forcedViewSpace); 
     3559 
     3560        // add first candidate for view space partition 
     3561        KdLeaf *leaf = new KdLeaf(NULL, 0); 
     3562        leaf->mObjects = objects; 
     3563 
     3564        mOspTree.mRoot = leaf; 
     3565         
     3566 
     3567        //-- first osp traversal data 
     3568        OspTree::OspTraversalData oData(mOspTree.mRoot, 
     3569                                                                        0, 
     3570                                                                        rays, 
     3571                                                                        pvsSize, 
     3572                                                                        prop, 
     3573                                                                        mOspTree.mBoundingBox); 
     3574 
     3575                 
     3576        mOspTree.ProcessLeafObjects(leaf, NULL); 
     3577 
     3578        // compute first split candidate 
     3579        OspTree::OspSplitCandidate *oSplitCandidate = new OspTree::OspSplitCandidate(oData); 
     3580    mOspTree.EvalSplitCandidate(*oSplitCandidate); 
     3581 
     3582        mTQueue.Push(splitCandidate); 
     3583 
     3584        i = 0; 
     3585        while (!FinishedConstruction()) 
     3586        { 
     3587                SplitCandidate *splitCandidate = NextSplitCandidate(); 
     3588             
     3589                const bool globalTerminationCriteriaMet =  
     3590                        GlobalTerminationCriteriaMet(splitCandidate); 
     3591 
     3592                cout << "view cells: " << i ++ << endl; 
     3593 
     3594                // cost ratio of cost decrease / totalCost 
     3595                const float costRatio = splitCandidate->GetPriority() / mTotalCost; 
     3596                //Debug << "cost ratio: " << costRatio << endl; 
     3597 
     3598                if (costRatio < mTermMinGlobalCostRatio) 
     3599                        ++ mGlobalCostMisses; 
     3600 
     3601                //-- subdivide leaf node 
     3602 
     3603                // object space split 
     3604                OspTree::OspSplitCandidate *sc =  
     3605                        dynamic_cast<OspTree::OspSplitCandidate *>(splitCandidate); 
     3606 
     3607                KdNode *r = mOspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 
     3608                 
     3609                DEL_PTR(splitCandidate); 
     3610        } 
     3611 
     3612        cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
     3613} 
     3614 
     3615 
     3616void HierarchyManager::Construct(const VssRayContainer &sampleRays, 
     3617                                                                 const ObjectContainer &objects, 
     3618                                                                 AxisAlignedBox3 *forcedViewSpace) 
     3619{ 
     3620        RayInfoContainer *rays = new RayInfoContainer(); 
     3621         
     3622        // prepare vsp and osp trees for traversal 
     3623        PrepareConstruction(sampleRays, objects, forcedViewSpace, *rays); 
     3624 
     3625        mVspTree.mVspStats.Reset(); 
     3626        mVspTree.mVspStats.Start(); 
     3627 
     3628        cout << "Constructing view space / object space tree ... \n"; 
     3629        const long startTime = GetTime();        
     3630         
     3631        int i = 0; 
     3632        while (!FinishedConstruction()) 
     3633        { 
     3634                SplitCandidate *splitCandidate = NextSplitCandidate(); 
     3635             
     3636                const bool globalTerminationCriteriaMet =  
     3637                        GlobalTerminationCriteriaMet(splitCandidate); 
     3638 
     3639                cout << "view cells: " << i ++ << endl; 
     3640 
     3641                // cost ratio of cost decrease / totalCost 
     3642                const float costRatio = splitCandidate->GetPriority() / mTotalCost; 
     3643                //Debug << "cost ratio: " << costRatio << endl; 
     3644 
     3645                if (costRatio < mTermMinGlobalCostRatio) 
     3646                        ++ mGlobalCostMisses; 
     3647 
     3648                //-- subdivide leaf node 
     3649 
     3650                // we have either a object space or view space split 
    34903651                if (splitCandidate->Type() == SplitCandidate::VIEW_SPACE) 
    34913652                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1099 r1101  
    16721672                                   AxisAlignedBox3 *forcedViewSpace); 
    16731673 
     1674        /** Constructs first view cells, then object space partition. 
     1675        */ 
     1676        void Construct2(const VssRayContainer &sampleRays, 
     1677                                        const ObjectContainer &objects, 
     1678                                        AxisAlignedBox3 *forcedViewSpace); 
    16741679public: 
    16751680        VspTree &mVspTree; 
Note: See TracChangeset for help on using the changeset viewer.