30 #include <vtkImageReader2.h>
32 #include "boost/filesystem/path.hpp"
34 #pragma warning(disable: 4996)
37 namespace creaImageIO{
40 const std::string& name,
41 const std::string& extensions)
42 : mReader(r), mExtensions(extensions)
50 const char *test =
mReader->GetDescriptiveName();
53 std::string emptyString(
"");
54 if(test != emptyString)
80 return (
mReader->CanReadFile(filename.c_str())!=0);
92 std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
101 printf(
"EED VtkImageReader::ReadImage Name:%s\n",
GetName().c_str() );
102 mReader->SetFileName( filename.c_str() );
104 im = vtkImageData::New();
106 im->ShallowCopy(
mReader->GetOutput());
109 printf(
"EED ......\n");
110 printf(
"EED ......\n");
111 printf(
"EED VtkImageReader::ReadImage line 108 Missing FlipImage for JPEG, PNG, etc\n");
112 printf(
"EED ......\n");
113 printf(
"EED ......\n");
154 if (im!=0) im->Delete();
163 const std::string& delimiters,
164 std::vector<std::string>& tokens)
167 std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
169 std::string::size_type pos = str.find_first_of(delimiters, lastPos);
171 while (std::string::npos != pos || std::string::npos != lastPos)
175 tokens.push_back(str.substr(lastPos+1, pos - lastPos));
177 lastPos = str.find_first_not_of(delimiters, pos);
179 pos = str.find_first_of(delimiters, lastPos);
189 if (ext.size()==0) ext =
mReader->GetFileExtensions ();
199 std::map<std::string,std::string>& attr)
204 mReader->SetFileName(filename.c_str());
210 sprintf(cols,
"%i",ext[1]-ext[0]);
213 sprintf(rows,
"%i",ext[3]-ext[2]);
216 sprintf(planes,
"%i",ext[5]-ext[4]);
218 std::map<std::string,std::string>::iterator i;
219 if ( (i = attr.find(
"FullFileName")) != attr.end())
221 i->second = filename;
223 if ( (i = attr.find(
"D0004_1500")) != attr.end())
225 boost::filesystem::path full_path(filename);
226 std::string f = full_path.leaf().string();
229 if ( (i = attr.find(
"D0028_0010")) != attr.end())
233 if ( (i = attr.find(
"D0028_0011")) != attr.end())
238 if ( (i = attr.find(
"D0028_0012")) != attr.end())
242 if ( (i = attr.find(
"FullFileDirectory")) != attr.end())
244 std::string::size_type last_pos = filename.find_last_of(
"//");
245 i->second = filename.substr(0, last_pos);