Changeset 1533 for GTP/trunk/Lib
- Timestamp:
- 09/29/06 08:57:34 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1528 r1533 23 23 static vector<VizStruct> vizContainer; 24 24 25 GvsPreprocessor::GvsPreprocessor(): Preprocessor(), mSamplingType(0), mCastPassSamples(0), mCastTotalSamples(0) 25 GvsPreprocessor::GvsPreprocessor(): 26 Preprocessor(), mSamplingType(0), mSampleContriPerPass(0), mTotalSampleContri(0), 27 mReverseSamples(0), mBorderSamples(0) 26 28 { 27 29 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); … … 75 77 if (vssRay->mPvsContribution > 0) 76 78 { 77 cout << " h " << mCastPassSamples << " " << mSamplesPerPass << " " << mTotalSamples << " q: " << mRayQueue.size() << endl; 78 79 cout << "error!!! " << vssRay->mPvsContribution << " " << vssRay->mTerminationObject << endl; 80 79 //cout << " h " << mSampleContriPerPass << " " << mSamplesPerPass << " " << mTotalSamples << endl; 81 80 mRayQueue.push(vssRay); 82 81 mVssRays.push_back(new VssRay(*vssRay)); 83 ++ mCastPassSamples; 82 83 ++ mSampleContriPerPass; 84 84 85 return true; 85 86 } … … 104 105 const Vector3 c = hitTriangle.mVertices[index] - hitTriangle.mVertices[indexL]; 105 106 106 const float len = 1;//Magnitude(a);107 const float len = Magnitude(a); 107 108 108 109 const Vector3 dir1 = Normalize(CrossProd(a, b)); //N((pi-xp)×(pi+1- pi)); … … 170 171 if (EqualVisibility(x, y)) 171 172 { 172 return 2;173 return 0; 173 174 } 174 175 else 175 176 { 177 cout << "s"; 176 178 const Vector3 p = (p1 + p2) * 0.5f; 177 179 SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin); … … 179 181 VssRay *newRay = mRayCaster->CastSingleRay(sray, mViewSpaceBox); 180 182 181 if (!newRay) return 0; 183 if (!newRay) 184 return 0; 185 182 186 const bool enqueued = HandleRay(newRay); 183 187 184 188 const int s1 = SubdivideEdge(hitTriangle, p1, p, x, *newRay, oldRay); 185 189 const int s2 = SubdivideEdge(hitTriangle, p, p2, *newRay, y, oldRay); 186 return s1 + s2; 187 190 188 191 if (!enqueued) 189 192 delete newRay; 193 194 return s1 + s2 + 1; 190 195 } 191 196 } … … 224 229 SimpleRay sr(currentRay.GetOrigin(), rayDir); 225 230 simpleRays.AddRay(sr); 226 227 //cout << "here244 " << (*vit) << " " << currentRay.GetOrigin() << endl;228 //cout << " sr" << sr.mOrigin << sr.mDirection << endl;229 231 } 230 232 … … 238 240 VssRayContainer vssRays; 239 241 CastRays(simpleRays, vssRays, false, false); 240 //CastRays(simpleRays, vssRays, true, true); 241 //cout << "here211 " << simpleRays.size() << " " << vssRays.size() << endl; 242 242 243 // add to ray queue 243 244 EnqueueRays(vssRays); 244 245 245 246 const int n = (int)enlargedTriangle.size(); 246 247 #if 0247 int castRays = (int)vssRays.size(); 248 #if 1 248 249 // recursivly subdivide each edge 249 250 for (int i = 0; i < n; ++ i) 250 251 { 251 SubdivideEdge(252 castRays += SubdivideEdge( 252 253 hitTriangle, 253 254 enlargedTriangle[i], … … 258 259 } 259 260 #endif 260 return (int)vssRays.size(); 261 262 mBorderSamples = castRays; 263 return castRays; 261 264 } 262 265 263 266 264 267 static Vector3 GetPassingPoint(const VssRay ¤tRay, 265 266 268 const Triangle3 &hitTriangle, 269 const VssRay &oldRay) 267 270 { 268 271 // intersect triangle plane with plane spanned by current samples … … 275 278 const float factor = 0.95f; 276 279 float t = triPlane.FindT(intersectLine); 277 278 280 const Vector3 newPoint = intersectLine.mOrigin + t * factor * intersectLine.mDirection; 279 281 … … 286 288 const VssRay &oldRay) 287 289 { 288 cout << "r" << endl; 290 cout << "r"; 291 ++ mReverseSamples; 292 289 293 //-- The plane p = (xp, hit(x), hit(xold)) is intersected 290 294 //-- with the newly found triangle (xold is the previous ray from … … 315 319 GenerateRays(numSamples, sampleType, simpleRays); 316 320 317 //cout << "here909 " << simpleRays.size() << endl;318 //for (int i = 0; i < simpleRays.size(); ++ i)319 // cout << "here544 " << simpleRays[i].mOrigin << endl;320 321 // generate vss rays 321 322 VssRayContainer samples; … … 324 325 // add to ray queue 325 326 EnqueueRays(samples); 326 //for (int i = 0; i < samples.size(); ++ i) 327 // cout << "here1544 " << samples[i]->mOrigin << endl; 327 328 328 Debug << "generated " << numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 329 329 … … 348 348 const int mSampleType = 0; 349 349 // reset samples 350 mCastPassSamples = 0; 351 352 while (mCastPassSamples < mSamplesPerPass) 350 int castSamples = 0; 351 mSampleContriPerPass = 0; 352 353 while (castSamples < mSamplesPerPass) 353 354 { 354 355 // Ray queue empty => 355 356 // cast a number of uniform samples to fill ray Queue 356 CastInitialSamples(mInitialSamples, mSampleType); 357 ProcessQueue(); 358 359 cout << "\nround finished, cast " << mCastPassSamples << " of " << mSamplesPerPass << endl; 360 } 361 362 mCastTotalSamples += mCastPassSamples; 363 364 return mCastPassSamples; 357 castSamples += CastInitialSamples(mInitialSamples, mSampleType); 358 castSamples += ProcessQueue(); 359 cout << "\ncast " << castSamples << " samples in a processing pass" << endl; 360 } 361 362 mTotalSampleContri += mSampleContriPerPass; 363 364 return castSamples; 365 365 } 366 366 … … 377 377 378 378 castSamples += AdaptiveBorderSampling(*ray); 379 379 380 delete ray; 380 381 } … … 386 387 bool GvsPreprocessor::ComputeVisibility() 387 388 { 389 cout << "Gvs Preprocessor started\n" << flush; 390 388 391 Randomize(0); 389 392 const long startTime = GetTime(); 390 393 int castSamples = 0; 391 394 mViewSpaceBox = mKdTree->GetBox(); 392 cout << "Gvs Preprocessor started\n" << flush;393 395 394 396 if (!mLoadViewCells) … … 398 400 } 399 401 400 while ( mCastTotalSamples < mTotalSamples)401 { 402 Pass();402 while (castSamples < mTotalSamples) 403 { 404 castSamples += Pass(); 403 405 404 406 //////// 405 407 //-- stats 406 cout << "+"; 407 cout << "\nsamples cast " << mCastPassSamples << " (=" << mCastTotalSamples << " of " << mTotalSamples << ")" << endl; 408 //cout << "+"; 409 cout << "\nsamples cast: " << castSamples << " of " << mTotalSamples << endl; 410 408 411 //mVssRays.PrintStatistics(mStats); 409 412 mStats << "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl 410 << "#TotalSamples\n" << mCastTotalSamples << endl; 413 << "#TotalSamples\n" << castSamples << endl 414 << "#ContributingSamples\n" << mTotalSampleContri << endl 415 << "#Reverse samples\n" << mReverseSamples << endl 416 << "#Border samples\n" << mBorderSamples << endl; 417 411 418 412 419 mViewCellsManager->PrintPvsStatistics(mStats); -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1528 r1533 129 129 float mThreshold; 130 130 VssRayContainer mVssRays; 131 int mCastPassSamples; 132 int mCastTotalSamples; 131 int mSampleContriPerPass; 132 int mTotalSampleContri; 133 int mReverseSamples; 134 int mBorderSamples; 133 135 }; 134 136 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
r1528 r1533 43 43 int hits = 0; 44 44 int hittriangle; 45 Intersection hitA , hitB;45 Intersection hitA(simpleRay.mOrigin), hitB(simpleRay.mOrigin); 46 46 47 47 float dist; … … 159 159 for (i=0; i < num; i++) 160 160 { 161 Intersection hitA , hitB;161 Intersection hitA(rays[i].mOrigin), hitB(rays[i].mOrigin); 162 162 163 163 if (forward_hit_triangles[i] != -1 ) {
Note: See TracChangeset
for help on using the changeset viewer.