Changeset 1414 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 09/18/06 10:52:24 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r1112 r1414 32 32 mMin = nMin; mMax = nMax; 33 33 } 34 35 // AxisAlignedBox3(const Vector3 ¢er, const float radius):min(center - Vector3(radius)),36 // max(center + Vector3(radius)) {}37 34 38 35 /** initialization to the non existing bounding box -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1408 r1414 808 808 809 809 #ifdef _DEBUG 810 cout << "\n\nobjects=(" << objectsBack.size() << "," << objectsFront.size() << " of " << tData.mNode->mObjects.size() << ")\t area=(" 810 cout << "\n\nobjects=(" << (int)objectsBack.size() << "," << (int)objectsFront.size() << " of " 811 << (int)tData.mNode->mObjects.size() << ")\t area=(" 811 812 << areaLeft << "," << areaRight << ")" << endl; 812 813 cout << "cost= " << minSum << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1379 r1414 1143 1143 "true"); 1144 1144 1145 1146 1145 RegisterOption("MeshKdTree.Termination.minCost", 1147 1146 optInt, … … 1426 1425 "false"); 1427 1426 1428 RegisterOption("ViewCells.pruneEmptyViewCells",1429 optBool,1430 "view_cells_prune_empty=",1431 "false");1432 1433 1427 RegisterOption("ViewCells.processOnlyValidViewCells", 1434 1428 optBool, … … 1436 1430 "false"); 1437 1431 1438 1439 1432 RegisterOption("ViewCells.PostProcess.maxCostRatio", 1440 1433 optFloat, … … 1745 1738 "20"); 1746 1739 1740 RegisterOption("Preprocessor.exportKdTree", 1741 optBool, 1742 "preprocessor_export_kd_tree=", 1743 "false"); 1744 1745 RegisterOption("Preprocessor.loadKdTree", 1746 optBool, 1747 "preprocessor_load_kd_tree=", 1748 "false"); 1749 1750 1747 1751 1748 1752 /************************************************************************************/ -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1387 r1414 1319 1319 if (!stream.is_open()) return false; 1320 1320 1321 // sort objects by their id 1321 1322 std::stable_sort(objects.begin(), objects.end(), ilt); 1322 1323 … … 1324 1325 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1325 1326 1326 //-- compute bounding box 1327 1328 /////////////////////////// 1329 //-- compute bounding box of object space 1327 1330 for (oit = objects.begin(); oit != oit_end; ++ oit) 1328 1331 { 1329 Intersectable *obj = *oit;1330 // compute bounding box of view space1331 mBox.Include(obj->GetBox());1332 } 1333 1334 DEL_PTR(mRoot); // we make a new root1332 const AxisAlignedBox3 box = (*oit)->GetBox(); 1333 mBox.Include(box); 1334 } 1335 1336 // hack: we make a new root 1337 DEL_PTR(mRoot); 1335 1338 1336 1339 KdNode *node = LoadNextNode(stream, NULL, objects); … … 1377 1380 { 1378 1381 EvaluateLeafStats(tData); 1379 //Debug << "l" << endl;1382 cout << "l"; 1380 1383 } 1381 1384 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1405 r1414 580 580 581 581 582 bool Preprocessor::LoadKdTree() 583 { 584 return true; 585 } 586 587 bool Preprocessor::ExportKdTree() 588 { 589 return true; 582 bool Preprocessor::LoadKdTree(const string filename) 583 { 584 mKdTree = new KdTree(); 585 return mKdTree->LoadBinTree(filename.c_str(), mObjects); 586 } 587 588 589 bool Preprocessor::ExportKdTree(const string filename) 590 { 591 return mKdTree->ExportBinTree(filename.c_str()); 590 592 } 591 593 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1381 r1414 120 120 bool ExportSamples(const VssRayContainer &samples) const; 121 121 122 bool LoadKdTree( );123 bool ExportKdTree( );122 bool LoadKdTree(const string filename); 123 bool ExportKdTree(const string filename); 124 124 125 125 /** Get Sample rays of particular type, returns false if this -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1404 r1414 77 77 Environment::GetSingleton()->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio); 78 78 79 Environment::GetSingleton()->GetBoolValue("ViewCells.pruneEmptyViewCells", mPruneEmptyViewCells);80 81 // HACK82 if (0)83 mMinPvsSize = mPruneEmptyViewCells ? 1 : 0;84 else85 mMinPvsSize = 0;86 87 79 Environment::GetSingleton()->GetBoolValue("ViewCells.processOnlyValidViewCells", mOnlyValidViewCells); 88 80 … … 196 188 Debug << "export geometry: " << mExportGeometry << endl; 197 189 Debug << "max pvs ratio: " << mMaxPvsRatio << endl; 198 199 Debug << "prune empty view cells: " << mPruneEmptyViewCells << endl;200 190 201 191 Debug << "process only valid view cells: " << mOnlyValidViewCells << endl; … … 338 328 339 329 long startTime = GetTime(); 340 341 330 cout << "view cell construction: casting " << mInitialSamples << " initial samples ... "; 331 342 332 // cast initial samples 343 333 CastPassSamples(mInitialSamples, mSamplingType, initialSamples); … … 366 356 367 357 ResetViewCells(); 368 Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 369 370 371 //-- optionally export initial view cells 358 if (0) Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 359 360 //-- optionally export initial view cell partition 372 361 if (0) 373 362 { 374 const char filename[] = "view_cells.wrl";375 Exporter *exporter = Exporter::GetExporter(filename );363 const string filename("viewcells.wrl"); 364 Exporter *exporter = Exporter::GetExporter(filename.c_str()); 376 365 377 366 if (exporter) 378 367 { 379 cout << "exporting initial view cells (=leaves) to " << filename << " ... "; 368 cout << "exporting initial view cells (=leaves) to " << filename.c_str() << " ... "; 369 380 370 if (mExportGeometry) 381 371 { … … 399 389 //-- note: guided rays could be used for this task 400 390 401 // time spent after initial construction391 // time spent after construction of the initial partition 402 392 startTime = GetTime(); 403 404 393 const int n = mConstructionSamples; //+initialSamples; 405 394 // should we use directional samples? … … 439 428 440 429 430 #if 0 441 431 //////////////////////////////////////////////// 442 432 //-- get stats after the additional sampling step … … 452 442 453 443 Debug << ss << endl; 454 444 #endif 455 445 456 446 … … 479 469 PostProcess(preprocessor->mObjects, postProcessSamples); 480 470 481 cout << "time needed for post processing (merge) step: " 482 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 483 484 Debug << "time needed for post processing (merge) step: " 485 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 486 471 const float secs = TimeDiff(startTime, GetTime()) * 1e-3f; 472 cout << "post processing (=merge) finished in " << secs << " secs" << endl; 473 474 Debug << "post processing time: " << secs << endl; 487 475 disposeRays(postProcessSamples, outRays); 488 476 489 477 490 ////////////////////////////////////////////////////////////// ///////478 ////////////////////////////////////////////////////////////// 491 479 //-- Evaluation of the resulting view cell partition. 492 480 //-- We cast a number of new samples and measure the render cost … … 2616 2604 } 2617 2605 2618 // view cells already finished before post processing step (i.e. because they were loaded) 2606 // view cells already finished before post processing step, 2607 // i.e., because they were loaded from disc 2619 2608 if (mViewCellsFinished) 2620 2609 { … … 2625 2614 } 2626 2615 2627 ///////////////////////////////////////2628 //-- post processing of bsp view cells2629 2630 2616 int vcSize = 0; 2631 2617 int pvsSize = 0; 2632 2618 2633 //-- merge view cells 2634 2619 2620 /////////////////////// 2621 //-- merge leaves of the view cell hierarchy 2622 2635 2623 cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 2636 2624 long startTime = GetTime(); … … 2748 2736 } 2749 2737 2750 // export bounding boxes2751 if (0 && mExportBboxesForPvs)2752 {2753 char filename[100];2754 Environment::GetSingleton()->GetStringValue("ViewCells.boxesFilename", filename);2755 ExportBoundingBoxes(filename, objects);2756 }2757 2758 2759 2738 return 0; 2760 2739 } … … 3833 3812 const ObjectContainer &objects) 3834 3813 { 3835 Debug << "render time before refine:" << endl;3836 3814 mRenderer->RenderScene(); 3837 3815 SimulationStatistics ss; 3838 3816 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 3839 Debug << ss << endl; 3840 3817 Debug << "render time before refine\n" << ss << endl; 3818 3819 const long startTime = GetTime(); 3841 3820 cout << "Refining the merged view cells ... "; 3842 long startTime = GetTime();3843 3821 3844 3822 // refining the merged view cells … … 3885 3863 else 3886 3864 { 3887 minPvs = mPruneEmptyViewCells ? 1 : 0; 3865 // problem matt: why did I start here from zero? 3866 minPvs = 0; 3888 3867 maxPvs = mMaxPvsSize; 3889 3868 } … … 3904 3883 Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 3905 3884 3906 3907 // should maybe be done here to allow merge working with area or volume 3908 // and to correct the rendering statistics 3885 // should maybe be done here to allow merge working 3886 // with area or volume and to correct the rendering statistics 3909 3887 if (0) FinalizeViewCells(false); 3910 3888 3889 ////////////////////////////////////// 3911 3890 //-- merge the individual view cells 3912 3891 MergeViewCells(postProcessRays, objects); 3913 3892 3914 3915 // only for debugging purpose: test if the subdivision is valid 3916 if (0) TestSubdivision(); 3917 3893 ///////////////////////////////// 3918 3894 //-- refines the merged view cells 3919 3895 if (0) RefineViewCells(postProcessRays, objects); 3920 3896 3921 3897 /////////////////////////////////////////// 3922 3898 //-- render simulation after merge + refine 3923 cout << "\nevaluating bsp view cells render time before compress ... "; 3899 3900 cout << "\nview cells partition render time before compress"; 3924 3901 dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 3925 3902 SimulationStatistics ss; 3926 3903 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 3927 3928 3929 cout << " finished" << endl; 3904 3930 3905 cout << ss << endl; 3931 Debug << ss << endl;3932 3933 3906 3907 3908 /////////////////// 3934 3909 //-- compression 3910 3935 3911 if (ViewCellsTreeConstructed() && mCompressViewCells) 3936 3912 { … … 3960 3936 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); 3961 3937 ExportViewCells(filename, mExportPvs, objects); 3962 }3963 3964 3965 // export bounding boxes3966 if (mExportBboxesForPvs)3967 {3968 char filename[100];3969 Environment::GetSingleton()->GetStringValue("ViewCells.boxesFilename", filename);3970 3971 ExportBoundingBoxes(filename, objects);3972 3938 } 3973 3939 … … 4906 4872 else 4907 4873 { 4908 minPvs = mPruneEmptyViewCells ? 1 : 0; 4874 // problem matt: why did I start here from zero? 4875 minPvs = 0; 4909 4876 maxPvs = mMaxPvsSize; 4910 4877 } … … 4916 4883 4917 4884 4918 // area has to be recomputed4885 // area is not up to date, has to be recomputed 4919 4886 mTotalAreaValid = false; 4920 4887 VssRayContainer postProcessRays; … … 4932 4899 mViewCellsTree->SetRoot(root); 4933 4900 4934 // compute pvs 4901 //////////////////////////////////// 4902 //-- update pvs in the whole hierarchy 4935 4903 ObjectPvs pvs; 4936 4904 UpdatePvsForEvaluation(root, pvs); 4937 4905 4938 4906 4907 /////////////////////////////////////////// 4939 4908 //-- render simulation after merge + refine 4940 cout << "\nevaluating bsp view cells render time before compress ... "; 4909 4910 cout << "\nview cells partition render time before compress"; 4941 4911 dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 4942 4912 SimulationStatistics ss; 4943 4913 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 4944 4945 4946 cout << " finished" << endl;4947 4914 cout << ss << endl; 4948 Debug << ss << endl; 4949 4950 4915 4916 /////////////////////// 4951 4917 //-- compression 4952 4918 … … 4962 4928 } 4963 4929 4964 // compute final meshes and volume / area 4930 ///////////////////////////////////// 4931 //-- compute final meshes and volume / area 4965 4932 if (1) FinalizeViewCells(true); 4966 4933 4967 // write view cells to disc 4934 4935 // write out view cells 4968 4936 if (mExportViewCells) 4969 4937 { … … 4972 4940 ExportViewCells(filename, mExportPvs, objects); 4973 4941 } 4974 4975 4942 4976 4943 return 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1294 r1414 614 614 /// the corresponding view cell tree holding the logical description of view cells 615 615 ViewCellsTree *mViewCellsTree; 616 /// if empty view cells should be pruned (i.e., invalidated) from this point on 617 bool mPruneEmptyViewCells; 618 616 619 617 /// if the values in the view cell leaves and the interiors are up to date 620 618 /// this is meant for lazy storing of the pvs, where only a scalar indicating -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1404 r1414 593 593 cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 594 594 595 ExportRays("kdtree.x3d", mVssRays, 10);595 if (0) ExportRays("kdtree.x3d", mVssRays, 10); 596 596 597 597 if (0) … … 692 692 if (0) 693 693 { 694 VssRayContainer viewCellRays;695 696 const int numRays = mViewCellsManager->GetVisualizationSamples();697 vssTree->CollectRays(viewCellRays, numRays);698 } 699 700 //-- render simulation after merge 701 cout << "\nevaluating bsp view cells render time after sampling ... ";702 Debug << "\nStatistics after sampling: " << endl;694 VssRayContainer viewCellRays; 695 // compute rays used for view cells construction 696 const int numRays = mViewCellsManager->GetVisualizationSamples(); 697 vssTree->CollectRays(viewCellRays, numRays); 698 } 699 700 701 ////////////////////////////////// 702 //-- render simulation after 703 703 704 704 mRenderSimulator->RenderScene(); 705 705 SimulationStatistics ss; 706 706 mRenderSimulator->GetStatistics(ss); 707 708 cout << " finished" << endl; 709 cout << ss << endl; 710 Debug << ss << endl; 707 Debug << "\nFinal view cells partition render time\n" << ss << endl; 708 cout << "\nFinal view cells partition render time\n" << ss << endl; 711 709 712 710 delete vssTree; -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1408 r1414 180 180 Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree); 181 181 182 const string kdtreename("kd.bin.gz"); 183 182 184 if (!loadKdTree) 183 185 { 184 //-- build kd tree from scene geometry186 //-- build new kd tree from scene geometry 185 187 preprocessor->BuildKdTree(); 186 188 preprocessor->KdTreeStatistics(cout); … … 188 190 else 189 191 { 192 const long startTime = GetTime(); 190 193 cout << "loading kd tree ... "; 194 195 if (!preprocessor->LoadKdTree(kdtreename)) 196 { 197 cout << "error loading kd tree with filename " << kdtreename << endl; 198 Cleanup(); 199 exit(1); 200 } 201 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 202 203 if (0) 204 { 205 Exporter *exporter = Exporter::GetExporter("dummykd.x3d"); 206 207 if (exporter) 208 { 209 exporter->ExportKdTree(*preprocessor->mKdTree, true); 210 delete exporter; 211 } 212 } 213 } 214 215 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree); 216 217 if (exportKdTree) 218 { 191 219 const long startTime = GetTime(); 192 preprocessor->mKdTree->LoadBinTree("kd.bin.gz", preprocessor->mObjects);193 194 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;195 }196 197 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree);198 199 if (exportKdTree)200 {201 220 cout << "exporting kd tree ... "; 202 preprocessor->mKdTree->ExportBinTree("kd.bin.gz"); 203 cout << "finished" << endl; 221 if (!preprocessor->ExportKdTree(kdtreename)) 222 { 223 cout << " error exporting kd tree with filename " << kdtreename << endl; 224 } 225 else 226 { 227 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 228 } 204 229 } 205 230
Note: See TracChangeset
for help on using the changeset viewer.