7 #include "vtkGdcmIO/helper/GdcmHelper.hpp" 9 #include <fwCore/base.hpp> 11 #include <boost/algorithm/string/split.hpp> 12 #include <boost/algorithm/string/predicate.hpp> 13 #include <boost/algorithm/string/classification.hpp> 15 #include <gdcmImageHelper.h> 16 #include <gdcmIPPSorter.h> 17 #include <gdcmFilename.h> 18 #include <gdcmTesting.h> 19 #include <gdcmSystem.h> 20 #include <gdcmTrace.h> 21 #include <gdcmDirectory.h> 22 #include <gdcmScanner.h> 23 #include <gdcmReader.h> 24 #include <gdcmIPPSorter.h> 25 #include <gdcmFilenameGenerator.h> 26 #include <gdcmAttribute.h> 34 void DicomSearch::searchRecursivelyFiles(const ::boost::filesystem::path &dirPath, std::vector<std::string>& dicomFiles)
36 std::vector<std::string> vecStr;
37 std::string strIgnoreFile =
".zip|.txt|.htm|.html|.xml|.exe|.gz|.dir|.gif|.jpeg|.jpg|dicomdir|.DS_Store";
38 ::boost::algorithm::split( vecStr, strIgnoreFile, ::boost::algorithm::is_any_of(
39 "|"), ::boost::algorithm::token_compress_on );
41 std::string lowerFilename;
43 for( ::boost::filesystem::recursive_directory_iterator it(dirPath);
44 it != ::boost::filesystem::recursive_directory_iterator(); ++it)
46 if(!::boost::filesystem::is_directory(*it))
48 lowerFilename = filename = it->path().string();
49 std::transform ( lowerFilename.begin(), lowerFilename.end(), lowerFilename.begin(), tolower );
50 if(DicomSearch::compare( lowerFilename, &vecStr) )
54 ::gdcm::Reader reader;
55 reader.SetFileName( filename.c_str() );
56 if( !reader.CanRead() )
58 OSLM_WARN(
"Failed to read: " << filename );
62 dicomFiles.push_back( filename.c_str() );
65 catch (std::exception& e)
67 OSLM_ERROR (
"Try with another reader for this file : " << filename.c_str());
76 bool DicomSearch::compare(std::string & _strOrgin, std::vector<std::string> * vecStr)
79 for (
size_t i = 0; i < vecStr->size() && res; ++i)
81 res = !::boost::ends_with(_strOrgin, vecStr->at(i));
vtkmGdcm reader/writer lib
#define OSLM_ERROR(message)
#define OSLM_WARN(message)