- Timestamp:
- 02/21/06 17:42:39 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
r633 r660 15 15 OutputDirectory="..\lib\$(ConfigurationName)" 16 16 IntermediateDirectory="..\obj\$(ConfigurationName)" 17 ConfigurationType=" 4"17 ConfigurationType="1" 18 18 CharacterSet="2"> 19 19 <Tool 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include ;"$(QTDIR)"\includ";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Devil";"22 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include..\support;"..\include ..\support";..\include;"$(GTPDIR)\NonGTP\Devil\include";"$(QTDIR)\include\QtCore";"$(GTPDIR)\NonGTP\Xerces";"$(CG_INC_PATH)";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(QTDIR)\include\QtGui";"$(GTPDIR)\NonGTP\Zlib\include"" 23 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB" 24 24 MinimalRebuild="TRUE" … … 33 33 Name="VCCustomBuildTool"/> 34 34 <Tool 35 Name="VCLibrarianTool" 36 OutputFile="$(OutDir)/GtpVisibility.lib"/> 35 Name="VCLinkerTool" 36 AdditionalDependencies="xerces-c_2D.lib zdll.lib zziplibd.lib devil.lib qtmain.lib QtOpenGLd4.lib QtCored4.lib QtGuid4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 37 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib""/> 37 38 <Tool 38 39 Name="VCMIDLTool"/> … … 49 50 <Tool 50 51 Name="VCXMLDataGeneratorTool"/> 52 <Tool 53 Name="VCWebDeploymentTool"/> 51 54 <Tool 52 55 Name="VCManagedWrapperGeneratorTool"/> -
GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env
r658 r660 203 203 pruneEmptyViewCells false 204 204 processOnlyValidViewCells false 205 205 206 stats viewCellStats.log 207 208 samplingType directional 209 206 210 PostProcess { 207 211 # how much samples are used for post processing … … 216 220 compress false 217 221 merge true 222 statsPrefix ../scripts/viewCells 218 223 } 219 224 … … 314 319 maxStaticMemory 50 315 320 321 subdivisionStats ../subDivisionStats.log 322 316 323 # factors for evaluating split plane costs 317 324 Factor { … … 405 412 maxTests 10000 406 413 414 subdivisionStats ../subDivisionStats.log 415 407 416 # factors for evaluating split plane costs 408 417 Factor { -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r658 r660 1206 1206 "bspTree"); 1207 1207 1208 RegisterOption("ViewCells.stats", 1209 optString, 1210 "view_cells_stats=", 1211 "viewCellsStats.log"); 1212 1213 RegisterOption("ViewCells.PostProcess.statsPrefix", 1214 optString, 1215 "view_cells_stats_prefix=", 1216 "viewCells"); 1217 1218 1219 RegisterOption("ViewCells.active", 1220 optInt, 1221 "1000"); 1222 1208 1223 RegisterOption("ViewCells.active", 1209 1224 optInt, … … 1214 1229 "view_cells_construction_samples=", 1215 1230 "5000000"); 1231 1232 RegisterOption("ViewCells.Evaluation.samples", 1233 optInt, 1234 "view_cells_evaluation_samples=", 1235 "8000000"); 1236 1237 RegisterOption("ViewCells.Evaluation.samplesPerPass", 1238 optInt, 1239 "view_cells_evaluation_samples_per_oass=", 1240 "300000"); 1216 1241 1217 1242 RegisterOption("ViewCells.Construction.samplesPerPass", … … 1280 1305 "-view_cells_delayed_construction", 1281 1306 "false"); 1282 1283 1307 1284 1308 … … 1297 1321 "-view_cells_process_only_valid_view_cells", 1298 1322 "false"); 1299 1323 1300 1324 1301 1325 RegisterOption("ViewCells.PostProcess.maxCostRatio", … … 1303 1327 "-view_cells_post_process_max_cost_ratio=", 1304 1328 "0.9"); 1305 1306 1329 1307 1330 RegisterOption("ViewCells.PostProcess.renderCostWeight", … … 1309 1332 "-view_cells_post_process_render_cost_weight", 1310 1333 "0.5"); 1311 1312 1334 1313 1335 RegisterOption("ViewCells.PostProcess.avgCostMaxDeviation", … … 1346 1368 "8.0"); 1347 1369 1348 RegisterOption("ViewCells.Visualization.useC uttingPlane",1370 RegisterOption("ViewCells.Visualization.useClipPlane", 1349 1371 optBool, 1350 "view_cells_viz_use_c utting_plane=",1372 "view_cells_viz_use_clip_plane=", 1351 1373 "false"); 1352 1353 1374 1354 RegisterOption("ViewCells.Visualization.c uttingPlaneAxis",1375 RegisterOption("ViewCells.Visualization.clipPlaneAxis", 1355 1376 optInt, 1356 "view_cells_viz_c utting_plane_axis=",1377 "view_cells_viz_clip_plane_axis=", 1357 1378 "0"); 1358 1379 … … 1390 1411 "bsp_construction_input=", 1391 1412 "fromViewCells"); 1413 1414 RegisterOption("BspTree.subdivisionStats", 1415 optString, 1416 "vsp_bsp_subdivision_stats=", 1417 "bspSubdivisionStats.log"); 1392 1418 1393 1419 RegisterOption("BspTree.Construction.samples", … … 1840 1866 "vsp_bsp_term_min_pvs=", 1841 1867 "20"); 1868 1842 1869 RegisterOption("VspBspTree.Termination.minProbability", 1843 1870 optFloat, 1844 1871 "vsp_bsp_term_min_probability=", 1845 1872 "0.001"); 1873 1874 RegisterOption("VspBspTree.subdivisionStats", 1875 optString, 1876 "vsp_bsp_subdivision_stats=", 1877 "vspBspSubdivisionStats.log"); 1846 1878 1847 1879 RegisterOption("VspBspTree.Termination.maxRayContribution", -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r651 r660 30 30 int ViewCell::sMailId = 21843194198; 31 31 int ViewCell::sReservedMailboxes = 1; 32 int ViewCell::sLastUpdated = 0; 32 33 33 34 //int upperPvsLimit = 120; … … 117 118 mParent(NULL), 118 119 mMergeCost(0), 119 mIsActive(false) 120 mIsActive(false), 121 mLastUpdated(sLastUpdated) 120 122 { 121 123 } … … 216 218 } 217 219 220 221 void ViewCell::SetActive() 222 { 223 mIsActive = true; 224 mLastUpdated = sLastUpdated; 225 } 226 227 228 bool ViewCell::IsActive() const 229 { 230 return mIsActive && (mLastUpdated == sLastUpdated); 231 } 218 232 219 233 … … 1251 1265 1252 1266 1253 void ViewCellsTree::ExportStats( )1267 void ViewCellsTree::ExportStats(const string &mergeStats) 1254 1268 { 1255 1269 TraversalQueue tqueue; … … 1269 1283 1270 1284 ofstream stats; 1271 stats.open( "mergeStats.log");1285 stats.open(mergeStats.c_str()); 1272 1286 1273 1287 stats … … 1376 1390 } 1377 1391 1392 1393 1378 1394 void ViewCellsTree::CollectBestViewCellSet(ViewCellContainer &viewCells, 1379 1395 const int numViewCells) … … 1391 1407 if (vc->IsLeaf() || ((viewCells.size() + tqueue.size() + 1) >= numViewCells)) 1392 1408 { 1393 // todo: should be done with a function taking the active flag and some1394 // time stamp so I don't have to reset view cells, this also means that1395 // the leaf view cells can be set active fist1396 vc->mIsActive = true;1397 1409 viewCells.push_back(vc); 1398 1410 } … … 1611 1623 ViewCell *ViewCellsTree::GetActiveViewCell(ViewCell *vc) const 1612 1624 { 1613 while (vc->GetParent() && !vc-> mIsActive)1625 while (vc->GetParent() && !vc->IsActive()) 1614 1626 { 1615 1627 vc = vc->GetParent(); … … 1622 1634 void ViewCellsTree::PropagatePvs(ViewCell *vc) 1623 1635 { 1636 // propagate pvs up 1624 1637 while (vc->GetParent()) 1625 1638 { … … 1631 1644 return; 1632 1645 1646 // propagate pvs to the leaves 1633 1647 stack<ViewCell *> tstack; 1634 1635 1648 tstack.push(vc); 1636 1649 … … 1791 1804 stream << "<Leaf "; 1792 1805 stream << "id=\"" << viewCell->GetId() << "\" "; 1793 stream << "active=\"" << viewCell-> mIsActive<< "\" ";1806 stream << "active=\"" << viewCell->IsActive() << "\" "; 1794 1807 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 1795 1808 stream << "pvs=\""; … … 1810 1823 stream << "<Interior "; 1811 1824 stream << "id=\"" << viewCell->GetId() << "\" "; 1812 stream << "active=\"" << viewCell-> mIsActive<< "\" ";1825 stream << "active=\"" << viewCell->IsActive() << "\" "; 1813 1826 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 1814 1827 stream << "pvs=\""; … … 1834 1847 1835 1848 1849 void ViewCellsTree::ResetPvs() 1850 { 1851 stack<ViewCell *> tstack; 1852 1853 tstack.push(mRoot); 1854 1855 while (!tstack.empty()) 1856 { 1857 ViewCell *vc = tstack.top(); 1858 tstack.pop(); 1859 1860 vc->GetPvs().mEntries.clear(); 1861 1862 if (!vc->IsLeaf()) 1863 { 1864 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1865 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1866 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1867 { 1868 tstack.push(*it); 1869 } 1870 } 1871 } 1872 } 1873 1874 1875 void ViewCellsTree::SetActiveSetToLeaves() 1876 { 1877 } 1836 1878 1837 1879 /**************************************************************************/ -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r651 r660 191 191 192 192 193 193 /** Sets this view cell to be an active view cell. 194 */ 195 void SetActive(); 196 /** Returns if this view cell is active. 197 */ 198 bool IsActive() const; 199 194 200 // last mail id -> warning not thread safe! 195 201 // both mailId and mailbox should be unique for each thread!!! 196 202 static int sMailId; 197 203 static int sReservedMailboxes; 198 199 bool mIsActive; 200 204 205 static int sLastUpdated; 201 206 202 207 protected: … … 212 217 bool mValid; 213 218 214 /** color used for consistent visualization */ 215 RgbColor mColor; 219 int mLastUpdated; 220 bool mIsActive; 221 /** color used for consistent visualization */ 222 RgbColor mColor; 216 223 }; 217 224 … … 350 357 bool IsCompressed() const; 351 358 359 /** Returns active view cell that is in the path of this view cell. 360 */ 352 361 ViewCell *GetActiveViewCell(ViewCell *vc) const; 353 362 363 /** Sets the leaves to be the currently active view cells. 364 */ 365 void SetActiveSetToLeaves(); 366 354 367 /** Propagates pvs up the tree to the root and downwards the tree. 355 368 */ … … 360 373 /** Export statistics of this view cell tree. 361 374 */ 362 void ExportStats( );375 void ExportStats(const string &mergeStats); 363 376 364 377 /** Sets root of hierarchy. … … 372 385 void CreateUniqueViewCellsIds(); 373 386 387 /** Resets pvs of whole tree. 388 */ 389 void ResetPvs(); 374 390 375 391 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r650 r660 264 264 environment->GetFloatValue("BspTree.Construction.epsilon", mEpsilon); 265 265 266 mSubdivisionStats.open("subdivisionStats.log"); 266 char subdivisionStatsLog[100]; 267 environment->GetStringValue("BspTree.subdivisionStats", subdivisionStatsLog); 268 mSubdivisionStats.open(subdivisionStatsLog); 267 269 268 270 Debug << "BSP max depth: " << mTermMaxDepth << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r658 r660 61 61 environment->GetIntValue("ViewCells.active", mNumActiveViewCells); 62 62 environment->GetBoolValue("ViewCells.PostProcess.compress", mCompressViewCells); 63 environment->GetBoolValue("ViewCells.Visualization.useC uttingPlane", mUseCuttingPlaneForViz);63 environment->GetBoolValue("ViewCells.Visualization.useClipPlane", mUseClipPlaneForViz); 64 64 65 65 environment->GetBoolValue("ViewCells.PostProcess.merge", mMergeViewCells); 66 67 char samplingBuf[50]; 68 environment->GetStringValue("ViewCells.samplingType", samplingBuf); 69 70 if (strcmp(samplingBuf, "box") == 0) 71 mSamplingType = Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 72 else if (strcmp(samplingBuf, "directional") == 0) 73 mSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION; 74 75 #if 0 76 77 char viewCellsStatsLog[100]; 78 environment->GetStringValue("ViewCells.stats", viewCellsStats); 79 mViewCellsStats.open(viewCellsStatsLog); 80 #endif 66 81 67 82 mMinPvsSize = emptyViewCells ? 1 : 0; … … 157 172 //-- construction rays => we use uniform samples for this 158 173 CastPassSamples(mInitialSamples, 159 //Preprocessor::DIRECTION_BASED_DISTRIBUTION, 160 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION, 174 mSamplingType, 161 175 initialSamples); 162 176 163 177 cout << "finished" << endl; 164 178 179 165 180 // construct view cells 166 181 const int numInitialSamples = … … 172 187 disposeRays(initialSamples, outRays); 173 188 189 190 // -- stats after contruction 191 ResetViewCells(); 192 Debug << "\nView cells after initial sampling: " << mCurrentViewCellsStats << endl; 193 194 if (0) // export initial view cells 195 { 196 cout << "exporting initial view cells (=leaves) ... "; 197 Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 198 199 if (exporter) 200 { 201 if (mExportGeometry) 202 exporter->ExportGeometry(preprocessor->mObjects); 203 204 ExportViewCellsForViz(exporter); 205 206 delete exporter; 207 } 208 cout << "finished" << endl; 209 } 210 174 211 175 212 //-- guided rays are used for further sampling … … 191 228 dirSamples = !dirSamples; // toggle sampling method 192 229 numSamples += CastPassSamples(mSamplesPerPass, 193 samplingType,230 mSamplingType, 194 231 constructionSamples); 195 232 … … 217 254 Preprocessor::DIRECTION_BASED_DISTRIBUTION, 218 255 postProcessSamples); 219 256 257 258 // stats before post processing (i.e., merge) 259 EvaluateViewCellsStats(); 260 Debug << "\noriginal view cell partition before post process:\n" << mCurrentViewCellsStats << endl; 261 262 mRenderer->RenderScene(); 263 SimulationStatistics ss; 264 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 265 266 Debug << ss << endl; 267 268 269 220 270 cout << "starting post processing and visualization" << endl; 271 221 272 222 273 // store viewCells for postprocessing 223 274 const bool storeViewCells = true; 275 224 276 225 277 if (SAMPLE_AFTER_SUBDIVISION) … … 240 292 ComputeSampleContributions(visualizationSamples, true, storeViewCells); 241 293 242 //Debug << "visualizationsamples: " << mVisualizationSamples << " " << visualizationSamples.size() << endl;243 294 // different visualizations 244 295 Visualize(preprocessor->mObjects, visualizationSamples); … … 247 298 248 299 return numSamples; 300 } 301 302 303 void ViewCellsManager::EvalViewCellPartition() 304 { 305 int samplesPerPass; 306 int numSamples; 307 int castSamples = 0; 308 309 environment->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 310 environment->GetIntValue("ViewCells.Evaluation.samples", numSamples); 311 312 while (castSamples < numSamples) 313 { 314 } 315 //char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 249 316 } 250 317 … … 385 452 void ViewCellsManager::EvaluateViewCellsStats() 386 453 { 387 m ViewCellsStats.Reset();454 mCurrentViewCellsStats.Reset(); 388 455 389 456 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); … … 391 458 for (it = mViewCells.begin(); it != it_end; ++ it) 392 459 { 393 mViewCellsTree->UpdateViewCellsStats(*it, m ViewCellsStats);460 mViewCellsTree->UpdateViewCellsStats(*it, mCurrentViewCellsStats); 394 461 } 395 462 } … … 698 765 mViewSpaceBox = box; 699 766 700 CreateC uttingPlane();767 CreateClipPlane(); 701 768 702 769 mTotalAreaValid = false; … … 704 771 705 772 706 void ViewCellsManager::CreateC uttingPlane()773 void ViewCellsManager::CreateClipPlane() 707 774 { 708 775 int axis = 0; 709 776 710 const float factor = 0.65 ;777 const float factor = 0.65f; 711 778 Vector3 point = mViewSpaceBox.Min() + mViewSpaceBox.Size() * factor; 712 779 713 if (mUseC uttingPlaneForViz)714 environment->GetIntValue("ViewCells.Visualization.c uttingPlaneAxis", axis);780 if (mUseClipPlaneForViz) 781 environment->GetIntValue("ViewCells.Visualization.clipPlaneAxis", axis); 715 782 716 783 Vector3 normal(0,0,0); 717 784 normal[axis] = 1; 718 785 719 mC uttingPlane = Plane3(normal, point);786 mClipPlane = Plane3(normal, point); 720 787 } 721 788 … … 733 800 CollectViewCells(); 734 801 735 m ViewCellsStats.Reset();802 mCurrentViewCellsStats.Reset(); 736 803 EvaluateViewCellsStats(); 737 804 … … 813 880 814 881 CastLineSegment(origin, termination, viewcells); 815 //Debug << "constribution: " << (int)viewcells.size() << endl; 816 882 817 883 // copy viewcells memory efficiently 818 884 //const bool storeViewcells = !addRays; … … 902 968 void ViewCellsManager::PrintStatistics(ostream &s) const 903 969 { 904 s << m ViewCellsStats << endl;970 s << mCurrentViewCellsStats << endl; 905 971 } 906 972 … … 926 992 ExportColor(exporter, *it); 927 993 ExportViewCellGeometry(exporter, *it, 928 mUseC uttingPlaneForViz ? &mCuttingPlane : NULL);994 mUseClipPlaneForViz ? &mClipPlane : NULL); 929 995 } 930 996 } … … 960 1026 961 1027 1028 void ViewCellsManager::SetViewCellsActive() 1029 { 1030 ++ ViewCell::sLastUpdated; 1031 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1032 for (it = mViewCells.begin(); it != it_end; ++ it) 1033 { 1034 (*it)->SetActive(); 1035 } 1036 } 962 1037 963 1038 /**********************************************************************/ … … 1032 1107 1033 1108 //EvaluateViewCellsStats(); 1034 Debug << "\nView cells after construction:\n" << m ViewCellsStats << endl;1109 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 1035 1110 1036 1111 // recast rest of the rays 1037 1112 if (SAMPLE_AFTER_SUBDIVISION) 1038 1113 ComputeSampleContributions(savedRays, true, false); 1039 1040 1041 ResetViewCells();1042 1043 Debug << "\nView cells after " << (int)savedRays.size()1044 << " samples:\n" << mViewCellsStats << endl;1045 1046 if (1) // export initial view cells1047 {1048 cout << "exporting initial view cells (=leaves) ... ";1049 Exporter *exporter = Exporter::GetExporter("view_cells.x3d");1050 1051 if (exporter)1052 {1053 if (0 && mExportRays)1054 exporter->ExportRays(rays, RgbColor(1, 1, 1));1055 1056 if (mExportGeometry)1057 exporter->ExportGeometry(objects);1058 1059 //exporter->SetWireframe();1060 exporter->SetFilled();1061 ExportViewCellsForViz(exporter);1062 1063 1064 delete exporter;1065 }1066 cout << "finished" << endl;1067 }1068 1069 1114 1070 1115 return sampleContributions; … … 1115 1160 return 0; 1116 1161 } 1117 1118 1162 1119 1163 // view cells already finished before post processing step (i.e. because they were loaded) … … 1130 1174 int vcSize = 0; 1131 1175 int pvsSize = 0; 1132 1133 EvaluateViewCellsStats();1134 Debug << "\noriginal view cell partition:\n" << mViewCellsStats << endl;1135 1136 mRenderer->RenderScene();1137 SimulationStatistics ss;1138 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss);1139 1140 Debug << ss << endl;1141 1142 1143 1176 1144 1177 //-- merge view cells … … 1151 1184 if (mMergeViewCells) 1152 1185 { 1153 Debug<< "constructing visibility based merge tree" << endl;1186 cout << "constructing visibility based merge tree" << endl; 1154 1187 mViewCellsTree->ConstructMergeTree(rays, objects); 1155 1188 } 1156 1189 else 1157 1190 { 1158 Debug<< "constructing spatial merge tree" << endl;1191 cout << "constructing spatial merge tree" << endl; 1159 1192 // create spatial merge hierarchy 1160 1193 mViewCellsTree->SetRoot(ConstructSpatialMergeTree(mBspTree->GetRoot())); 1161 1194 } 1162 1195 1163 mViewCellsTree->ExportStats(); 1196 // export statistics after merge 1197 if (0) 1198 mViewCellsTree->ExportStats("mergeStats.log"); 1164 1199 1165 1200 //-- stats and visualizations … … 1172 1207 1173 1208 1209 //-- visualization and statistics 1174 1210 // reset view cells and stats 1175 1211 ResetViewCells(); 1176 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 1212 Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 1213 1177 1214 1178 1215 int savedColorCode = mColorCode; … … 1468 1505 { 1469 1506 importance = (float)vc->GetPvs().GetSize() / 1470 (float)m ViewCellsStats.maxPvs;1507 (float)mCurrentViewCellsStats.maxPvs; 1471 1508 1472 1509 } … … 1475 1512 { 1476 1513 int lSize = mViewCellsTree->GetSize(vc); 1477 importance = (float)lSize / (float)m ViewCellsStats.maxLeaves;1514 importance = (float)lSize / (float)mCurrentViewCellsStats.maxLeaves; 1478 1515 } 1479 1516 //break; … … 1502 1539 void BspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 1503 1540 ViewCell *vc, 1504 const Plane3 *c uttingPlane) const1541 const Plane3 *clipPlane) const 1505 1542 { 1506 1543 if (vc->GetMesh()) … … 1513 1550 mBspTree->ConstructGeometry(vc, geom); 1514 1551 1515 1516 if (cuttingPlane) 1552 if (clipPlane) 1517 1553 { 1518 1554 BspNodeGeometry front; … … 1521 1557 geom.SplitGeometry(front, 1522 1558 back, 1523 *c uttingPlane,1559 *clipPlane, 1524 1560 mViewSpaceBox, 1525 1561 0.0001f); … … 1775 1811 1776 1812 EvaluateViewCellsStats(); 1777 Debug << "\nView cells after construction:\n" << m ViewCellsStats << endl;1813 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 1778 1814 1779 1815 return 0; … … 1978 2014 void KdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 1979 2015 ViewCell *vc, 1980 const Plane3 *c uttingPlane) const2016 const Plane3 *clipPlane) const 1981 2017 { 1982 2018 ViewCellContainer leaves; … … 2098 2134 ResetViewCells(); 2099 2135 2100 Debug << "\nView cells after construction:\n" << m ViewCellsStats << endl;2136 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 2101 2137 2102 2138 long startTime = GetTime(); 2139 2103 2140 // recast rest of rays 2104 2141 ComputeSampleContributions(savedRays, true, false); … … 2328 2365 { 2329 2366 importance = (float)vc->GetPvs().GetSize() / 2330 (float)m ViewCellsStats.maxPvs;2367 (float)mCurrentViewCellsStats.maxPvs; 2331 2368 } 2332 2369 break; … … 2335 2372 int lSize = mViewCellsTree->GetSize(vc); 2336 2373 importance = (float)lSize / 2337 (float)m ViewCellsStats.maxLeaves;2374 (float)mCurrentViewCellsStats.maxLeaves; 2338 2375 } 2339 2376 break; … … 2359 2396 void VspKdViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 2360 2397 ViewCell *vc, 2361 const Plane3 *c uttingPlane) const2398 const Plane3 *clipPlane) const 2362 2399 { 2363 2400 VspKdViewCell *kdVc = dynamic_cast<VspKdViewCell *>(vc); … … 2450 2487 2451 2488 2452 /*void VspBspViewCellsManager::CollectNodes(ViewCell *vc, vector<BspNode *>nodes)2453 {2454 void ViewCellsTree::CollectLeaves(ViewCell *vc, vector<BspNode *> &nodes) const2455 2456 if (vc->IsLeaf())2457 {2458 BspViewCell *bvc = dynamic_cast<BspViewCell *>(vc);2459 nodes->push_back(bvc->mLeaf);2460 }2461 else2462 {2463 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end();2464 2465 for (it = interior->mChildren.begin; it != it_end; ++ it)2466 {2467 vector<BspNode *> mynodes;2468 CollectNodes(*it, mynodes);2469 2470 if (mynodes[0]->GetParent() && (mynodes[0]->GetParent() == mynodes[1]->GetParent()))2471 {2472 nodes.push_back(nodes[0]->GetParent());2473 }2474 2475 }2476 }2477 }*/2478 2479 2480 2489 int VspBspViewCellsManager::ConstructSubdivision(const ObjectContainer &objects, 2481 2490 const VssRayContainer &rays) … … 2485 2494 return 0; 2486 2495 2487 Debug << "Constructing bsp view cells" << endl;2488 2489 2496 int sampleContributions = 0; 2490 2497 … … 2496 2503 VssRayContainer savedRays; 2497 2504 2498 Debug << "samples used for subdivision: " << mInitialSamples2505 Debug << "samples used for vsp bsp subdivision: " << mInitialSamples 2499 2506 << " rays: " << (int)rays.size() << endl; 2500 2507 … … 2507 2514 2508 2515 mVspBspTree->Construct(constructionRays, &mViewSpaceBox); 2509 2510 Debug << mVspBspTree->GetStatistics() << endl;2511 2516 2512 2517 // collapse invalid regions … … 2519 2524 cout << "finished" << endl; 2520 2525 2521 cout << "reseting view cell stats ... "; 2526 // -- stats 2527 Debug << mVspBspTree->GetStatistics() << endl; 2528 2522 2529 ResetViewCells(); 2523 cout << "finished" << endl; 2524 2525 Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 2526 2527 if (0) // export initial view cells 2528 { 2529 cout << "exporting initial view cells (=leaves) ... "; 2530 Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 2531 2532 if (exporter) 2533 { 2534 if (0 && mExportRays) 2535 exporter->ExportRays(rays, RgbColor(1, 1, 1)); 2536 2537 if (mExportGeometry) 2538 exporter->ExportGeometry(objects); 2539 2540 //exporter->SetWireframe(); 2541 exporter->SetFilled(); 2542 ExportViewCellsForViz(exporter); 2543 2544 delete exporter; 2545 } 2546 cout << "finished" << endl; 2547 } 2530 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 2531 2548 2532 2549 2533 startTime = GetTime(); 2550 2551 // reset view cells and stats2552 ResetViewCells();2553 2534 2554 2535 cout << "Computing remaining ray contributions ... "; … … 2575 2556 int pvsSize = 0; 2576 2557 2577 mRenderer->RenderScene();2578 SimulationStatistics ss;2579 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss);2580 Debug << ss << endl;2581 2582 2558 //-- merge view cells 2583 2559 … … 2588 2564 if (mMergeViewCells) 2589 2565 { 2590 Debug << "merging view cells" << endl;2591 2566 // TODO: should be done BEFORE the ray casting 2592 2567 mViewCellsTree->ConstructMergeTree(rays, objects); … … 2594 2569 else 2595 2570 { 2596 Debug << "spatial merge" << endl;2597 2571 mViewCellsTree->SetRoot(ConstructSpatialMergeTree(mVspBspTree->GetRoot())); 2598 2572 } 2599 2573 2600 mViewCellsTree->ExportStats(); 2574 if (0) 2575 mViewCellsTree->ExportStats("mergeStats.log"); 2601 2576 2602 2577 //-- stats and visualizations … … 2611 2586 int savedColorCode = mColorCode; 2612 2587 2588 // get currently active view cell set 2589 ResetViewCells(); 2590 Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 2591 2613 2592 //BspLeaf::NewMail(); 2614 2593 if (0) // export merged view cells 2615 2594 { 2616 2595 mColorCode = 0; 2617 cout << "reseting view cells ... ";2618 ResetViewCells();2619 2620 cout << "finished" << endl;2621 2622 2596 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 2623 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 2624 2597 2625 2598 cout << "exporting view cells after merge ... "; 2626 2599 … … 2775 2748 mVspBspTree->ValidateTree(); 2776 2749 2777 // recompute view cell statistics2778 mViewCellsStats.Reset();2779 EvaluateViewCellsStats();2780 2781 2750 // has to be recomputed 2782 2751 mTotalAreaValid = false; 2783 2784 2785 2752 VssRayContainer postProcessRays; 2786 2787 2753 GetRaySets(rays, mPostProcessSamples, postProcessRays); 2788 2754 2789 2755 Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; 2790 2756 2791 Debug << "\nview cell partition after sampling:\n" << mViewCellsStats << endl << endl;2792 2757 2793 2758 // should maybe be done here to allow merge working with area or volume … … 2806 2771 RefineViewCells(postProcessRays, objects); 2807 2772 2808 //-- render simulation after merge 2773 2774 //-- render simulation after merge + refine 2775 2809 2776 cout << "\nevaluating bsp view cells render time before compress ... "; 2810 2777 dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); … … 2831 2798 Debug << "number of entries after compress: " << pvsEntries << endl; 2832 2799 } 2800 2833 2801 2834 2802 // collapse sibling leaves that share the same view cell … … 3288 3256 { 3289 3257 importance = (float)vc->GetPvs().GetSize() / 3290 (float)m ViewCellsStats.maxPvs;3258 (float)mCurrentViewCellsStats.maxPvs; 3291 3259 3292 3260 } … … 3295 3263 { 3296 3264 int lSize = mViewCellsTree->GetSize(vc); 3297 importance = (float)lSize / (float)m ViewCellsStats.maxLeaves;3265 importance = (float)lSize / (float)mCurrentViewCellsStats.maxLeaves; 3298 3266 } 3299 3267 break; … … 3321 3289 void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 3322 3290 ViewCell *vc, 3323 const Plane3 *c uttingPlane) const3291 const Plane3 *clipPlane) const 3324 3292 { 3325 3293 if (vc->GetMesh()) … … 3331 3299 3332 3300 3333 if (c uttingPlane)3301 if (clipPlane) 3334 3302 { 3335 3303 ViewCellContainer leaves; … … 3351 3319 geom.SplitGeometry(front, 3352 3320 back, 3353 *c uttingPlane,3321 *clipPlane, 3354 3322 mViewSpaceBox, 3355 3323 0.0001f); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r651 r660 320 320 virtual void ExportViewCellGeometry(Exporter *exporter, 321 321 ViewCell *vc, 322 const Plane3 *c uttingPlane = NULL) const = 0;322 const Plane3 *clipPlane = NULL) const = 0; 323 323 324 324 virtual void FinalizeViewCells(const bool createMesh); … … 352 352 void CollectViewCells(const int n); 353 353 354 /** Returns true if this (logical) view cell is equal to a spatial node. 355 */ 354 356 virtual bool EqualToSpatialNode(ViewCell *viewCell) const { return false;} 355 357 358 /** Sets current view cells set to active, i.e., the sampling is done in this view cell set. 359 */ 360 void SetViewCellsActive(); 361 362 /** Evaluates worth of current view cell hierarchy. 363 */ 364 void EvalViewCellPartition(); 356 365 357 366 protected: … … 407 416 void CreateViewCellMeshes(); 408 417 409 410 418 /** Takes different measures to prepares the view cells after loading them from disc. 411 419 */ 412 420 virtual void PrepareLoadedViewCells() {}; 413 421 414 415 void CreateCuttingPlane(); 416 417 Plane3 mCuttingPlane; 418 bool mUseCuttingPlaneForViz; 422 /** Creates clip plane for visualization. 423 */ 424 void CreateClipPlane(); 425 426 Plane3 mClipPlane; 427 bool mUseClipPlaneForViz; 419 428 420 429 … … 441 450 float mMaxPvsRatio; 442 451 452 int mSamplingType; 443 453 int mNumActiveViewCells; 444 454 bool mCompressViewCells; 445 455 446 ViewCellsStatistics m ViewCellsStats;456 ViewCellsStatistics mCurrentViewCellsStats; 447 457 /// the scene bounding box 448 458 AxisAlignedBox3 mViewSpaceBox; … … 517 527 void ExportViewCellGeometry(Exporter *exporter, 518 528 ViewCell *vc, 519 const Plane3 *c uttingPlane = NULL) const;529 const Plane3 *clipPlane = NULL) const; 520 530 521 531 void CollectMergeCandidates(const VssRayContainer &rays, … … 600 610 void ExportViewCellGeometry(Exporter *exporter, 601 611 ViewCell *vc, 602 const Plane3 *c uttingPlane = NULL) const;612 const Plane3 *clipPlane = NULL) const; 603 613 604 614 void CollectMergeCandidates(const VssRayContainer &rays, … … 666 676 void ExportViewCellGeometry(Exporter *exporter, 667 677 ViewCell *vc, 668 const Plane3 *c uttingPlane = NULL) const;678 const Plane3 *clipPlane = NULL) const; 669 679 670 680 void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); … … 735 745 void ExportViewCellGeometry(Exporter *exporter, 736 746 ViewCell *vc, 737 const Plane3 *c uttingPlane = NULL) const;747 const Plane3 *clipPlane = NULL) const; 738 748 739 749 //float GetVolume(ViewCell *viewCell) const; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r654 r660 329 329 const bool isActive = (bool)strtol(ptr, &endptr, 10); 330 330 331 viewCell->mIsActive = isActive; 331 if (isActive) 332 viewCell->SetActive(); 332 333 } 333 334 else if (attrName == "mergecost") -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r656 r660 129 129 environment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 130 130 environment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 131 132 char subdivisionStatsLog[100]; 133 environment->GetStringValue("BspTree.subdivisionStats", subdivisionStatsLog); 134 mSubdivisionStats.open(subdivisionStatsLog); 131 135 132 136 … … 556 560 geom); 557 561 562 // compute first split candidate 558 563 VspBspSplitCandidate splitCandidate; 559 560 561 564 EvalSplitCandidate(tData, splitCandidate); 562 565 … … 820 823 VspBspTraversalData tBackData; 821 824 822 #if OCTREE_HACK823 //Debug << "new axis:" << (tData.mAxis + 1) % 3 << endl;824 tFrontData.mAxis = (tData.mAxis + 1) % 3;825 tBackData.mAxis = (tData.mAxis + 1) % 3;826 #endif827 825 //-- continue subdivision 828 826 // create new interior node and two leaf node … … 831 829 newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData, coincident); 832 830 833 #if 0 // TODO 831 const int splitAxis = splitCandidate.mSplitAxis; 832 const int maxCostMisses = splitCandidate.mMaxCostMisses; 833 834 834 if (splitAxis < 3) 835 835 ++ mBspStats.splits[splitAxis]; … … 838 838 839 839 tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && splitAxis < 3); 840 840 841 // how often was max cost ratio missed in this branch? 841 842 tFrontData.mMaxCostMisses = maxCostMisses; 842 843 tBackData.mMaxCostMisses = maxCostMisses; 843 844 #endif 844 845 845 846 if (1) 846 847 { … … 936 937 937 938 // compute locally best split plane 938 SelectPlane(splitData.mSplitPlane, leaf, tData, frontData, backData, splitAxis);939 bool success = SelectPlane(splitData.mSplitPlane, leaf, tData, frontData, backData, splitAxis); 939 940 940 941 // TODO: reuse … … 945 946 splitData.mRenderCost = EvalRenderCostDecrease(splitData.mSplitPlane, tData); 946 947 splitData.mParentData = tData; 948 splitData.mMaxCostMisses = success ? tData.mMaxCostMisses : tData.mMaxCostMisses + 1; 947 949 } 948 950 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r655 r660 167 167 /// the current node 168 168 Plane3 mSplitPlane; 169 169 /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) 170 int mSplitAxis; 171 /// the number of misses of max cost ratio until this split 172 int mMaxCostMisses; 173 170 174 // parent data 171 175 VspBspTraversalData mParentData; 172 176 // cost of applying this split 173 177 float mRenderCost; 174 178 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r658 r660 99 99 Mesh *mesh = new Mesh(); 100 100 101 VertexIndexContainer vc; 102 101 103 // add vertices 102 104 for (int i = 0; i < (int)(*it).size(); ++ i) 103 105 { 104 106 mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]); 105 107 vc.push_back(i); 106 108 } 107 109 108 mesh->mFaces.push_back(new Face( 0,1,2));110 mesh->mFaces.push_back(new Face(vc)); 109 111 mesh->Preprocess(); 110 112 // make an instance of this mesh
Note: See TracChangeset
for help on using the changeset viewer.