- Timestamp:
- 01/20/07 14:03:37 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r1997 r2001 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 18. I 20:30:3120073 # Generated by qmake (2.00a) (Qt 4.1.2) on: pá 19. I 15:33:39 2007 4 4 # Project: preprocessor.pro 5 5 # Template: app … … 63 63 $(MAKE) -f $(MAKEFILE).Debug uninstall 64 64 65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc .net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 66 66 C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 67 67 C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ -
GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
r1997 r2001 9 9 #include "RndGauss.h" 10 10 #include "Mutation.h" 11 #include "Exporter.h" 11 12 12 13 #ifdef GTP_INTERNAL … … 20 21 21 22 #define USE_SIL_TERMINATION_MUTATION 1 23 #define MUTATE_ORIGIN 1 22 24 23 25 #define EVALUATE_MUTATION_STATS 1 26 27 #define Q_SEARCH_STEPS 2 24 28 25 29 void … … 51 55 int dummyNcMutations = 0; 52 56 int dummyCMutations = 0; 57 58 int reverseCandidates = 0; 53 59 54 60 for (int i=0; i < vssRays.size(); i++) { … … 86 92 *mRays[mBufferStart].mRay = *vssRays[i]; 87 93 mRays[mBufferStart].mMutations = 0; 94 mRays[mBufferStart].ResetReverseMutation(); 88 95 // mRays[mBufferStart] = RayEntry(newRay); 89 96 mBufferStart++; 90 97 if (mBufferStart >= mMaxRays) 91 98 mBufferStart = 0; 99 100 92 101 } 93 102 } else { 94 #if EVALUATE_MUTATION_STATS95 103 if (vssRays[i]->mDistribution == MUTATION_BASED_DISTRIBUTION && 96 104 vssRays[i]->mGeneratorId != -1 97 105 ) { 106 // check whether not to store a new backward mutation candidate 107 VssRay *oldRay = mRays[vssRays[i]->mGeneratorId].mRay; 108 VssRay *newRay = vssRays[i]; 109 110 #define DIST_THRESHOLD 3.0f 111 112 Intersectable *oldObject = 113 mPreprocessor.mViewCellsManager->GetIntersectable( 114 *oldRay, 115 true); 116 117 118 if (!mRays[newRay->mGeneratorId].HasReverseMutation()) { 119 if (DotProd(oldRay->GetDir(), newRay->GetDir()) > 0.0f) { 120 float oldDist = Magnitude(oldRay->mTermination - newRay->mOrigin); 121 float newDist = Magnitude(newRay->mTermination - newRay->mOrigin); 122 123 if (newDist < oldDist - oldObject->GetBox().Radius()*DIST_THRESHOLD) { 124 Vector3 origin, termination; 125 if (ComputeReverseMutation(*oldRay, *newRay, origin, termination)) { 126 mRays[newRay->mGeneratorId].SetReverseMutation(origin, termination); 127 } 128 129 reverseCandidates++; 130 //mReverseCandidates 131 } 132 } 133 } 134 #if EVALUATE_MUTATION_STATS 98 135 mutationRays++; 99 136 100 137 Intersectable *newObject = 101 138 mPreprocessor.mViewCellsManager->GetIntersectable( … … 103 140 true); 104 141 105 Intersectable *oldObject =106 mPreprocessor.mViewCellsManager->GetIntersectable(107 *mRays[vssRays[i]->mGeneratorId].mRay,108 true);109 142 110 143 if (oldObject == newObject) 111 144 dummyNcMutations++; 145 #endif 112 146 } 113 #endif114 147 } 115 148 } 116 149 117 150 if (mutationRays) { 118 151 cout<<"Mutated rays:"<<mutationRays<<endl; … … 121 154 cout<<"Dummy NC mutations ratio:"<<100.0f*dummyNcMutations/(float)mutationRays<<"%"<<endl; 122 155 cout<<"Dummy C mutations ratio:"<<100.0f*dummyCMutations/(float)mutationRays<<"%"<<endl; 156 cout<<"Reverse candidates:"<<reverseCandidates<<endl; 123 157 } 124 158 … … 259 293 } 260 294 295 bool 296 MutationBasedDistribution::ComputeReverseMutation( 297 const VssRay &oldRay, 298 const VssRay &newRay, 299 Vector3 &origin, 300 Vector3 &termination 301 ) 302 { 303 // first reconstruct the termination point 304 Vector3 oldDir = Normalize(oldRay.GetDir()); 305 Plane3 oldPlane(oldDir, oldRay.mTermination); 306 307 termination = oldPlane.FindIntersection(newRay.mOrigin, 308 newRay.mTermination); 309 310 // now find the new origin of the ray by casting ray backward from the termination and termining 311 // silhouette point with respect to the occluding object (object containing the newRay termination) 312 313 Plane3 newPlane(oldDir, newRay.mTermination); 314 315 Vector3 oldPivot = newPlane.FindIntersection(oldRay.mOrigin, 316 oldRay.mTermination); 317 318 Vector3 newPivot = newRay.mTermination; 319 Vector3 line = 2.0f*(oldPivot - newPivot); 320 321 Intersectable *occluder = mPreprocessor.mViewCellsManager->GetIntersectable( 322 newRay, 323 true); 324 325 AxisAlignedBox3 box = occluder->GetBox(); 326 box.Scale(2.0f); 327 328 const int packetSize = 4; 329 static int hit_triangles[packetSize]; 330 static float dist[packetSize]; 331 static Vector3 dirs[packetSize]; 332 static Vector3 shifts[packetSize]; 333 // now find the silhouette along the line 334 int i; 335 float left = 0.0f; 336 float right = 1.0f; 337 // cast rays to find silhouette ray 338 for (int j=0; j < Q_SEARCH_STEPS; j++) { 339 for (i=0; i < packetSize; i++) { 340 float r = left + (i+1)*(right-left)/(packetSize+1); 341 shifts[i] = r*line; 342 dirs[i] = Normalize(newPivot + shifts[i] - termination ); 343 mlrtaStoreRayASEye4(&termination.x, 344 &dirs[i].x, 345 i); 346 } 347 348 mlrtaTraverseGroupASEye4(&box.Min().x, 349 &box.Max().x, 350 hit_triangles, 351 dist); 352 353 for (i=0; i < packetSize; i++) { 354 if (hit_triangles[i] == -1) { 355 // break on first passing ray 356 break; 357 } 358 } 359 float rr = left + (i+1)*(right-left)/(packetSize+1); 360 float rl = left + i*(right-left)/(packetSize+1); 361 left = rl; 362 right = rr; 363 } 364 365 float t = right; 366 if (right==1.0f) 367 return false; 368 369 if (i == packetSize) 370 origin = newPivot + right*line; 371 else 372 origin = newPivot + shifts[i]; 373 374 if (0) { 375 376 static VssRayContainer rRays; 377 static int counter = 0; 378 char filename[256]; 379 380 if (counter < 50) { 381 sprintf(filename, "reverse_rays_%03d.x3d", counter++); 382 383 VssRay tRay(origin, termination, NULL, NULL); 384 rRays.push_back((VssRay *)&oldRay); 385 rRays.push_back((VssRay *)&newRay); 386 rRays.push_back(&tRay); 387 388 Exporter *exporter = NULL; 389 exporter = Exporter::GetExporter(filename); 390 391 exporter->SetFilled(); 392 393 Intersectable *occludee = mPreprocessor.mViewCellsManager->GetIntersectable( 394 oldRay, 395 true); 396 397 exporter->SetForcedMaterial(RgbColor(0,0,1)); 398 exporter->ExportIntersectable(occluder); 399 exporter->SetForcedMaterial(RgbColor(0,1,0)); 400 exporter->ExportIntersectable(occludee); 401 exporter->ResetForcedMaterial(); 402 403 exporter->SetWireframe(); 404 405 406 exporter->ExportRays(rRays, RgbColor(1, 0, 0)); 407 delete exporter; 408 rRays.clear(); 409 } 410 } 411 412 413 414 return true; 415 416 // now the origin and termination is swapped compred to the generator ray 417 // swap(origin, termination);??? 418 // -> perhaps not neccessary as the reverse mutation wil only be used once! 419 } 261 420 262 421 Vector3 … … 270 429 ) 271 430 { 272 const int packetSize = 16; 273 431 const int packetSize = 4; 274 432 static int hit_triangles[packetSize]; 275 433 static float dist[packetSize]; 276 434 static Vector3 dirs[packetSize]; 435 static Vector3 shifts[packetSize]; 277 436 // mutate the 278 437 float alpha = RandomValue(0.0f, 2.0f*M_PI); 438 //float alpha = vr2.x*2.0f*M_PI; 279 439 280 440 // direction along which we will mutate the ray … … 283 443 // cout<<line<<endl; 284 444 // create 16 rays along the selected dir 285 445 int i; 446 float left = 0.0f; 447 float right = radius; 286 448 // cast rays to find silhouette ray 287 for (int i=0; i < packetSize; i++) { 288 dirs[i] = Normalize(ray.mTermination + ((radius/(packetSize - i))*line) - origin ); 289 mlrtaStoreRayAS16(&origin.x, 290 &dirs[i].x, 291 i); 292 } 293 294 mlrtaTraverseGroupAS16(&box.Min().x, 295 &box.Max().x, 296 hit_triangles, 297 dist); 298 299 for (int i=0; i < packetSize; i++) { 300 if (hit_triangles[i] == -1 || !box.IsInside(origin + dist[i]*dirs[i])) { 301 // break on first passing ray 302 break; 449 for (int j=0; j < Q_SEARCH_STEPS; j++) { 450 for (i=0; i < packetSize; i++) { 451 float r = left + (i+1)*(right-left)/(packetSize+1); 452 shifts[i] = r*line; 453 dirs[i] = Normalize(ray.mTermination + shifts[i] - origin ); 454 mlrtaStoreRayASEye4(&origin.x, 455 &dirs[i].x, 456 i); 303 457 } 458 459 mlrtaTraverseGroupASEye4(&box.Min().x, 460 &box.Max().x, 461 hit_triangles, 462 dist); 463 464 for (i=0; i < packetSize; i++) { 465 if (hit_triangles[i] == -1) { 466 // if (hit_triangles[i] == -1 || !box.IsInside(origin + dist[i]*dirs[i])) { 467 // break on first passing ray 468 break; 469 } 470 } 471 float rr = left + (i+1)*(right-left)/(packetSize+1); 472 float rl = left + i*(right-left)/(packetSize+1); 473 left = rl; 474 right = rr; 304 475 } 305 476 … … 307 478 // cerr<<"Warning: hit the same box here should never happen!"<<endl; 308 479 // shift the ray even a bit more 309 // cout<<"W"<<i<<endl; 310 return ray.mTermination + (RandomValue(1.0f, 2.0f)*radius)*line; 311 } 312 480 //cout<<"W"<<i<<endl; 481 // return (RandomValue(1.0f, 1.5f)*radius)*line; 482 return right*line; 483 } 484 313 485 // cout<<i<<endl; 314 return dirs[i];486 return shifts[i]; 315 487 } 316 488 … … 386 558 mLastIndex = index; 387 559 560 if (mRays[index].HasReverseMutation()) { 561 //cout<<"R "<<mRays[index].mutatedOrigin<<" "<<mRays[index].mutatedTermination<<endl; 562 sray = SimpleRay(mRays[index].mutatedOrigin, 563 Normalize(mRays[index].mutatedTermination - mRays[index].mutatedOrigin), 564 MUTATION_BASED_DISTRIBUTION, 1.0f); 565 sray.mGeneratorId = index; 566 mRays[index].ResetReverseMutation(); 567 mRays[index].mMutations++; 568 return true; 569 } 570 388 571 #if USE_SILHOUETTE_MUTATIONS 389 572 return GenerateSilhouetteMutation(index, sray); … … 391 574 return GenerateMutation(index, sray); 392 575 #endif 393 394 576 } 395 577 … … 410 592 411 593 mRays[index].mHalton.GetNext(4, rr); 594 // rr[0] = RandomValue(0.0f,0.99999f); 595 // rr[1] = RandomValue(0.0f,0.99999f); 596 // rr[2] = RandomValue(0.0f,0.99999f); 597 // rr[3] = RandomValue(0.0f,0.99999f); 412 598 413 599 // mutate the origin … … 430 616 // optimal for Vienna 0.5f 431 617 432 float radiusExtension = 0. 05f;618 float radiusExtension = 0.5f; 433 619 // + mRays[index].mMutations/50.0f; 434 620 435 621 float mutationRadius = objectRadius*radiusExtension; 436 622 437 623 // tmp for pompeii 438 mutationRadius = 0.22f; 439 624 // mutationRadius = 0.22f; 625 626 #if MUTATE_ORIGIN 440 627 origin += ComputeOriginMutation(*ray, U, V, 441 628 Vector2(rr[0], rr[1]), 442 629 mutationRadius); 630 #endif 443 631 444 632 #if USE_SIL_TERMINATION_MUTATION … … 448 636 U, V, 449 637 Vector2(rr[2], rr[3]), 450 3.0f*objectRadius);638 2.0f*objectRadius); 451 639 #else 452 640 termination += ComputeTerminationMutation(*ray, U, V, -
GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.h
r1997 r2001 47 47 // halton sequence for generatin gmutations of this ray 48 48 VssRay *mRay; 49 int mMutations;50 int mUnsuccessfulMutations;49 short mMutations; 50 short mUnsuccessfulMutations; 51 51 HaltonSequence mHalton; 52 52 float mImportance; 53 53 float mCdf; 54 54 55 Vector3 mutatedOrigin; 56 Vector3 mutatedTermination; 57 55 58 float GetSamplingFactor() const { return mMutations/mImportance; } 56 59 RayEntry() {} … … 59 62 mUnsuccessfulMutations(0), 60 63 mHalton(), 61 mImportance(1.0f) {} 64 mImportance(1.0f) 65 { 66 ResetReverseMutation(); 67 } 68 69 void ResetReverseMutation() { 70 mutatedOrigin = mutatedTermination = Vector3(0,0,0); 71 } 72 bool HasReverseMutation() const { 73 return !(mutatedOrigin == mutatedTermination); 74 } 75 76 void SetReverseMutation(const Vector3 &a, const Vector3 &b) { 77 mutatedOrigin = a; 78 mutatedTermination = b; 79 } 80 62 81 }; 63 82 64 83 65 84 Vector3 … … 90 109 ); 91 110 111 112 bool 113 ComputeReverseMutation( 114 const VssRay &oldRay, 115 const VssRay &newRay, 116 Vector3 &origin, 117 Vector3 &termination 118 ); 119 92 120 RayEntry &GetEntry(const int index) { 93 121 return mRays[(mBufferStart+index)%mRays.size()]; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1999 r2001 1294 1294 Preprocessor::ExportRays(const char *filename, 1295 1295 const VssRayContainer &vssRays, 1296 const int number 1296 const int number, 1297 const bool exportScene 1297 1298 ) 1298 1299 { … … 1309 1310 exporter->SetFilled(); 1310 1311 // $$JB temporarily do not export the scene 1311 if ( 0)1312 if (exportScene) 1312 1313 exporter->ExportScene(mSceneGraph->GetRoot()); 1313 1314 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1996 r2001 123 123 124 124 virtual bool 125 ExportRays(const char *filename, 126 const VssRayContainer &vssRays, 127 const int number 128 ); 125 ExportRays(const char *filename, 126 const VssRayContainer &vssRays, 127 const int number, 128 const bool exportScene = false 129 ); 129 130 130 131 virtual int -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r2000 r2001 652 652 } else 653 653 if (strcmp(curr, "mutation")==0) { 654 655 //mDistributions.push_back(new MutationBasedDistribution(mPreprocessor));656 } 654 // temp matt: still no mutationstrategy! 655 mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 656 } 657 657 658 658 -
GTP/trunk/Lib/Vis/Preprocessing/src/common.cpp
r1634 r2001 115 115 QueryPerformanceCounter(&counter); 116 116 // return in usec 117 return (long) (1000000*counter.QuadPart/(hrFreq.QuadPart)); 117 //return (long) (1000000*counter.QuadPart/(hrFreq.QuadPart)); 118 // $$ 119 // tmp store time in ms 120 return (long) (1000*counter.QuadPart/(hrFreq.QuadPart)); 118 121 } else { 119 122 static struct _timeb mtime; … … 152 155 TimeDiff(long time1,long time2) // in ms 153 156 { 154 const Real clk=1.0e-3f; // ticks per second 157 // const Real clk=1.0e-3f; // ticks per second 158 // $$ tmp store time in ms 159 const Real clk=1.0f; // ticks per second 155 160 long t=time2-time1; 156 161 -
GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
r1974 r2001 15 15 16 16 #SCENE=../data/soda/soda.dat 17 #VIEWCELLS=../data/soda/soda5-viewcells -1000.xml17 #VIEWCELLS=../data/soda/soda5-viewcells.xml 18 18 #VIEWCELLS=../data/soda/soda-viewcells-5000.xml 19 19 #VIEWCELLS=../data/soda/soda5-viewcells-single.xml … … 49 49 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 50 50 -rss_distributions=mutation+object_direction+spatial -view_cells_filter_max_size=1 \ 51 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4e.xml \ 52 -preprocessor_stats=$PREFIX-i-mixed-b1-n4e.log \ 53 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4e.hlog 51 -preprocessor_visibility_file=$PREFIX-i-mixed-b1-n4g.xml \ 52 -preprocessor_stats=$PREFIX-i-mixed-b1-n4g.log \ 53 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4g.hlog 54 55 56 # e - no origin mutation, silh. tm Q=2, reverse samples 57 # f - no origin, q=2, no reverse samples 58 # g - gaussian origin, q=2, reverse samples 59 54 60 55 61 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \
Note: See TracChangeset
for help on using the changeset viewer.