7 #include "fwItkIO/ImageWriter.hpp" 9 #include "fwItkIO/helper/ProgressItkToFw.hpp" 10 #include "fwItkIO/itk.hpp" 12 #include <fwCore/base.hpp> 14 #include <fwDataIO/writer/registry/macros.hpp> 16 #include <fwTools/Dispatcher.hpp> 17 #include <fwTools/DynamicTypeKeyTypeMapping.hpp> 18 #include <fwTools/IntrinsicTypes.hpp> 20 #include <boost/filesystem.hpp> 22 #include <itkImageFileWriter.h> 31 ::
fwData::location::enableSingleFile< ::
fwDataIO::writer::IObjectWriter >(this)
38 ImageWriter::~ImageWriter()
48 std::string m_filename;
49 ::fwData::Image::csptr m_dataImage;
50 ::fwItkIO::ImageWriter::sptr m_fwWriter;
55 template<
class PIXELTYPE>
58 OSLM_DEBUG(
"itk::ImageFileWriter with PIXELTYPE "<< fwTools::DynamicType::string<PIXELTYPE>() );
67 typename itk::ImageIOBase::Pointer imageIOWrite = itk::ImageIOFactory::CreateImageIO(
68 param.m_filename.c_str(), itk::ImageIOFactory::WriteMode);
69 assert( imageIOWrite.IsNotNull() );
72 typedef itk::Image< PIXELTYPE, 3> itkImageType;
73 typedef typename itk::ImageFileWriter< itkImageType > WriterType;
74 typename WriterType::Pointer writer = WriterType::New();
77 itk::LightProcessObject::Pointer castHelper = (itk::LightProcessObject*)(imageIOWrite.GetPointer());
78 assert( castHelper.IsNotNull() );
79 Progressor progress(castHelper, param.m_fwWriter, param.m_filename);
82 typename itkImageType::Pointer itkImage = ::fwItkIO::itkImageFactory<itkImageType>( param.m_dataImage );
84 writer->SetFileName( param.m_filename.c_str() );
85 writer->SetInput( itkImage );
86 writer->SetImageIO( imageIOWrite );
95 void ImageWriter::write()
97 assert( !m_object.expired() );
98 assert( m_object.lock() );
101 saverParam.m_filename = this->getFile().string();
102 saverParam.m_dataImage = getConcreteObject();
103 saverParam.m_fwWriter = this->getSptr();
104 assert( saverParam.m_dataImage );
107 saverParam.m_dataImage->getPixelType(), saverParam );
112 std::string ImageWriter::extension()
114 if ( getFile().empty() || ( getFile().
string().find(
".inr.gz") != std::string::npos ) )
120 return ::boost::filesystem::extension( getFile().leaf() );
#define SLM_TRACE_FUNC()
Trace contextual function signature.
This namespace fwDataIO contains reader and writer for several framework's data.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
The namespace fwItkIO contains reader, writer and helper for itk image.
Contains the representation of the data objects used in the framework.
#define OSLM_DEBUG(message)