Changeset 2575 for GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
- Timestamp:
- 01/03/08 15:53:44 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
r2571 r2575 20 20 class Preprocessor; 21 21 struct SimpleRay; 22 22 class RayPacket2x2; 23 23 24 24 /** This class provides an interface for ray casting. … … 29 29 public: 30 30 31 enum { 32 INTERNAL_RAYCASTER = 0, 33 INTEL_RAYCASTER 34 }; 35 36 RayCaster(const Preprocessor &preprocessor); 37 38 virtual ~RayCaster(); 39 40 virtual int Type() const = 0; 41 42 /** Wrapper for casting single ray. 43 @returns ray or NULL if invalid 44 */ 45 VssRay *CastRay(const SimpleRay &simpleRay, 46 const AxisAlignedBox3 &box, 47 const bool castDoubleRay); 48 49 virtual int CastRay(const SimpleRay &simpleRay, 50 VssRayContainer &vssRays, 51 const AxisAlignedBox3 &box, 52 const bool castDoubleRay, 53 const bool pruneInvalidRays = true) = 0; 54 55 virtual void CastRays16(SimpleRayContainer &rays, 56 VssRayContainer &vssRays, 57 const AxisAlignedBox3 &sbox, 58 const bool castDoubleRay, 59 const bool pruneInvalidRays = true) = 0; 60 31 enum { 32 INTERNAL_RAYCASTER = 0, 33 INTEL_RAYCASTER = 1, 34 HAVRAN_RAYCASTER = 2 35 }; 36 37 RayCaster(const Preprocessor &preprocessor); 38 39 virtual ~RayCaster(); 40 41 virtual int Type() const = 0; 42 43 /** Wrapper for casting single ray. 44 @returns ray or NULL if invalid 45 */ 46 VssRay *CastRay(const SimpleRay &simpleRay, 47 const AxisAlignedBox3 &box, 48 const bool castDoubleRay); 49 50 virtual int CastRay(const SimpleRay &simpleRay, 51 VssRayContainer &vssRays, 52 const AxisAlignedBox3 &box, 53 const bool castDoubleRay, 54 const bool pruneInvalidRays = true) = 0; 55 56 virtual void CastRays16(SimpleRayContainer &rays, 57 VssRayContainer &vssRays, 58 const AxisAlignedBox3 &sbox, 59 const bool castDoubleRay, 60 const bool pruneInvalidRays = true) = 0; 61 61 62 virtual void CastRays( 62 SimpleRayContainer &rays, 63 VssRayContainer &vssRays, 64 const AxisAlignedBox3 &sbox, 65 const bool castDoubleRay, 66 const bool pruneInvalidRays = true); 67 63 SimpleRayContainer &rays, 64 VssRayContainer &vssRays, 65 const AxisAlignedBox3 &sbox, 66 const bool castDoubleRay, 67 const bool pruneInvalidRays = true); 68 69 // Just for testing concept 70 virtual void CastRaysPacket2x2(RayPacket2x2 &raysPack, 71 bool castDoubleRay, 72 const bool pruneInvalidRays = true) 73 { } 74 68 75 /*virtual void CastRaysEye4(SimpleRayContainer &rays, 69 70 71 72 73 */74 virtual void 75 SortRays(SimpleRayContainer &rays); 76 77 78 // pool of vss rays to be used in one pass of the sampling 79 struct VssRayPool 80 { 81 VssRayPool(): mRays(NULL), mIndex(0), mNumber(0) 82 {} 83 84 ~VssRayPool()85 { 86 DEL_PTR(mRays); 87 } 88 89 void Reserve(const int number)90 { 91 DEL_PTR(mRays); 92 mRays = new VssRay[number];93 mNumber = number;94 } 95 96 void Clear()97 { 98 mIndex = 0; 99 } 100 101 VssRay *Alloc()102 { 103 // reset pool 104 if (mIndex == mNumber) 105 mIndex = 0; 106 return mRays + mIndex ++;107 } 108 109 110 111 VssRay *mRays;112 int mIndex;113 int mNumber;114 }; 115 116 117 118 119 120 121 122 123 124 125 126 127 128 76 VssRayContainer &vssRays, 77 const AxisAlignedBox3 &sbox, 78 const bool castDoubleRay, 79 const bool pruneInvalidRays = true) = 0; 80 */ 81 82 virtual void 83 SortRays(SimpleRayContainer &rays); 84 85 86 // pool of vss rays to be used in one pass of the sampling 87 struct VssRayPool 88 { 89 VssRayPool(): mRays(NULL), mIndex(0), mNumber(0) 90 {} 91 92 ~VssRayPool() 93 { 94 delete []mRays; 95 } 96 97 void Reserve(const int number) 98 { 99 DEL_PTR(mRays); 100 mRays = new VssRay[number]; 101 mNumber = number; 102 } 103 104 void Clear() 105 { 106 mIndex = 0; 107 } 108 109 VssRay *Alloc() 110 { 111 // reset pool 112 if (mIndex == mNumber) 113 mIndex = 0; 114 return mRays + mIndex ++; 115 } 116 protected: 117 VssRay *mRays; 118 int mIndex; 119 int mNumber; 120 }; 121 122 123 VssRayPool mVssRayPool; 124 125 void ReserveVssRayPool(const int n) 126 { 127 mVssRayPool.Reserve(n); 128 } 129 130 void InitPass() 131 { 132 mVssRayPool.Clear(); 133 } 134 135 129 136 protected: 130 131 132 const Vector3 &termination,133 Intersectable *originObject,134 Intersectable *terminationObject,135 const int pass,136 const float pdf);137 138 139 const int l,140 const int r,141 const int depth,142 float box[12]);143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 const Preprocessor &mPreprocessor; 137 138 VssRay *RequestRay(const Vector3 &origin, 139 const Vector3 &termination, 140 Intersectable *originObject, 141 Intersectable *terminationObject, 142 const int pass, 143 const float pdf); 144 145 void _SortRays(SimpleRayContainer &rays, 146 const int l, 147 const int r, 148 const int depth, 149 float box[12]); 150 151 struct Intersection 152 { 153 Intersection(): mObject(NULL), mFaceId(0) 154 {} 155 156 Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f): 157 mPoint(p), mNormal(n), mObject(o), mFaceId(f) 158 {} 159 160 Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0) 161 {} 162 163 164 //////////// 165 166 Vector3 mPoint; 167 Vector3 mNormal; 168 Intersectable *mObject; 169 int mFaceId; 170 }; 171 172 173 int ProcessRay(const SimpleRay &ray, 174 Intersection &hitA, 175 Intersection &hitB, 176 VssRayContainer &vssRays, 177 const AxisAlignedBox3 &box, 178 const bool castDoubleRay, 179 const bool pruneInvalidRays = true); 180 181 /** Checks if ray is valid. 182 I.e., the ray is in valid view space. 183 @note: clamps the ray to valid view space. 184 */ 185 bool ValidateRay(const Vector3 &origin, 186 const Vector3 &direction, 187 const AxisAlignedBox3 &box, 188 Intersection &hit); 189 190 bool ClipToViewSpaceBox(const Vector3 &origin, 191 const Vector3 &termination, 192 Vector3 &clippedOrigin, 193 Vector3 &clippedTermination); 194 195 const Preprocessor &mPreprocessor; 196 #if 1 197 public: 198 // Added by VH for debugging 199 Intersection intersect; 200 #endif 194 201 }; 195 202
Note: See TracChangeset
for help on using the changeset viewer.