[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 | |
---|
| 9 | namespace GtpVisibility { |
---|
[316] | 10 | |
---|
[145] | 11 | /** Class storing visibility information. |
---|
[71] | 12 | */ |
---|
[316] | 13 | template<typename T>
|
---|
| 14 | class VisibilityInfo
|
---|
[71] | 15 | { |
---|
| 16 | public: |
---|
[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] | 53 | protected: |
---|
[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 | //-----------------------------------------------------------------------
|
---|
| 65 | template <typename T>
|
---|
| 66 | T VisibilityInfo<T>::GetSource() const
|
---|
| 67 | {
|
---|
| 68 | return mSource;
|
---|
| 69 | } |
---|
[143] | 70 | |
---|
[316] | 71 | //-----------------------------------------------------------------------
|
---|
| 72 | template <typename T>
|
---|
| 73 | void VisibilityInfo<T>::SetSource(T source)
|
---|
| 74 | {
|
---|
| 75 | return mSource;
|
---|
| 76 | } |
---|
| 77 |
|
---|
| 78 | //-----------------------------------------------------------------------
|
---|
| 79 | template <typename T> |
---|
| 80 | VisibilityInfo<T>::VisibilityInfo(T source, const int visiblePixels, const int projectedPixels): |
---|
| 81 | mSource(source), mProjectedPixels(projectedPixels), mVisiblePixels(visiblePixels) |
---|
| 82 | {
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | //-----------------------------------------------------------------------
|
---|
| 86 | template <typename T>
|
---|
| 87 | int VisibilityInfo<T>::GetVisiblePixels() const |
---|
| 88 | { |
---|
| 89 | return mVisiblePixels; |
---|
| 90 | } |
---|
| 91 | //-----------------------------------------------------------------------
|
---|
| 92 | template <typename T> |
---|
| 93 | int VisibilityInfo<T>::GetProjectedPixels() const |
---|
| 94 | { |
---|
| 95 | return mProjectedPixels; |
---|
| 96 | } |
---|
| 97 | //-----------------------------------------------------------------------
|
---|
| 98 | template <typename T> |
---|
| 99 | void VisibilityInfo<T>::SetVisiblePixels(int vis) |
---|
| 100 | { |
---|
| 101 | mVisiblePixels = vis; |
---|
| 102 | } |
---|
| 103 | //-----------------------------------------------------------------------
|
---|
| 104 | template <typename T> |
---|
| 105 | void VisibilityInfo<T>::SetProjectedPixels(int vis) |
---|
| 106 | { |
---|
| 107 | mProjectedPixels = vis; |
---|
| 108 | } |
---|
| 109 | //-----------------------------------------------------------------------
|
---|
| 110 | template <typename T> |
---|
| 111 | float VisibilityInfo<T>::ComputeRelativeVisibility() |
---|
| 112 | { |
---|
| 113 | if (!mProjectedPixels) |
---|
| 114 | return 0; |
---|
[141] | 115 | |
---|
[316] | 116 | return (float)mVisiblePixels / (float)mProjectedPixels; |
---|
| 117 | } |
---|
| 118 | //-----------------------------------------------------------------------
|
---|
| 119 | template <typename T> |
---|
| 120 | void VisibilityInfo<T>::AddVisibility(const VisibilityInfo<T> &info) |
---|
[71] | 121 | { |
---|
[316] | 122 | mVisiblePixels += info.GetVisiblePixels(); |
---|
| 123 | mProjectedPixels += info.GetProjectedPixels(); |
---|
| 124 | } |
---|
[65] | 125 | |
---|
[316] | 126 | //-----------------------------------------------------------------------
|
---|
| 127 | template <typename T> |
---|
| 128 | void VisibilityInfo<T>::AddVisibility(const int visiblePixels, const int projectedPixels) |
---|
[159] | 129 | { |
---|
[316] | 130 | mVisiblePixels += visiblePixels; |
---|
| 131 | mProjectedPixels += projectedPixels; |
---|
| 132 | } |
---|
[159] | 133 | |
---|
[316] | 134 | template<class T>
|
---|
| 135 | struct InfoContainer
|
---|
| 136 | {
|
---|
| 137 | typedef std::vector<VisibilityInfo<T> > Type;
|
---|
| 138 | };
|
---|
| 139 |
|
---|
[65] | 140 | |
---|
[316] | 141 | } // namespace GtpVisibility
|
---|
[65] | 142 | |
---|
| 143 | #endif |
---|