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

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

implemented several accelleration svhemes for the gradient method

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), mDirty(true) {};
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        inline bool IsDirty() const
96        {
97                return mDirty;
98        }
99
100        //////////
101        //-- mailing stuff
102
103        static void NewMail(const int reserve = 1)
104        {
105                sMailId += sReservedMailboxes;
106                sReservedMailboxes = reserve;
107        }
108
109        void Mail() { mMailbox = sMailId; }
110        bool Mailed() const { return mMailbox == sMailId; }
111
112        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
113        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
114
115        int IncMail() { return ++ mMailbox - sMailId; }
116
117
118        // last mail id -> warning not thread safe!
119        // both mailId and mailbox should be unique for each thread!!!
120        static int sMailId;
121        static int sReservedMailboxes;
122
123        void *mEvaluationHack;
124protected:
125
126        /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
127        int mSplitAxis;
128        /// the number of misses of max cost ratio until this split
129        int mMaxCostMisses;
130        /// render cost decrease achieved through this split
131        float mRenderCostDecrease;
132        /// the decrease of the number of pvs entries
133        int mPvsEntriesIncr;
134
135        int mMailbox;
136
137        bool mDirty;
138};
139
140
141}
142
143// SUBDIVISIONCANDIDATE_H
144#endif
Note: See TracBrowser for help on using the repository browser.