source: GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h @ 1233

Revision 1233, 3.0 KB checked in by mattausch, 18 years ago (diff)
Line 
1#ifndef __KDINTERSECTABLE_H
2#define __KDINTERSECTABLE_H
3
4#include "AxisAlignedBox3.h"
5#include "Intersectable.h"
6
7
8namespace GtpVisibilityPreprocessor {
9
10struct VssRayContainer;
11class KdNode;
12class BvhNode;
13
14/**
15        Wrapper used for creating a PVS compliant intersectable.
16*/
17template<typename T>
18class IntersectableWrapper: public Intersectable
19{
20public:
21        IntersectableWrapper(T *item);
22
23        /** Returns node associated with this instance.
24        */
25        T *GetItem() const;
26
27        /** See get.
28        */
29        void SetItem(T *item);
30
31        //-- inherited functions from Intersectable
32
33        AxisAlignedBox3 GetBox() const;
34       
35        int CastRay(Ray &ray);
36       
37        bool IsConvex() const;
38        bool IsWatertight() const;
39        float IntersectionComplexity();
40 
41        int NumberOfFaces() const;
42        //int Type() const;
43
44        int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
45                                                          GtpVisibilityPreprocessor::Vector3 &normal);
46
47        int GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
48                                                                         GtpVisibilityPreprocessor::Vector3 &normal,
49                                                                         const GtpVisibilityPreprocessor::Vector3 &viewpoint,
50                                                                         const int maxTries);
51 
52        ostream &Describe(ostream &s);
53       
54
55protected:
56       
57        T *mItem;
58};
59
60template<typename T>
61IntersectableWrapper<T>::IntersectableWrapper(T *item):
62Intersectable(), mItem(item)
63{
64}
65
66template<typename T>
67void IntersectableWrapper<T>::SetItem(T *item)
68{
69        mItem = item;
70}
71
72template<typename T>
73T *IntersectableWrapper<T>::GetItem() const
74{
75        return mItem;
76}
77       
78template<typename T>
79AxisAlignedBox3 IntersectableWrapper<T>::GetBox() const
80{       // TODO matt
81        return AxisAlignedBox3();
82}
83
84template<typename T>
85int IntersectableWrapper<T>::CastRay(Ray &ray)
86{       // TODO matt
87        return 0;
88}
89       
90template<typename T>
91bool IntersectableWrapper<T>::IsConvex() const
92{
93        return true;
94}
95
96template<typename T>
97bool IntersectableWrapper<T>::IsWatertight() const
98{
99        return true;
100}
101
102template<typename T>
103float IntersectableWrapper<T>::IntersectionComplexity()
104{
105        return 1.0f;
106}
107
108template<typename T>
109int IntersectableWrapper<T>::NumberOfFaces() const
110{
111        return 0;
112}
113
114template<typename T>
115int IntersectableWrapper<T>::GetRandomSurfacePoint(Vector3 &point,
116                                                                                                Vector3 &normal)
117{
118        return 0;
119}
120
121template<typename T>
122int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point,
123                                                                                                           Vector3 &normal,
124                                                                                                           const Vector3 &viewpoint,
125                                                                                                           const int maxTries)
126{
127        return 0;
128}
129 
130template<typename T>
131ostream &IntersectableWrapper<T>::Describe(ostream &s)
132{
133        s << mItem;
134        return s;
135}
136
137
138class KdIntersectable: public IntersectableWrapper<KdNode>
139{
140public:
141        KdIntersectable(KdNode *item):
142        IntersectableWrapper<KdNode>(item) {}
143
144        int Type() const
145        {
146                return Intersectable::KD_INTERSECTABLE;
147        }
148};
149
150
151class BvhIntersectable: public IntersectableWrapper<BvhNode>
152{
153public:
154        BvhIntersectable(BvhNode *item):
155        IntersectableWrapper<BvhNode>(item) {}
156
157        int Type() const
158        {
159                return Intersectable::BVH_INTERSECTABLE;
160        }
161};
162
163}
164
165#endif
Note: See TracBrowser for help on using the repository browser.