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

Revision 1974, 2.5 KB checked in by bittner, 17 years ago (diff)

mutation updates, ray sorting, merge

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