source: GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h @ 1633

Revision 1633, 2.7 KB checked in by mattausch, 18 years ago (diff)

worked on gradient method for vsposp

RevLine 
[1239]1#ifndef SUBDIVISIONCANDIDATE_H
2#define SUBDIVISIONCANDIDATE_H
[1237]3
[1239]4
[1237]5#include "FlexibleHeap.h"
6
7using namespace std;
8
9namespace GtpVisibilityPreprocessor {
10
[1633]11class SubdivisionCandidate;
12
13typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer;
14typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue;
15
[1237]16/** Candidate for a view space / object space split.
17*/
18class SubdivisionCandidate: public Heapable
19
20public:
21
22        enum {OBJECT_SPACE, VIEW_SPACE};
23
24        SubdivisionCandidate(): mRenderCostDecrease(0) {};
25
[1305]26        virtual ~SubdivisionCandidate() {};
[1633]27        virtual void EvalPriority(bool computeSplitplane = true) = 0;
[1237]28        virtual int Type() const = 0;
[1633]29        virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0;
[1237]30        virtual bool GlobalTerminationCriteriaMet() const = 0;
31
[1633]32        virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
33                                                                                const bool onlyUnmailed) = 0;
34
[1237]35        /** Set render cost decrease achieved through this split.
36        */
[1473]37        inline void SetRenderCostDecrease(const float renderCostDecr)
[1237]38        {
39                mRenderCostDecrease = renderCostDecr;
40        }
41       
[1473]42        inline float GetRenderCostDecrease() const
[1237]43        {
44                return mRenderCostDecrease;
45        }
46
[1297]47        /** Position in queue.
48        */
[1576]49        inline int GetPosition() const
[1297]50        {
51                return mPosition;
52        }
53
[1576]54        inline void SetSplitAxis(const int splitAxis)
55        {
56                mSplitAxis = splitAxis;
57        }
58        inline void SetMaxCostMisses(const int misses)
59        {
60                mMaxCostMisses = misses;
61        }
62        inline void SetPvsEntriesIncr(const int pvsEntriesIncr)
63        {
64                mPvsEntriesIncr = pvsEntriesIncr;
65        }
66
67        inline int GetSplitAxis() const
68        {
69                return mSplitAxis;
70        }
71        inline int GetMaxCostMisses() const
72        {
73                return mMaxCostMisses;
74        }
75        inline int GetPvsEntriesIncr() const
76        {
77                return mPvsEntriesIncr;
78        }
79
[1633]80        //////////
81        //-- mailing stuff
82
83        static void NewMail(const int reserve = 1)
84        {
85                sMailId += sReservedMailboxes;
86                sReservedMailboxes = reserve;
87        }
88
89        void Mail() { mMailbox = sMailId; }
90        bool Mailed() const { return mMailbox == sMailId; }
91
92        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
93        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
94
95        int IncMail() { return ++ mMailbox - sMailId; }
96
97
98        // last mail id -> warning not thread safe!
99        // both mailId and mailbox should be unique for each thread!!!
100        static int sMailId;
101        static int sReservedMailboxes;
102
[1576]103protected:
104
[1473]105        /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
106        int mSplitAxis;
107        /// the number of misses of max cost ratio until this split
108        int mMaxCostMisses;
[1237]109        /// render cost decrease achieved through this split
110        float mRenderCostDecrease;
[1576]111        /// the decrease of the number of pvs entries
112        int mPvsEntriesIncr;
[1633]113
114        int mMailbox;
[1237]115};
116
[1313]117
[1237]118}
119
[1633]120// SUBDIVISIONCANDIDATE_H
[1237]121#endif
Note: See TracBrowser for help on using the repository browser.