7 #include "fwGdcmIO/writer/iod/CTMRImageIOD.hpp" 9 #include "fwGdcmIO/helper/FileWriter.hpp" 10 #include "fwGdcmIO/writer/ie/Equipment.hpp" 11 #include "fwGdcmIO/writer/ie/FrameOfReference.hpp" 12 #include "fwGdcmIO/writer/ie/Image.hpp" 13 #include "fwGdcmIO/writer/ie/Patient.hpp" 14 #include "fwGdcmIO/writer/ie/Series.hpp" 15 #include "fwGdcmIO/writer/ie/Study.hpp" 19 #include <fwData/Image.hpp> 21 #include <fwMedData/Equipment.hpp> 22 #include <fwMedData/ImageSeries.hpp> 23 #include <fwMedData/Patient.hpp> 24 #include <fwMedData/Study.hpp> 26 #include <boost/make_shared.hpp> 28 #include <gdcmImageWriter.h> 40 const ::boost::filesystem::path& destinationPath,
41 const ::fwLog::Logger::sptr& logger,
42 ProgressCallback progress,
43 CancelRequestedCallback cancel) :
60 ::fwMedData::ImageSeries::csptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
61 SLM_ASSERT(
"Image series should not be null.", imageSeries);
64 ::fwData::Image::sptr image = imageSeries->getImage();
67 SPTR(::gdcm::ImageWriter) writer = std::make_shared< ::gdcm::ImageWriter >();
78 patientIE.writePatientModule();
81 studyIE.writeGeneralStudyModule();
84 studyIE.writePatientStudyModule();
87 seriesIE.writeGeneralSeriesModule();
93 equipmentIE.writeGeneralEquipmentModule();
96 imageIE.writeGeneralImageModule();
99 imageIE.writeImagePlaneModule();
102 imageIE.writeImagePixelModule();
104 if(
m_instance->getSOPClassUID() == ::gdcm::MediaStorage::GetMSString(::gdcm::MediaStorage::CTImageStorage))
107 imageIE.writeCTImageModule();
109 else if(
m_instance->getSOPClassUID() == ::gdcm::MediaStorage::GetMSString(::gdcm::MediaStorage::MRImageStorage))
112 imageIE.writeMRImageModule();
116 imageIE.writeVOILUTModule();
119 imageIE.writeSOPCommonModule();
122 const ::gdcm::DataSet datasetCopy = writer->GetFile().GetDataSet();
125 std::size_t nbFrames = (
m_instance->getIsMultiFiles()) ? (image->getSize()[2]) : 1;
128 for(
unsigned int i = 0; i < nbFrames; ++i)
131 writer->GetFile().SetDataSet(datasetCopy);
134 imageIE.writeSOPCommonModuleSpecificTags(i);
137 imageIE.writeGeneralImageModuleSpecificTags(i);
140 imageIE.writeImagePlaneModuleSpecificTags(i);
143 imageIE.writeImagePixelModuleSpecificTags(i);
146 std::stringstream ss;
147 ss << std::setfill(
'0') << std::setw(5) << i;
149 framePath += ss.str();
Frame Of Reference Information Entity class.
Equipment Information Entity class.
virtual FWGDCMIO_API void writeFrameOfReferenceModule()
Write Frame of Reference Module tags.
This class defines a DICOM SOP instance. It is useful during the whole writing process. This class allows to share data between module writers.
Series Information Entity class.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
Patient Information Entity class.
Study Information Entity class.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Image Information Entity class.
FWGDCMIO_API CTMRImageIOD(const std::shared_ptr< ::fwGdcmIO::container::DicomInstance > &instance, const ::boost::filesystem::path &destinationPath, const ::fwLog::Logger::sptr &logger=nullptr, ProgressCallback progress=nullptr, CancelRequestedCallback cancel=nullptr)
Constructor.
static FWGDCMIO_API void write(const ::boost::filesystem::path &filename, const std::shared_ptr< ::gdcm::Writer > &writer)
Write a file from the dataset.
virtual FWGDCMIO_API void write(const ::fwMedData::Series::csptr &series) override
Write DICOM file.
virtual FWGDCMIO_API ~CTMRImageIOD()
Destructor.
This file defines SpyLog macros. These macros are used to log messages to a file or to the console du...