fw4spl
DicomSRImageNode.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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/container/sr/DicomSRImageNode.hpp"
8 
9 #include "fwGdcmIO/helper/DicomDataWriter.hxx"
10 
11 namespace fwGdcmIO
12 {
13 namespace container
14 {
15 namespace sr
16 {
17 
18 //------------------------------------------------------------------------------
19 
21  const std::string& relationship,
22  const std::string& sopClassUID,
23  const std::string& sopInstanceUID,
24  int frameNumber) :
25  ::fwGdcmIO::container::sr::DicomSRNode(codedAttribute, "IMAGE", relationship),
26  m_sopClassUID(sopClassUID),
27  m_sopInstanceUID(sopInstanceUID),
28  m_frameNumber(frameNumber)
29 {
30 }
31 
32 //------------------------------------------------------------------------------
33 
35 {
36 }
37 
38 //------------------------------------------------------------------------------
39 
40 void DicomSRImageNode::write(::gdcm::DataSet& dataset) const
41 {
43 
44  // Referenced SOP Sequence
45  this->writeReferencedSOPSequence(dataset);
46 }
47 
48 //------------------------------------------------------------------------------
49 
50 void DicomSRImageNode::writeReferencedSOPSequence(::gdcm::DataSet& dataset) const
51 {
52  ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sequence = new ::gdcm::SequenceOfItems();
53  ::gdcm::Item item;
54  item.SetVLToUndefined();
55  ::gdcm::DataSet& itemDataset = item.GetNestedDataSet();
56 
57  // Referenced SOP Class UID - Type 1
58  ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x1150 >(m_sopClassUID, itemDataset);
59 
60  // Referenced SOP Instance UID - Type 1
61  ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x1155 >(m_sopInstanceUID, itemDataset);
62 
63  // Referenced Frame Number - Type 1C
64  ::fwGdcmIO::helper::DicomDataWriter::setTagValues< int, 0x0008, 0x1160 >(&m_frameNumber, 1, itemDataset);
65 
66  sequence->AddItem(item);
67  ::fwGdcmIO::helper::DicomDataWriter::setSequenceTagValue< 0x0008, 0x1199 >(sequence, dataset);
68 }
69 
70 //------------------------------------------------------------------------------
71 
72 void DicomSRImageNode::print(std::ostream& os) const
73 {
75  os << "\\nSOP Class UID : [" << m_sopClassUID << "]";
76  os << "\\nSOP Instance UID : [" << m_sopInstanceUID << "]";
77  os << "\\nFrame number : [" << m_frameNumber << "]";
78 }
79 
80 //------------------------------------------------------------------------------
81 
82 } //namespace sr
83 } //namespace container
84 } //namespace fwGdcmIO
virtual void print(std::ostream &os) const
Dump function.
FWGDCMIO_API DicomSRImageNode(const DicomCodedAttribute &codedAttribute, const std::string &relationship, const std::string &sopClassUID, const std::string &sopInstanceUID, int frameNumber)
Constructor.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
This class defines a node in a SR document.
Definition: DicomSRNode.hpp:27
std::string m_sopClassUID
Referenced SOP Class UID (0008,1150)
This class represents a DICOM basic coded entry. It stores the four mains attributes : Code Value...
int m_frameNumber
Referenced Frame Number (0008,1199)
virtual void print(std::ostream &os) const
Dump function.
std::string m_sopInstanceUID
Referenced SOP Instance UID (0008,1155)
virtual FWGDCMIO_API void write(::gdcm::DataSet &dataset) const
Write the SR node in the dataset.
Definition: DicomSRNode.cpp:44
virtual FWGDCMIO_API ~DicomSRImageNode()
Destructor.
virtual FWGDCMIO_API void write(::gdcm::DataSet &dataset) const
Write the SR node in the dataset.
void writeReferencedSOPSequence(::gdcm::DataSet &dataset) const
Write a referenced SOP sequence.