Changeset 859
- Timestamp:
- 04/28/06 12:23:14 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r850 r859 25 25 // Constructors. 26 26 AxisAlignedBox3() { } 27 27 28 AxisAlignedBox3(const Vector3 &nMin, const Vector3 &nMax) 28 29 { -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r850 r859 1036 1036 } 1037 1037 1038 /** 1039 Input scene filename. Currently simplified X3D (.x3d), Unigraphics (.dat), 1040 and UNC (.ply) formats are supported. 1041 */ 1038 1042 1039 1043 Environment::Environment() … … 1062 1066 RegisterOption("Limits.infinity", optFloat, NULL, "1e6"); 1063 1067 1064 1065 1068 RegisterOption("Scene.filename", 1066 1069 optString, … … 1068 1071 "atlanta2.x3d"); 1069 1072 1073 1070 1074 RegisterOption("Unigraphics.meshGrouping", 1071 1075 optInt, … … 1078 1082 "kd_term_min_cost=", 1079 1083 "10"); 1080 1084 1081 1085 RegisterOption("KdTree.Termination.maxNodes", 1082 1086 optInt, 1083 1087 "kd_term_max_nodes=", 1084 1088 "200000"); 1085 1089 1086 1090 RegisterOption("KdTree.Termination.maxDepth", 1087 1091 optInt, -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r811 r859 41 41 //PFNGLGETQUERYUIVARBPROC glGetQueryuivARB; 42 42 #endif 43 44 bool useFilter = false; 43 45 44 46 GlRenderer::GlRenderer(SceneGraph *sceneGraph, … … 838 840 839 841 ViewCell *viewcell; 840 // viewcell = mViewCellsManager->GetViewCell(mViewPoint);841 842 842 843 PrVs prvs; 843 // mViewCellsManager->SetMaxFilterSize(1); 844 mViewCellsManager->GetPrVS(mViewPoint, prvs); 845 viewcell = prvs.mViewCell; 844 845 if (!useFilter) 846 viewcell = mViewCellsManager->GetViewCell(mViewPoint); 847 else { 848 // mViewCellsManager->SetMaxFilterSize(1); 849 mViewCellsManager->GetPrVS(mViewPoint, prvs); 850 viewcell = prvs.mViewCell; 851 } 846 852 847 853 if (viewcell) { … … 869 875 mWireFrame = false; 870 876 } 871 mViewCellsManager->DeleteLocalMergeTree(viewcell); 877 878 if (useFilter) 879 mViewCellsManager->DeleteLocalMergeTree(viewcell); 872 880 } else { 873 881 ObjectContainer::const_iterator oi = mObjects.begin(); … … 910 918 911 919 ViewCell *viewcell; 912 // viewcell = mViewCellsManager->GetViewCell(mViewPoint);913 920 914 921 PrVs prvs; 915 922 // mViewCellsManager->SetMaxFilterSize(1); 916 mViewCellsManager->GetPrVS(mViewPoint, prvs); 917 viewcell = prvs.mViewCell; 923 924 925 if (!useFilter) 926 viewcell = mViewCellsManager->GetViewCell(mViewPoint); 927 else { 928 mViewCellsManager->GetPrVS(mViewPoint, prvs); 929 viewcell = prvs.mViewCell; 930 } 918 931 919 932 QImage im1, im2; … … 1016 1029 glDisable(GL_CLIP_PLANE0); 1017 1030 1018 if ( viewcell)1031 if (useFilter && viewcell) 1019 1032 mViewCellsManager->DeleteLocalMergeTree(viewcell); 1020 1033 1021 1034 mRenderError = pErrorPixels; 1022 1035 return pErrorPixels; -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r837 r859 714 714 715 715 void 716 KdTree::CollectObjects(const AxisAlignedBox3 &box, 717 ObjectContainer &objects) 718 { 719 stack<KdNode *> nodeStack; 720 721 nodeStack.push(mRoot); 722 723 while (!nodeStack.empty()) { 724 KdNode *node = nodeStack.top(); 725 nodeStack.pop(); 726 if (node->IsLeaf()) { 727 KdLeaf *leaf = (KdLeaf *)node; 728 for (int j=0; j < leaf->mObjects.size(); j++) { 729 Intersectable *object = leaf->mObjects[j]; 730 if (!object->Mailed()) { 731 object->Mail(); 732 objects.push_back(object); 733 } 734 } 735 } else { 736 KdInterior *interior = (KdInterior *)node; 737 738 if ( box.Max()[interior->mAxis] > interior->mPosition ) 739 nodeStack.push(interior->mFront); 740 741 if (box.Min()[interior->mAxis] < interior->mPosition) 742 nodeStack.push(interior->mBack); 743 } 744 } 745 } 746 747 void 716 748 KdTree::CollectObjects(KdNode *n, ObjectContainer &objects) 717 749 { -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r752 r859 307 307 void 308 308 CollectObjects(KdNode *n, ObjectContainer &objects); 309 309 310 void 311 CollectObjects(const AxisAlignedBox3 &box, 312 ObjectContainer &objects); 313 310 314 void 311 315 CollectLeaves(vector<KdLeaf *> &leaves); … … 342 346 KdTree::GetRandomLeaf(const Plane3 &halfspace); 343 347 344 345 346 348 KdNode * 349 GetRandomLeaf(const bool onlyUnmailed = false); 350 347 351 int 348 352 FindNeighbors(KdNode *n, 349 vector<KdNode *> &neighbors,350 bool onlyUnmailed351 );353 vector<KdNode *> &neighbors, 354 bool onlyUnmailed 355 ); 352 356 353 357 int -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r811 r859 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: pá 14. IV 14:54:4120063 # Generated by qmake (2.00a) (Qt 4.1.2) on: út 25. IV 12:50:38 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r811 r859 50 50 }; 51 51 52 void 53 Mesh::Preprocess() 54 { 55 Cleanup(); 56 52 53 void 54 Mesh::ComputeBoundingBox() 55 { 56 57 57 mBox.Initialize(); 58 58 VertexContainer::const_iterator vi = mVertices.begin(); … … 61 61 } 62 62 63 63 } 64 65 void 66 Mesh::Preprocess() 67 { 68 Cleanup(); 69 70 ComputeBoundingBox(); 71 64 72 /** true if it is a watertight convex mesh */ 65 73 mIsConvex = false; -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r752 r859 100 100 mFaces.push_back(face); 101 101 } 102 102 103 void ComputeBoundingBox(); 103 104 void Preprocess(); 104 105 -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r811 r859 798 798 Debug<<"Done.\n"; 799 799 800 801 cout<<"Applying visibility filter..."; 802 mViewCellsManager->ApplyFilter(mKdTree, 803 0.05f, 804 0.05f); 805 cout<<"done."; 800 806 801 807 return true; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r850 r859 207 207 } 208 208 209 AxisAlignedBox3 210 ViewCellsManager::GetViewCellBox(ViewCell *vc) 211 { 212 Mesh *m = vc->GetMesh(); 213 214 if (m) { 215 m->ComputeBoundingBox(); 216 return m->mBox; 217 } 218 219 AxisAlignedBox3 box; 220 221 box.Initialize(); 222 223 if (!vc->IsLeaf()) { 224 ViewCellInterior *vci = (ViewCellInterior *) vc; 225 226 ViewCellContainer::iterator it = vci->mChildren.begin(); 227 for (; it != vci->mChildren.end(); ++it) { 228 box.Include(GetViewCellBox(*it)); 229 } 230 } 231 232 return box; 233 } 209 234 210 235 void ViewCellsManager::CollectEmptyViewCells() … … 4807 4832 4808 4833 4834 void 4835 ViewCellsManager::ApplyFilter(ViewCell *viewCell, 4836 KdTree *kdTree, 4837 const float viewSpaceFilterSize, 4838 const float spatialFilterSize, 4839 ObjectPvs &pvs 4840 ) 4841 { 4842 // extend the pvs of the viewcell by pvs of its neighbors 4843 // and apply spatial filter by including all neighbors of the objects 4844 // in the pvs 4845 4846 // get all viewcells intersecting the viewSpaceFilterBox 4847 // and compute the pvs union 4848 4849 //Vector3 center = viewCell->GetBox().Center(); 4850 // Vector3 center = m->mBox.Center(); 4851 4852 // AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 4853 // center + Vector3(viewSpaceFilterSize/2)); 4854 4855 AxisAlignedBox3 box = GetViewCellBox(viewCell); 4856 box.Enlarge(Vector3(viewSpaceFilterSize/2)); 4857 4858 ViewCellContainer viewCells; 4859 ComputeBoxIntersections(box, viewCells); 4860 4861 // cout<<"box="<<box<<endl; 4862 ViewCellContainer::const_iterator it=viewCells.begin(), it_end = viewCells.end(); 4863 4864 int i; 4865 for (i=0; it != it_end; ++it, i++) { 4866 // cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 4867 pvs.Merge((*it)->GetPvs()); 4868 } 4869 4870 // now compute a new Pvs by including also objects intersecting the extended boxes of 4871 // visible objects 4872 4873 Intersectable::NewMail(); 4874 4875 std::map<Intersectable *, 4876 PvsData<Intersectable *>, 4877 LtSample<Intersectable *> >::const_iterator oi; 4878 4879 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 4880 Intersectable *object = (*oi).first; 4881 object->Mail(); 4882 } 4883 4884 ObjectPvs nPvs; 4885 // now go through the pvs again 4886 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 4887 Intersectable *object = (*oi).first; 4888 4889 // Vector3 center = object->GetBox().Center(); 4890 // AxisAlignedBox3 box(center - Vector3(spatialFilterSize/2), 4891 // center + Vector3(spatialFilterSize/2)); 4892 4893 AxisAlignedBox3 box = object->GetBox(); 4894 box.Enlarge(Vector3(spatialFilterSize/2)); 4895 4896 ObjectContainer objects; 4897 4898 // $$ warning collect objects takes only unmailed ones! 4899 kdTree->CollectObjects(box, 4900 objects); 4901 // cout<<"collected objects="<<objects.size()<<endl; 4902 ObjectContainer::const_iterator noi = objects.begin(); 4903 for (; noi != objects.end(); ++noi) { 4904 Intersectable *o = *noi; 4905 if (!o->Mailed()) 4906 // $$ JB warning: pdfs are not correct at this point! 4907 nPvs.AddSample(o, Limits::Small); 4908 } 4909 } 4910 4911 pvs.Merge(nPvs); 4912 4913 } 4914 4915 4916 4917 void 4918 ViewCellsManager::ApplyFilter(KdTree *kdTree, 4919 const float relViewSpaceFilterSize, 4920 const float relSpatialFilterSize 4921 ) 4922 { 4923 4924 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 4925 4926 ObjectPvs *newPvs; 4927 newPvs = new ObjectPvs[mViewCells.size()]; 4928 4929 float viewSpaceFilterSize = Magnitude(mViewSpaceBox.Size())*relViewSpaceFilterSize; 4930 float spatialFilterSize = Magnitude(kdTree->GetBox().Size())*relSpatialFilterSize; 4931 4932 int i; 4933 for (i=0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 4934 ApplyFilter(*it, 4935 kdTree, 4936 viewSpaceFilterSize, 4937 spatialFilterSize, 4938 newPvs[i] 4939 ); 4940 } 4941 4942 // now replace all pvss 4943 for (i= 0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 4944 ObjectPvs &pvs = (*it)->GetPvs(); 4945 pvs.Clear(); 4946 pvs = newPvs[i]; 4947 } 4948 4949 } 4950 4809 4951 void VspBspViewCellsManager::TestFilter(const ObjectContainer &objects) 4810 4952 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r850 r859 422 422 float EvalRenderCost(Intersectable *obj) const; 423 423 424 void 425 ApplyFilter(KdTree *kdTree, 426 const float viewSpaceFilterSize, 427 const float spatialFilterSize 428 ); 429 430 AxisAlignedBox3 431 GetViewCellBox(ViewCell *vc); 432 424 433 /** Exports bounding boxes of objects to file. 425 434 */ … … 431 440 432 441 protected: 433 442 void 443 ApplyFilter(ViewCell *viewCell, 444 KdTree *kdTree, 445 const float viewSpaceFilterSize, 446 const float spatialFilterSize, 447 ObjectPvs &pvs 448 ); 449 450 434 451 /** Returns the bounding box of filter width. 435 452 */ … … 667 684 void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 668 685 686 669 687 protected: 670 688 -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r811 r859 12 12 #filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-plane.x3d;../data/vienna/vienna-roads.x3d 13 13 # filename ../data/vienna/viewcells-25-sel.x3d 14 #filename ../data/atlanta/atlanta2.x3d14 filename ../data/atlanta/atlanta2.x3d 15 15 #filename ../data/soda/soda.dat 16 filename ../data/soda/soda5.dat16 #filename ../data/soda/soda5.dat 17 17 #filename ../data/PowerPlant/ppsection1/part_a/g0.ply 18 18 #filename ../data/PowerPlant/ppsection1/part_b/g0.ply … … 28 28 # stored sample rays 29 29 samplesFilename rays.out 30 useGlRenderer false31 useGlDebugger true30 useGlRenderer true 31 useGlDebugger false 32 32 # type sampling 33 33 # type vss 34 #type rss35 type render34 type rss 35 # type render 36 36 detectEmptyViewSpace false 37 37 pvsRenderErrorSamples 0 … … 51 51 vssSamples 1000000 52 52 vssSamplesPerPass 200000 53 useImportanceSampling true53 useImportanceSampling false 54 54 loadInitialSamples false 55 55 storeInitialSamples false … … 89 89 90 90 RssPreprocessor { 91 samplesPerPass 100000 92 initialSamples 50000093 vssSamples 1000000 00094 vssSamplesPerPass 100000 95 useImportanceSampling true91 samplesPerPass 1000000 92 initialSamples 1000000 93 vssSamples 1000000 94 vssSamplesPerPass 1000000 95 useImportanceSampling false 96 96 97 97 directionalSampling false … … 101 101 pvs false 102 102 rssTree false 103 rays true103 rays false 104 104 numRays 20000 105 105 } … … 170 170 MeshKdTree { 171 171 Termination { 172 minCost 8172 minCost 40 173 173 maxDepth 18 174 174 maxCostRatio 0.9 … … 201 201 202 202 #number of active view cells 203 active 15000203 active 5000 204 204 maxStaticMemory 40 205 205 … … 214 214 215 215 height 5.0 216 maxViewCells 4000216 maxViewCells 5000 217 217 218 218 #percentage of total visible objects where pvs is considered invalid … … 248 248 #colorCode MergedTreeDiff 249 249 colorCode Random 250 exportRays true250 exportRays false 251 251 exportGeometry false 252 252 exportMergedViewCells false … … 273 273 # filename ../data/soda/soda5-viewcells.xml 274 274 # filename ../scripts/viewcells_atlanta.xml 275 filename ../data/soda/soda5-viewcells2.xml276 #filename ../data/atlanta/viewcells_atlanta3.xml275 # filename ../data/soda/soda5-viewcells2.xml 276 filename ../data/atlanta/viewcells_atlanta3.xml 277 277 # filename ../data/vienna/viewcells_vienna.xml 278 278 # filename ../data/PowerPlant/power_plant_viewcells_all3.xml … … 376 376 minGlobalCostRatio 0.0000001 377 377 # minGlobalCostRatio 0.0001 378 maxViewCells 3000378 maxViewCells 50000 379 379 380 380
Note: See TracChangeset
for help on using the changeset viewer.