source: GTP/trunk/Lib/Vis/Preprocessing/src/MutualVisibility.h @ 860

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