File: modusfor.cc

package info (click to toggle)
dcmtk 3.6.9-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 95,648 kB
  • sloc: ansic: 426,874; cpp: 318,177; makefile: 6,401; sh: 4,341; yacc: 1,026; xml: 482; lex: 321; perl: 277
file content (234 lines) | stat: -rw-r--r-- 8,064 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
 *
 *  Copyright (C) 2015-2024, Open Connections GmbH
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation are maintained by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module: dcmiod
 *
 *  Author: Michael Onken
 *
 *  Purpose: Class for managing the Ultrasound Frame of Reference Module
 *
 */

#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmiod/modusfor.h"
#include "dcmtk/dcmdata/dcdeftag.h"
#include "dcmtk/dcmdata/dcvrcs.h"
#include "dcmtk/dcmdata/dcvrui.h"
#include "dcmtk/dcmiod/iodutil.h"

const OFString IODUSFoRModule::m_ModuleName = "UltrasoundFrameOfReferenceModule";

IODUSFoRModule::IODUSFoRModule(OFshared_ptr<DcmItem> item, OFshared_ptr<IODRules> rules)
    : IODModule(item, rules)
{
    // reset element rules
    resetRules();
}

IODUSFoRModule::IODUSFoRModule()
    : IODModule()
{
    resetRules();
}

void IODUSFoRModule::resetRules()
{
    // parameters are tag, VM, type. Overwrite old rules if any.
    m_Rules->addRule(new IODRule(DCM_VolumeFrameOfReferenceUID, "1", "1", getName(), DcmIODTypes::IE_FOR), OFTrue);
    m_Rules->addRule(new IODRule(DCM_UltrasoundAcquisitionGeometry, "1", "1", getName(), DcmIODTypes::IE_FOR), OFTrue);
    m_Rules->addRule(new IODRule(DCM_ApexPosition, "3", "1C", getName(), DcmIODTypes::IE_FOR), OFTrue);
    m_Rules->addRule(new IODRule(DCM_VolumeToTransducerRelationship, "1", "1C", getName(), DcmIODTypes::IE_FOR),
                     OFTrue);
    m_Rules->addRule(new IODRule(DCM_VolumeToTransducerMappingMatrix, "16", "1", getName(), DcmIODTypes::IE_FOR),
                     OFTrue);
    m_Rules->addRule(new IODRule(DCM_PatientFrameOfReferenceSource, "1", "1C", getName(), DcmIODTypes::IE_FOR), OFTrue);
    m_Rules->addRule(new IODRule(DCM_TableFrameOfReferenceUID, "1", "1C", getName(), DcmIODTypes::IE_FOR), OFTrue);
    m_Rules->addRule(new IODRule(DCM_VolumeToTableMappingMatrix, "16", "1C", getName(), DcmIODTypes::IE_FOR), OFTrue);
}

OFString IODUSFoRModule::getName() const
{
    return m_ModuleName;
}

IODUSFoRModule::~IODUSFoRModule()
{
    // Nothing to do
}

OFCondition IODUSFoRModule::getVolumeFrameOfReferenceUID(OFString& value, const long signed int pos) const
{
    return DcmIODUtil::getStringValueFromItem(DCM_VolumeFrameOfReferenceUID, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getUltrasoundAcquisitionGeometry(OFString& value, const long signed int pos) const
{
    return DcmIODUtil::getStringValueFromItem(DCM_UltrasoundAcquisitionGeometry, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getApexPosition(OFVector<Float64>& value)
{
    return DcmIODUtil::getFloat64ValuesFromItem(DCM_ApexPosition, *m_Item, value);
}

OFCondition IODUSFoRModule::getApexPosition(Float64& value, const unsigned long pos) const
{
    return DcmIODUtil::getFloat64ValueFromItem(DCM_ApexPosition, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getVolumetoTransducerRelationship(OFString& value, const signed long pos)
{
    return DcmIODUtil::getStringValueFromItem(DCM_UltrasoundAcquisitionGeometry, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getVolumetoTransducerMappingMatrix(Float64& value, const unsigned long pos) const
{
    return DcmIODUtil::getFloat64ValueFromItem(DCM_VolumeToTransducerMappingMatrix, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getVolumetoTransducerMappingMatrix(OFVector<Float64>& value)
{
    return DcmIODUtil::getFloat64ValuesFromItem(DCM_VolumeToTransducerMappingMatrix, *m_Item, value);
}

OFCondition IODUSFoRModule::getPatientFrameofReferenceSource(OFString& value, const long signed int pos)
{
    return DcmIODUtil::getStringValueFromItem(DCM_PatientFrameOfReferenceSource, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getTableFrameofReferenceUID(OFString& value, const long signed int pos)
{
    return DcmIODUtil::getStringValueFromItem(DCM_TableFrameOfReferenceUID, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getVolumetoTableMappingMatrix(Float64& value, const unsigned long pos) const
{
    return DcmIODUtil::getFloat64ValueFromItem(DCM_VolumeToTableMappingMatrix, *m_Item, value, pos);
}

OFCondition IODUSFoRModule::getVolumetoTableMappingMatrix(OFVector<Float64>& value)
{
    return DcmIODUtil::getFloat64ValuesFromItem(DCM_VolumeToTableMappingMatrix, *m_Item, value);
}

OFCondition IODUSFoRModule::setVolumeFrameOfReferenceUID(const OFString& value, const OFBool checkValue)
{
    OFCondition result = (checkValue) ? DcmUniqueIdentifier::checkStringValue(value, "1") : EC_Normal;
    if (result.good())
        result = m_Item->putAndInsertOFStringArray(DCM_VolumeFrameOfReferenceUID, value);
    return result;
}

OFCondition IODUSFoRModule::setUltrasoundAcquisitionGeometry(const OFString& value, const OFBool checkValue)
{
    OFCondition result = (checkValue) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
    if (result.good())
        result = m_Item->putAndInsertOFStringArray(DCM_UltrasoundAcquisitionGeometry, value);
    return result;
}

OFCondition
IODUSFoRModule::setApexPosition(const Float64& xValue, const Float64& yValue, const Float64& zValue, const OFBool)
{

    DcmElement* elem = DcmItem::newDicomElement(DCM_ApexPosition);

    OFCondition result = elem->putFloat64(xValue, 0);
    if (result.good())
        result = elem->putFloat64(yValue, 1);
    if (result.good())
        result = elem->putFloat64(zValue, 2);
    m_Item->insert(elem);

    return result;
}

OFCondition IODUSFoRModule::setVolumetoTransducerRelationship(const OFString& value, const OFBool checkValue)
{
    OFCondition result = (checkValue) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
    if (result.good())
        result = m_Item->putAndInsertOFStringArray(DCM_VolumeToTransducerRelationship, value);
    return result;
}

OFCondition IODUSFoRModule::setVolumetoTransducerMappingMatrix(const OFVector<Float64>& value, const OFBool checkValue)
{
    size_t vm = value.size();
    if (checkValue && (vm != 16))
    {
        return EC_ValueMultiplicityViolated;
    }

    OFCondition result;

    DcmElement* elem = NULL;
    result           = DcmItem::newDicomElement(elem, DCM_VolumeToTransducerMappingMatrix);
    if (result.good())
    {
        for (size_t n = 0; result.good() && n < vm; n++)
        {
            result = elem->putFloat64(value[n], OFstatic_cast(unsigned long, n));
        }
    }
    if (result.good())
    {
        result = m_Item->insert(elem);
        if (result.bad())
            delete elem;
    }
    return result;
}

OFCondition IODUSFoRModule::setPatientFrameOfReferenceSource(const OFString& value, const OFBool checkValue)
{
    OFCondition result = (checkValue) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
    if (result.good())
        result = m_Item->putAndInsertOFStringArray(DCM_PatientFrameOfReferenceSource, value);
    return result;
}

OFCondition IODUSFoRModule::setTableFrameofReferenceUID(const OFString& value, const OFBool checkValue)
{
    OFCondition result = (checkValue) ? DcmUniqueIdentifier::checkStringValue(value, "1") : EC_Normal;
    if (result.good())
        result = m_Item->putAndInsertOFStringArray(DCM_TableFrameOfReferenceUID, value);
    return result;
}

OFCondition IODUSFoRModule::setVolumeToTableMappingMatrix(const OFVector<Float64>& value, const OFBool checkValue)
{
    size_t vm = value.size();
    if (checkValue && (vm != 16))
    {
        return EC_ValueMultiplicityViolated;
    }

    OFCondition result;

    DcmElement* elem = NULL;
    result           = DcmItem::newDicomElement(elem, DCM_VolumeToTableMappingMatrix);
    if (result.good())
    {
        for (size_t n = 0; result.good() && (n < vm); n++)
        {
            result = elem->putFloat64(value[n], OFstatic_cast(unsigned long, n));
        }
    }
    if (result.good())
    {
        result = m_Item->insert(elem);
        if (result.bad())
            delete elem;
    }
    return result;
}