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

Revision 2199, 4.0 KB checked in by mattausch, 18 years ago (diff)

using mutationsamples for evaluation

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