Changeset 1489 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 09/26/06 10:05:29 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1486 r1489 2432 2432 optBool, 2433 2433 "bvh_construction_use_global_sorting=", 2434 " false");2434 "true"); 2435 2435 2436 2436 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1486 r1489 5 5 #include "ViewCellsManager.h" 6 6 #include "Triangle3.h" 7 7 #include "IntersectableWrapper.h" 8 8 9 9 … … 29 29 30 30 31 const bool GvsPreprocessor::DiscontinuityFound(const VssRay &ray) const 32 { 31 const bool GvsPreprocessor::DiscontinuityFound(const VssRay &ray, 32 const VssRay &oldRay) const 33 { 34 //const Plane3 plane = tri->GetPlane(); 33 35 return false; 34 36 } … … 52 54 } 53 55 54 55 void GvsPreprocessor::CreateNewSamples(VertexContainer &samples, 56 const VssRay &ray, 57 const Triangle3 &hitTriangle, 58 const int index, 59 const float eps) 56 /** Hepler function for adaptive border sampling. It finds 57 new sample points around a triangle in a eps environment 58 */ 59 static void CreateNewSamples(VertexContainer &samples, 60 const Triangle3 &hitTriangle, 61 const VssRay &ray, 62 const int index, 63 const float eps) 60 64 { 61 65 const int indexU = (index + 1) % 3; … … 86 90 87 91 88 int GvsPreprocessor::AdaptiveBorderSampling(const VssRay &ray) 92 /** Generate rays from sample points. 93 */ 94 static void CreateRays(VssRayContainer &rays, 95 const VertexContainer &samples) 96 { 97 VertexContainer::const_iterator vit, vit_end = samples.end(); 98 99 for (vit = samples.begin(); vit != vit_end; ++ vit) 100 { 101 const Vector3 currentSample = *vit; 102 VssRay *ray;// = new VssRay(ray->mOrigin, currentSample); 103 } 104 } 105 106 107 int GvsPreprocessor::AdaptiveBorderSampling(const VssRay &prevRay) 89 108 { 90 109 cout << "a"; 91 //Intersectable *tObj = ray->GetTerminationObject;110 Intersectable *tObj = prevRay.mTerminationObject; 92 111 Triangle3 hitTriangle; 93 vector<Vector3> samples; 112 113 // other types not implemented yet 114 if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE) 115 { 116 hitTriangle = dynamic_cast<TriangleIntersectable *>(tObj)->GetItem(); 117 } 118 119 VertexContainer samples; 94 120 samples.reserve(9); 95 121 96 CreateNewSamples(samples, ray, hitTriangle, 0, mEps); 97 CreateNewSamples(samples, ray, hitTriangle, 1, mEps); 98 CreateNewSamples(samples, ray, hitTriangle, 2, mEps); 99 100 VertexContainer::const_iterator vit, vit_end = samples.end(); 101 102 for (vit = samples.begin(); vit != vit_end; ++ vit) 103 { 104 VssRay *ray;// = CreateRay(*vit); 105 106 if (DiscontinuityFound(*ray)) 107 { 108 // schedule for reverse sampling 109 mRayQueue.push(GvsRayInfo(ray, true)); 110 } 111 else 112 { 113 // schedule for adaptive border sampling 114 mRayQueue.push(GvsRayInfo(ray, false)); 115 } 116 } 117 118 // TODO 119 return 1; 122 CreateNewSamples(samples, hitTriangle, prevRay, 0, mEps); 123 CreateNewSamples(samples, hitTriangle, prevRay, 1, mEps); 124 CreateNewSamples(samples, hitTriangle, prevRay, 2, mEps); 125 126 VssRayContainer vssRays; 127 CreateRays(vssRays, samples); 128 129 VssRayContainer::const_iterator rit, rit_end = vssRays.end(); 130 131 for (rit = vssRays.begin(); rit != rit_end; ++ rit) 132 { 133 VssRay *ray = *rit; 134 135 // discontinuity found? 136 // schedule for reverse sampling or adaptive border sampling 137 const bool gap = DiscontinuityFound(*ray, prevRay); 138 mRayQueue.push(GvsRayInfo(ray, gap)); 139 } 140 141 return 9; 120 142 } 121 143 … … 128 150 } 129 151 130 int GvsPreprocessor::CastAvsSamples(const int samplesPerPass, 131 const int sampleType, 132 RayQueue &passSamples) 133 { 152 153 int GvsPreprocessor::CastInitialSamples(const int numSamples, 154 const int sampleType) 155 { 156 const long startTime = GetTime(); 157 158 // generate simple rays 134 159 SimpleRayContainer simpleRays; 135 const long startTime = GetTime(); 136 137 GenerateRays(samplesPerPass, sampleType, simpleRays); 138 Debug << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 139 140 // cast the rays and optain hitpoints with geometry 160 GenerateRays(numSamples, sampleType, simpleRays); 161 162 // generate vss rays 141 163 VssRayContainer samples; 142 164 CastRays(simpleRays, samples); 143 144 Debug << "cast " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 145 165 166 // add to ray queue 167 EnqueueSamples(samples); 168 169 Debug << "generated " << numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 170 171 return (int)samples.size(); 172 } 173 174 175 void GvsPreprocessor::EnqueueSamples(VssRayContainer &samples, VssRay *oldRay) 176 { 146 177 // add samples to ray queue 147 178 VssRayContainer::const_iterator vit, vit_end = samples.end(); 148 179 for (vit = samples.begin(); vit != vit_end; ++ vit) 149 180 { 150 mRayQueue.push(*vit); 151 } 152 153 return (int)mRayQueue.size(); 181 /// if there is no old ray, no discontinuity 182 const bool gap = oldRay ? DiscontinuityFound(*(*vit), *oldRay) : false; 183 mRayQueue.push(GvsRayInfo(*vit, gap)); 184 } 185 154 186 } 155 187 … … 158 190 { 159 191 int castSamples = 0; 160 192 const int mSampleType = 0; 161 193 while (castSamples < mSamplesPerPass) 162 194 { 163 195 // Ray queue empty => 164 196 // cast a number of uniform samples to fill ray Queue 165 Cast AvsSamples(mInitialSamples, mSamplingType, mRayQueue);166 167 const int gvsSamples = RunSampling();197 CastInitialSamples(mInitialSamples, mSampleType); 198 199 const int gvsSamples = ProcessQueue(); 168 200 castSamples += gvsSamples; 169 //cout << "\ngvs samples: " << gvsSamples << endl; 170 //cout << "cast " << castSamples << " of " << mSamplesPerPass << endl; 201 //cout << "\ncast " << castSamples << " of " << mSamplesPerPass << endl; 171 202 } 172 203 … … 175 206 176 207 177 int GvsPreprocessor:: RunSampling()208 int GvsPreprocessor::ProcessQueue() 178 209 { 179 210 int castSamples = 0; … … 182 213 { 183 214 // handle next ray 184 VssRay *ray= mRayQueue.top();215 GvsRayInfo rayInfo = mRayQueue.top(); 185 216 mRayQueue.pop(); 186 217 187 castSamples += HandleRay( *ray);218 castSamples += HandleRay(rayInfo); 188 219 } 189 220 … … 192 223 193 224 194 bool 195 GvsPreprocessor::ComputeVisibility() 225 bool GvsPreprocessor::ComputeVisibility() 196 226 { 197 227 Randomize(0); … … 213 243 const int passSamples = Pass(); 214 244 castSamples += passSamples; 245 246 ///////////// 247 // -- stats 215 248 cout << "+"; 216 249 cout << "\nsamples cast " << passSamples << " (=" << castSamples << " of " << mTotalSamples << ")" << endl; 217 250 //mVssRays.PrintStatistics(mStats); 218 //mStats << "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl219 // << "#TotalSamples\n" << samples << endl;251 mStats << "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl 252 << "#TotalSamples\n" << castSamples << endl; 220 253 221 254 mViewCellsManager->PrintPvsStatistics(mStats); -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1486 r1489 12 12 class Exporter; 13 13 class VssRay; 14 14 15 15 16 … … 31 32 struct GvsRayInfo 32 33 { 34 GvsRayInfo(VssRay *ray, const bool d) 35 : mRay(ray), mFoundDiscontinuity(d) 36 {} 37 33 38 VssRay *mRay; 34 39 bool mFoundDiscontinuity; 35 } 40 }; 36 41 37 42 38 43 typedef stack<GvsRayInfo> RayQueue; 39 44 40 /** Runs the adaptive sampling. The method starts with a number of random rays given 41 by the queue and continues as long it finds new visible geometry (i.e., the queue is 42 not empty). 45 /** Runs the adaptive sampling until the ray queue is empty. 46 The method starts with a number of random rays given 47 by the queue and continues as long it finds new visible geometry 48 (i.e., the queue is not empty). 43 49 44 50 @returns the number of samples cast. 45 51 */ 46 int RunSampling();52 int ProcessQueue(); 47 53 48 /** One pass of the sampling preprocessor. Continues as long as at least passSample49 rays have been cast.54 /** One pass of the sampling preprocessor. 55 Continues as long as at least passSample rays have been cast. 50 56 @returns the number of samples cast. 51 57 */ … … 54 60 /** Generates the rays starting the adaptive visibility sampling process. 55 61 */ 56 int CastAvsSamples( 57 const int samplesPerPass, 58 const int sampleType, 59 RayQueue &passSamples); 62 int CastInitialSamples(const int numSamples, const int sampleType); 60 63 61 64 /** Uses the information gained from the ray for doing adaptive border sampling. … … 70 73 int HandleRay(const GvsRayInfo &ray); 71 74 72 /** 75 /** The adaptive border sampling step. It aims to find neighbouring 76 triangles of the one hit by the previous ray. 73 77 */ 74 int AdaptiveBorderSampling(const VssRay & ray);78 int AdaptiveBorderSampling(const VssRay &prevRay); 75 79 76 int ReverseSampling(const VssRay &ray); 80 /** The reverse sampling step. It is started once the cast 81 ray finds a discontinuity, i.e., a closer triangle. 82 Then the process tries to find a ray from the old 83 triangle passing through a gap. 84 */ 85 int ReverseSampling(const VssRay &prevRay); 77 86 78 /** Cast samples according to a specific sampling strategy.87 /** Returns true if we sampled a closer triangle than with the previous ray. 79 88 */ 80 int CastPassSamples( 81 const int samplesPerPass, 82 const int sampleType, 83 VssRayContainer &passSamples) const; 89 const bool DiscontinuityFound(const VssRay &ray, const VssRay &prevRay) const; 84 90 85 void CreateNewSamples( 86 VertexContainer &samples, 87 const VssRay &ray, 88 const Triangle3 &hitTriangle, 89 const int index, 90 const float eps); 91 92 const bool DiscontinuityFound(const VssRay &ray) const; 93 94 91 /** Adds new samples to the ray queue and classifies them 92 with respect to the previous ray. 93 */ 94 void EnqueueSamples(VssRayContainer &samples, VssRay *prevRay = NULL); 95 95 96 ////////////////////// 96 97 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1416 r1489 1485 1485 { 1486 1486 stats << "#Pass\n" << pass << endl 1487 //<< "#Merged\n" << mergeStats.merged << endl1488 1487 << "#ViewCells\n" << viewCells << endl 1489 1488 << "#RenderCostDecrease\n" << renderCostDecrease << endl // TODO … … 1499 1498 << endl; 1500 1499 } 1500 1501 1501 1502 1502 void ViewCellsTree::ExportStats(const string &mergeStats)
Note: See TracChangeset
for help on using the changeset viewer.