source: GTP/trunk/Lib/Vis/Preprocessing/src/PvsBase.h @ 2176

Revision 2176, 2.9 KB checked in by mattausch, 18 years ago (diff)

removed using namespace std from .h

Line 
1#ifndef __PVSBASE_H
2#define __PVSBASE_H
3
4#include "common.h"
5#include "Containers.h"
6
7//
8
9namespace GtpVisibilityPreprocessor {
10
11//class Intersectable;
12
13/** Information stored with a PVS entry. Consists of the number
14        the object was seen from the view cell.
15*/
16template<typename T, typename S>
17struct PvsEntry
18{
19public:
20
21        PvsEntry(): mObject(NULL), mData(0) {}
22        PvsEntry(T sample): mObject(sample), mData(0) {}
23        PvsEntry(T sample, const S &data): mObject(sample), mData(data) {}
24
25        T mObject;
26        S mData;
27
28        template<typename T, typename S>
29        friend int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b);
30        template<typename T, typename S>
31        friend int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b);
32};
33
34
35template<typename T, typename S>
36int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b)
37{
38        return a.mObject < b.mObject;
39}
40
41template<typename T, typename S>
42int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b)
43{
44        return a.mObject == b.mObject;
45}
46
47
48template<typename T, typename S>
49struct LtSample
50{
51    bool operator()(const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) const
52    {
53                return a.mObject < b.mObject;
54        }
55};
56
57template<typename T, typename S>
58int equalSample (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b)
59{
60        return a.mObject == b.mObject;
61}
62
63/** Information stored with a PVS entry. Consists of the number
64        the object was seen from the view cell.
65*/
66struct PvsData
67{
68public:
69        PvsData() {}
70        PvsData(const float sumPdf):
71        mSumPdf(sumPdf) {}
72       
73        // $$JB in order to return meaningfull values
74        // it assumes that the sum pdf has been normalized somehow!!!
75        inline float GetVisibility()
76        {
77                return mSumPdf;
78        }
79
80        /// sum of probability density of visible sample rays
81        float mSumPdf;
82};
83
84
85class MailablePvsData
86{
87public:
88        // sum of probability density of visible sample rays
89        float mSumPdf;
90        int mCounter;
91
92        MailablePvsData() {}
93        MailablePvsData(const float sumPdf):
94        mSumPdf(sumPdf) {}
95
96        // $$JB in order to return meaningfull values
97        // it assumes that the sum pdf has been normalized somehow!!!
98        float GetVisibility()
99        {
100                return mSumPdf;
101        }
102
103        ///////////////
104        //  Mailing stuff
105
106        // last mail id -> warning not thread safe!
107        // both mailId and mailbox should be unique for each thread!!!
108        static int sMailId;
109        static int sReservedMailboxes;
110
111        static void NewMail(const int reserve = 1)
112        {
113                sMailId += sReservedMailboxes;
114                sReservedMailboxes = reserve;
115        }
116
117        void Mail() { mMailbox = sMailId; }
118        bool Mailed() const { return mMailbox == sMailId; }
119
120        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
121        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
122
123        int IncMail() { return ++ mMailbox - sMailId; }
124       
125        //////////////////////////////////////////
126
127protected:
128
129        int mMailbox;
130
131};
132
133}
134
135#endif
Note: See TracBrowser for help on using the repository browser.