fw4spl
writer/iod/ComprehensiveSRIOD.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwGdcmIO/writer/iod/ComprehensiveSRIOD.hpp"
8 
9 #include "fwGdcmIO/helper/FileWriter.hpp"
10 #include "fwGdcmIO/writer/ie/Document.hpp"
11 #include "fwGdcmIO/writer/ie/Equipment.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"
16 
17 #include <fwCore/spyLog.hpp>
18 
19 #include <fwData/Image.hpp>
20 
21 #include <fwMedData/Equipment.hpp>
22 #include <fwMedData/ImageSeries.hpp>
23 #include <fwMedData/Patient.hpp>
24 #include <fwMedData/Study.hpp>
25 
26 #include <boost/make_shared.hpp>
27 
28 #include <gdcmWriter.h>
29 
30 namespace fwGdcmIO
31 {
32 namespace writer
33 {
34 namespace iod
35 {
36 
37 //------------------------------------------------------------------------------
38 
40  const ::boost::filesystem::path& destinationPath,
41  bool use3DSR,
42  const ::fwLog::Logger::sptr& logger,
43  ProgressCallback progress,
44  CancelRequestedCallback cancel) :
45  ::fwGdcmIO::writer::iod::InformationObjectDefinition(instance, destinationPath, logger, progress, cancel),
46  m_use3DSR(use3DSR)
47 {
48 }
49 
50 //------------------------------------------------------------------------------
51 
53 {
54 }
55 
56 //------------------------------------------------------------------------------
57 
58 void ComprehensiveSRIOD::write(const ::fwMedData::Series::csptr& series)
59 {
60  // Retrieve image series
61  ::fwMedData::ImageSeries::csptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
62  SLM_ASSERT("Image series should not be null.", imageSeries);
63 
64  // Retrieve image
65  ::fwData::Image::sptr image = imageSeries->getImage();
66 
67  // Create writer
68  SPTR(::gdcm::Writer) writer = std::make_shared< ::gdcm::Writer >();
69 
70  // Create Information Entity helpers
71  ::fwGdcmIO::writer::ie::Patient patientIE(writer, m_instance, series->getPatient());
72  ::fwGdcmIO::writer::ie::Study studyIE(writer, m_instance, series->getStudy());
73  ::fwGdcmIO::writer::ie::Series seriesIE(writer, m_instance, series);
74  ::fwGdcmIO::writer::ie::Equipment equipmentIE(writer, m_instance, series->getEquipment());
75  ::fwGdcmIO::writer::ie::Document documentIE(writer, m_instance, image, m_use3DSR);
76 
77  // Write Patient Module - PS 3.3 C.7.1.1
78  patientIE.writePatientModule();
79 
80  // Write General Study Module - PS 3.3 C.7.2.1
81  studyIE.writeGeneralStudyModule();
82 
83  // Write Patient Study Module - PS 3.3 C.7.2.2
84  studyIE.writePatientStudyModule();
85 
86  // Write SR Document Series Module - PS 3.3 C.17.1
87  seriesIE.writeSRDocumentSeriesModule();
88 
89  // Write General Equipment Module - PS 3.3 C.7.5.1
90  equipmentIE.writeGeneralEquipmentModule();
91 
92  // Write SR Document General Module - PS 3.3 C.17.2
93  documentIE.writeSRDocumentGeneralModule();
94 
95  // Write SR Document Content Module - PS 3.3 C.17.3
96  documentIE.writeSRDocumentContentModule();
97 
98  // Write SOP Common module - PS 3.3 C.12.1
99  documentIE.writeSOPCommonModule();
100 
101  // Write document
103 }
104 
105 //------------------------------------------------------------------------------
106 } // namespace iod
107 } // namespace writer
108 } // namespace fwGdcmIO
#define SPTR(_cls_)
std::shared_ptr< ::fwGdcmIO::container::DicomInstance > m_instance
DICOM Instance.
virtual FWGDCMIO_API ~ComprehensiveSRIOD()
Destructor.
virtual FWGDCMIO_API void write(const ::fwMedData::Series::csptr &series) override
Write DICOM file.
FWGDCMIO_API ComprehensiveSRIOD(const std::shared_ptr< ::fwGdcmIO::container::DicomInstance > &instance, const ::boost::filesystem::path &destinationPath, bool use3DSR=false, const ::fwLog::Logger::sptr &logger=nullptr, ProgressCallback progress=nullptr, CancelRequestedCallback cancel=nullptr)
Constructor.
This class defines a DICOM SOP instance. It is useful during the whole writing process. This class allows to share data between module writers.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
static FWGDCMIO_API void write(const ::boost::filesystem::path &filename, const std::shared_ptr< ::gdcm::Writer > &writer)
Write a file from the dataset.
Definition: FileWriter.cpp:20
This file defines SpyLog macros. These macros are used to log messages to a file or to the console du...
InformationObjectDefinition base class used to write DICOM modules.
Document Information Entity class.