source: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/VisibilityInfo.h @ 2280

Revision 2280, 3.4 KB checked in by mattausch, 18 years ago (diff)

removed dependency on ogre in gtpvisibility

RevLine 
[65]1#ifndef _VisibilityInfo_H__
2#define _VisibilityInfo_H__
3
4#include <vector>
5
[2280]6//#include "VisibilityMesh.h"
[65]7#include "HierarchyInterface.h"
8
9namespace GtpVisibility {
[316]10 
[145]11/** Class storing visibility information.
[71]12*/
[316]13template<typename T>
14class VisibilityInfo
[71]15{
16public:
[316]17        VisibilityInfo(T source, const int visiblePixels, const int projectedPixels);
[65]18
[316]19        /** set source of the info.
20        */
21        void SetSource(T source);
22        /** get source of the info.
23        */
24        T GetSource() const;
25
[145]26        int GetVisiblePixels() const;
27        int GetProjectedPixels() const;
[130]28
[145]29        void SetVisiblePixels(int vis);
30        void SetProjectedPixels(int vis);
31       
[318]32        /** Computes ratio of visible to projected pixels.
33        */
[145]34        float ComputeRelativeVisibility();
[143]35
[145]36        /** Adds visibility to current visibility information.
37        */
[316]38        void AddVisibility(const VisibilityInfo<T> &info);
[150]39        /** Adds visibility to current visibility information.
40        */
[316]41        void AddVisibility(const int visiblePixels, const int projectedPixels);
[143]42
[318]43        bool operator<(const VisibilityInfo<T> &b) const
44        {
45                return mSource < b.mSource;
46        }
47
48        bool operator==(const VisibilityInfo<T> &b) const
49        {
50                return mSource == b.mSource;
51        }
52
[145]53protected:
[150]54        /** number of visible pixels.
55        */
[145]56    int mVisiblePixels;
[150]57        /** number of projected pixels
58        */
[316]59        int mProjectedPixels;
60
61        T mSource;
[145]62};
63
[316]64//-----------------------------------------------------------------------
65template <typename T>
66T VisibilityInfo<T>::GetSource() const
67{
68        return mSource;
69}
[143]70
[316]71//-----------------------------------------------------------------------
72template <typename T>
73void VisibilityInfo<T>::SetSource(T source)
74{
75        return mSource;
76}
77
78//-----------------------------------------------------------------------
79template <typename T>
80VisibilityInfo<T>::VisibilityInfo(T source, const int visiblePixels, const int projectedPixels):
81mSource(source), mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels)
82{
83}
84
85//-----------------------------------------------------------------------
86template <typename T>
87int VisibilityInfo<T>::GetVisiblePixels() const
88{
89        return mVisiblePixels;
90}
91//-----------------------------------------------------------------------
92template <typename T>
93int VisibilityInfo<T>::GetProjectedPixels() const
94{
95        return mProjectedPixels;
96}
97//-----------------------------------------------------------------------
98template <typename T>
99void VisibilityInfo<T>::SetVisiblePixels(int vis)
100{
101        mVisiblePixels = vis;
102}
103//-----------------------------------------------------------------------
104template <typename T>
105void VisibilityInfo<T>::SetProjectedPixels(int vis)
106{
107        mProjectedPixels = vis;
108}
109//-----------------------------------------------------------------------
110template <typename T>
111float VisibilityInfo<T>::ComputeRelativeVisibility()
112{
113        if (!mProjectedPixels)
114                return 0;
[141]115
[316]116        return (float)mVisiblePixels / (float)mProjectedPixels;
117}
118//-----------------------------------------------------------------------
119template <typename T>
120void VisibilityInfo<T>::AddVisibility(const VisibilityInfo<T> &info)
[71]121{
[316]122        mVisiblePixels += info.GetVisiblePixels();
123        mProjectedPixels += info.GetProjectedPixels();
124}
[65]125
[316]126//-----------------------------------------------------------------------
127template <typename T>
128void VisibilityInfo<T>::AddVisibility(const int visiblePixels, const int projectedPixels)
[159]129{
[316]130        mVisiblePixels += visiblePixels;
131        mProjectedPixels += projectedPixels;
132}
[159]133
[316]134template<class T>
135struct InfoContainer
136{
137        typedef std::vector<VisibilityInfo<T> > Type;
138};
139
[65]140
[316]141} // namespace GtpVisibility
[65]142
143#endif
Note: See TracBrowser for help on using the repository browser.