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

Revision 1314, 3.3 KB checked in by mattausch, 18 years ago (diff)

started osp mesh construction for obj files. Introduced new primitive faceintersectable

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