source: GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h @ 1996

Revision 1996, 2.5 KB checked in by mattausch, 17 years ago (diff)
Line 
1#ifndef _RayCaster_H__
2#define _RayCaster_H__
3
4#include "Containers.h"
5#include <string>
6#include "Vector3.h"
7
8using namespace std;
9
10
11namespace GtpVisibilityPreprocessor {
12
13
14class Intersectable;
15class VssRay;
16class SimpleRayContainer;
17class AxisAlignedBox3;
18//class Vector3;
19struct VssRayContainer;
20class Preprocessor;
21struct SimpleRay;
22
23
24/** This class provides an interface for ray casting.
25*/
26class RayCaster
27{
28
29public:
30       
31        enum {
32          INTERNAL_RAYCASTER = 0,
33          INTEL_RAYCASTER
34        };
35
36        RayCaster(const Preprocessor &preprocessor);
37
38        virtual ~RayCaster();
39
40        virtual int Type() const = 0;
41
42        /** Wrapper for casting single ray.
43                @returns ray or NULL if invalid
44        */
45        VssRay *CastRay(const SimpleRay &simpleRay,
46                                        const AxisAlignedBox3 &box,
47                                        const bool castDoubleRay);
48
49        virtual int CastRay(const SimpleRay &simpleRay,
50                                                VssRayContainer &vssRays,
51                                                const AxisAlignedBox3 &box,
52                                                const bool castDoubleRay,
53                                                const bool pruneInvalidRays = true) = 0;
54
55        virtual void CastRays16(
56                                                         SimpleRayContainer &rays,
57                                                         VssRayContainer &vssRays,
58                                                         const AxisAlignedBox3 &sbox,
59                                                         const bool castDoubleRay,
60                                                         const bool pruneInvalidRays = true) = 0;
61
62
63  virtual void
64  SortRays(SimpleRayContainer &rays);
65
66       
67
68protected:
69  void _SortRays(SimpleRayContainer &rays,
70                                 const int l,
71                                 const int r,
72                                 const int depth,
73                                 float box[12]);
74       
75  struct Intersection
76        {
77                Intersection(): mObject(NULL), mFaceId(0)
78                {}
79
80                Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
81                        mPoint(p), mNormal(n), mObject(o), mFaceId(f)
82                {}
83
84                Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0)
85                {}
86                Vector3 mPoint;
87                Vector3 mNormal;
88                Intersectable *mObject;
89                int mFaceId;
90        };
91
92
93        int ProcessRay(const SimpleRay &ray,
94                                   Intersection &hitA,
95                                   Intersection &hitB,
96                                   VssRayContainer &vssRays,
97                                   const AxisAlignedBox3 &box,
98                                   const bool castDoubleRay,
99                                   const bool pruneInvalidRays = true);
100
101        /** Checks if ray is valid.
102                I.e., the ray is in valid view space.
103                @note: clamps the ray to valid view space.
104        */
105        bool ValidateRay(const Vector3 &origin,
106                                         const Vector3 &direction,
107                                 const AxisAlignedBox3 &box,
108                                         Intersection &hit);
109
110        bool
111                ClipToViewSpaceBox(const Vector3 &origin,
112                                                   const Vector3 &termination,
113                                                   Vector3 &clippedOrigin,
114                                                   Vector3 &clippedTermination);
115       
116        const Preprocessor &mPreprocessor;
117};
118
119
120}
121
122#endif
Note: See TracBrowser for help on using the repository browser.