fw4spl
DicomSRNumNode.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/DicomSRNumNode.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 double numValue,
23  const DicomCodedAttribute& measurementUnits) :
24  ::fwGdcmIO::container::sr::DicomSRNode(codedAttribute, "NUM", relationship),
25  m_numValue(numValue),
26  m_measurementUnits(measurementUnits)
27 {
28 }
29 
30 //------------------------------------------------------------------------------
31 
33 {
34 }
35 
36 //------------------------------------------------------------------------------
37 
38 void DicomSRNumNode::write(::gdcm::DataSet& dataset) const
39 {
41 
42  // Measured Value Sequence - Type 2
43  this->writeMeasuredValueSequence(dataset);
44 }
45 
46 //------------------------------------------------------------------------------
47 
48 void DicomSRNumNode::writeMeasuredValueSequence(::gdcm::DataSet& dataset) const
49 {
50  ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sequence = new ::gdcm::SequenceOfItems();
51  ::gdcm::Item item;
52  item.SetVLToUndefined();
53  ::gdcm::DataSet& itemDataset = item.GetNestedDataSet();
54 
55  // Add numerical value - Type 1
56  ::fwGdcmIO::helper::DicomDataWriter::setTagValues< double, 0x0040, 0xa30a >(&m_numValue, 1, itemDataset);
57 
58  // Add measured units code sequence - Type 1
59  ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > codeSequence =
61  ::fwGdcmIO::helper::DicomDataWriter::setAndMergeSequenceTagValue<0x0040, 0x08ea>(codeSequence, itemDataset);
62 
63  sequence->AddItem(item);
64  ::fwGdcmIO::helper::DicomDataWriter::setSequenceTagValue< 0x0040, 0xa300 >(sequence, dataset);
65 }
66 
67 //------------------------------------------------------------------------------
68 
69 void DicomSRNumNode::print(std::ostream& os) const
70 {
72  os << "\\nMeasurement units : [" << m_measurementUnits << "]";
73  os << "\\nMeasurement value : [" << m_numValue << "]";
74 }
75 
76 //------------------------------------------------------------------------------
77 
78 } //namespace sr
79 } //namespace container
80 } //namespace fwGdcmIO
FWGDCMIO_API DicomSRNumNode(const DicomCodedAttribute &codedAttribute, const std::string &relationship, const double numValue, const DicomCodedAttribute &measurementUnits)
Constructor.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
virtual FWGDCMIO_API ~DicomSRNumNode()
Destructor.
This class defines a node in a SR document.
Definition: DicomSRNode.hpp:27
This class represents a DICOM basic coded entry. It stores the four mains attributes : Code Value...
virtual void print(std::ostream &os) const
Dump function.
void writeMeasuredValueSequence(::gdcm::DataSet &dataset) const
Write a Measured Value Sequence.
DicomCodedAttribute m_measurementUnits
Measurement Units.
virtual void print(std::ostream &os) const
Dump function.
virtual FWGDCMIO_API void write(::gdcm::DataSet &dataset) const
Write the SR node in the dataset.
Definition: DicomSRNode.cpp:44
::gdcm::SmartPointer< ::gdcm::SequenceOfItems > createConceptNameCodeSequence(const DicomCodedAttribute &codedAttribute) const
Create a concept name code sequence.
Definition: DicomSRNode.cpp:73
virtual FWGDCMIO_API void write(::gdcm::DataSet &dataset) const
Write the SR node in the dataset.