Changeset 1634 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/18/06 01:49:50 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1633 r1634 581 581 inline bool BvHierarchy::LocalTerminationCriteriaMet(const BvhTraversalData &data) const 582 582 { 583 // matt: TODO584 583 return ( 0 585 || ((int)data.mNode->mObjects.size() <= mTermMinObjects)586 //|| (data.mProbability <= mTermMinProbability)587 //|| (data.mNumRays <= mTermMinRays)584 || ((int)data.mNode->mObjects.size() <= mTermMinObjects) 585 //|| (data.mProbability <= mTermMinProbability) 586 //|| (data.mNumRays <= mTermMinRays) 588 587 ); 589 588 } … … 1229 1228 HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) 1230 1229 { 1230 /////////// 1231 1231 //-- heuristics using objects weighted by view cells volume 1232 1232 nCostRatio[axis] = -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1633 r1634 330 330 331 331 // number of initial splits 332 int m axSteps = 200;333 float renderCostDecr = 0;332 int minSteps = 200; 333 float renderCostDecr = Limits::Infinity; 334 334 335 335 SubdivisionCandidate *osc = … … 347 347 // has started, use render cost heuristics instead 348 348 const int ospSteps = 349 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, m axSteps);349 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 350 350 351 351 cout << ospSteps << " object space partition steps taken" << endl; … … 376 376 { 377 377 // use splits of one kind until rendercost slope is reached 378 renderCostDecr = mHierarchyStats.mRenderCostDecrease; 378 //renderCostDecr = mHierarchyStats.mRenderCostDecrease; 379 380 // lower number of minsteps: this should be solved 381 // with render cost decrease from now 382 //minSteps = 5; 379 383 380 384 // dirtied view space candidates … … 385 389 // has started, use render cost heuristics instead 386 390 const int ospSteps = 387 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, m axSteps);391 RunConstruction(objectSpaceQueue, dirtyVspList, renderCostDecr, minSteps); 388 392 389 393 cout << ospSteps << " object space partition steps taken" << endl; … … 400 404 { 401 405 // use splits of one kind until rendercost slope is reached 402 renderCostDecr = mHierarchyStats.mRenderCostDecrease;406 // renderCostDecr = mHierarchyStats.mRenderCostDecrease; 403 407 404 408 ///////////////// … … 409 413 // process view space candidates 410 414 const int vspSteps = 411 RunConstruction(viewSpaceQueue, dirtyOspList, renderCostDecr, m axSteps);415 RunConstruction(viewSpaceQueue, dirtyOspList, renderCostDecr, minSteps); 412 416 413 417 cout << vspSteps << " view space partition steps taken" << endl; … … 480 484 481 485 // begin subdivision 482 RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 486 RunConstruction(mRepairQueue, 487 sampleRays, 488 objects, 489 forcedViewSpace//, 490 /*vspSc*/); 483 491 484 492 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 760 768 SubdivisionCandidateContainer &dirtyCandidates, 761 769 const float minRenderCostDecr, 762 const int m axSteps)770 const int minSteps) 763 771 { 764 772 int steps = 0; … … 766 774 767 775 // main loop 768 while (!splitQueue.Empty() && (steps < maxSteps))776 while (!splitQueue.Empty()) 769 777 { 770 778 SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue); 771 779 772 780 // minimum slope reached 773 //if (sc->GetRenderCostDecrease() < minRenderCostDecr) break; 781 if ((sc->GetRenderCostDecrease() < minRenderCostDecr) && 782 !(steps < minSteps)) 783 break; 774 784 775 785 //////// -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1633 r1634 263 263 SubdivisionCandidateContainer &chosenCandidates, 264 264 const float minRenderCostDecr, 265 const int m axSteps);265 const int minSteps); 266 266 267 267 /** Default subdivision method. -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1633 r1634 822 822 { 823 823 // always try to load the kd tree 824 bool loadKdTree = true;825 //Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree); 826 827 if (!loadKdTree)828 {824 cout << "loading kd tree file " << internKdTree << " ... "; 825 826 if (!LoadKdTree(internKdTree)) 827 { 828 cout << "error loading kd tree with filename " << internKdTree << ", rebuilding it instead ... " << endl; 829 829 // build new kd tree from scene geometry 830 830 BuildKdTree(); 831 }832 else833 {834 cout << "loading kd tree file " << internKdTree << " ... ";835 836 if (!LoadKdTree(internKdTree))837 {838 cout << "error loading kd tree with filename " << internKdTree << ", rebuilding it instead ... " << endl;839 BuildKdTree();840 }841 831 842 832 // export kd tree? … … 866 856 delete exporter; 867 857 } 868 869 /*ofstream objstr("objects.txt"); 870 871 vector<KdLeaf *> leaves; 872 mKdTree->CollectLeaves(leaves); 873 874 vector<KdLeaf *>::const_iterator lit, lit_end = leaves.end(); 875 for (lit = leaves.begin(); lit != lit_end; ++ lit) 876 { 877 objstr << "objects: " << (*lit)->mObjects.size() << " bb " << mKdTree->GetBox(*lit) << endl; 878 }*/ 879 } 880 858 } 881 859 882 860 int rayCastMethod; -
GTP/trunk/Lib/Vis/Preprocessing/src/common.cpp
r863 r1634 218 218 219 219 char * 220 StripPath(const char *s) 221 { 222 const int len = strlen(s); 223 224 int i = len; 225 for (; i>0; i--) { 226 if (s[i]=='/' || s[i]=='\\') 227 break; 228 } 229 230 char *filename = new char[len - i]; 231 int j = 0; 232 233 for (; j < len - i; ++ j) 234 filename[j] = s[i + j + 1]; 235 //filename[j] = 0; 236 237 return filename; 238 } 239 240 char * 220 241 strdup(char *a) 221 242 { -
GTP/trunk/Lib/Vis/Preprocessing/src/common.h
r1557 r1634 499 499 GetPath(const char *s); 500 500 501 char * 502 StripPath(const char *s); 501 503 } 502 504 -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1633 r1634 20 20 #include "MeshKdTree.h" 21 21 #include "Preprocessor.h" 22 22 #include "common.h" 23 23 24 24 #include "PreprocessorThread.h" … … 73 73 74 74 75 static string GetInternKdTreeName(string &filename) 76 { 77 //Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", internKdTree); 78 string suffix; 79 80 if (preprocessor->mLoadMeshes) 81 { 82 suffix = ".kdm"; 83 } 84 else 85 { 86 suffix = ".kdt"; 87 } 88 89 // hack! should take any extension 90 if (strstr(filename.c_str(), ".x3d")) 91 { 92 return ReplaceSuffix(filename, ".x3d", suffix); 93 } 94 else if (strstr(filename.c_str(), ".dat")) 95 { 96 return ReplaceSuffix(filename, ".dat", suffix); 97 } 98 else if (strstr(filename.c_str(), ".obj")) 99 { 100 return ReplaceSuffix(filename, ".dat", suffix); 101 } 102 103 cerr << "Error: Currently unsupported format for kd, filename " << filename << endl; 104 105 // return empty string 106 return string(); 75 static int SplitFilenames(const string str, vector<string> &filenames) 76 { 77 int pos = 0; 78 79 while(1) { 80 int npos = (int)str.find(';', pos); 81 82 if (npos < 0 || npos - pos < 1) 83 break; 84 filenames.push_back(string(str, pos, npos - pos)); 85 pos = npos + 1; 86 } 87 88 filenames.push_back(string(str, pos, str.size() - pos)); 89 return (int)filenames.size(); 90 } 91 92 93 static string GetInternKdTreeName(const string &filename) 94 { 95 vector<string> filenames; 96 const int files = SplitFilenames(filename, filenames); 97 98 vector<string>::const_iterator sit, sit_end = filenames.end(); 99 string kdFilename; 100 101 int i = 0; 102 for (sit = filenames.begin(); sit != sit_end; ++ sit, ++ i) 103 { 104 string currentFile = *sit; 105 //cout << "here6 " << currentFile << endl; 106 string strippedFilename; 107 108 if (i == 0) 109 { 110 strippedFilename = currentFile; 111 } 112 else 113 { 114 strippedFilename = string(StripPath(currentFile.c_str())); 115 } 116 117 string suffix("_"); 118 119 if (i == (int)filenames.size() - 1) 120 { 121 if (preprocessor->mLoadMeshes) 122 { 123 suffix = ".kdm"; 124 } 125 else 126 { 127 suffix = ".kdt"; 128 } 129 } 130 131 if (strstr(strippedFilename.c_str(), ".x3d")) 132 { 133 kdFilename += ReplaceSuffix(strippedFilename, ".x3d", suffix); 134 } 135 else if (strstr(strippedFilename.c_str(), ".dat")) 136 { 137 kdFilename += ReplaceSuffix(strippedFilename, ".dat", suffix); 138 } 139 else if (strstr(strippedFilename.c_str(), ".obj")) 140 { 141 kdFilename += ReplaceSuffix(strippedFilename, ".dat", suffix); 142 } 143 else 144 { 145 cerr << "Error: Currently unsupported format for kd, filename " << currentFile << endl; 146 } 147 } 148 149 //cout << "kdfilename: " << kdFilename << endl; 150 return kdFilename; 107 151 } 108 152 … … 150 194 Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 151 195 string filename(buff); 196 const string dummyname = GetInternKdTreeName(filename); 152 197 153 198 if (!preprocessor->LoadScene(filename))
Note: See TracChangeset
for help on using the changeset viewer.