Changeset 2729 for GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
- Timestamp:
- 06/02/08 04:11:30 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h
r2660 r2729 8 8 #include "Vector3.h" 9 9 #include "VssRay.h" 10 11 using namespace std; 10 #include "Timer/PerfTimer.h" 12 11 13 12 // … … 124 123 SortRays2(SimpleRayContainer &rays); 125 124 126 // pool of vss rays to be used in one pass of the sampling127 struct VssRayPool128 {129 VssRayPool(): mRays(NULL), mIndex(0), mNumber(0)130 {}131 132 ~VssRayPool()133 {134 delete []mRays;135 }136 137 void Reserve(const int number)138 {139 DEL_PTR(mRays);140 mRays = new VssRay[number];141 mNumber = number;142 }143 144 void Clear()145 {146 mIndex = 0;147 }148 149 VssRay *Alloc()150 {151 // reset pool152 if (mIndex == mNumber)153 mIndex = 0;154 return mRays + mIndex ++;155 }156 protected:157 VssRay *mRays;158 int mIndex;159 int mNumber;160 };161 162 163 VssRayPool mVssRayPool;164 165 void ReserveVssRayPool(const int n)166 {167 mVssRayPool.Reserve(n);168 }169 170 void InitPass()171 {172 mVssRayPool.Clear();173 }174 175 176 protected:177 178 125 VssRay *RequestRay(const Vector3 &origin, 179 126 const Vector3 &termination, … … 182 129 const int pass, 183 130 const float pdf); 131 132 // pool of vss rays to be used in one pass of the sampling 133 struct VssRayPool 134 { 135 VssRayPool(): mRays(NULL), mIndex(0), mNumber(0) 136 {} 137 138 ~VssRayPool() 139 { 140 delete []mRays; 141 } 142 143 void Reserve(const int number) 144 { 145 DEL_PTR(mRays); 146 mRays = new VssRay[number]; 147 mNumber = number; 148 } 149 150 void Clear() 151 { 152 mIndex = 0; 153 } 154 155 VssRay *Alloc() 156 { 157 #if 1 158 // reset pool 159 if (mIndex == mNumber) 160 { 161 std::cerr << "warning: ray pool too small! " << std::endl; 162 mIndex = 0; 163 } 164 165 // raypool larger index => enlarge ray pool 166 #else 167 if (mNumber == mIndex) 168 { 169 cerr << "warning: ray pool too small! " << "reserving " << mNumber * 2 << " rays" << std::endl; 170 Reserve(mNumber * 2); 171 } 172 #endif 173 return mRays + mIndex ++; 174 } 175 protected: 176 VssRay *mRays; 177 int mIndex; 178 int mNumber; 179 }; 180 181 182 VssRayPool mVssRayPool; 183 184 void ReserveVssRayPool(const int n) 185 { 186 mVssRayPool.Reserve(n); 187 } 188 189 void InitPass() 190 { 191 mVssRayPool.Clear(); 192 } 193 194 PerfTimer rawCastTimer; 195 196 protected: 197 184 198 185 199 void _SortRays(SimpleRayContainer &rays,
Note: See TracChangeset
for help on using the changeset viewer.