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

Revision 501, 3.7 KB checked in by mattausch, 19 years ago (diff)
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
[501]89  MutualVisibilitySampler(
90                                                  SceneGraph *sceneGraph,
91                                                  KdTree *kdTree,
92                                                  const AxisAlignedBox3 &source,
93                                                  const AxisAlignedBox3 &target,
94                                                  const float solidAngleThreshold
95                                                  );
[191]96  int
97  ComputeVisibility();
98
99  void
[501]100  ConstructInitialSamples(const AxisAlignedBox3 &source,
101                                                  const AxisAlignedBox3 &target,
102                                                  vector<RayShaft *> &samples
103                                                  );
[359]104       
[191]105  void
[245]106  ConstructInitialSamples2(
[501]107                                                   const AxisAlignedBox3 &source,
108                                                   const AxisAlignedBox3 &target,
109                                                   vector<RayShaft *> &samples
110                                                   );
[359]111       
[245]112  void
113  ConstructInitialSamples3(
[501]114                                                   const AxisAlignedBox3 &source,
115                                                   const AxisAlignedBox3 &target,
116                                                   vector<RayShaft *> &samples
117                                                   );
[359]118       
[245]119  void
[191]120  AddInitialSamples(
[501]121                                        const Rectangle3 &sourceRect,
122                                        const Rectangle3 &targetRect,
123                                        vector<RayShaft *> &samples
124                                        );
[359]125       
[245]126  void
127  AddInitialSamples2(
[501]128                                         const Rectangle3 &sourceRect,
129                                         const Rectangle3 &targetRect,
130                                         vector<RayShaft *> &samples
131                                         );
[359]132       
[191]133  // the split sample method contains a methodology to create new samples
134  // or terminate the sampling
135  bool
136  SplitSample(
[501]137                        const RayShaft &source,
138                        RayShaft &sample1,
139                        RayShaft &sample2
140                        );
[191]141  void
142  PerformSplit(
[501]143                                const RayShaft &sample,
144                                const bool splitSource,
145                                const int axis,
146                                RayShaft &sample1,
147                                RayShaft &sample2
148                                 );
[191]149 
[359]150       
[191]151  bool
152  SampleTerminationCriteriaMet(
[501]153                                                                 const RayShaft &sample);
[191]154 
155  float
[209]156  GetSpatialAngle(const RayShaft &sample,
[501]157                                  const Vector3 &point
158                                 );
[359]159       
[223]160  int
161  CastRays(RayShaft &shaft);
[359]162       
[191]163  void
[209]164  ComputeError(RayShaft &sample);
[223]165 
[209]166  void
[245]167  ExportShafts(vector<RayShaft *> &samples, const bool singleFile);
[191]168
[209]169
[191]170};
171 
172int
[245]173ComputeBoxVisibility(SceneGraph *sceneGraph,
174                     KdTree *kdTree,
[359]175                     const AxisAlignedBox3 &source,
176                     const AxisAlignedBox3 &target,
177                     const float solidAngleThreshold);
[191]178
179
180
181
182
183
184#endif
Note: See TracBrowser for help on using the repository browser.