Ignore:
Timestamp:
10/16/06 15:11:13 (18 years ago)
Author:
mattausch
Message:

worked on gradient method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1624 r1625  
    239239protected: 
    240240 
     241        /** Returns true if the global termination criteria were met. 
     242        */ 
    241243        bool GlobalTerminationCriteriaMet(SubdivisionCandidate *candidate) const; 
    242244 
     
    244246                first split candidates. 
    245247        */ 
    246         void PrepareObjectSpaceSubdivision( 
    247                 const VssRayContainer &sampleRays, 
    248                 const ObjectContainer &objects); 
    249  
    250         void RunConstruction( 
    251                 const bool repairQueue, 
    252                 const VssRayContainer &sampleRays, 
    253                 const ObjectContainer &objects, 
    254                 AxisAlignedBox3 *forcedViewSpace); 
    255          
     248        SubdivisionCandidate *PrepareObjectSpaceSubdivision(const VssRayContainer &sampleRays, 
     249                                                                                                                const ObjectContainer &objects); 
     250 
     251 
     252        ////////////////////////////// 
     253        // the main loop 
     254        ////////////////////// 
     255 
     256        /** This is for interleaved construction / sequential construction. 
     257        */ 
     258        void RunConstruction(const bool repairQueue, 
     259                                                 const VssRayContainer &sampleRays, 
     260                                                 const ObjectContainer &objects, 
     261                                                 AxisAlignedBox3 *forcedViewSpace); 
     262         
     263        /** This is for interleaved construction using some objects  
     264                and some view space splits. 
     265        */ 
     266        int RunConstruction(SplitQueue &splitQueue, 
     267                                                SubdivisionCandidateContainer &chosenCandidates, 
     268                                                const float minRenderCostDecr, 
     269                                                const int maxSteps); 
     270 
     271        /** Default subdivision method. 
     272        */ 
    256273        void RunConstruction(const bool repairQueue); 
    257274                 
     275        //////////////////////////////////////////////// 
     276 
    258277        /** Evaluates the subdivision candidate and executes the split. 
    259278        */ 
    260         bool ApplySubdivisionCandidate(SubdivisionCandidate *sc, const bool repairQueue); 
    261  
     279        bool ApplySubdivisionCandidate(SubdivisionCandidate *sc,  
     280                                                                   SplitQueue &splitQueue, 
     281                                                                   const bool repairQueue); 
     282 
     283        /** Tests if hierarchy construction is finished. 
     284        */ 
    262285        bool FinishedConstruction() const; 
    263286 
    264         SubdivisionCandidate *NextSubdivisionCandidate(); 
    265  
    266         /** Repairs the dirty entries of the candidate queue. 
    267         */ 
    268         void RepairQueue(SubdivisionCandidate *sc); 
     287        /** Returns next subdivision candidate from the split queue. 
     288        */ 
     289        SubdivisionCandidate *NextSubdivisionCandidate(SplitQueue &splitQueue); 
     290 
     291        /** Repairs the dirty entries of the subdivision candidate queue. The 
     292                list of entries is given in the dirty list. 
     293        */ 
     294        void RepairQueue(const vector<SubdivisionCandidate *> &dirtyList, SplitQueue &splitQueue); 
     295 
     296        /** Collect subdivision candidates which were affected by the splits from the 
     297                chosenCandidates list. 
     298        */  
     299        void CollectDirtyCandidates(const SubdivisionCandidateContainer &chosenCandidates,  
     300                                                                SubdivisionCandidateContainer &dirtyList); 
    269301 
    270302        /** Collect the list of dirty candidates after the current  
    271303                subdivision candidate split. 
    272304        */ 
    273         void CollectDirtyCandidates( 
    274                 SubdivisionCandidate *sc, 
    275                 vector<SubdivisionCandidate *> &dirtyList); 
     305        void CollectDirtyCandidates(SubdivisionCandidate *sc, 
     306                                                                vector<SubdivisionCandidate *> &dirtyList); 
    276307 
    277308        /** Evaluate subdivision stats for log. 
     
    279310        void EvalSubdivisionStats(); 
    280311 
    281         void AddSubdivisionStats( 
    282                 const int splits, 
    283                 const float renderCostDecr, 
    284                 const float totalRenderCost, 
    285                 const int totalPvsEntries); 
    286  
    287         bool AddSampleToPvs( 
    288                 Intersectable *obj,  
    289                 const float pdf, 
    290                 float &contribution) const; 
    291  
    292         void CollectViewSpaceDirtyList( 
    293                 SubdivisionCandidate *sc, 
    294                 SubdivisionCandidateContainer &dirtyList); 
    295  
    296         void CollectObjectSpaceDirtyList( 
    297                 SubdivisionCandidate *sc, 
    298                 SubdivisionCandidateContainer &dirtyList); 
     312        void AddSubdivisionStats(const int splits, 
     313                                                         const float renderCostDecr, 
     314                                                         const float totalRenderCost, 
     315                                                         const int totalPvsEntries,  
     316                                                         const int memory, 
     317                                                         const float renderCostPerStorage); 
     318 
     319        bool AddSampleToPvs(Intersectable *obj,  
     320                                                const float pdf, 
     321                                                float &contribution) const; 
     322 
     323        /** Collect affected view space candidates. 
     324        */ 
     325        void CollectViewSpaceDirtyList(SubdivisionCandidate *sc, 
     326                                                                   SubdivisionCandidateContainer &dirtyList); 
     327 
     328        /** Collect affected object space candidates. 
     329        */ 
     330        void CollectObjectSpaceDirtyList(SubdivisionCandidate *sc, 
     331                                                                         SubdivisionCandidateContainer &dirtyList); 
    299332                 
    300         void ExportOspTree( 
    301                 Exporter *exporter,  
    302                 const ObjectContainer &objects) const; 
    303  
     333        /** Export object space partition tree. 
     334        */ 
     335        void ExportOspTree(Exporter *exporter,  
     336                                           const ObjectContainer &objects) const; 
     337 
     338        /** Parse the environment variables. 
     339        */ 
    304340        void ParseEnvironment(); 
    305341 
     
    307343        bool StartViewSpaceSubdivision() const; 
    308344 
    309         void PrepareBvHierarchy( 
    310                 const VssRayContainer &sampleRays, 
    311                 const ObjectContainer &objects); 
    312  
    313         void PrepareOspTree( 
    314                 const VssRayContainer &sampleRays, 
    315                 const ObjectContainer &objects); 
    316  
    317         void PrepareViewSpaceSubdivision( 
    318                 const VssRayContainer &sampleRays, 
    319                 const ObjectContainer &objects); 
    320  
     345        //////////////////////////// 
     346        // Helper function for preparation of subdivision 
     347        /////// 
     348 
     349        /** Prepare bv hierarchy for subdivision 
     350        */ 
     351        SubdivisionCandidate *PrepareBvHierarchy(const VssRayContainer &sampleRays, 
     352                                                                           const ObjectContainer &objects); 
     353 
     354        /** Prepare object space kd tree for subdivision. 
     355        */ 
     356        SubdivisionCandidate *PrepareOspTree(const VssRayContainer &sampleRays, 
     357                                                                   const ObjectContainer &objects); 
     358 
     359        /** Prepare view space subdivision and add candidate to queue. 
     360        */ 
     361        SubdivisionCandidate *PrepareViewSpaceSubdivision(const VssRayContainer &sampleRays, 
     362                                                                                                          const ObjectContainer &objects); 
     363 
     364        /** Was object space subdivision already constructed? 
     365        */ 
    321366        bool ObjectSpaceSubdivisionConstructed() const; 
     367         
     368        /** Was view space subdivision already constructed? 
     369        */ 
    322370        bool ViewSpaceSubdivisionConstructed() const; 
    323371 
     372        /** Reset the split queue, i.e., reevaluate the split candidates. 
     373        */ 
    324374    void ResetQueue(); 
    325375 
     376        /** After the suddivision has ended, do some final tasks. 
     377        */ 
    326378        void FinishObjectSpaceSubdivision(const ObjectContainer &objects) const; 
    327379 
     380        /** Returns depth of object space subdivision. 
     381        */ 
    328382        int GetObjectSpaceSubdivisionDepth() const; 
    329383 
     384        /** Construct object space partition interleaved with view space partition. 
     385                Each time the best object or view space candidate is selected 
     386                for the next split. 
     387        */ 
    330388        void ConstructInterleaved( 
    331389                const VssRayContainer &sampleRays, 
     
    333391                AxisAlignedBox3 *forcedViewSpace); 
    334392 
     393        /** Construct object space partition interleaved with view space partition. 
     394                The method chooses a number candidates of each type for subdivision. 
     395                The number is determined by the "gradient", i.e., the render cost decrease. 
     396                Once this render cost decrease is lower than the render cost decrease 
     397                for the splits of previous type, the method will stop current subdivision and 
     398                evaluate if view space or object space would be the beneficial for the  
     399                next number of split. 
     400        */ 
    335401        void ConstructInterleaved2( 
    336402                const VssRayContainer &sampleRays, 
     
    349415                so construction can be restarted. 
    350416        */ 
    351         void ResetObjectSpaceSubdivision( 
    352                 const VssRayContainer &rays,  
    353                 const ObjectContainer &objects); 
    354  
    355         void HierarchyManager::ResetViewSpaceSubdivision( 
    356                 const VssRayContainer &rays,  
    357                 const ObjectContainer &objects); 
     417        SubdivisionCandidate *ResetObjectSpaceSubdivision(const VssRayContainer &rays,  
     418                                                                                                          const ObjectContainer &objects); 
     419 
     420        SubdivisionCandidate *ResetViewSpaceSubdivision(const VssRayContainer &rays,  
     421                                                                                                        const ObjectContainer &objects); 
    358422 
    359423 
     
    390454        /// object space partition kd tree 
    391455        OspTree *mOspTree; 
     456 
    392457        public: 
    393458        /// bounding volume hierarchy 
     
    409474        //////////////////// 
    410475 
    411         /// keeps track of cost during subdivision 
    412         //float mTotalCost; 
    413476        /// statistics about the hierarchy 
    414477        HierarchyStatistics mHierarchyStats; 
     
    417480        int mMinDepthForViewSpaceSubdivion; 
    418481         
    419         int mMinRenderCostDecrease; 
     482        //int mMinRenderCostDecrease; 
    420483 
    421484        ofstream mSubdivisionStats; 
Note: See TracChangeset for help on using the changeset viewer.