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

Revision 1528, 2.1 KB checked in by mattausch, 18 years ago (diff)

worked on gvs

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        */
44        VssRay *CastSingleRay(
45                const SimpleRay &simpleRay,
46            const AxisAlignedBox3 &box
47                );
48
49        virtual int CastRay(
50                const SimpleRay &simpleRay,
51        VssRayContainer &vssRays,
52                const AxisAlignedBox3 &box,
53                const bool castDoubleRay,
54                const bool pruneInvalidRays = true
55                ) = 0;
56
57         virtual void CastRays16(
58                 const int i,
59                 SimpleRayContainer &rays,
60                 VssRayContainer &vssRays,
61                 const AxisAlignedBox3 &sbox,
62                 const bool castDoubleRay,
63                 const bool pruneInvalidRays = true
64                 ) = 0;
65       
66
67protected:
68        struct Intersection
69        {
70                Intersection(): mObject(NULL), mFaceId(0)
71                {}
72
73                Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
74                mPoint(p), mNormal(n), mObject(o), mFaceId(f)
75                {}
76
77                Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0)
78                {}
79                Vector3 mPoint;
80                Vector3 mNormal;
81                Intersectable *mObject;
82                int mFaceId;
83        };
84
85        int ProcessRay(
86                         const SimpleRay &ray,
87                         Intersection &hitA,
88                         Intersection &hitB,
89                         VssRayContainer &vssRays,
90                         const AxisAlignedBox3 &box,
91                         const bool castDoubleRay,
92                         const bool pruneInvalidRays = true
93                         );
94
95        /** Checks if ray is valid.
96                I.e., the ray is in valid view space.
97                @note: clamps the ray to valid view space.
98        */
99        bool ValidateRay(const Vector3 &origin,
100                                         const Vector3 &direction,
101                                 const AxisAlignedBox3 &box,
102                                         Intersection &hit);
103       
104        const Preprocessor &mPreprocessor;
105};
106
107
108}
109
110#endif
Note: See TracBrowser for help on using the repository browser.