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

Revision 2543, 4.3 KB checked in by mattausch, 17 years ago (diff)
RevLine 
[1239]1#ifndef SUBDIVISIONCANDIDATE_H
2#define SUBDIVISIONCANDIDATE_H
[1237]3
[1239]4
[1237]5#include "FlexibleHeap.h"
6
[2176]7//
[1237]8
9namespace GtpVisibilityPreprocessor {
10
[1633]11class SubdivisionCandidate;
12
[2176]13typedef std::vector<SubdivisionCandidate *> SubdivisionCandidateContainer;
[1633]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
[1895]24        SubdivisionCandidate():
25                mRenderCostDecrease(0),
26                mAvgRayContribution(0),
27                mDirty(true)
28                {}
[1237]29
[1305]30        virtual ~SubdivisionCandidate() {};
[1667]31        /** Evaluate this subdivision candidate.
32        */
33        virtual void EvalCandidate(bool computeSplitplane = true) = 0;
34        /** Returns type of this subdivision candidate.
35        */
[1237]36        virtual int Type() const = 0;
[1667]37        /** Evaluate this candidate and put results into queue for further traversal.
38        */
[2227]39        virtual bool Apply(SplitQueue &splitQueue,
40                                           bool terminationCriteriaMet,
41                                           SubdivisionCandidateContainer &dirtyList) = 0;
[1667]42        /** Returns true of the global termination criteria of this split were met,
43                false otherwise.
44        */
[1237]45        virtual bool GlobalTerminationCriteriaMet() const = 0;
[1684]46        /** Collects subdivision candidates that were affected by the
[1667]47                application of this one.
48        */
[1633]49        virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
50                                                                                const bool onlyUnmailed) = 0;
[1237]51        /** Set render cost decrease achieved through this split.
52        */
[1473]53        inline void SetRenderCostDecrease(const float renderCostDecr)
[1237]54        {
55                mRenderCostDecrease = renderCostDecr;
56        }
[1473]57        inline float GetRenderCostDecrease() const
[1237]58        {
59                return mRenderCostDecrease;
60        }
[1895]61        /** The average ray contribution of this candidate .
62                This is somewhat of a confidence value into the computed values. If
63                it is high, there is likely to be a lot of undersampling.
64        */
65        inline void SetAvgRayContribution(const float rayContri)
66        {
67                mAvgRayContribution = rayContri;
68        }
[2227]69        /** The average ray contribution of this candidate .
70                This is somewhat of a confidence value into the computed values. If
71                it is high, there is likely to be a lot of undersampling.
72        */
73        inline void SetAvgRaysPerObject(const float raysPerObject)
74        {
75                mAvgRaysPerObject = raysPerObject;
76
77        }
[1895]78        inline float GetAvgRayContribution() const
79        {
80                return mAvgRayContribution;
81        }
[2227]82        /** Returns average rays per object.
83        */
84        float GetAvgRaysPerObject() const
85        {
86                return (float)mAvgRaysPerObject;
87        }
[1297]88        /** Position in queue.
89        */
[1576]90        inline int GetPosition() const
[1297]91        {
92                return mPosition;
93        }
[2543]94       
[1576]95        inline void SetSplitAxis(const int splitAxis)
96        {
97                mSplitAxis = splitAxis;
98        }
[1667]99       
[1576]100        inline void SetMaxCostMisses(const int misses)
101        {
102                mMaxCostMisses = misses;
103        }
[1667]104
[1576]105        inline void SetPvsEntriesIncr(const int pvsEntriesIncr)
106        {
107                mPvsEntriesIncr = pvsEntriesIncr;
108        }
109
110        inline int GetSplitAxis() const
111        {
112                return mSplitAxis;
113        }
[1667]114
[1576]115        inline int GetMaxCostMisses() const
116        {
117                return mMaxCostMisses;
118        }
[1667]119
[1576]120        inline int GetPvsEntriesIncr() const
121        {
122                return mPvsEntriesIncr;
123        }
124
[1727]125        inline bool IsDirty() const
126        {
127                return mDirty;
128        }
[1667]129
[1733]130        inline void SetDirty(const bool dirty)
131        {
132                mDirty = dirty;
133        }
134
[2543]135
[1633]136        //////////
137        //-- mailing stuff
138
139        static void NewMail(const int reserve = 1)
140        {
141                sMailId += sReservedMailboxes;
142                sReservedMailboxes = reserve;
143        }
144
145        void Mail() { mMailbox = sMailId; }
146        bool Mailed() const { return mMailbox == sMailId; }
147
148        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
149        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
150
151        int IncMail() { return ++ mMailbox - sMailId; }
152
153        // last mail id -> warning not thread safe!
154        static int sMailId;
155        static int sReservedMailboxes;
156
[2543]157        // note: both mailId and mailbox should be unique for each thread!!!
[1733]158
[2543]159
[1576]160protected:
161
[1473]162        /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
163        int mSplitAxis;
164        /// the number of misses of max cost ratio until this split
165        int mMaxCostMisses;
[1237]166        /// render cost decrease achieved through this split
167        float mRenderCostDecrease;
[1576]168        /// the decrease of the number of pvs entries
169        int mPvsEntriesIncr;
[1633]170
[1895]171        /// the average ray contribution of this candidate
172        float mAvgRayContribution;
173
[2227]174        /// the average ray contribution of this candidate
175        float mAvgRaysPerObject;
176
[1633]177        int mMailbox;
[1695]178
179        bool mDirty;
[1237]180};
181
[1313]182
[1237]183}
184
[1633]185// SUBDIVISIONCANDIDATE_H
[1237]186#endif
Note: See TracBrowser for help on using the repository browser.