Changeset 979
- Timestamp:
- 05/24/06 08:47:19 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r975 r979 16 16 #include "RssPreprocessor.h" 17 17 #include "BoundingBoxConverter.h" 18 18 #include "GlRenderer.h" 19 19 20 20 … … 631 631 632 632 633 634 ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename, 635 ObjectContainer *objects, 636 Environment *env, 637 const bool finalizeViewCells, 638 BoundingBoxConverter *bconverter) 639 640 { 641 ViewCellsParser parser; 642 643 ViewCellsManager *vm = NULL; 644 645 if (parser.ParseFile(filename, &vm, objects, bconverter, env)) 646 { 647 long startTime = GetTime(); 648 649 //vm->PrepareLoadedViewCells(); 650 vm->ResetViewCells(); 651 652 vm->mViewCellsFinished = true; 653 vm->mMaxPvsSize = (int)objects->size(); 654 655 // create the meshes and compute volumes 656 if (finalizeViewCells) 657 { 658 vm->FinalizeViewCells(true); 659 vm->mViewCellsTree->AssignRandomColors(); 660 } 661 662 Debug << (int)vm->mViewCells.size() << " view cells loaded in " 663 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 664 } 665 else 666 { 667 Debug << "Error: loading view cells failed!" << endl; 668 DEL_PTR(vm); 669 } 670 671 return vm; 672 } 673 674 675 bool VspBspViewCellsManager::ExportViewCells(const string filename, 676 const bool exportPvs, 677 const ObjectContainer &objects) 678 { 679 cout << "exporting view cells to xml ... "; 680 681 #if ZIPPED_VIEWCELLS 682 ogzstream stream(filename.c_str()); 683 cout << "!!!!!!!!!!!!!!!!!!!!!!" << endl; 684 #else 685 std::ofstream stream(filename.c_str()); 686 #endif 687 688 // for output we need unique ids for each view cell 689 CreateUniqueViewCellIds(); 690 691 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 692 stream << "<VisibilitySolution>" << endl; 693 694 //-- the view space bounding box 695 stream << "<ViewSpaceBox" 696 << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\"" 697 << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 698 699 700 //-- export bounding boxes 701 stream << "<BoundingBoxes>" << endl; 702 703 ObjectContainer::const_iterator oit, oit_end = objects.end(); 704 705 for (oit = objects.begin(); oit != oit_end; ++ oit) 706 { 707 MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit); 708 const AxisAlignedBox3 box = mi->GetBox(); 709 710 //-- the bounding boxes 711 stream << "<BoundingBox" << " id=\"" << mi->GetId() << "\"" 712 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 713 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 714 } 715 716 stream << "</BoundingBoxes>" << endl; 717 718 719 //-- export the view cells and the pvs 720 stream << "<HierarchyType name=\"vspBspTree\" />" << endl; 721 722 const int numViewCells = mCurrentViewCellsStats.viewCells; 723 724 stream << "<ViewCells number=\"" << numViewCells << "\" >" << endl; 725 726 mViewCellsTree->Export(stream, exportPvs); 727 728 stream << "</ViewCells>" << endl; 729 730 731 //-- export the spatial hierarchy 732 733 // the type of the view cells hierarchy 734 stream << "<Hierarchy>" << endl; 735 mVspBspTree->Export(stream); 736 stream << endl << "</Hierarchy>" << endl; 737 738 stream << "</VisibilitySolution>" << endl; 739 740 741 stream.close(); 742 cout << "finished" << endl; 743 744 return true; 745 } 746 747 633 748 void ViewCellsManager::EvalViewCellHistogramForPvsSize(const string filename, 634 749 const int nViewCells) … … 660 775 661 776 if (!stepSize) stepSize = 1; 662 Debug << "stepsize: " << stepSize << endl; 777 778 Debug << "stepsize: " << stepSize << endl; 663 779 cout << "stepsize: " << stepSize << endl; 664 780 … … 4589 4705 4590 4706 4707 void VspBspViewCellsManager::VisualizeWithFromPointQueries() 4708 { 4709 int numSamples; 4710 environment->GetIntValue("RenderSampler.samples", numSamples); 4711 cout << "samples" << numSamples << endl; 4712 4713 vector<RenderCostSample> samples; 4714 4715 if (!preprocessor->GetRenderer()) 4716 return; 4717 4718 // doing the query 4719 long startTime = GetTime(); 4720 cout << "starting sampling of render cost ... "; 4721 4722 preprocessor->GetRenderer()->SampleRenderCost(numSamples, samples); 4723 4724 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 4725 4726 4727 // counting the pvss 4728 vector<RenderCostSample>::const_iterator rit, rit_end = samples.end(); 4729 4730 for (rit = samples.begin(); rit != rit_end; ++ rit) 4731 { 4732 RenderCostSample sample = *rit; 4733 //ViewCell *vc = GetViewCell(sample.)pos; 4734 } 4735 } 4736 4737 4591 4738 void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 4592 4739 ViewCell *vc, … … 4702 4849 // put mesh into mesh container so we can savely delete it 4703 4850 mMeshContainer.push_back(mesh); 4704 }4705 4706 4707 ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename,4708 ObjectContainer *objects,4709 Environment *env,4710 const bool finalizeViewCells,4711 BoundingBoxConverter *bconverter)4712 4713 {4714 ViewCellsParser parser;4715 4716 ViewCellsManager *vm = NULL;4717 4718 if (parser.ParseFile(filename, &vm, objects, bconverter, env))4719 {4720 long startTime = GetTime();4721 4722 //vm->PrepareLoadedViewCells();4723 vm->ResetViewCells();4724 4725 vm->mViewCellsFinished = true;4726 vm->mMaxPvsSize = (int)objects->size();4727 4728 // create the meshes and compute volumes4729 if (finalizeViewCells)4730 {4731 vm->FinalizeViewCells(true);4732 vm->mViewCellsTree->AssignRandomColors();4733 }4734 4735 Debug << (int)vm->mViewCells.size() << " view cells loaded in "4736 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;4737 }4738 else4739 {4740 Debug << "Error: loading view cells failed!" << endl;4741 DEL_PTR(vm);4742 }4743 4744 return vm;4745 }4746 4747 4748 bool VspBspViewCellsManager::ExportViewCells(const string filename,4749 const bool exportPvs,4750 const ObjectContainer &objects)4751 {4752 cout << "exporting view cells to xml ... ";4753 4754 #if ZIPPED_VIEWCELLS4755 ogzstream stream(filename.c_str());4756 cout << "!!!!!!!!!!!!!!!!!!!!!!" << endl;4757 #else4758 std::ofstream stream(filename.c_str());4759 #endif4760 4761 // for output we need unique ids for each view cell4762 CreateUniqueViewCellIds();4763 4764 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl;4765 stream << "<VisibilitySolution>" << endl;4766 4767 //-- the view space bounding box4768 stream << "<ViewSpaceBox"4769 << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\""4770 << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl;4771 4772 4773 //-- export bounding boxes4774 stream << "<BoundingBoxes>" << endl;4775 4776 ObjectContainer::const_iterator oit, oit_end = objects.end();4777 4778 for (oit = objects.begin(); oit != oit_end; ++ oit)4779 {4780 MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit);4781 const AxisAlignedBox3 box = mi->GetBox();4782 4783 //-- the bounding boxes4784 stream << "<BoundingBox" << " id=\"" << mi->GetId() << "\""4785 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""4786 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;4787 }4788 4789 stream << "</BoundingBoxes>" << endl;4790 4791 4792 //-- export the view cells and the pvs4793 stream << "<HierarchyType name=\"vspBspTree\" />" << endl;4794 4795 const int numViewCells = mCurrentViewCellsStats.viewCells;4796 4797 stream << "<ViewCells number=\"" << numViewCells << "\" >" << endl;4798 4799 mViewCellsTree->Export(stream, exportPvs);4800 4801 stream << "</ViewCells>" << endl;4802 4803 4804 //-- export the spatial hierarchy4805 4806 // the type of the view cells hierarchy4807 stream << "<Hierarchy>" << endl;4808 mVspBspTree->Export(stream);4809 stream << endl << "</Hierarchy>" << endl;4810 4811 stream << "</VisibilitySolution>" << endl;4812 4813 4814 stream.close();4815 cout << "finished" << endl;4816 4817 return true;4818 4851 } 4819 4852 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r955 r979 462 462 AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const; 463 463 464 464 465 protected: 465 466 /** Exports bounding boxes as xml stream … … 552 553 553 554 555 //////////////////////////////////////////////// 554 556 555 557 /// if bounding boxes should also be exported … … 846 848 847 849 virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) {}; 850 851 848 852 protected: 849 853 … … 960 964 961 965 962 // HACK966 /// HACK for testing visibility filter functionality 963 967 void TestFilter(const ObjectContainer &objects); 964 968 969 970 /** Visualization of the pvs difference to exact visubility using 971 from point queries. 972 */ 973 void VisualizeWithFromPointQueries(); 965 974 966 975
Note: See TracChangeset
for help on using the changeset viewer.