Ignore:
Timestamp:
10/18/06 01:49:50 (18 years ago)
Author:
mattausch
Message:

multiple path support for kd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1633 r1634  
    2020#include "MeshKdTree.h" 
    2121#include "Preprocessor.h" 
    22  
     22#include "common.h" 
    2323 
    2424#include "PreprocessorThread.h" 
     
    7373 
    7474 
    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(); 
     75static 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 
     93static 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; 
    107151} 
    108152 
     
    150194        Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 
    151195        string filename(buff); 
     196        const string dummyname = GetInternKdTreeName(filename); 
    152197 
    153198        if (!preprocessor->LoadScene(filename)) 
Note: See TracChangeset for help on using the changeset viewer.