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

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