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

Revision 1143, 2.3 KB checked in by mattausch, 18 years ago (diff)

worked on vsp osp tree

RevLine 
[162]1#ifndef __INTERSECTABLE_H
2#define __INTERSECTABLE_H
3
[176]4#include "AxisAlignedBox3.h"
5#include "Pvs.h"
[1074]6#include <set>
[162]7
[860]8namespace GtpVisibilityPreprocessor {
9
[497]10struct VssRayContainer;
[1072]11class KdLeaf;
[176]12
[162]13class Intersectable {
[176]14public:
[811]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 
[1072]21  /// unique object Id
[811]22  int mId;
23 
[1072]24  /// universal counter
[811]25  int mCounter;
[339]26       
[1072]27  /// object based pvs
[811]28  KdPvs mKdPvs;
[162]29 
[1077]30  ViewCellPvs mViewCellPvs;
31
[1072]32  /// kd leaves that this intersectable belongs to
[1133]33  //set<KdLeaf *> mKdLeaves;
[1072]34
[1135]35  /// # of object references
[1143]36  int mReferences;
[1135]37
38  enum { MESH_INSTANCE,
39                 TRANSFORMED_MESH_INSTANCE,
40                 SPHERE,
41                 VIEW_CELL,
42                 OGRE_MESH_INSTANCE,
43                 KD_INTERSECTABLE
44                };
[162]45 
[1143]46  Intersectable():mMailbox(0), mReferences(0) {}
[245]47
[339]48        void SetId(const int id) { mId = id; }
49        int GetId() { return mId; }
50       
[382]51
52        static void NewMail(const int reserve = 1) {
53                sMailId += sReservedMailboxes;
54                sReservedMailboxes = reserve;
55        }
56       
[339]57        void Mail() { mMailbox = sMailId; }
[837]58        bool Mailed() const { return mMailbox == sMailId; }
[339]59
[382]60        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
61        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
62
63        int IncMail() { return ++mMailbox - sMailId; }
64
65
[1020]66    virtual AxisAlignedBox3 GetBox() const = 0;
[870]67        virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0;
[382]68       
[1020]69        virtual bool IsConvex() const = 0;
70        virtual bool IsWatertight() const = 0;
[850]71        virtual float IntersectionComplexity() = 0;
[176]72 
[850]73        virtual int NumberOfFaces() const = 0;
74        virtual int Type() const = 0;
[176]75
[850]76        virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
77
78        virtual int GetRandomVisibleSurfacePoint(Vector3 &point,
79                                                                                         Vector3 &normal,
80                                                                                         const Vector3 &viewpoint,
81                                                                                         const int maxTries) = 0;
[492]82 
[850]83        virtual ostream &Describe(ostream &s) = 0;
84       
85        virtual int GenerateSilhouetteRays(const int nrays,
86                                                                           const AxisAlignedBox3 &originBox,
87                                                                           const AxisAlignedBox3 &directionBox, VssRayContainer &rays)
88        {
89                return 0;
90        }
[556]91
[850]92        static bool GreaterCounter(const Intersectable *a,
93                                                         const Intersectable *b)
94        {
95                return a->mCounter > b->mCounter;
96        }
[162]97};
98
[1135]99
[860]100}
[162]101
102#endif
Note: See TracBrowser for help on using the repository browser.