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

Revision 1990, 2.6 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 keepOrigin);
48
49        virtual int CastRay(const SimpleRay &simpleRay,
50                                                VssRayContainer &vssRays,
51                                                const AxisAlignedBox3 &box,
52                                                const bool castDoubleRay,
53                                                const bool pruneInvalidRays = true,
54                                                const bool keepOrigin = false
55                                                ) = 0;
56
57        virtual void CastRays16(
58                                                         SimpleRayContainer &rays,
59                                                         VssRayContainer &vssRays,
60                                                         const AxisAlignedBox3 &sbox,
61                                                         const bool castDoubleRay,
62                                                         const bool pruneInvalidRays = true,
63                                                         const bool keepOrigin = false
64                                                         ) = 0;
65
66
67  virtual void
68  SortRays(SimpleRayContainer &rays);
69
70       
71
72protected:
73  void _SortRays(SimpleRayContainer &rays,
74                                 const int l,
75                                 const int r,
76                                 const int depth,
77                                 float box[12]);
78       
79  struct Intersection
80        {
81                Intersection(): mObject(NULL), mFaceId(0)
82                {}
83
84                Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
85                        mPoint(p), mNormal(n), mObject(o), mFaceId(f)
86                {}
87
88                Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0)
89                {}
90                Vector3 mPoint;
91                Vector3 mNormal;
92                Intersectable *mObject;
93                int mFaceId;
94        };
95
96
97        int ProcessRay(const SimpleRay &ray,
98                                   Intersection &hitA,
99                                   Intersection &hitB,
100                                   VssRayContainer &vssRays,
101                                   const AxisAlignedBox3 &box,
102                                   const bool castDoubleRay,
103                                   const bool pruneInvalidRays = true,
104                                   const bool keepOrigin = false);
105
106        /** Checks if ray is valid.
107                I.e., the ray is in valid view space.
108                @note: clamps the ray to valid view space.
109        */
110        bool ValidateRay(const Vector3 &origin,
111                                         const Vector3 &direction,
112                                 const AxisAlignedBox3 &box,
113                                         Intersection &hit);
114
115        bool
116                ClipToViewSpaceBox(const Vector3 &origin,
117                                                   const Vector3 &termination,
118                                                   Vector3 &clippedOrigin,
119                                                   Vector3 &clippedTermination);
120       
121        const Preprocessor &mPreprocessor;
122};
123
124
125}
126
127#endif
Note: See TracBrowser for help on using the repository browser.