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

Revision 870, 2.0 KB checked in by mattausch, 18 years ago (diff)

added pvs

Line 
1#ifndef __INTERSECTABLE_H
2#define __INTERSECTABLE_H
3
4#include "AxisAlignedBox3.h"
5#include "Pvs.h"
6
7namespace GtpVisibilityPreprocessor {
8
9struct VssRayContainer;
10
11class Intersectable {
12public:
13  // last mail id -> warning not thread safe!
14  // both mailId and mailbox should be unique for each thread!!!
15  static int sMailId;
16  static int sReservedMailboxes;
17  int mMailbox;
18 
19  // unique object Id
20  int mId;
21 
22  // universal counter
23  int mCounter;
24       
25  // object based pvs
26  KdPvs mKdPvs;
27 
28  enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL, OGRE_MESH_INSTANCE };
29 
30  Intersectable():mMailbox(0) {}
31
32        void SetId(const int id) { mId = id; }
33        int GetId() { return mId; }
34       
35
36        static void NewMail(const int reserve = 1) {
37                sMailId += sReservedMailboxes;
38                sReservedMailboxes = reserve;
39        }
40       
41        void Mail() { mMailbox = sMailId; }
42        bool Mailed() const { return mMailbox == sMailId; }
43
44        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
45        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
46
47        int IncMail() { return ++mMailbox - sMailId; }
48
49
50    virtual AxisAlignedBox3 GetBox() = 0;
51        virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0;
52       
53        virtual bool IsConvex() = 0;
54        virtual bool IsWatertight() = 0;
55        virtual float IntersectionComplexity() = 0;
56 
57        virtual int NumberOfFaces() const = 0;
58        virtual int Type() const = 0;
59
60        virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
61
62        virtual int GetRandomVisibleSurfacePoint(Vector3 &point,
63                                                                                         Vector3 &normal,
64                                                                                         const Vector3 &viewpoint,
65                                                                                         const int maxTries) = 0;
66 
67        virtual ostream &Describe(ostream &s) = 0;
68       
69        virtual int GenerateSilhouetteRays(const int nrays,
70                                                                           const AxisAlignedBox3 &originBox,
71                                                                           const AxisAlignedBox3 &directionBox, VssRayContainer &rays)
72        {
73                return 0;
74        }
75
76        static bool GreaterCounter(const Intersectable *a,
77                                                         const Intersectable *b)
78        {
79                return a->mCounter > b->mCounter;
80        }
81};
82
83}
84
85#endif
Note: See TracBrowser for help on using the repository browser.