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

Revision 2176, 2.7 KB checked in by mattausch, 17 years ago (diff)

removed using namespace std from .h

  • Property svn:executable set to *
Line 
1#ifndef __BEAM_H
2#define __BEAM_H
3
4#include <vector>
5#include "AxisAlignedBox3.h"
6#include "Statistics.h"
7
8
9namespace GtpVisibilityPreprocessor {
10
11class KdNode;
12class Intersectable;
13class Mesh;
14
15
16// the values need for rss tree update computed already inside the glrendererbuffer
17// not all of them need to be computed
18class BeamSampleStatistics: public StatisticsBase
19{
20public:
21        enum {COMPUTE_PVS_SIZE, COMPUTE_RAY_CONTRIBUTIONS, COMPUTE_PVS_ENTROPY};
22        int flags;
23
24        BeamSampleStatistics(): flags(COMPUTE_RAY_CONTRIBUTIONS)
25        {
26                Reset();
27        }
28       
29        float pvsSize;
30        float rays;
31        float rayContributions;
32        float pvsEntropy;
33        float rayLengthEntropy;
34        float importance;
35       
36        float weightedRayContribution;
37
38        void Reset()
39        {
40                pvsSize = 0;
41                rays = 0;
42                rayContributions = 0;
43                pvsEntropy = 0;
44                rayLengthEntropy = 0;
45                importance = 0;
46        }
47
48        void Print(std::ostream &app) const;
49
50        friend std::ostream &operator<<(std::ostream &s, const BeamSampleStatistics &stat)
51        {
52                stat.Print(s);
53                return s;
54        } 
55};
56
57 
58class Beam {
59 
60public:                 
61  enum {STORE_KD_NODES=1, STORE_OBJECTS=2, STORE_VIEW_CELLS, VALID=8};
62  int mFlags;
63 
64  // list of nodes intersected by the frustum
65  vector<KdNode *> mKdNodes;
66  // list of objects intersected by the frustum
67  ObjectContainer mObjects;
68  // view cells intersected by frustum
69  ViewCellContainer mViewCells;
70
71  // spatial box
72  AxisAlignedBox3 mBox;
73  // directional box (it is actually a 2D box - only x and y ranges are valid)
74  // directional parametrization according to VssRay::GetDirParametrization
75  AxisAlignedBox3 mDirBox;
76
77  vector<Plane3> mPlanes;
78
79  Mesh *mMesh;
80   
81  /** Constructs a beam from a spatial and a directional box.
82  */
83  void Construct(const AxisAlignedBox3 &box,
84                             const AxisAlignedBox3 &dBox);
85 
86  /** Computes parameters for glFrustum.
87  */
88  void ComputePerspectiveFrustum(float &left, float &right,
89                                                                 float &bottom, float &top,
90                                                                 float &near, float &far,
91                                                                 const AxisAlignedBox3 &sceneBBox) const;
92
93  /** Computes parameters for glOrtho.
94  */
95  void ComputeOrthoFrustum(float &left, float &right,
96                                                   float &bottom, float &top,
97                                                   float &near, float &far,
98                                                   const AxisAlignedBox3 &sceneBBox) const;
99
100  int ComputeIntersection(const AxisAlignedBox3 &box);
101
102  Vector3 GetMainDirection() const;
103
104  bool IsValid() { return mFlags & VALID; }
105  bool SetValid() { return mFlags |= VALID; }
106
107  Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0), mViewCells(0), mMesh(NULL)
108  {
109  }
110
111  ~Beam();
112
113  /** Creates beam mesh bounded at zfar.
114  */
115  void CreateMesh(const float zfar);
116};
117
118}
119
120#endif
Note: See TracBrowser for help on using the repository browser.