gdcm::Reader reader;
reader.SetFileName( filename.c_str() );
return reader.Read();
-
}
//=====================================================================
vtkImageData* DicomImageReader::ReadImage(const std::string& filename)
{
vtkImageData* im = 0;
- try
+ try
{
- mReader->SetFileName(filename.c_str());
- mReader->Update();
- im = vtkImageData::New();
- im->ShallowCopy(mReader->GetOutput());
- }
- catch (...)
- {
- if (im!=0) im->Delete();
- im = 0;
+ mReader->SetFileName(filename.c_str());
+ mReader->FileLowerLeftOn();
+ mReader->Update();
+ im = vtkImageData::New();
+ im->ShallowCopy(mReader->GetOutput());
+ } catch (...) {
+ if (im!=0) im->Delete();
+ im = 0;
}
return im;
//gdcm::Tag grouplength(0x0000,0x0000);
//std::ostream os;
//de.Write(&os);
-
}
//=====================================================================
#include "boost/algorithm/string.hpp"
#if defined(USE_GDCM)
-#include <gdcmGlobal.h>
-#include <gdcmFile.h>
-#include <gdcmSerieHelper.h>
-#include <gdcmFile.h>
+ #include <gdcmGlobal.h>
+ #include <gdcmFile.h>
+ #include <gdcmSerieHelper.h>
+ #include <gdcmFile.h>
#endif
#if defined(USE_GDCM2)
-#include <gdcmDict.h>
-#include <gdcmDicts.h>
-#include <gdcmGlobal.h>
+ #include <gdcmDict.h>
+ #include <gdcmDicts.h>
+ #include <gdcmGlobal.h>
+ #include "gdcmIPPSorter.h"
#endif
#if defined(USE_XERCES)
#if defined(USE_GDCM2)
// TO DO
double OutputModel::orderFilesWithZspacing(std::vector<std::string> &im)
- {
- return 1;
+{
+ //EED 2026-05-26
+ gdcm::IPPSorter s;
+ s.SetComputeZSpacing( true );
+ s.SetZSpacingTolerance( 1e-3 );
+ bool b = s.Sort( im );
+ if( !b )
+ {
+ std::cerr << "Failed to sort DICOM Files:" << std::endl;
+ //return ;
+ }
+ //std::cout << "Sorting succeeded:" << std::endl;
+ //s.Print( std::cout );
+
+ //std::cout << "Found z-spacing:" << std::endl;
+ //std::cout << s.GetZSpacing() << std::endl;
+ double ippzspacing = s.GetZSpacing();
+
+ const std::vector<std::string> & sorted = s.GetFilenames();
+
+ im.clear();
+ int iEED,sizeEED = sorted.size();
+ for (iEED = 0; iEED<sizeEED; iEED++)
+ {
+ im.push_back( sorted[iEED].c_str() );
+ } // for
+
+ return ippzspacing;
}
#endif
std::vector<std::string>::iterator it = i_filenames.begin();
for (; it != i_filenames.end(); it++)
{
- bresult = mReader->CanRead((*it).c_str());
+ printf("EED SimpleView::readFile .H.H.H %s \n" , (*it).c_str() );
+ bresult = mReader->CanRead( (*it).c_str() );
if(bresult)
{
std::map <std::string , std::string> mapAttr;
// Next we create model and sort files
std::vector<std::string> sort_files(files);
+
double zspacing = 1;
if( !out_model.empty() )
{
readImages(outG, sort_files, Oattr, i_dim_out, zspacing);
outFileNames = sort_files;
}
-
-
-
-
- //======================================================================
-
//======================================================================