Changeset 991 for GTP/trunk/Lib/Vis
- Timestamp:
- 05/29/06 18:54:02 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj
r938 r991 80 80 <Tool 81 81 Name="VCLinkerTool" 82 AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib Qt OpenGL4.lib QtCored4.lib QtGuid4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib"82 AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtGuid4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib QtCore4.lib QtOpenGL4.lib" 83 83 OutputFile="$(OutDir)/Preprocessor.exe" 84 84 LinkIncremental="1" -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r975 r991 1697 1697 "0.02"); 1698 1698 1699 1699 RegisterOption("Preprocessor.histogram.maxValue", 1700 optInt, 1701 "preprocessor_histogram_max_value=", 1702 "1000"); 1703 1704 RegisterOption("Preprocessor.histogram.intervals", 1705 optInt, 1706 "preprocessor_histogram_intervals=", 1707 "20"); 1700 1708 1701 1709 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r931 r991 449 449 { 450 450 mViewCellsManager->GetViewPoint(mViewPoint); 451 cout<<mViewPoint<<endl; 451 sample.mPosition = mViewPoint; 452 453 cout << mViewPoint << endl; 452 454 453 455 // take a render cost sample by rendering a cube … … 573 575 vector<RenderCostSample> &samples 574 576 ) 575 { 577 {cout << "here1" << endl; 576 578 makeCurrent(); 577 579 … … 586 588 int i; 587 589 int numQ = 500; 588 589 if (mOcclusionQueries.size() < numQ) { 590 cout<<"allocating occ queries..."<<endl; 591 592 numQ; 593 unsigned int *queries = new unsigned int[numQ]; 594 for (i=0; i < numQ; i++) 595 queries[i] = 111; 596 597 glGenOcclusionQueriesNV(numQ, queries); 598 599 mOcclusionQueries.resize(numQ); 600 601 for (i=0; i < numQ; i++) 602 mOcclusionQueries[i] = queries[i]; 603 604 delete queries; 605 } 606 607 for (i=0; i < n; i++) 608 EvalRenderCostSample( 609 samples[i] 610 ); 590 591 cout << "here2988" << endl; 592 593 if (mOcclusionQueries.size() < numQ) 594 { 595 cout << "allocating occ queries..." << endl; 596 597 unsigned int *queries = new unsigned int[numQ]; 598 599 // matt: ? 600 for (i = 0; i < numQ; ++ i) 601 queries[i] = 111; 602 603 glGenOcclusionQueriesNV(numQ, queries); 604 605 mOcclusionQueries.resize(numQ); 606 607 for (i=0; i < numQ; ++ i) 608 { 609 mOcclusionQueries[i] = queries[i]; 610 } 611 612 DEL_PTR(queries); 613 } 614 615 for (i=0; i < n; ++ i) 616 { 617 cout << i << " "; 618 EvalRenderCostSample(samples[i]); 619 } 611 620 612 621 doneCurrent(); -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r884 r991 63 63 } 64 64 65 Vector3 mPosition; 66 65 67 // visible object from the given point 66 68 int mVisibleObjects; -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r878 r991 601 601 602 602 603 Mesh *Create Box(const AxisAlignedBox3 &box)603 Mesh *CreateMeshFromBox(const AxisAlignedBox3 &box) 604 604 { 605 605 Mesh *mesh = new Mesh; -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r878 r991 182 182 } 183 183 184 friend Mesh *CreateBox(const AxisAlignedBox3 &box); 184 /** Creates a mesh from a axis aligned bounding box 185 */ 186 friend Mesh *CreateMeshFromBox(const AxisAlignedBox3 &box); 185 187 }; 186 188 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r944 r991 41 41 const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 42 42 AxisAlignedBox3 box(pt2, pt2 + boxSize); 43 Mesh *mesh = Create Box(box);43 Mesh *mesh = CreateMeshFromBox(box); 44 44 45 45 mesh->Preprocess(); … … 60 60 Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 61 61 AxisAlignedBox3 box(pt2, pt2 + boxSize); 62 Mesh *mesh = Create Box(box);62 Mesh *mesh = CreateMeshFromBox(box); 63 63 64 64 mesh->Preprocess(); … … 78 78 Vector3 boxSize = sceneBox.Size() * Vector3(0.005, 0.02, 0.005); 79 79 AxisAlignedBox3 box(pt2 + 0.1, pt2 + boxSize); 80 Mesh *mesh = Create Box(box);80 Mesh *mesh = CreateMeshFromBox(box); 81 81 82 82 mesh->Preprocess(); -
GTP/trunk/Lib/Vis/Preprocessing/src/RenderSampler.cpp
r897 r991 9 9 { 10 10 environment->GetIntValue("RenderSampler.samples", mSamples); 11 cout <<"mspamples"<<mSamples<<endl;11 cout << "number of render samples: " << mSamples << endl; 12 12 } 13 13 … … 15 15 RenderSampler::ComputeVisibility() 16 16 { 17 long startTime = GetTime(); 18 19 int histoMaxVal = 0; 20 int histoIntervals = 0; 21 22 environment->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 23 environment->GetIntValue("Preprocessor.histogram.intervals", histoIntervals); 24 25 const int intervals = histoIntervals; 26 27 cout << "starting sampling of render cost ... "; 28 29 vector<RenderCostSample> samples; 17 30 18 cout<<"HERE I WAS!\n"; 31 if (renderer) 32 {cout << "here18 " << mSamples << endl; 33 renderer->SampleRenderCost(mSamples, samples); 34 } 19 35 20 vector<RenderCostSample> samples; 21 22 if (renderer) 23 renderer->SampleRenderCost( 24 mSamples, 25 samples 26 ); 36 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 27 37 28 38 29 // compute histogram from the samples 30 int bins = 100; 31 int maxPvs = 0; 39 //-- Evaluate properties 40 32 41 33 vector<int> histogram(bins); 42 //-- compute histogram from the samples 43 int avgPvs = 0; 44 int maxPvs = 0; 45 46 vector<int> histogram(intervals); 34 47 35 int i; 36 for (i = 0; i < bins; i++) 37 histogram[i] = 0; 48 int i; 49 50 /// initialise histogram 51 for (i = 0; i < intervals; ++ i) 52 { 53 histogram[i] = 0; 54 } 55 56 57 58 for (i = 0; i < mSamples; ++ i) 59 { 60 if (samples[i].mVisibleObjects > maxPvs) 61 { 62 maxPvs = samples[i].mVisibleObjects; 63 } 64 65 avgPvs += samples[i].mVisibleObjects; 66 } 67 68 // sometimes need need to unifiy maximum pvs to compare with other method's histograms 69 // => choose histoMaxPvs accordingly (higher than all pvsss) 70 const int maxVal = max(histoMaxVal, maxPvs); 71 72 for (i = 0; i < mSamples; ++ i) 73 { 74 const int bin = (samples[i].mVisibleObjects * intervals) / maxVal; 75 76 ++ histogram[bin]; 77 } 78 79 80 //-- output the histogram 81 82 const string filename("fromPointHisto.log"); 83 std::ofstream outstream; 84 outstream.open(filename.c_str()); 85 86 87 88 Debug << "****************************************" << endl; 89 Debug << "From point queries: " << endl; 90 91 for (i = 0; i < intervals; ++ i) 92 { 93 outstream << "#Pass\n" << i << endl; 94 outstream << "#Pvs\n" << histogram[i] << endl; 95 //cout << histogram[i] << endl; 96 } 97 98 outstream.close(); 99 100 avgPvs /= mSamples; 101 102 Debug << "max pvs: " << maxPvs << endl; 103 Debug << "avg pvs: " << avgPvs << endl; 38 104 39 for (i = 0; i < mSamples; i++) { 40 if (samples[i].mVisibleObjects > maxPvs) 41 maxPvs = samples[i].mVisibleObjects; 42 } 43 44 for (i = 0; i < mSamples; i++) { 45 int bin = (samples[i].mVisibleObjects*bins)/maxPvs; 46 histogram[bin]++; 47 } 48 49 // output the histogram 50 for (i = 0; i < bins; i++) { 51 cout<<histogram[i]<<endl; 52 } 53 54 55 return true; 105 return true; 56 106 } 57 107 108 109 58 110 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r979 r991 566 566 maxRenderCost = viewCells.back()->GetRenderCost(); 567 567 568 Debug << "histogram minrc: " << minRenderCost << " maxrc: " << maxRenderCost << endl; 569 570 const int intervals = min(50, (int)viewCells.size()); 568 Debug << "histogram min rc: " << minRenderCost << " max rc: " << maxRenderCost << endl; 569 570 571 const int intervals = min(20, (int)viewCells.size()); 571 572 572 573 const float range = maxRenderCost - minRenderCost; … … 614 615 const float volRatioDif = volDif / totalVol; 615 616 616 outstream << "#Pass\n" << j << endl;617 outstream << "#Pass\n" << j ++ << endl; 617 618 outstream << "#RenderCostRatio\n" << rcRatio << endl; 618 619 outstream << "#WeightedCost\n" << currentRenderCost / totalVol << endl; … … 624 625 // increase current render cost 625 626 currentRenderCost += stepSize; 626 ++ j;627 627 } 628 628 … … 763 763 maxPvsSize = viewCells.back()->GetPvs().GetSize(); 764 764 minPvsSize = 0; 765 // hack: normalize pvs size 765 766 maxPvsSize = 1200; 766 767 minPvsSize = 0; … … 768 769 769 770 Debug << "histogram minpvssize: " << minPvsSize << " maxpvssize: " << maxPvsSize << endl; 771 770 772 771 773 const int intervals = min(20, (int)viewCells.size()); … … 826 828 currentPvsSize += stepSize; 827 829 } 830 828 831 outstream.close(); 829 832 } … … 902 905 cout << "compute new statistics ... "; 903 906 904 /*Debug << "*******+" << endl;905 float overall = 0;906 stable_sort(leaves.begin(), leaves.end(), ViewCell::SmallerPvs);907 for (int i = 0; i < leaves.size(); ++ i)908 {909 overall += leaves[i]->GetPvs().GetSize();910 Debug << "i " << i << " !size: " << leaves[i]->GetPvs().GetSize() << " vol: " << leaves[i]->GetVolume() << " overall " << overall << endl;911 912 }913 */914 907 915 908 //-- propagate pvs or pvs size information … … 1242 1235 int maxPvsSize) const 1243 1236 { 1244 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1245 1246 for (it = mViewCells.begin(); it != it_end; ++ it) { 1247 SetValidity(*it, minPvsSize, maxPvsSize); 1248 } 1237 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1238 1239 1240 for (it = mViewCells.begin(); it != it_end; ++ it) 1241 { 1242 SetValidity(*it, minPvsSize, maxPvsSize); 1243 } 1249 1244 } 1250 1245 … … 1261 1256 1262 1257 for (int i=0; i < mViewCells.size(); i++) 1263 mViewCells[i]->SetValid(i >= start && i <= end); 1264 } 1265 1266 int 1267 ViewCellsManager::CountValidViewcells() const 1268 { 1269 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1270 int valid = 0; 1271 for (it = mViewCells.begin(); it != it_end; ++ it) { 1272 if ((*it)->GetValid()) 1273 valid ++; 1258 { 1259 mViewCells[i]->SetValid(i >= start && i <= end); 1260 1274 1261 } 1275 return valid; 1262 } 1263 1264 int ViewCellsManager::CountValidViewcells() const 1265 { 1266 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1267 int valid = 0; 1268 1269 for (it = mViewCells.begin(); it != it_end; ++ it) 1270 { 1271 if ((*it)->GetValid()) 1272 ++ valid; 1273 } 1274 1275 return valid; 1276 1276 } 1277 1277 … … 4708 4708 { 4709 4709 int numSamples; 4710 4710 4711 environment->GetIntValue("RenderSampler.samples", numSamples); 4711 4712 cout << "samples" << numSamples << endl; … … 4716 4717 return; 4717 4718 4718 // doing the query4719 //start the from point queries 4719 4720 long startTime = GetTime(); 4720 4721 cout << "starting sampling of render cost ... "; … … 4728 4729 vector<RenderCostSample>::const_iterator rit, rit_end = samples.end(); 4729 4730 4731 //std::map<ViewCell *, ObjectPvs> sampleMap; 4732 4730 4733 for (rit = samples.begin(); rit != rit_end; ++ rit) 4731 4734 { 4732 4735 RenderCostSample sample = *rit; 4733 //ViewCell *vc = GetViewCell(sample.)pos; 4736 4737 ViewCell *vc = GetViewCell(sample.mPosition); 4738 4739 AxisAlignedBox3 box(sample.mPosition - Vector3(1, 1, 1), sample.mPosition + Vector3(1, 1, 1)); 4740 4741 Mesh *hMesh = CreateMeshFromBox(box); 4742 4743 DEL_PTR(hMesh); 4744 #if 0 4745 if (!sampleMap.find(vc)) 4746 sampleMap.insert(vc, sample.mVisibleObjects); 4747 else 4748 sampleMap[vc].Merge(Merge(sample.mVisibleObjects); 4749 #endif 4734 4750 } 4735 4751 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r979 r991 973 973 void VisualizeWithFromPointQueries(); 974 974 975 /** Evaluate from point queries for the current scene. 976 */ 977 void EvalFromPointQueries(); 978 975 979 976 980 /// the view space partition BSP tree. -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r878 r991 28 28 int 29 29 main(int argc, char **argv) 30 { 31 30 {QApplication *app = new QApplication(argc, argv); 31 32 cout << "here222237" << endl; 32 33 //Now just call this function at the start of your program and if you're 33 34 //compiling in debug mode (F5), any leaks will be displayed in the Output … … 38 39 _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 39 40 _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR); 40 41 Debug.open("debug.log"); 41 cout << "here3" << endl; 42 Debug.open("debug.log");cout << "here2" << endl; 42 43 environment = new Environment; 44 cout << "here122223" << endl; cout.flush(); 43 45 environment->Parse(argc, argv, USE_EXE_PATH); 44 46 MeshKdTree::ParseEnvironment(); 45 47 cout << "here222283" << endl; 46 48 char buff[128]; 47 49 environment->GetStringValue("Preprocessor.type", buff); … … 49 51 50 52 Preprocessor *p; 51 53 cout << "here22223" << endl; 52 54 if (preprocessorType == "vss") 55 {cout << "here223" << endl; 53 56 p = new VssPreprocessor(); 57 } 54 58 else 55 59 if (preprocessorType == "rss") … … 63 67 else 64 68 if (preprocessorType == "render") 69 { 70 cout << "here23" << endl; 65 71 p = new RenderSampler(); 72 } 66 73 else { 67 74 cerr<<"Unknown preprocessor type"<<endl; … … 70 77 } 71 78 72 73 QApplication *app = NULL;79 80 //QApplication *app = NULL; 74 81 75 82 if (p->mUseGlRenderer || p->mUseGlDebugger) { 83 cout << "here1111" << endl; 76 84 // create a qt application first (must be created before any opengl widget... 77 app = new QApplication(argc, argv);78 85 //app = new QApplication(argc, argv); 86 cout << "here1112" << endl; 79 87 if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 88 cout << "here1133" << endl;cout.flush(); 80 89 QMessageBox::information(0, "OpenGL pbuffers", 81 90 "This system does not support OpenGL/pbuffers.", … … 83 92 return -1; 84 93 } 94 cout << "here1119" << endl; 85 95 } 86 96 cout << "here1123" << endl; 87 97 preprocessor = p; 88 98 … … 93 103 p->BuildKdTree(); 94 104 p->KdTreeStatistics(cout); 95 105 cout << "here1199" << endl; 96 106 // parse view cells related options 97 107 p->PrepareViewCells(); 98 108 99 109 cout << "here1117" << endl; 100 110 // create a preprocessor thread 101 111 PreprocessorThread *pt = new PreprocessorThread(p, app); … … 106 116 p->Export(filename + "-kdtree.x3d", false, true, false); 107 117 } 108 118 cout << "here1118" << endl; 109 119 if (p->mUseGlRenderer) { 110 120 cout << "here1114" << endl; 111 121 rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 112 122 // renderer->resize(640, 480); 123 cout << "here1115" << endl; 113 124 rendererWidget->resize(640, 480); 114 125 rendererWidget->show(); 115 126 cout << "here1113" << endl; 116 127 if (p->GetRenderer()) { 117 128
Note: See TracChangeset
for help on using the changeset viewer.