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

Revision 1684, 3.2 KB checked in by mattausch, 18 years ago (diff)

found constant for ratio

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        /** Evaluate this subdivision candidate.
28        */
29        virtual void EvalCandidate(bool computeSplitplane = true) = 0;
30        /** Returns type of this subdivision candidate.
31        */
32        virtual int Type() const = 0;
33        /** Evaluate this candidate and put results into queue for further traversal.
34        */
35        virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0;
36        /** Returns true of the global termination criteria of this split were met,
37                false otherwise.
38        */
39        virtual bool GlobalTerminationCriteriaMet() const = 0;
40        /** Collects subdivision candidates that were affected by the
41                application of this one.
42        */
43        virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
44                                                                                const bool onlyUnmailed) = 0;
45
46        /** Set render cost decrease achieved through this split.
47        */
48        inline void SetRenderCostDecrease(const float renderCostDecr)
49        {
50                mRenderCostDecrease = renderCostDecr;
51        }
52       
53        inline float GetRenderCostDecrease() const
54        {
55                return mRenderCostDecrease;
56        }
57
58        /** Position in queue.
59        */
60        inline int GetPosition() const
61        {
62                return mPosition;
63        }
64
65        inline void SetSplitAxis(const int splitAxis)
66        {
67                mSplitAxis = splitAxis;
68        }
69       
70        inline void SetMaxCostMisses(const int misses)
71        {
72                mMaxCostMisses = misses;
73        }
74
75        inline void SetPvsEntriesIncr(const int pvsEntriesIncr)
76        {
77                mPvsEntriesIncr = pvsEntriesIncr;
78        }
79
80        inline int GetSplitAxis() const
81        {
82                return mSplitAxis;
83        }
84
85        inline int GetMaxCostMisses() const
86        {
87                return mMaxCostMisses;
88        }
89
90        inline int GetPvsEntriesIncr() const
91        {
92                return mPvsEntriesIncr;
93        }
94
95
96        //////////
97        //-- mailing stuff
98
99        static void NewMail(const int reserve = 1)
100        {
101                sMailId += sReservedMailboxes;
102                sReservedMailboxes = reserve;
103        }
104
105        void Mail() { mMailbox = sMailId; }
106        bool Mailed() const { return mMailbox == sMailId; }
107
108        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
109        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
110
111        int IncMail() { return ++ mMailbox - sMailId; }
112
113
114        // last mail id -> warning not thread safe!
115        // both mailId and mailbox should be unique for each thread!!!
116        static int sMailId;
117        static int sReservedMailboxes;
118
119        void *mEvaluationHack;
120protected:
121
122        /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
123        int mSplitAxis;
124        /// the number of misses of max cost ratio until this split
125        int mMaxCostMisses;
126        /// render cost decrease achieved through this split
127        float mRenderCostDecrease;
128        /// the decrease of the number of pvs entries
129        int mPvsEntriesIncr;
130
131        int mMailbox;
132};
133
134
135}
136
137// SUBDIVISIONCANDIDATE_H
138#endif
Note: See TracBrowser for help on using the repository browser.