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

Revision 2066, 3.7 KB checked in by mattausch, 17 years ago (diff)

worked on integration manual

RevLine 
[162]1#ifndef __INTERSECTABLE_H
2#define __INTERSECTABLE_H
3
[176]4#include "AxisAlignedBox3.h"
5#include "Pvs.h"
[1074]6#include <set>
[1184]7#include "VssRay.h"
[1867]8#include "Mailable.h"
[162]9
[860]10namespace GtpVisibilityPreprocessor {
11
[497]12struct VssRayContainer;
[1072]13class KdLeaf;
[1233]14class BvhLeaf;
[1680]15class BvhNode;
[1281]16class Intersectable;
17struct Face;
[1233]18
[1344]19
[2066]20struct FaceParentInfo
21{
[1344]22        /// intersectable
23        Intersectable *mObject;
24        /// face index
25        int mFaceIndex;
26
27        FaceParentInfo(Intersectable *obj, const int fi):
28        mObject(obj), mFaceIndex(fi)
29        {}
[1281]30};
31
[1344]32
[2066]33class Intersectable
34{
[176]35public:
[1999]36 
[1072]37  /// unique object Id
[811]38  int mId;
[1579]39
[1072]40  /// universal counter
[811]41  int mCounter;
[1077]42
[1680]43  /// pointer to the containing bvh leaf
[1233]44  BvhLeaf *mBvhLeaf;
[1696]45 
[1570]46  ///////////////////////
47
[1135]48  enum { MESH_INSTANCE,
49                 TRANSFORMED_MESH_INSTANCE,
50                 SPHERE,
51                 VIEW_CELL,
52                 OGRE_MESH_INSTANCE,
[1233]53                 KD_INTERSECTABLE,
[1314]54                 BVH_INTERSECTABLE,
[1615]55                 TRIANGLE_INTERSECTABLE,
[2066]56                 DUMMY_INTERSECTABLE,
57                 ENGINE_INTERSECTABLE,
[1135]58                };
[162]59 
[2066]60  Intersectable();
[245]61
[2066]62  virtual ~Intersectable();
[1615]63
[1579]64  void SetId(const int id) { mId = id; }
65  int GetId() { return mId; }
66 
[2066]67  /////////////
68  // Mailing stuff
[1579]69 
[2066]70  static void NewMail(const int reserve = 1)
71  {
72          sMailId += sReservedMailboxes;
73          sReservedMailboxes = reserve;
[1579]74  }
[339]75       
[1579]76  void Mail() { mMailbox = sMailId; }
77  bool Mailed() const { return mMailbox == sMailId; }
78 
79  void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
80  bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
81 
82  int IncMail() { return ++ mMailbox - sMailId; }
[382]83
[1999]84   // last mail id -> warning not thread safe!
85  // both mailId and mailbox should be unique for each thread!!!
86  static int sMailId;
87  static int sReservedMailboxes;
88
89  /// Mailbox used for traversals
90  int mMailbox;
91 
92
[2066]93  ////////////////
94  // virtual interface
95
[1579]96  virtual AxisAlignedBox3 GetBox() const = 0;
[1743]97  virtual int CastRay(Ray &ray) = 0;
[176]98 
[1579]99  virtual bool IsConvex() const = 0;
100  virtual bool IsWatertight() const = 0;
101  virtual float IntersectionComplexity() = 0;
102 
103  virtual int NumberOfFaces() const = 0;
104  virtual int Type() const = 0;
[2066]105 
[1579]106  virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
[2066]107 
[1763]108  virtual int GetRandomEdgePoint(Vector3 &point,
109                                                                 Vector3 &normal) = 0;
110
[1687]111  virtual int GetRandomVisibleSurfacePoint(Vector3 &point,
[1696]112                                                                                   Vector3 &normal,
113                                                                                   const Vector3 &viewpoint,
114                                           const int maxTries) = 0;
[1166]115
[2066]116  // virtual int GetRandomPoint(Vector3 &point,
117  // vector3 &normal) = 0;
[1990]118
[1687]119  virtual ostream &Describe(ostream &s) = 0;
[1166]120
[2066]121  //////////////////////////////////////
[1166]122
123
[2066]124  virtual int GenerateSilhouetteRays(const int nrays,
125                                                                         const AxisAlignedBox3 &originBox,
126                                                                         const AxisAlignedBox3 &directionBox,
127                                                                         VssRayContainer &rays);
128 
129   virtual int GetRandomSurfacePoint(const float u,
130                                                                         const float v,
131                                                                         Vector3 &point,
132                                                                         Vector3 &normal);
[1344]133
[2066]134   virtual float GetArea() const;
[1687]135
[2066]136   static bool GreaterCounter(const Intersectable *a,
137                                                          const Intersectable *b);
[1687]138
[2066]139  /** Returns the name of the type of this intersectable
[1687]140  */
[2066]141  static string GetTypeName(Intersectable *obj);
[1696]142
[2066]143   /** Returns normal from the face with the specified index.
144   PROBLEM: Does not fit to all intersectable types (e.g., spheres)
145   */
146   virtual Vector3 GetNormal(const int idx) const;
[1696]147
[2066]148   /** Returns rays stored with this intersectable.
149   */
150   VssRayContainer *GetOrCreateRays();
[1696]151
[2066]152   /** Deletes the rays associated with this intersectable.
153   */
154   void DelRayRefs();
155
[1696]156protected:
157
[2066]158        /// some rays piercing this intersectable
159        VssRayContainer *mVssRays;
[162]160};
161
[1135]162
[860]163}
[162]164
165#endif
Note: See TracBrowser for help on using the repository browser.