From: Vivien Delmon Date: Wed, 20 Apr 2011 09:37:44 +0000 (+0200) Subject: migration gdcm 2.0 clitkDicom2Image X-Git-Tag: v1.2.0~28 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=3716348744181e712832e6a812a012d3b7302141;p=clitk.git migration gdcm 2.0 clitkDicom2Image * Remove readDicomHeader from clitkImageCommon which were used only in clitkDicom2Image tool. * Make clitkDicom2Image compatible with gdcm 2.0 --- diff --git a/common/clitkImageCommon.cxx b/common/clitkImageCommon.cxx index 4c66654..4029845 100644 --- a/common/clitkImageCommon.cxx +++ b/common/clitkImageCommon.cxx @@ -58,30 +58,6 @@ void clitk::ReadImageDimensionAndPixelType(const std::string & filename, } //-------------------------------------------------------------------- -//-------------------------------------------------------------------- -// Read a dicom header -gdcm::File * clitk::readDicomHeader(const std::string & filename, - const bool verbose) -{ -#if GDCM_MAJOR_VERSION == 2 - gdcm::Reader hreader; - hreader.SetFileName(filename.c_str()); - hreader.Read(); - gdcm::SmartPointer p = hreader.GetFile(); - return p; -#else - if (verbose) { - std::cout << "Reading DICOM <" << filename << ">" << std::endl; - } - gdcm::File *header = new gdcm::File(); - header->SetFileName(filename); - header->SetMaxSizeLoadEntry(16384); // required ? - header->Load(); - return header; -#endif -} -///-------------------------------------------------------------------- - //-------------------------------------------------------------------- itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename, bool exit_on_error) { diff --git a/common/clitkImageCommon.h b/common/clitkImageCommon.h index 9559a80..3cd8ae5 100644 --- a/common/clitkImageCommon.h +++ b/common/clitkImageCommon.h @@ -26,12 +26,6 @@ #include "itkImageFileReader.h" #include "itkImageSeriesReader.h" #include "itkImageFileWriter.h" -#include "gdcmFile.h" -#if GDCM_MAJOR_VERSION == 2 - #include "gdcmReader.h" -#else - #include "gdcmFileHelper.h" -#endif namespace clitk { @@ -82,10 +76,6 @@ namespace clitk { // Determine pixetype, dimension and number of pixel components of an image file void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType, int & components); - //-------------------------------------------------------------------- - // Read a dicom header - gdcm::File * readDicomHeader(const std::string & filename, const bool verbose=false); - //-------------------------------------------------------------------- template int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image, diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index 0390c60..b13de42 100644 --- a/tools/clitkDicom2Image.cxx +++ b/tools/clitkDicom2Image.cxx @@ -22,6 +22,12 @@ #include "clitkImageCommon.h" #include "vvImageReader.h" #include "vvImageWriter.h" +#include +#if GDCM_MAJOR_VERSION == 2 + #include + #include + #include +#endif //==================================================================== int main(int argc, char * argv[]) @@ -48,13 +54,33 @@ int main(int argc, char * argv[]) std::vector sliceLocations; for(unsigned int i=0; iGetZOrigin()); - if (header->GetPixelSize() != 2) { +#if GDCM_MAJOR_VERSION == 2 + gdcm::Reader hreader; + hreader.SetFileName(input_files[i].c_str()); + hreader.Read(); + std::vector theorigin = gdcm::ImageHelper::GetOriginValue(hreader.GetFile()); + sliceLocations.push_back(theorigin[2]); + gdcm::Attribute<0x28, 0x100> pixel_size; + gdcm::DataSet& ds = hreader.GetFile().GetDataSet(); + pixel_size.SetFromDataSet(ds); + if (pixel_size.GetValue() != 16) + { std::cerr << "Pixel type 2 bytes ! " << std::endl; std::cerr << "In file " << input_files[i] << std::endl; exit(0); } +#else + gdcm::File *header = new gdcm::File(); + header->SetFileName(input_files[i]); + header->SetMaxSizeLoadEntry(16384); // required ? + header->Load(); + sliceLocations.push_back(header->GetZOrigin()); + if (header->GetPixelSize() != 2) { + std::cerr << "Pixel type 2 bytes ! " << std::endl; + std::cerr << "In file " << input_files[i] << std::endl; + exit(0); + } +#endif } //=========================================== diff --git a/tools/clitkDicomInfo.cxx b/tools/clitkDicomInfo.cxx index d4506a2..fe2d869 100644 --- a/tools/clitkDicomInfo.cxx +++ b/tools/clitkDicomInfo.cxx @@ -28,6 +28,10 @@ // itk (gdcm) include #include "gdcmFile.h" +#if GDCM_MAJOR_VERSION == 2 + #include "gdcmReader.h" + #include "gdcmPrinter.h" +#endif //-------------------------------------------------------------------- int main(int argc, char * argv[]) @@ -41,11 +45,21 @@ int main(int argc, char * argv[]) // Loop files for(unsigned int i=0; iSetFileName(args_info.inputs[i]); header->SetMaxSizeLoadEntry(163840); header->Load(); header->Print(); +#endif } // this is the end my friend