- Timestamp:
- 02/04/06 21:36:40 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r587 r590 686 686 { 687 687 mViewCells.clear(); 688 688 689 CollectViewCells(); 689 690 690 691 mViewCellsStats.Reset(); 691 692 EvaluateViewCellsStats(); 693 692 694 // has to be recomputed 693 695 mTotalAreaValid = false; … … 699 701 return mMaxPvsSize; 700 702 } 703 701 704 702 705 void … … 921 924 environment->GetIntValue("BspTree.Construction.samples", mInitialSamples); 922 925 mBspTree->SetViewCellsManager(this); 926 mBspTree->mViewCellsTree = mViewCellsTree; 923 927 } 924 928 … … 1024 1028 if (!ViewCellsTreeConstructed()) 1025 1029 { 1030 1026 1031 mBspTree->CollectViewCells(mViewCells); 1027 1032 } 1028 1033 else 1029 1034 { 1035 1030 1036 // we can use the view cells tree hierarchy to get the right set 1031 1037 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); … … 1069 1075 } 1070 1076 1077 1078 // view cells already finished before post processing step (i.e. because they were loaded) 1079 if (mViewCellsFinished) 1080 { 1081 FinalizeViewCells(true); 1082 EvaluateViewCellsStats(); 1083 1084 return 0; 1085 } 1086 1071 1087 //-- post processing of bsp view cells 1072 1088 int vcSize = 0; … … 1098 1114 m.mDiffuseColor = RgbColor(0, 1, 0); 1099 1115 exporter->SetForcedMaterial(m); 1116 1100 1117 exporter->SetWireframe(); 1101 1118 … … 1132 1149 FinalizeViewCells(true); 1133 1150 1134 // for output we need unique ids for each view cell 1135 CreateUniqueViewCellIds(); 1151 // HACK: removes view cells in bsp leaves with active ones 1152 if (0) 1153 AddCurrentViewCellsToHierarchy(); 1136 1154 1137 1155 // write view cells to disc … … 1186 1204 else 1187 1205 exporter->SetFilled(); 1206 1188 1207 ExportViewCellsForViz(exporter); 1189 1208 … … 1486 1505 1487 1506 1488 /**********************************************************************/ 1489 /* KdViewCellsManager implementation */ 1490 /**********************************************************************/ 1507 1508 bool BspViewCellsManager::ExportViewCells(const string filename) 1509 { 1510 cout << "exporting view cells to xml ... "; 1511 std::ofstream stream; 1512 1513 // for output we need unique ids for each view cell 1514 CreateUniqueViewCellIds(); 1515 1516 1517 stream.open(filename.c_str()); 1518 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 1519 stream << "<Visibility_Solution>" << endl; 1520 1521 //-- the view space bounding box 1522 stream << "<ViewSpaceBox" 1523 << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\"" 1524 << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 1525 1526 //-- the type of the view cells hierarchy 1527 //stream << "<Hierarchy name=\"bspTree\" />" << endl; 1528 stream << "<Hierarchy name=\"vspBspTree\" />" << endl; // write vsp bsp here because can use same tree and is bug free 1529 //-- load the view cells itself, i.e., the ids and the pvs 1530 stream << "<ViewCells>" << endl; 1531 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1532 for (it = mViewCells.begin(); it != it_end; ++ it) 1533 ExportViewCell(*it, stream); 1534 1535 stream << "</ViewCells>" << endl; 1536 1537 //-- load the hierarchy 1538 stream << "<Hierarchy>" << endl; 1539 mBspTree->Export(stream); 1540 stream << endl << "</Hierarchy>" << endl; 1541 1542 stream << "</Visibility_Solution>" << endl; 1543 stream.close(); 1544 1545 cout << "finished" << endl; 1546 1547 return true; 1548 } 1549 1550 1551 void BspViewCellsManager::AddCurrentViewCellsToHierarchy() 1552 { 1553 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1554 for (it = mViewCells.begin(); it != it_end; ++ it) 1555 { 1556 ViewCell *vc = *it; 1557 ViewCellContainer leaves; 1558 mViewCellsTree->CollectLeaves(vc, leaves); 1559 1560 ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 1561 1562 for (lit = leaves.begin(); lit != lit_end; ++ lit) 1563 { 1564 BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*lit); 1565 bspVc->mLeaf->SetViewCell(vc); 1566 } 1567 } 1568 } 1569 1570 /************************************************************************/ 1571 /* KdViewCellsManager implementation */ 1572 /************************************************************************/ 1491 1573 1492 1574 … … 2177 2259 environment->GetIntValue("VspBspTree.Construction.samples", mInitialSamples); 2178 2260 mVspBspTree->SetViewCellsManager(this); 2261 mVspBspTree->mViewCellsTree = mViewCellsTree; 2179 2262 } 2180 2263 … … 2199 2282 if (!ViewCellsTreeConstructed()) 2200 2283 { 2201 mVspBspTree->CollectViewCells(mViewCells, true);2284 mVspBspTree->CollectViewCells(mViewCells, false); 2202 2285 } 2203 2286 else … … 2568 2651 FinalizeViewCells(true); 2569 2652 2570 // for output we need unique ids for each view cell 2571 CreateUniqueViewCellIds(); 2653 // HACK: removes view cells in bsp leaves with active ones 2654 if (0) 2655 AddCurrentViewCellsToHierarchy(); 2656 2572 2657 2573 2658 // write view cells to disc … … 2966 3051 2967 3052 void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 2968 3053 ViewCell *vc) const 2969 3054 { 2970 3055 if (vc->GetMesh()) 2971 3056 { 2972 3057 exporter->ExportMesh(vc->GetMesh()); 3058 2973 3059 return; 2974 3060 } … … 3023 3109 delete vc->GetMesh(); 3024 3110 3111 3025 3112 BspNodeGeometry geom; 3113 3114 mVspBspTree->ConstructGeometry(vc, geom); 3026 3115 3027 mVspBspTree->ConstructGeometry(vc, geom);3028 3029 3116 Mesh *mesh = new Mesh(); 3030 3117 geom.AddToMesh(*mesh); … … 3043 3130 if (parser.ParseFile(filename, &vm, objects)) 3044 3131 { 3045 vm->PrepareLoadedViewCells();3132 //vm->PrepareLoadedViewCells(); 3046 3133 vm->ResetViewCells(); 3047 3134 … … 3052 3139 3053 3140 Debug << (int)vm->mViewCells.size() << " view cells loaded" << endl; 3054 3055 //vm->ExportViewCells("test.xml");3056 3141 } 3057 3142 else … … 3078 3163 3079 3164 // for output we need unique ids for each view cell 3080 //CreateUniqueViewCellIds(); 3165 CreateUniqueViewCellIds(); 3166 3081 3167 3082 3168 stream.open(filename.c_str()); … … 3101 3187 3102 3188 //-- load the hierarchy 3103 stream << "< BspTree>" << endl;3189 stream << "<Hierarchy>" << endl; 3104 3190 mVspBspTree->Export(stream); 3105 stream << endl << "</ BspTree>" << endl;3191 stream << endl << "</Hierarchy>" << endl; 3106 3192 3107 3193 stream << "</Visibility_Solution>" << endl; … … 3151 3237 { 3152 3238 // TODO: do I still need this here? 3239 if (0) 3153 3240 mVspBspTree->RepairViewCellsLeafLists(); 3154 3241 } … … 3176 3263 3177 3264 3265 void VspBspViewCellsManager::AddCurrentViewCellsToHierarchy() 3266 { 3267 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 3268 for (it = mViewCells.begin(); it != it_end; ++ it) 3269 { 3270 } 3271 } 3178 3272 3179 3273 //////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.