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

Line 
1#ifndef SUBDIVISIONCANDIDATE_H
2#define SUBDIVISIONCANDIDATE_H
3
4
5#include "FlexibleHeap.h"
6
7using namespace std;
8
9namespace GtpVisibilityPreprocessor {
10
11class SubdivisionCandidate;
12
13typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer;
14typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue;
15
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
26        virtual ~SubdivisionCandidate() {};
27        virtual void EvalPriority(bool computeSplitplane = true) = 0;
28        virtual int Type() const = 0;
29        virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0;
30        virtual bool GlobalTerminationCriteriaMet() const = 0;
31
32        virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
33                                                                                const bool onlyUnmailed) = 0;
34
35        /** Set render cost decrease achieved through this split.
36        */
37        inline void SetRenderCostDecrease(const float renderCostDecr)
38        {
39                mRenderCostDecrease = renderCostDecr;
40        }
41       
42        inline float GetRenderCostDecrease() const
43        {
44                return mRenderCostDecrease;
45        }
46
47        /** Position in queue.
48        */
49        inline int GetPosition() const
50        {
51                return mPosition;
52        }
53
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
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
103protected:
104
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;
109        /// render cost decrease achieved through this split
110        float mRenderCostDecrease;
111        /// the decrease of the number of pvs entries
112        int mPvsEntriesIncr;
113
114        int mMailbox;
115};
116
117
118}
119
120// SUBDIVISIONCANDIDATE_H
121#endif
Note: See TracBrowser for help on using the repository browser.