File: modfloatingpointimagepixel.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 (232 lines) | stat: -rw-r--r-- 9,296 bytes parent folder | download | duplicates (3)
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
/*
 *
 *  Copyright (C) 2016-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: Floating Point and Double Floating Point Image Pixel Module
 *
 */

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

const OFString IODFloatingPointImagePixelModule::m_ModuleName          = "FloatingPointImagePixelModule";
const DcmTagKey IODFloatingPointImagePixelModule::pixel_data_tag       = DCM_FloatPixelData;
const DcmTagKey IODDoubleFloatingPointImagePixelModule::pixel_data_tag = DCM_DoubleFloatPixelData;

IODFloatingPointImagePixelModule::IODFloatingPointImagePixelModule(OFshared_ptr<DcmItem> item,
                                                                   OFshared_ptr<IODRules> rules)
    : IODImagePixelBase(item, rules)
{
    // reset element rules
    resetRules();
    getData().putAndInsertUint16(DCM_BitsAllocated, 32);
    getData().putAndInsertUint16(DCM_SamplesPerPixel, 1);
    getData().putAndInsertUint16(DCM_PixelRepresentation, 1);
    getData().putAndInsertOFStringArray(DCM_PhotometricInterpretation, "MONOCHROME2");
}

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

IODFloatingPointImagePixelModule::IODFloatingPointImagePixelModule()
    : IODImagePixelBase()
{
    resetRules();
}

IODFloatingPointImagePixelModule::~IODFloatingPointImagePixelModule()
{
    // nothing to do
}

void IODFloatingPointImagePixelModule::resetRules()
{
    // Parameters this module is responsible for.
    m_Rules->addRule(new IODRule(DCM_SamplesPerPixel, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_PhotometricInterpretation, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_Rows, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_Columns, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_BitsAllocated, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_PixelAspectRatio, "2", "1C", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_FloatPixelPaddingValue, "1", "3", m_ModuleName, DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_FloatPixelPaddingRangeLimit, "1", "1C", m_ModuleName, DcmIODTypes::IE_IMAGE),
                     OFTrue);
}

OFCondition IODFloatingPointImagePixelModule::read(DcmItem& source, const OFBool clearOldData)
{
    // Read common attributes
    IODImagePixelBase::read(source, clearOldData);
    // Read extra attributes of Floating Point Image Pixel Module
    IODModule::read(source, clearOldData);
    return EC_Normal;
}

OFCondition IODFloatingPointImagePixelModule::write(DcmItem& destination)
{
    // Write Photometric Interpretation fixed value for Floating Point Image Pixel Module
    OFCondition result = m_Item->putAndInsertOFStringArray(DCM_PhotometricInterpretation, "MONOCHROME2");
    // Write common attributes
    if (result.good())
    {
        result = IODImagePixelBase::write(destination);
    }
    // Write extra attributes of Floating Point Image Pixel Module
    if (result.good())
    {
        result = IODModule::write(destination);
    }
    return result;
}

IODImagePixelBase::DataType IODFloatingPointImagePixelModule::getDataType() const
{
    return IODImagePixelBase::DATA_TYPE_FLOAT;
}

OFCondition IODFloatingPointImagePixelModule::getFloatPixelPaddingValue(Float32& value, const unsigned long pos)
{
    return m_Item->findAndGetFloat32(DCM_FloatPixelPaddingValue, value, pos);
}

OFCondition IODFloatingPointImagePixelModule::getFloatPixelPaddingRangeLimit(Float32& value, const unsigned long pos)
{
    return m_Item->findAndGetFloat32(DCM_FloatPixelPaddingRangeLimit, value, pos);
}

OFCondition IODFloatingPointImagePixelModule::setFloatPixelPaddingValue(const Float32 value, const OFBool checkValue)
{
    (void)checkValue;
    return m_Item->putAndInsertFloat32(DCM_FloatPixelPaddingValue, value);
}

OFCondition IODFloatingPointImagePixelModule::setFloatPixelPaddingRangeLimit(const Float32 value,
                                                                             const OFBool checkValue)
{
    (void)checkValue;
    return m_Item->putAndInsertFloat32(DCM_FloatPixelPaddingRangeLimit, value);
}

// ---------------- Double Floating Point Image Pixel Module ------------------

const OFString IODDoubleFloatingPointImagePixelModule::m_ModuleName = "DoubleFloatingPointImagePixelModule";

IODDoubleFloatingPointImagePixelModule::IODDoubleFloatingPointImagePixelModule(OFshared_ptr<DcmItem> item,
                                                                               OFshared_ptr<IODRules> rules)
    : IODImagePixelBase(item, rules)
{
    // reset element rules
    resetRules();

    getData().putAndInsertUint16(DCM_BitsAllocated, 64);
    getData().putAndInsertUint16(DCM_SamplesPerPixel, 1);
    getData().putAndInsertUint16(DCM_PixelRepresentation, 1);
    getData().putAndInsertOFStringArray(DCM_PhotometricInterpretation, "MONOCHROME2");
}

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

IODDoubleFloatingPointImagePixelModule::IODDoubleFloatingPointImagePixelModule()
    : IODImagePixelBase()
{
    resetRules();
}

IODDoubleFloatingPointImagePixelModule::~IODDoubleFloatingPointImagePixelModule()
{
    // nothing to do
}

void IODDoubleFloatingPointImagePixelModule::resetRules()
{
    // Parameters are tag, VM, type. Overwrite old rules if any.
    // Take over responsibility for Photometric Interpretation since we want to write
    // "MONOCHROME2" as a fixed value.
    m_Rules->addRule(new IODRule(DCM_SamplesPerPixel, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(
        new IODRule(DCM_PhotometricInterpretation, "1", "1", getName(), DcmIODTypes::IE_IMAGE, "MONOCHROME2"), OFTrue);
    m_Rules->addRule(new IODRule(DCM_Rows, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_Columns, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_BitsAllocated, "1", "1", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_PixelAspectRatio, "2", "1C", getName(), DcmIODTypes::IE_IMAGE), OFTrue);
    m_Rules->addRule(new IODRule(DCM_DoubleFloatPixelPaddingValue, "1", "3", m_ModuleName, DcmIODTypes::IE_IMAGE),
                     OFTrue);
    m_Rules->addRule(new IODRule(DCM_DoubleFloatPixelPaddingRangeLimit, "1", "1C", m_ModuleName, DcmIODTypes::IE_IMAGE),
                     OFTrue);
}

OFCondition IODDoubleFloatingPointImagePixelModule::read(DcmItem& source, const OFBool clearOldData)
{
    // Read common attributes
    IODImagePixelBase::read(source, clearOldData);
    // Read extra attributes of Floating Point Image Pixel Module
    IODModule::read(source, clearOldData);
    return EC_Normal;
}

OFCondition IODDoubleFloatingPointImagePixelModule::write(DcmItem& destination)
{
    // Write Photometric Interpretation fixed value for Floating Point Image Pixel Module
    OFCondition result = m_Item->putAndInsertOFStringArray(DCM_PhotometricInterpretation, "MONOCHROME2");
    // Write common attributes
    if (result.good())
    {
        result = IODImagePixelBase::write(destination);
    }
    // Write extra attributes of Floating Point Image Pixel Module
    if (result.good())
    {
        result = IODModule::write(destination);
    }
    return result;
}

IODImagePixelBase::DataType IODDoubleFloatingPointImagePixelModule::getDataType() const
{
    return IODImagePixelBase::DATA_TYPE_DOUBLE;
}

OFCondition IODDoubleFloatingPointImagePixelModule::getDoubleFloatPixelPaddingValue(Float64& value,
                                                                                    const unsigned long pos)
{
    return m_Item->findAndGetFloat64(DCM_FloatPixelPaddingValue, value, pos);
}

OFCondition IODDoubleFloatingPointImagePixelModule::getDoubleFloatPixelPaddingRangeLimit(Float64& value,
                                                                                         const unsigned long pos)
{
    return m_Item->findAndGetFloat64(DCM_DoubleFloatPixelPaddingRangeLimit, value, pos);
}

OFCondition IODDoubleFloatingPointImagePixelModule::setDoubleFloatPixelPaddingValue(const Float64 value,
                                                                                    const OFBool checkValue)
{
    (void)checkValue;
    return m_Item->putAndInsertFloat64(DCM_DoubleFloatPixelPaddingValue, value);
}

OFCondition IODDoubleFloatingPointImagePixelModule::setDoubleFloatPixelPaddingRangeLimit(const Float64 value,
                                                                                         const OFBool checkValue)
{
    (void)checkValue;
    return m_Item->putAndInsertFloat64(DCM_DoubleFloatPixelPaddingRangeLimit, value);
}