7 #ifndef __FWGDCMIO_HELPER_DICOMDATAWRITER_HXX__ 8 #define __FWGDCMIO_HELPER_DICOMDATAWRITER_HXX__ 10 #include "fwGdcmIO/config.hpp" 11 #include "fwGdcmIO/container/DicomCodedAttribute.hpp" 13 #include <gdcmAttribute.h> 14 #include <gdcmDataSet.h> 15 #include <gdcmElement.h> 16 #include <gdcmSequenceOfItems.h> 37 template< std::u
int16_t GROUP, std::u
int16_t ELEMENT >
40 ::gdcm::Attribute< GROUP, ELEMENT > attribute;
41 dataset.Insert(attribute.GetAsDataElement());
52 template<
typename T, std::u
int16_t GROUP, std::u
int16_t ELEMENT >
53 static void setTagValue(
const T& value, ::gdcm::DataSet& dataset)
55 ::gdcm::Attribute< GROUP, ELEMENT > attribute;
56 attribute.SetValue(value);
57 dataset.Insert(attribute.GetAsDataElement());
67 template< std::u
int16_t GROUP, std::u
int16_t ELEMENT >
68 static void setTagValue(
const std::string& value, ::gdcm::DataSet& dataset)
70 setTagValue<std::string, GROUP, ELEMENT>(value, dataset);
82 template<
typename T, std::u
int16_t GROUP, std::u
int16_t ELEMENT >
83 static void setTagValues(
const T* array,
const size_t size, ::gdcm::DataSet& dataset)
85 ::gdcm::Attribute< GROUP, ELEMENT > attribute;
88 attribute.SetValues(array, static_cast<unsigned int>(size));
90 dataset.Insert(attribute.GetAsDataElement());
100 template< std::u
int16_t GROUP, std::u
int16_t ELEMENT >
102 ::gdcm::DataSet& dataset)
105 ::gdcm::DataElement dataElement(::gdcm::Attribute< GROUP, ELEMENT >::GetTag());
106 dataElement.SetVR(::gdcm::VR::SQ);
107 dataElement.SetValue(*sequence);
108 dataElement.SetVL(sequence->GetLength());
111 dataset.Insert(dataElement);
120 template< std::u
int16_t GROUP, std::u
int16_t ELEMENT >
123 ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sequence = new ::gdcm::SequenceOfItems();
124 sequence->SetLengthToUndefined();
125 setSequenceTagValue< GROUP, ELEMENT >(sequence, dataset);
138 template< std::u
int16_t GROUP, std::u
int16_t ELEMENT >
140 ::gdcm::DataSet& dataset)
143 if (!dataset.FindDataElement(::gdcm::Attribute< GROUP, ELEMENT >::GetTag()))
145 setSequenceTagValue< GROUP, ELEMENT >(sequence, dataset);
150 const ::gdcm::DataElement& dataElement =
151 dataset.GetDataElement(::gdcm::Attribute< GROUP, ELEMENT >::GetTag());
152 ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > oldSequence = dataElement.GetValueAsSQ();
155 auto nbItem = sequence->GetNumberOfItems();
156 for (decltype(nbItem)i = 1; i <= nbItem; ++i)
158 oldSequence->AddItem(sequence->GetItem(i));
171 template< std::u
int16_t GROUP, std::u
int16_t ELEMENT >
173 ::gdcm::DataSet& dataset)
175 auto sequence = createAndSetSequenceTagValue< GROUP, ELEMENT >(dataset);
178 item.SetVLToUndefined();
179 ::gdcm::DataSet& itemDataset = item.GetNestedDataSet();
182 setTagValue< 0x0008, 0x0100 >(attribute.
getCodeValue(), itemDataset);
194 setTagValue< 0x0008, 0x0104>(attribute.
getCodeMeaning(), itemDataset);
196 sequence->AddItem(item);
204 #endif // __FWGDCMIO_HELPER_DICOMDATAWRITER_HXX__ static void setEmptyTagValue(::gdcm::DataSet &dataset)
Insert an empty tag in a data set. Useful for empty type 2 tags.
static void setCodeSequenceTagValue(::fwGdcmIO::container::DicomCodedAttribute attribute,::gdcm::DataSet &dataset)
Set tag value for the code sequence.
static void setAndMergeSequenceTagValue(::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sequence,::gdcm::DataSet &dataset)
Insert a sequence of items with a tag in the specified data set. If the tag already exists...
static void setSequenceTagValue(::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sequence,::gdcm::DataSet &dataset)
Set and insert a sequence of items with a tag in the specified data set.
const std::string getCodingSchemeVersion() const
Get coding scheme version.
const std::string getCodeMeaning() const
Get code meaning.
static::gdcm::SmartPointer< ::gdcm::SequenceOfItems > createAndSetSequenceTagValue(::gdcm::DataSet &dataset)
Create and set a sequence of items with a tag in the specified data set.
static void setTagValues(const T *array, const size_t size,::gdcm::DataSet &dataset)
Insert multiple values of a tag in a data set.
const std::string getCodingSchemeDesignator() const
Get coding scheme designator.
const std::string getCodeValue() const
Get code value.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
static void setTagValue(const T &value,::gdcm::DataSet &dataset)
Insert the value of a tag in a data set.
This class represents a DICOM basic coded entry. It stores the four mains attributes : Code Value...
This class contains helpers to write information into GDCM datasets.
static void setTagValue(const std::string &value,::gdcm::DataSet &dataset)
Insert the string value of a tag in a data set.