fw4spl
reader/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/reader/iod/ComprehensiveSRIOD.hpp"
8 
9 #include "fwGdcmIO/reader/ie/Document.hpp"
10 
11 #include <fwData/PointList.hpp>
12 #include <fwData/String.hpp>
13 
14 #include <fwMedData/ImageSeries.hpp>
15 
16 namespace fwGdcmIO
17 {
18 namespace reader
19 {
20 namespace iod
21 {
22 
23 //------------------------------------------------------------------------------
24 
25 ComprehensiveSRIOD::ComprehensiveSRIOD(const ::fwMedData::DicomSeries::csptr& dicomSeries,
26  const SPTR(::fwGdcmIO::container::DicomInstance)& instance,
27  const ::fwLog::Logger::sptr& logger,
28  ProgressCallback progress,
29  CancelRequestedCallback cancel) :
30  ::fwGdcmIO::reader::iod::InformationObjectDefinition(dicomSeries, instance, logger, progress, cancel)
31 {
32 }
33 
34 //------------------------------------------------------------------------------
35 
37 {
39 }
40 
41 //------------------------------------------------------------------------------
42 
43 void ComprehensiveSRIOD::read(::fwMedData::Series::sptr series) throw(::fwGdcmIO::exception::Failed)
44 {
45  // Retrieve image series
46  ::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
47  SLM_ASSERT("Image series should not be null.", imageSeries);
48 
49  // Create GDCM reader
50  SPTR(::gdcm::Reader) reader = std::shared_ptr< ::gdcm::Reader >( new ::gdcm::Reader );
51 
52  // Read the first file
53  const auto& dicomContainer = m_dicomSeries->getDicomContainer();
54  const ::fwMemory::BufferObject::sptr bufferObj = dicomContainer.begin()->second;
55  const ::fwMemory::BufferManager::StreamInfo streamInfo = bufferObj->getStreamInfo();
56  SPTR(std::istream) is = streamInfo.stream;
57  reader->SetStream(*is);
58  const bool success = reader->Read();
59 
60  FW_RAISE_EXCEPTION_IF(::fwGdcmIO::exception::Failed("Unable to read the DICOM instance \""+
61  bufferObj->getStreamInfo().fsFile.string()+
62  "\" using the GDCM Image Reader."), !success);
63 
64  // Create Information Entity helpers
65  ::fwGdcmIO::reader::ie::Document documentIE(m_dicomSeries, reader, m_instance, imageSeries->getImage(), m_logger,
67 
68  // Read SR
69  documentIE.readSR();
70 }
71 
72 //------------------------------------------------------------------------------
73 
74 } // namespace iod
75 } // namespace reader
76 } // namespace fwGdcmIO
#define SPTR(_cls_)
FWGDCMIO_API ComprehensiveSRIOD(const ::fwMedData::DicomSeries::csptr &dicomSeries, const std::shared_ptr< ::fwGdcmIO::container::DicomInstance > &instance, const ::fwLog::Logger::sptr &logger=nullptr, ProgressCallback progress=nullptr, CancelRequestedCallback cancel=nullptr)
Constructor.
CancelRequestedCallback m_cancelRequestedCallback
Cancel information for jobs.
Document Information Entity class It search and read a specific template from the root of the documen...
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
This class defines a DICOM SOP instance. It is useful during the whole writing process. This class allows to share data between module writers.
FWGDCMIO_API void readSR()
Read the Structured Report.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
Implements a failed exception class for fwGdcmIO.
InformationObjectDefinition base class used to read DICOM IODs.
#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
std::shared_ptr< ::fwGdcmIO::container::DicomInstance > m_instance
DICOM Instance.
FWGDCMIO_API void read(::fwMedData::Series::sptr series)
Read DICOM file.