source: trunk/VUT/GtpVisibilityPreprocessor/src/MutualVisibility.h @ 359

Revision 359, 3.9 KB checked in by bittner, 19 years ago (diff)

gnomi compilation

RevLine 
[191]1#ifndef __MUTUAL_VISIBILITY_H
2#define __MUTUAL_VISIBILITY_H
3
4#include "Vector3.h"
5#include "Ray.h"
6
7class Intersectable;
8class AxisAlignedBox3;
[245]9class SceneGraph;
[191]10
11
[223]12struct RaySample {
13  /// true if the sample really intersects both boxes
14  float mMinT;
15  float mMaxT;
[245]16
17  RaySample():mMinT(-1.0f), mMaxT(-1.0f) {}
[223]18  /// intersections of the sample with the scene
19  vector<Ray::Intersection> mIntersections;
[245]20  void SetInvalid() {
21    mMinT = 0.0f;
22    mMaxT = -1.0f;
23  }
24  bool IsValid() const { return mMaxT > 0.0f; }
25  bool IsProcessed() const { return mMinT != mMaxT; }
[223]26};
[191]27
[209]28struct RayShaft {
[191]29public:
30  /// evaluted sampling error
31  float mError;
32  /// depth in recursion
33  int mDepth;
34  /// The source triangle
[209]35  Rectangle3 mSource;
[191]36  /// The target triangle
[209]37  Rectangle3 mTarget;
[191]38 
[223]39  RaySample mSamples[4];
[191]40 
41  void ComputeError();
42 
[245]43  RayShaft() {}
[191]44 
[209]45  RayShaft (
46            const Rectangle3 &source,
47            const Rectangle3 &target)
[191]48  {
49    Init(source, target);
50  }
[245]51
52  bool IsValid() const { return
53                           mSamples[0].IsValid() &&
54                           mSamples[1].IsValid() &&
55                           mSamples[2].IsValid() &&
56                           mSamples[3].IsValid();
57  }
58
[191]59  // initial triangle sample
60  void Init(
[209]61            const Rectangle3 &source,
62            const Rectangle3 &target);
[191]63 
64  Vector3
65  GetIntersectionPoint(const int rayIndex,
66                       const int depth) const;
[209]67 
[191]68  void GetRay(const int rayIndex,
69              Vector3 &origin,
70              Vector3 &direction) const;
[245]71
72  void
73  GetRaySegment(const int i, Ray &ray) const;
74
[191]75};
76
77enum { VISIBLE, INVISIBLE };
78
79 
80class MutualVisibilitySampler {
81public:
[245]82  SceneGraph *mSceneGraph;
[191]83  KdTree *mKdTree;
84  AxisAlignedBox3 mSource;
85  AxisAlignedBox3 mTarget;
86  float mSolidAngleThreshold;
[245]87  bool mUseBoxes;
[191]88
[245]89  MutualVisibilitySampler(SceneGraph *sceneGraph,
[359]90                                                                                                        KdTree *kdTree,
91                                                                                                        const AxisAlignedBox3 &source,
92                                                                                                        const AxisAlignedBox3 &target,
93                                                                                                        const float solidAngleThreshold);
[191]94  int
95  ComputeVisibility();
96
97  void
98  ConstructInitialSamples(
[359]99                                                                                                        const AxisAlignedBox3 &source,
100                                                                                                        const AxisAlignedBox3 &target,
101                                                                                                        vector<RayShaft *> &samples
102                                                                                                        );
103       
[191]104  void
[245]105  ConstructInitialSamples2(
[359]106                                                                                                         const AxisAlignedBox3 &source,
107                                                                                                         const AxisAlignedBox3 &target,
108                                                                                                         vector<RayShaft *> &samples
109                                                                                                         );
110       
[245]111  void
112  ConstructInitialSamples3(
[359]113                                                                                                         const AxisAlignedBox3 &source,
114                                                                                                         const AxisAlignedBox3 &target,
115                                                                                                         vector<RayShaft *> &samples
116                                                                                                         );
117       
[245]118  void
[191]119  AddInitialSamples(
[359]120                                                                                const Rectangle3 &sourceRect,
121                                                                                const Rectangle3 &targetRect,
122                                                                                vector<RayShaft *> &samples
123                                                                                );
124       
[245]125  void
126  AddInitialSamples2(
[359]127                                                                                 const Rectangle3 &sourceRect,
128                                                                                 const Rectangle3 &targetRect,
129                                                                                 vector<RayShaft *> &samples
130                                                                                 );
131       
[191]132  // the split sample method contains a methodology to create new samples
133  // or terminate the sampling
134  bool
135  SplitSample(
[359]136                                                        const RayShaft &source,
137                                                        RayShaft &sample1,
138                                                        RayShaft &sample2
139                                                        );
[191]140  void
141  PerformSplit(
[359]142                                                         const RayShaft &sample,
143                                                         const bool splitSource,
144                                                         const int axis,
145                                                         RayShaft &sample1,
146                                                         RayShaft &sample2
147                                                         );
[191]148 
[359]149       
[191]150  bool
151  SampleTerminationCriteriaMet(
[359]152                                                                                                                         const RayShaft &sample);
[191]153 
154  float
[209]155  GetSpatialAngle(const RayShaft &sample,
[359]156                                                                        const Vector3 &point
157                                                                        );
158       
[223]159  int
160  CastRays(RayShaft &shaft);
[359]161       
[191]162  void
[209]163  ComputeError(RayShaft &sample);
[223]164 
[209]165  void
[245]166  ExportShafts(vector<RayShaft *> &samples, const bool singleFile);
[191]167
[209]168
[191]169};
170 
171int
[245]172ComputeBoxVisibility(SceneGraph *sceneGraph,
173                     KdTree *kdTree,
[359]174                     const AxisAlignedBox3 &source,
175                     const AxisAlignedBox3 &target,
176                     const float solidAngleThreshold);
[191]177
178
179
180
181
182
183#endif
Note: See TracBrowser for help on using the repository browser.