source: GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h @ 1587

Revision 1587, 3.7 KB checked in by mattausch, 18 years ago (diff)

fixed bug in TriangleIntersectable::GetRandomSurfacePoint?

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