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

Revision 1344, 3.5 KB checked in by mattausch, 18 years ago (diff)

worked on triangle processing. logical units will be created by grouping objects
using their visibility definitions.

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
34        /** See get.
35        */
[1344]36        void SetItem(T item);
[1138]37
[1344]38
39        /////////////////////////////////////////////
[1138]40        //-- inherited functions from Intersectable
41
42        AxisAlignedBox3 GetBox() const;
43       
44        int CastRay(Ray &ray);
45       
46        bool IsConvex() const;
47        bool IsWatertight() const;
48        float IntersectionComplexity();
49 
50        int NumberOfFaces() const;
[1344]51       
[1138]52        int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
53                                                          GtpVisibilityPreprocessor::Vector3 &normal);
54
55        int GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point,
56                                                                         GtpVisibilityPreprocessor::Vector3 &normal,
57                                                                         const GtpVisibilityPreprocessor::Vector3 &viewpoint,
58                                                                         const int maxTries);
59 
60        ostream &Describe(ostream &s);
61       
62
63protected:
64       
[1344]65        T mItem;
[1138]66};
67
[1314]68
[1233]69template<typename T>
[1344]70IntersectableWrapper<T>::IntersectableWrapper(T item):
[1233]71Intersectable(), mItem(item)
72{
73}
[1138]74
[1233]75template<typename T>
[1344]76void IntersectableWrapper<T>::SetItem(T item)
[1233]77{
78        mItem = item;
[1138]79}
80
[1233]81template<typename T>
[1344]82T IntersectableWrapper<T>::GetItem() const
[1233]83{
84        return mItem;
85}
86       
87template<typename T>
88AxisAlignedBox3 IntersectableWrapper<T>::GetBox() const
89{       // TODO matt
90        return AxisAlignedBox3();
91}
92
93template<typename T>
94int IntersectableWrapper<T>::CastRay(Ray &ray)
95{       // TODO matt
96        return 0;
97}
98       
99template<typename T>
100bool IntersectableWrapper<T>::IsConvex() const
101{
102        return true;
103}
104
105template<typename T>
106bool IntersectableWrapper<T>::IsWatertight() const
107{
108        return true;
109}
110
111template<typename T>
112float IntersectableWrapper<T>::IntersectionComplexity()
113{
114        return 1.0f;
115}
116
117template<typename T>
118int IntersectableWrapper<T>::NumberOfFaces() const
119{
120        return 0;
121}
122
123template<typename T>
124int IntersectableWrapper<T>::GetRandomSurfacePoint(Vector3 &point,
[1344]125                                                                                                   Vector3 &normal)
[1233]126{
127        return 0;
128}
129
130template<typename T>
131int IntersectableWrapper<T>::GetRandomVisibleSurfacePoint(Vector3 &point,
[1344]132                                                                                                                  Vector3 &normal,
133                                                                                                                  const Vector3 &viewpoint,
134                                                                                                                  const int maxTries)
[1233]135{
136        return 0;
137}
138 
139template<typename T>
140ostream &IntersectableWrapper<T>::Describe(ostream &s)
141{
142        s << mItem;
143        return s;
144}
145
146
[1344]147class KdIntersectable: public IntersectableWrapper<KdNode *>
[1233]148{
149public:
150        KdIntersectable(KdNode *item):
[1344]151        IntersectableWrapper<KdNode *>(item) {}
[1233]152
153        int Type() const
154        {
155                return Intersectable::KD_INTERSECTABLE;
156        }
157};
158
159
[1344]160class BvhIntersectable: public IntersectableWrapper<BvhNode *>
[1233]161{
162public:
163        BvhIntersectable(BvhNode *item):
[1344]164        IntersectableWrapper<BvhNode *>(item) {}
[1233]165
166        int Type() const
167        {
168                return Intersectable::BVH_INTERSECTABLE;
169        }
170};
171
[1344]172
[1328]173class TriangleIntersectable: public IntersectableWrapper<Triangle3>
[1314]174{
175public:
[1344]176        TriangleIntersectable(Triangle3 item):
[1328]177        IntersectableWrapper<Triangle3>(item) {}
[1314]178
[1328]179        int CastRay(Ray &ray);
180        AxisAlignedBox3 GetBox() const;
181        int NumberOfFaces() const;
[1344]182        Vector3 GetNormal(const int idx) const;
[1328]183
[1314]184        int Type() const
185        {
[1328]186                return Intersectable::TRIANGLE_INTERSECTABLE;
[1314]187        }
188};
189
190
[1233]191}
192
[1138]193#endif
Note: See TracBrowser for help on using the repository browser.