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

Revision 863, 2.7 KB checked in by mattausch, 19 years ago (diff)

working on preprocessor integration
added iv stuff

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