Changeset 2048 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 01/24/07 01:33:39 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2043 r2048 352 352 353 353 354 bool ViewCellsManager::GenerateRandomViewCells(vector<ViewCellPoints *> &viewCells,354 /*bool ViewCellsManager::GenerateRandomViewCells(vector<ViewCellPoints *> &viewCells, 355 355 const int nViewCells, 356 356 const int nViewPoints) … … 369 369 ViewCellContainer::const_iterator vit, vit_end = rViewCells.end(); 370 370 371 for (vit = rViewCells.begin(); vit != vit_end; ++ vit) 371 int i = 0; 372 for (vit = rViewCells.begin(); vit != vit_end; ++ vit, ++ i) 372 373 { 373 374 ViewCell *vc = *vit; … … 379 380 380 381 SimpleRayContainer viewPoints; 382 cout << "processing view cell " << i << endl; 381 383 // generate random view points 382 384 GenerateViewPoints(vc, nViewPoints, viewPoints); … … 388 390 vcPts->second.push_back(*pit); 389 391 } 392 } 393 394 return true; 395 }*/ 396 397 398 bool ViewCellsManager::GenerateRandomViewCells(vector<ViewCellPoints *> &viewCells, 399 const int nViewCells, 400 const int nViewPoints) 401 { 402 ViewCellContainer rViewCells; 403 404 cout << "generating " << nViewCells << " random view cells" << endl; 405 ///GenerateRandomViewCells(rViewCells, nViewCells); 406 407 //cout << "finished" << endl; 408 409 //for (int i = 0; i < viewCells.size(); ++ i) 410 // cout << "vc " << i << ": " << viewCells[i]->GetId() << endl; 411 412 cout << "generating " << nViewPoints << " view points per view cell" << endl; 413 414 int generatedViewCells = 0; 415 int i = 0; 416 while (generatedViewCells < nViewCells) 417 { 418 ++ i; 419 420 const int idx = (int)RandomValue(0.0f, (float)mViewCells.size() - 0.5f); 421 422 ViewCell *viewCell = GetViewCell(idx); 423 424 cout << "testing view cell: " << viewCell->GetId() << endl; 425 426 if (!viewCell->Mailed()) 427 { 428 viewCell->Mail(); 429 430 SimpleRayContainer viewPoints; 431 cout<<"here18"<<endl; 432 // generate random view points 433 if (IsValidViewSpace(viewCell) && 434 GenerateViewPoints(viewCell, nViewPoints, viewPoints)) 435 {cout << "here99" << endl; 436 Debug << "vc: " << viewCell->GetId() << endl; 437 438 ViewCellPoints *vcPts = new ViewCellPoints(); 439 viewCells.push_back(vcPts); 440 441 // valid view cell found 442 vcPts->first = viewCell; 443 444 // generate view points 445 ++ generatedViewCells; 446 447 SimpleRayContainer::const_iterator pit, pit_end = viewPoints.end(); 448 449 for (pit = viewPoints.begin(); pit != pit_end; ++ pit) 450 { 451 Debug << "vp: " << (*pit) << endl; 452 vcPts->second.push_back(*pit); 453 } 454 cout << "view cell " << generatedViewCells << " generated: " << viewCell->GetId() << endl; 455 } 456 else 457 { 458 cout << "error: invalid view cell " << generatedViewCells << " with id " << viewCell->GetId() << endl; 459 } 460 } 461 462 if (i > nViewCells * 1000000) // safety 463 { 464 cout << "big error" << endl; 465 break; 466 } 467 cout << "processd view cells " << generatedViewCells << " of " << nViewCells << endl << endl; 390 468 } 391 469 … … 437 515 438 516 517 bool ViewCellsManager::ImportRandomViewCells(const string &filename) 518 { 519 return ImportRandomViewCells(filename, mViewCellPoints); 520 } 521 522 439 523 bool ViewCellsManager::GenerateViewPoints(ViewCell *viewCell, 440 524 const int numViewPoints, … … 445 529 int i = 0; 446 530 531 cout << "generating view points for view cell " << viewCell->GetId() << endl; 532 447 533 while (generatedPts < numViewPoints) 448 534 { … … 450 536 451 537 if (GenerateViewPoint(viewCell, pt)) 452 { 538 {cout<<"here4"<<endl; 453 539 ++ generatedPts; 540 cout << "generated view point " << generatedPts << endl; 454 541 viewPoints.push_back(pt); 455 542 } 456 543 457 544 // savety criterium 458 if (++ i > numViewPoints + 100000)545 if (++ i > numViewPoints * 3) 459 546 { 460 547 return false; … … 462 549 } 463 550 551 cout << "view point generation finished" << endl; 552 464 553 return true; 554 } 555 556 557 bool ViewCellsManager::ExportRandomViewCells(const string &filename) 558 { 559 const int numViewCells = 100; 560 const int numViewPoints = 10; 561 562 preprocessor->mViewCellsManager-> 563 GenerateRandomViewCells(mViewCellPoints, numViewCells, numViewPoints); 564 565 //cout << "exporting random view cells" << endl; 566 return preprocessor->mViewCellsManager->ExportRandomViewCells(filename, mViewCellPoints); 465 567 } 466 568 … … 473 575 int tries = 0; 474 576 Vector3 viewPoint, direction; 475 const int maxTries = 10 0;577 const int maxTries = 10; 476 578 477 579 while (1) … … 499 601 //halton.GenerateNext(); 500 602 501 //cout << "vp: " << viewPoint << endl;502 //cout << "dir: " << direction << endl;503 504 603 ViewCell *v = GetViewCell(viewPoint); 505 604 506 605 if (v && v->GetValid()) 507 606 { 508 //cout << "validating view point" << endl;509 510 607 mPreprocessor->GetRenderer()->mViewPoint = viewPoint; 511 608 mPreprocessor->GetRenderer()->mViewDirection = direction; 512 // preprocessor->renderer->EvalPvsStat();513 cout<<"*********hgere55"<<endl; 514 if ( preprocessor->renderer->ValidViewPoint())609 //mPreprocessor->GetRenderer()->EvalPvsStat(); 610 611 if (mPreprocessor->GetRenderer()->ValidViewPoint()) 515 612 { 516 cout << "view point valid "<< endl;613 cout << "view point valid " << viewPoint << " " << direction << endl; 517 614 break; 518 615 } 519 cout<<"here33"<<endl;616 520 617 } 521 618 … … 526 623 // cout << "error!" << endl; 527 624 if (++ tries > maxTries) 625 { 626 cerr << "error: no view point computed" << endl; 528 627 return false; 628 } 529 629 } 530 630 … … 584 684 else 585 685 { 586 cout << "error: invalid view cell " << generatedViewCells << " generated:" << viewCell->GetId() << endl;686 cout << "error: invalid view cell " << generatedViewCells << " with id " << viewCell->GetId() << endl; 587 687 } 588 688 } … … 615 715 616 716 DEL_PTR(mMixtureDistribution); 717 718 CLEAR_CONTAINER(mViewCellPoints); 617 719 } 618 720 … … 1005 1107 vm->FinalizeViewCells(true); 1006 1108 // vm->mViewCellsTree->AssignRandomColors(); 1109 } 1110 1111 if (0) 1112 { 1113 cout << "=============== " << vm->GetViewCellById(5318)->GetPvs().GetSize() << "========" << endl; 1007 1114 } 1008 1115 … … 2609 2716 2610 2717 2611 2612 2613 2718 int ViewCellsManager::GetNumViewCells() const 2614 2719 { … … 3540 3645 } 3541 3646 3647 3542 3648 void ViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 3543 3649 {
Note: See TracChangeset
for help on using the changeset viewer.