source: GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h @ 1176

Revision 1176, 2.8 KB checked in by mattausch, 18 years ago (diff)

corrected errors in the object space partition, but still buggy!

Line 
1#ifndef __INTERSECTABLE_H
2#define __INTERSECTABLE_H
3
4#include "AxisAlignedBox3.h"
5#include "Pvs.h"
6#include <set>
7
8namespace GtpVisibilityPreprocessor {
9
10struct VssRayContainer;
11class KdLeaf;
12
13class Intersectable {
14public:
15  // last mail id -> warning not thread safe!
16  // both mailId and mailbox should be unique for each thread!!!
17  static int sMailId;
18  static int sReservedMailboxes;
19  int mMailbox;
20 
21  /// unique object Id
22  int mId;
23 
24  /// universal counter
25  int mCounter;
26       
27  /// object based pvs
28  KdPvs mKdPvs;
29 
30  /// view cell based pvs per object
31  ViewCellPvs mViewCellPvs;
32
33  /// kd leaves that this intersectable belongs to
34  //set<KdLeaf *> mKdLeaves;
35
36  /// # of object references
37  int mReferences;
38
39  enum { MESH_INSTANCE,
40                 TRANSFORMED_MESH_INSTANCE,
41                 SPHERE,
42                 VIEW_CELL,
43                 OGRE_MESH_INSTANCE,
44                 KD_INTERSECTABLE
45                };
46 
47  Intersectable(): mMailbox(0), mReferences(0) {}
48
49        void SetId(const int id) { mId = id; }
50        int GetId() { return mId; }
51       
52
53        static void NewMail(const int reserve = 1) {
54                sMailId += sReservedMailboxes;
55                sReservedMailboxes = reserve;
56        }
57       
58        void Mail() { mMailbox = sMailId; }
59        bool Mailed() const { return mMailbox == sMailId; }
60
61        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
62        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
63
64        int IncMail() { return ++ mMailbox - sMailId; }
65
66
67    virtual AxisAlignedBox3 GetBox() const = 0;
68        virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0;
69       
70        virtual bool IsConvex() const = 0;
71        virtual bool IsWatertight() const = 0;
72        virtual float IntersectionComplexity() = 0;
73 
74        virtual int NumberOfFaces() const = 0;
75        virtual int Type() const = 0;
76
77        virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
78
79        virtual int GetRandomVisibleSurfacePoint(Vector3 &point,
80                                                                                         Vector3 &normal,
81                                                                                         const Vector3 &viewpoint,
82                                                                                         const int maxTries) = 0;
83 
84        virtual ostream &Describe(ostream &s) = 0;
85       
86        virtual int GenerateSilhouetteRays(const int nrays,
87                                                                           const AxisAlignedBox3 &originBox,
88                                                                           const AxisAlignedBox3 &directionBox, VssRayContainer &rays)
89        {
90                return 0;
91        }
92
93        static bool GreaterCounter(const Intersectable *a,
94                                                         const Intersectable *b)
95        {
96                return a->mCounter > b->mCounter;
97        }
98
99        static string GetTypeName(Intersectable *obj)
100        {
101                switch(obj->Type())
102                {
103                case MESH_INSTANCE:
104                        return "mesh_instance\n";
105               
106                case TRANSFORMED_MESH_INSTANCE:
107                        return "transformed_mesh_instance\n";
108                       
109                case SPHERE:
110                        return "sphere\n";
111
112                case VIEW_CELL:
113                        return "view cell\n";
114               
115                case OGRE_MESH_INSTANCE:
116                        return "ogre_mesh_instance\n";
117
118                case KD_INTERSECTABLE:
119                        return "kd_intersectable\n";
120
121                default:
122                        return "unknown\n";
123                }
124        }
125};
126
127
128}
129
130#endif
Note: See TracBrowser for help on using the repository browser.