1 /*
2 *
3 * Copyright (C) 2008-2012, OFFIS e.V. and ICSMED AG, Oldenburg, Germany
4 * Copyright (C) 2013-2017, J. Riesmeier, Oldenburg, Germany
5 * All rights reserved. See COPYRIGHT file for details.
6 *
7 * Source file for class DRTIonRangeCompensatorSequence
8 *
9 * Generated automatically from DICOM PS 3.3-2017e
10 * File created on 2017-12-05 09:30:54
11 *
12 */
13
14
15 #include "dcmtk/config/osconfig.h" // make sure OS specific configuration is included first
16
17 #include "dcmtk/dcmrt/seq/drtircs.h"
18
19
20 // --- item class ---
21
Item(const OFBool emptyDefaultItem)22 DRTIonRangeCompensatorSequence::Item::Item(const OFBool emptyDefaultItem)
23 : EmptyDefaultItem(emptyDefaultItem),
24 AccessoryCode(DCM_AccessoryCode),
25 CompensatorColumnOffset(DCM_CompensatorColumnOffset),
26 CompensatorColumns(DCM_CompensatorColumns),
27 CompensatorDescription(DCM_CompensatorDescription),
28 CompensatorDivergence(DCM_CompensatorDivergence),
29 CompensatorID(DCM_CompensatorID),
30 CompensatorMillingToolDiameter(DCM_CompensatorMillingToolDiameter),
31 CompensatorMountingPosition(DCM_CompensatorMountingPosition),
32 CompensatorNumber(DCM_CompensatorNumber),
33 CompensatorPixelSpacing(DCM_CompensatorPixelSpacing),
34 CompensatorPosition(DCM_CompensatorPosition),
35 CompensatorRelativeStoppingPowerRatio(DCM_CompensatorRelativeStoppingPowerRatio),
36 CompensatorRows(DCM_CompensatorRows),
37 CompensatorThicknessData(DCM_CompensatorThicknessData),
38 IsocenterToCompensatorDistances(DCM_IsocenterToCompensatorDistances),
39 IsocenterToCompensatorTrayDistance(DCM_IsocenterToCompensatorTrayDistance),
40 MaterialID(DCM_MaterialID)
41 {
42 }
43
44
Item(const Item & copy)45 DRTIonRangeCompensatorSequence::Item::Item(const Item ©)
46 : EmptyDefaultItem(copy.EmptyDefaultItem),
47 AccessoryCode(copy.AccessoryCode),
48 CompensatorColumnOffset(copy.CompensatorColumnOffset),
49 CompensatorColumns(copy.CompensatorColumns),
50 CompensatorDescription(copy.CompensatorDescription),
51 CompensatorDivergence(copy.CompensatorDivergence),
52 CompensatorID(copy.CompensatorID),
53 CompensatorMillingToolDiameter(copy.CompensatorMillingToolDiameter),
54 CompensatorMountingPosition(copy.CompensatorMountingPosition),
55 CompensatorNumber(copy.CompensatorNumber),
56 CompensatorPixelSpacing(copy.CompensatorPixelSpacing),
57 CompensatorPosition(copy.CompensatorPosition),
58 CompensatorRelativeStoppingPowerRatio(copy.CompensatorRelativeStoppingPowerRatio),
59 CompensatorRows(copy.CompensatorRows),
60 CompensatorThicknessData(copy.CompensatorThicknessData),
61 IsocenterToCompensatorDistances(copy.IsocenterToCompensatorDistances),
62 IsocenterToCompensatorTrayDistance(copy.IsocenterToCompensatorTrayDistance),
63 MaterialID(copy.MaterialID)
64 {
65 }
66
67
~Item()68 DRTIonRangeCompensatorSequence::Item::~Item()
69 {
70 }
71
72
operator =(const Item & copy)73 DRTIonRangeCompensatorSequence::Item &DRTIonRangeCompensatorSequence::Item::operator=(const Item ©)
74 {
75 if (this != ©)
76 {
77 EmptyDefaultItem = copy.EmptyDefaultItem;
78 AccessoryCode = copy.AccessoryCode;
79 CompensatorColumnOffset = copy.CompensatorColumnOffset;
80 CompensatorColumns = copy.CompensatorColumns;
81 CompensatorDescription = copy.CompensatorDescription;
82 CompensatorDivergence = copy.CompensatorDivergence;
83 CompensatorID = copy.CompensatorID;
84 CompensatorMillingToolDiameter = copy.CompensatorMillingToolDiameter;
85 CompensatorMountingPosition = copy.CompensatorMountingPosition;
86 CompensatorNumber = copy.CompensatorNumber;
87 CompensatorPixelSpacing = copy.CompensatorPixelSpacing;
88 CompensatorPosition = copy.CompensatorPosition;
89 CompensatorRelativeStoppingPowerRatio = copy.CompensatorRelativeStoppingPowerRatio;
90 CompensatorRows = copy.CompensatorRows;
91 CompensatorThicknessData = copy.CompensatorThicknessData;
92 IsocenterToCompensatorDistances = copy.IsocenterToCompensatorDistances;
93 IsocenterToCompensatorTrayDistance = copy.IsocenterToCompensatorTrayDistance;
94 MaterialID = copy.MaterialID;
95 }
96 return *this;
97 }
98
99
clear()100 void DRTIonRangeCompensatorSequence::Item::clear()
101 {
102 if (!EmptyDefaultItem)
103 {
104 /* clear all DICOM attributes */
105 CompensatorDescription.clear();
106 CompensatorNumber.clear();
107 MaterialID.clear();
108 CompensatorID.clear();
109 AccessoryCode.clear();
110 IsocenterToCompensatorTrayDistance.clear();
111 CompensatorDivergence.clear();
112 CompensatorMountingPosition.clear();
113 CompensatorRows.clear();
114 CompensatorColumns.clear();
115 CompensatorPixelSpacing.clear();
116 CompensatorPosition.clear();
117 CompensatorColumnOffset.clear();
118 CompensatorThicknessData.clear();
119 IsocenterToCompensatorDistances.clear();
120 CompensatorRelativeStoppingPowerRatio.clear();
121 CompensatorMillingToolDiameter.clear();
122 }
123 }
124
125
isEmpty()126 OFBool DRTIonRangeCompensatorSequence::Item::isEmpty()
127 {
128 return CompensatorDescription.isEmpty() &&
129 CompensatorNumber.isEmpty() &&
130 MaterialID.isEmpty() &&
131 CompensatorID.isEmpty() &&
132 AccessoryCode.isEmpty() &&
133 IsocenterToCompensatorTrayDistance.isEmpty() &&
134 CompensatorDivergence.isEmpty() &&
135 CompensatorMountingPosition.isEmpty() &&
136 CompensatorRows.isEmpty() &&
137 CompensatorColumns.isEmpty() &&
138 CompensatorPixelSpacing.isEmpty() &&
139 CompensatorPosition.isEmpty() &&
140 CompensatorColumnOffset.isEmpty() &&
141 CompensatorThicknessData.isEmpty() &&
142 IsocenterToCompensatorDistances.isEmpty() &&
143 CompensatorRelativeStoppingPowerRatio.isEmpty() &&
144 CompensatorMillingToolDiameter.isEmpty();
145 }
146
147
isValid() const148 OFBool DRTIonRangeCompensatorSequence::Item::isValid() const
149 {
150 return !EmptyDefaultItem;
151 }
152
153
read(DcmItem & item)154 OFCondition DRTIonRangeCompensatorSequence::Item::read(DcmItem &item)
155 {
156 OFCondition result = EC_IllegalCall;
157 if (!EmptyDefaultItem)
158 {
159 /* re-initialize object */
160 clear();
161 getAndCheckElementFromDataset(item, CompensatorDescription, "1", "3", "IonRangeCompensatorSequence");
162 getAndCheckElementFromDataset(item, CompensatorNumber, "1", "1", "IonRangeCompensatorSequence");
163 getAndCheckElementFromDataset(item, MaterialID, "1", "2", "IonRangeCompensatorSequence");
164 getAndCheckElementFromDataset(item, CompensatorID, "1", "3", "IonRangeCompensatorSequence");
165 getAndCheckElementFromDataset(item, AccessoryCode, "1", "3", "IonRangeCompensatorSequence");
166 getAndCheckElementFromDataset(item, IsocenterToCompensatorTrayDistance, "1", "1C", "IonRangeCompensatorSequence");
167 getAndCheckElementFromDataset(item, CompensatorDivergence, "1", "1", "IonRangeCompensatorSequence");
168 getAndCheckElementFromDataset(item, CompensatorMountingPosition, "1", "1", "IonRangeCompensatorSequence");
169 getAndCheckElementFromDataset(item, CompensatorRows, "1", "1", "IonRangeCompensatorSequence");
170 getAndCheckElementFromDataset(item, CompensatorColumns, "1", "1", "IonRangeCompensatorSequence");
171 getAndCheckElementFromDataset(item, CompensatorPixelSpacing, "2", "1", "IonRangeCompensatorSequence");
172 getAndCheckElementFromDataset(item, CompensatorPosition, "2", "1", "IonRangeCompensatorSequence");
173 getAndCheckElementFromDataset(item, CompensatorColumnOffset, "1", "1C", "IonRangeCompensatorSequence");
174 getAndCheckElementFromDataset(item, CompensatorThicknessData, "1-n", "1", "IonRangeCompensatorSequence");
175 getAndCheckElementFromDataset(item, IsocenterToCompensatorDistances, "1-n", "1C", "IonRangeCompensatorSequence");
176 getAndCheckElementFromDataset(item, CompensatorRelativeStoppingPowerRatio, "1", "3", "IonRangeCompensatorSequence");
177 getAndCheckElementFromDataset(item, CompensatorMillingToolDiameter, "1", "3", "IonRangeCompensatorSequence");
178 result = EC_Normal;
179 }
180 return result;
181 }
182
183
write(DcmItem & item)184 OFCondition DRTIonRangeCompensatorSequence::Item::write(DcmItem &item)
185 {
186 OFCondition result = EC_IllegalCall;
187 if (!EmptyDefaultItem)
188 {
189 result = EC_Normal;
190 addElementToDataset(result, item, new DcmLongText(CompensatorDescription), "1", "3", "IonRangeCompensatorSequence");
191 addElementToDataset(result, item, new DcmIntegerString(CompensatorNumber), "1", "1", "IonRangeCompensatorSequence");
192 addElementToDataset(result, item, new DcmShortString(MaterialID), "1", "2", "IonRangeCompensatorSequence");
193 addElementToDataset(result, item, new DcmShortString(CompensatorID), "1", "3", "IonRangeCompensatorSequence");
194 addElementToDataset(result, item, new DcmLongString(AccessoryCode), "1", "3", "IonRangeCompensatorSequence");
195 addElementToDataset(result, item, new DcmFloatingPointSingle(IsocenterToCompensatorTrayDistance), "1", "1C", "IonRangeCompensatorSequence");
196 addElementToDataset(result, item, new DcmCodeString(CompensatorDivergence), "1", "1", "IonRangeCompensatorSequence");
197 addElementToDataset(result, item, new DcmCodeString(CompensatorMountingPosition), "1", "1", "IonRangeCompensatorSequence");
198 addElementToDataset(result, item, new DcmIntegerString(CompensatorRows), "1", "1", "IonRangeCompensatorSequence");
199 addElementToDataset(result, item, new DcmIntegerString(CompensatorColumns), "1", "1", "IonRangeCompensatorSequence");
200 addElementToDataset(result, item, new DcmDecimalString(CompensatorPixelSpacing), "2", "1", "IonRangeCompensatorSequence");
201 addElementToDataset(result, item, new DcmDecimalString(CompensatorPosition), "2", "1", "IonRangeCompensatorSequence");
202 addElementToDataset(result, item, new DcmFloatingPointSingle(CompensatorColumnOffset), "1", "1C", "IonRangeCompensatorSequence");
203 addElementToDataset(result, item, new DcmDecimalString(CompensatorThicknessData), "1-n", "1", "IonRangeCompensatorSequence");
204 addElementToDataset(result, item, new DcmFloatingPointSingle(IsocenterToCompensatorDistances), "1-n", "1C", "IonRangeCompensatorSequence");
205 addElementToDataset(result, item, new DcmFloatingPointSingle(CompensatorRelativeStoppingPowerRatio), "1", "3", "IonRangeCompensatorSequence");
206 addElementToDataset(result, item, new DcmFloatingPointSingle(CompensatorMillingToolDiameter), "1", "3", "IonRangeCompensatorSequence");
207 }
208 return result;
209 }
210
211
getAccessoryCode(OFString & value,const signed long pos) const212 OFCondition DRTIonRangeCompensatorSequence::Item::getAccessoryCode(OFString &value, const signed long pos) const
213 {
214 if (EmptyDefaultItem)
215 return EC_IllegalCall;
216 else
217 return getStringValueFromElement(AccessoryCode, value, pos);
218 }
219
220
getCompensatorColumnOffset(Float32 & value,const unsigned long pos) const221 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorColumnOffset(Float32 &value, const unsigned long pos) const
222 {
223 if (EmptyDefaultItem)
224 return EC_IllegalCall;
225 else
226 return OFconst_cast(DcmFloatingPointSingle &, CompensatorColumnOffset).getFloat32(value, pos);
227 }
228
229
getCompensatorColumns(OFString & value,const signed long pos) const230 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorColumns(OFString &value, const signed long pos) const
231 {
232 if (EmptyDefaultItem)
233 return EC_IllegalCall;
234 else
235 return getStringValueFromElement(CompensatorColumns, value, pos);
236 }
237
238
getCompensatorColumns(Sint32 & value,const unsigned long pos) const239 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorColumns(Sint32 &value, const unsigned long pos) const
240 {
241 if (EmptyDefaultItem)
242 return EC_IllegalCall;
243 else
244 return OFconst_cast(DcmIntegerString &, CompensatorColumns).getSint32(value, pos);
245 }
246
247
getCompensatorDescription(OFString & value,const signed long pos) const248 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorDescription(OFString &value, const signed long pos) const
249 {
250 if (EmptyDefaultItem)
251 return EC_IllegalCall;
252 else
253 return getStringValueFromElement(CompensatorDescription, value, pos);
254 }
255
256
getCompensatorDivergence(OFString & value,const signed long pos) const257 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorDivergence(OFString &value, const signed long pos) const
258 {
259 if (EmptyDefaultItem)
260 return EC_IllegalCall;
261 else
262 return getStringValueFromElement(CompensatorDivergence, value, pos);
263 }
264
265
getCompensatorID(OFString & value,const signed long pos) const266 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorID(OFString &value, const signed long pos) const
267 {
268 if (EmptyDefaultItem)
269 return EC_IllegalCall;
270 else
271 return getStringValueFromElement(CompensatorID, value, pos);
272 }
273
274
getCompensatorMillingToolDiameter(Float32 & value,const unsigned long pos) const275 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorMillingToolDiameter(Float32 &value, const unsigned long pos) const
276 {
277 if (EmptyDefaultItem)
278 return EC_IllegalCall;
279 else
280 return OFconst_cast(DcmFloatingPointSingle &, CompensatorMillingToolDiameter).getFloat32(value, pos);
281 }
282
283
getCompensatorMountingPosition(OFString & value,const signed long pos) const284 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorMountingPosition(OFString &value, const signed long pos) const
285 {
286 if (EmptyDefaultItem)
287 return EC_IllegalCall;
288 else
289 return getStringValueFromElement(CompensatorMountingPosition, value, pos);
290 }
291
292
getCompensatorNumber(OFString & value,const signed long pos) const293 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorNumber(OFString &value, const signed long pos) const
294 {
295 if (EmptyDefaultItem)
296 return EC_IllegalCall;
297 else
298 return getStringValueFromElement(CompensatorNumber, value, pos);
299 }
300
301
getCompensatorNumber(Sint32 & value,const unsigned long pos) const302 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorNumber(Sint32 &value, const unsigned long pos) const
303 {
304 if (EmptyDefaultItem)
305 return EC_IllegalCall;
306 else
307 return OFconst_cast(DcmIntegerString &, CompensatorNumber).getSint32(value, pos);
308 }
309
310
getCompensatorPixelSpacing(OFString & value,const signed long pos) const311 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorPixelSpacing(OFString &value, const signed long pos) const
312 {
313 if (EmptyDefaultItem)
314 return EC_IllegalCall;
315 else
316 return getStringValueFromElement(CompensatorPixelSpacing, value, pos);
317 }
318
319
getCompensatorPixelSpacing(Float64 & value,const unsigned long pos) const320 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorPixelSpacing(Float64 &value, const unsigned long pos) const
321 {
322 if (EmptyDefaultItem)
323 return EC_IllegalCall;
324 else
325 return OFconst_cast(DcmDecimalString &, CompensatorPixelSpacing).getFloat64(value, pos);
326 }
327
328
getCompensatorPixelSpacing(OFVector<Float64> & value) const329 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorPixelSpacing(OFVector<Float64> &value) const
330 {
331 if (EmptyDefaultItem)
332 return EC_IllegalCall;
333 else
334 return OFconst_cast(DcmDecimalString &, CompensatorPixelSpacing).getFloat64Vector(value);
335 }
336
337
getCompensatorPosition(OFString & value,const signed long pos) const338 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorPosition(OFString &value, const signed long pos) const
339 {
340 if (EmptyDefaultItem)
341 return EC_IllegalCall;
342 else
343 return getStringValueFromElement(CompensatorPosition, value, pos);
344 }
345
346
getCompensatorPosition(Float64 & value,const unsigned long pos) const347 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorPosition(Float64 &value, const unsigned long pos) const
348 {
349 if (EmptyDefaultItem)
350 return EC_IllegalCall;
351 else
352 return OFconst_cast(DcmDecimalString &, CompensatorPosition).getFloat64(value, pos);
353 }
354
355
getCompensatorPosition(OFVector<Float64> & value) const356 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorPosition(OFVector<Float64> &value) const
357 {
358 if (EmptyDefaultItem)
359 return EC_IllegalCall;
360 else
361 return OFconst_cast(DcmDecimalString &, CompensatorPosition).getFloat64Vector(value);
362 }
363
364
getCompensatorRelativeStoppingPowerRatio(Float32 & value,const unsigned long pos) const365 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorRelativeStoppingPowerRatio(Float32 &value, const unsigned long pos) const
366 {
367 if (EmptyDefaultItem)
368 return EC_IllegalCall;
369 else
370 return OFconst_cast(DcmFloatingPointSingle &, CompensatorRelativeStoppingPowerRatio).getFloat32(value, pos);
371 }
372
373
getCompensatorRows(OFString & value,const signed long pos) const374 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorRows(OFString &value, const signed long pos) const
375 {
376 if (EmptyDefaultItem)
377 return EC_IllegalCall;
378 else
379 return getStringValueFromElement(CompensatorRows, value, pos);
380 }
381
382
getCompensatorRows(Sint32 & value,const unsigned long pos) const383 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorRows(Sint32 &value, const unsigned long pos) const
384 {
385 if (EmptyDefaultItem)
386 return EC_IllegalCall;
387 else
388 return OFconst_cast(DcmIntegerString &, CompensatorRows).getSint32(value, pos);
389 }
390
391
getCompensatorThicknessData(OFString & value,const signed long pos) const392 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorThicknessData(OFString &value, const signed long pos) const
393 {
394 if (EmptyDefaultItem)
395 return EC_IllegalCall;
396 else
397 return getStringValueFromElement(CompensatorThicknessData, value, pos);
398 }
399
400
getCompensatorThicknessData(Float64 & value,const unsigned long pos) const401 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorThicknessData(Float64 &value, const unsigned long pos) const
402 {
403 if (EmptyDefaultItem)
404 return EC_IllegalCall;
405 else
406 return OFconst_cast(DcmDecimalString &, CompensatorThicknessData).getFloat64(value, pos);
407 }
408
409
getCompensatorThicknessData(OFVector<Float64> & value) const410 OFCondition DRTIonRangeCompensatorSequence::Item::getCompensatorThicknessData(OFVector<Float64> &value) const
411 {
412 if (EmptyDefaultItem)
413 return EC_IllegalCall;
414 else
415 return OFconst_cast(DcmDecimalString &, CompensatorThicknessData).getFloat64Vector(value);
416 }
417
418
getIsocenterToCompensatorDistances(Float32 & value,const unsigned long pos) const419 OFCondition DRTIonRangeCompensatorSequence::Item::getIsocenterToCompensatorDistances(Float32 &value, const unsigned long pos) const
420 {
421 if (EmptyDefaultItem)
422 return EC_IllegalCall;
423 else
424 return OFconst_cast(DcmFloatingPointSingle &, IsocenterToCompensatorDistances).getFloat32(value, pos);
425 }
426
427
getIsocenterToCompensatorTrayDistance(Float32 & value,const unsigned long pos) const428 OFCondition DRTIonRangeCompensatorSequence::Item::getIsocenterToCompensatorTrayDistance(Float32 &value, const unsigned long pos) const
429 {
430 if (EmptyDefaultItem)
431 return EC_IllegalCall;
432 else
433 return OFconst_cast(DcmFloatingPointSingle &, IsocenterToCompensatorTrayDistance).getFloat32(value, pos);
434 }
435
436
getMaterialID(OFString & value,const signed long pos) const437 OFCondition DRTIonRangeCompensatorSequence::Item::getMaterialID(OFString &value, const signed long pos) const
438 {
439 if (EmptyDefaultItem)
440 return EC_IllegalCall;
441 else
442 return getStringValueFromElement(MaterialID, value, pos);
443 }
444
445
setAccessoryCode(const OFString & value,const OFBool check)446 OFCondition DRTIonRangeCompensatorSequence::Item::setAccessoryCode(const OFString &value, const OFBool check)
447 {
448 OFCondition result = EC_IllegalCall;
449 if (!EmptyDefaultItem)
450 {
451 result = (check) ? DcmLongString::checkStringValue(value, "1") : EC_Normal;
452 if (result.good())
453 result = AccessoryCode.putOFStringArray(value);
454 }
455 return result;
456 }
457
458
setCompensatorColumnOffset(const Float32 value,const unsigned long pos)459 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorColumnOffset(const Float32 value, const unsigned long pos)
460 {
461 if (EmptyDefaultItem)
462 return EC_IllegalCall;
463 else
464 return CompensatorColumnOffset.putFloat32(value, pos);
465 }
466
467
setCompensatorColumns(const OFString & value,const OFBool check)468 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorColumns(const OFString &value, const OFBool check)
469 {
470 OFCondition result = EC_IllegalCall;
471 if (!EmptyDefaultItem)
472 {
473 result = (check) ? DcmIntegerString::checkStringValue(value, "1") : EC_Normal;
474 if (result.good())
475 result = CompensatorColumns.putOFStringArray(value);
476 }
477 return result;
478 }
479
480
setCompensatorDescription(const OFString & value,const OFBool check)481 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorDescription(const OFString &value, const OFBool check)
482 {
483 OFCondition result = EC_IllegalCall;
484 if (!EmptyDefaultItem)
485 {
486 result = (check) ? DcmLongText::checkStringValue(value) : EC_Normal;
487 if (result.good())
488 result = CompensatorDescription.putOFStringArray(value);
489 }
490 return result;
491 }
492
493
setCompensatorDivergence(const OFString & value,const OFBool check)494 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorDivergence(const OFString &value, const OFBool check)
495 {
496 OFCondition result = EC_IllegalCall;
497 if (!EmptyDefaultItem)
498 {
499 result = (check) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
500 if (result.good())
501 result = CompensatorDivergence.putOFStringArray(value);
502 }
503 return result;
504 }
505
506
setCompensatorID(const OFString & value,const OFBool check)507 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorID(const OFString &value, const OFBool check)
508 {
509 OFCondition result = EC_IllegalCall;
510 if (!EmptyDefaultItem)
511 {
512 result = (check) ? DcmShortString::checkStringValue(value, "1") : EC_Normal;
513 if (result.good())
514 result = CompensatorID.putOFStringArray(value);
515 }
516 return result;
517 }
518
519
setCompensatorMillingToolDiameter(const Float32 value,const unsigned long pos)520 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorMillingToolDiameter(const Float32 value, const unsigned long pos)
521 {
522 if (EmptyDefaultItem)
523 return EC_IllegalCall;
524 else
525 return CompensatorMillingToolDiameter.putFloat32(value, pos);
526 }
527
528
setCompensatorMountingPosition(const OFString & value,const OFBool check)529 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorMountingPosition(const OFString &value, const OFBool check)
530 {
531 OFCondition result = EC_IllegalCall;
532 if (!EmptyDefaultItem)
533 {
534 result = (check) ? DcmCodeString::checkStringValue(value, "1") : EC_Normal;
535 if (result.good())
536 result = CompensatorMountingPosition.putOFStringArray(value);
537 }
538 return result;
539 }
540
541
setCompensatorNumber(const OFString & value,const OFBool check)542 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorNumber(const OFString &value, const OFBool check)
543 {
544 OFCondition result = EC_IllegalCall;
545 if (!EmptyDefaultItem)
546 {
547 result = (check) ? DcmIntegerString::checkStringValue(value, "1") : EC_Normal;
548 if (result.good())
549 result = CompensatorNumber.putOFStringArray(value);
550 }
551 return result;
552 }
553
554
setCompensatorPixelSpacing(const OFString & value,const OFBool check)555 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorPixelSpacing(const OFString &value, const OFBool check)
556 {
557 OFCondition result = EC_IllegalCall;
558 if (!EmptyDefaultItem)
559 {
560 result = (check) ? DcmDecimalString::checkStringValue(value, "2") : EC_Normal;
561 if (result.good())
562 result = CompensatorPixelSpacing.putOFStringArray(value);
563 }
564 return result;
565 }
566
567
setCompensatorPosition(const OFString & value,const OFBool check)568 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorPosition(const OFString &value, const OFBool check)
569 {
570 OFCondition result = EC_IllegalCall;
571 if (!EmptyDefaultItem)
572 {
573 result = (check) ? DcmDecimalString::checkStringValue(value, "2") : EC_Normal;
574 if (result.good())
575 result = CompensatorPosition.putOFStringArray(value);
576 }
577 return result;
578 }
579
580
setCompensatorRelativeStoppingPowerRatio(const Float32 value,const unsigned long pos)581 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorRelativeStoppingPowerRatio(const Float32 value, const unsigned long pos)
582 {
583 if (EmptyDefaultItem)
584 return EC_IllegalCall;
585 else
586 return CompensatorRelativeStoppingPowerRatio.putFloat32(value, pos);
587 }
588
589
setCompensatorRows(const OFString & value,const OFBool check)590 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorRows(const OFString &value, const OFBool check)
591 {
592 OFCondition result = EC_IllegalCall;
593 if (!EmptyDefaultItem)
594 {
595 result = (check) ? DcmIntegerString::checkStringValue(value, "1") : EC_Normal;
596 if (result.good())
597 result = CompensatorRows.putOFStringArray(value);
598 }
599 return result;
600 }
601
602
setCompensatorThicknessData(const OFString & value,const OFBool check)603 OFCondition DRTIonRangeCompensatorSequence::Item::setCompensatorThicknessData(const OFString &value, const OFBool check)
604 {
605 OFCondition result = EC_IllegalCall;
606 if (!EmptyDefaultItem)
607 {
608 result = (check) ? DcmDecimalString::checkStringValue(value, "1-n") : EC_Normal;
609 if (result.good())
610 result = CompensatorThicknessData.putOFStringArray(value);
611 }
612 return result;
613 }
614
615
setIsocenterToCompensatorDistances(const Float32 value,const unsigned long pos)616 OFCondition DRTIonRangeCompensatorSequence::Item::setIsocenterToCompensatorDistances(const Float32 value, const unsigned long pos)
617 {
618 if (EmptyDefaultItem)
619 return EC_IllegalCall;
620 else
621 return IsocenterToCompensatorDistances.putFloat32(value, pos);
622 }
623
624
setIsocenterToCompensatorTrayDistance(const Float32 value,const unsigned long pos)625 OFCondition DRTIonRangeCompensatorSequence::Item::setIsocenterToCompensatorTrayDistance(const Float32 value, const unsigned long pos)
626 {
627 if (EmptyDefaultItem)
628 return EC_IllegalCall;
629 else
630 return IsocenterToCompensatorTrayDistance.putFloat32(value, pos);
631 }
632
633
setMaterialID(const OFString & value,const OFBool check)634 OFCondition DRTIonRangeCompensatorSequence::Item::setMaterialID(const OFString &value, const OFBool check)
635 {
636 OFCondition result = EC_IllegalCall;
637 if (!EmptyDefaultItem)
638 {
639 result = (check) ? DcmShortString::checkStringValue(value, "1") : EC_Normal;
640 if (result.good())
641 result = MaterialID.putOFStringArray(value);
642 }
643 return result;
644 }
645
646
647 // --- sequence class ---
648
DRTIonRangeCompensatorSequence(const OFBool emptyDefaultSequence)649 DRTIonRangeCompensatorSequence::DRTIonRangeCompensatorSequence(const OFBool emptyDefaultSequence)
650 : EmptyDefaultSequence(emptyDefaultSequence),
651 SequenceOfItems(),
652 CurrentItem(),
653 EmptyItem(OFTrue /*emptyDefaultItem*/)
654 {
655 CurrentItem = SequenceOfItems.end();
656 }
657
658
DRTIonRangeCompensatorSequence(const DRTIonRangeCompensatorSequence & copy)659 DRTIonRangeCompensatorSequence::DRTIonRangeCompensatorSequence(const DRTIonRangeCompensatorSequence ©)
660 : EmptyDefaultSequence(copy.EmptyDefaultSequence),
661 SequenceOfItems(),
662 CurrentItem(),
663 EmptyItem(OFTrue /*emptyDefaultItem*/)
664 {
665 /* create a copy of the internal sequence of items */
666 Item *item = NULL;
667 OFListConstIterator(Item *) current = copy.SequenceOfItems.begin();
668 const OFListConstIterator(Item *) last = copy.SequenceOfItems.end();
669 while (current != last)
670 {
671 item = new Item(**current);
672 if (item != NULL)
673 {
674 SequenceOfItems.push_back(item);
675 } else {
676 /* memory exhausted, there is nothing we can do about it */
677 break;
678 }
679 ++current;
680 }
681 CurrentItem = SequenceOfItems.begin();
682 }
683
684
operator =(const DRTIonRangeCompensatorSequence & copy)685 DRTIonRangeCompensatorSequence &DRTIonRangeCompensatorSequence::operator=(const DRTIonRangeCompensatorSequence ©)
686 {
687 if (this != ©)
688 {
689 clear();
690 EmptyDefaultSequence = copy.EmptyDefaultSequence;
691 /* create a copy of the internal sequence of items */
692 Item *item = NULL;
693 OFListConstIterator(Item *) current = copy.SequenceOfItems.begin();
694 const OFListConstIterator(Item *) last = copy.SequenceOfItems.end();
695 while (current != last)
696 {
697 item = new Item(**current);
698 if (item != NULL)
699 {
700 SequenceOfItems.push_back(item);
701 } else {
702 /* memory exhausted, there is nothing we can do about it */
703 break;
704 }
705 ++current;
706 }
707 CurrentItem = SequenceOfItems.begin();
708 }
709 return *this;
710 }
711
712
~DRTIonRangeCompensatorSequence()713 DRTIonRangeCompensatorSequence::~DRTIonRangeCompensatorSequence()
714 {
715 clear();
716 }
717
718
clear()719 void DRTIonRangeCompensatorSequence::clear()
720 {
721 if (!EmptyDefaultSequence)
722 {
723 CurrentItem = SequenceOfItems.begin();
724 const OFListConstIterator(Item *) last = SequenceOfItems.end();
725 /* delete all items and free memory */
726 while (CurrentItem != last)
727 {
728 delete (*CurrentItem);
729 CurrentItem = SequenceOfItems.erase(CurrentItem);
730 }
731 /* make sure that the list is empty */
732 SequenceOfItems.clear();
733 CurrentItem = SequenceOfItems.end();
734 }
735 }
736
737
isEmpty()738 OFBool DRTIonRangeCompensatorSequence::isEmpty()
739 {
740 return SequenceOfItems.empty();
741 }
742
743
isValid() const744 OFBool DRTIonRangeCompensatorSequence::isValid() const
745 {
746 return !EmptyDefaultSequence;
747 }
748
749
getNumberOfItems() const750 size_t DRTIonRangeCompensatorSequence::getNumberOfItems() const
751 {
752 return SequenceOfItems.size();
753 }
754
755
gotoFirstItem()756 OFCondition DRTIonRangeCompensatorSequence::gotoFirstItem()
757 {
758 OFCondition result = EC_IllegalCall;
759 if (!SequenceOfItems.empty())
760 {
761 CurrentItem = SequenceOfItems.begin();
762 result = EC_Normal;
763 }
764 return result;
765 }
766
767
gotoNextItem()768 OFCondition DRTIonRangeCompensatorSequence::gotoNextItem()
769 {
770 OFCondition result = EC_IllegalCall;
771 if (CurrentItem != SequenceOfItems.end())
772 {
773 ++CurrentItem;
774 result = EC_Normal;
775 }
776 return result;
777 }
778
779
gotoItem(const size_t num,OFListIterator (Item *)& iterator)780 OFCondition DRTIonRangeCompensatorSequence::gotoItem(const size_t num, OFListIterator(Item *) &iterator)
781 {
782 OFCondition result = EC_IllegalCall;
783 if (!SequenceOfItems.empty())
784 {
785 size_t idx = num + 1;
786 iterator = SequenceOfItems.begin();
787 const OFListConstIterator(Item *) last = SequenceOfItems.end();
788 while ((--idx > 0) && (iterator != last))
789 ++iterator;
790 /* specified list item found? */
791 if ((idx == 0) && (iterator != last))
792 result = EC_Normal;
793 else
794 result = EC_IllegalParameter;
795 }
796 return result;
797 }
798
799
gotoItem(const size_t num,OFListConstIterator (Item *)& iterator) const800 OFCondition DRTIonRangeCompensatorSequence::gotoItem(const size_t num, OFListConstIterator(Item *) &iterator) const
801 {
802 OFCondition result = EC_IllegalCall;
803 if (!SequenceOfItems.empty())
804 {
805 size_t idx = num + 1;
806 iterator = SequenceOfItems.begin();
807 const OFListConstIterator(Item *) last = SequenceOfItems.end();
808 while ((--idx > 0) && (iterator != last))
809 ++iterator;
810 /* specified list item found? */
811 if ((idx == 0) && (iterator != last))
812 result = EC_Normal;
813 else
814 result = EC_IllegalParameter;
815 }
816 return result;
817 }
818
819
gotoItem(const size_t num)820 OFCondition DRTIonRangeCompensatorSequence::gotoItem(const size_t num)
821 {
822 return gotoItem(num, CurrentItem);
823 }
824
825
getCurrentItem(Item * & item) const826 OFCondition DRTIonRangeCompensatorSequence::getCurrentItem(Item *&item) const
827 {
828 OFCondition result = EC_IllegalCall;
829 if (CurrentItem != SequenceOfItems.end())
830 {
831 item = *CurrentItem;
832 result = EC_Normal;
833 }
834 return result;
835 }
836
837
getCurrentItem()838 DRTIonRangeCompensatorSequence::Item &DRTIonRangeCompensatorSequence::getCurrentItem()
839 {
840 if (CurrentItem != SequenceOfItems.end())
841 return **CurrentItem;
842 else
843 return EmptyItem;
844 }
845
846
getCurrentItem() const847 const DRTIonRangeCompensatorSequence::Item &DRTIonRangeCompensatorSequence::getCurrentItem() const
848 {
849 if (CurrentItem != SequenceOfItems.end())
850 return **CurrentItem;
851 else
852 return EmptyItem;
853 }
854
855
getItem(const size_t num,Item * & item)856 OFCondition DRTIonRangeCompensatorSequence::getItem(const size_t num, Item *&item)
857 {
858 OFListIterator(Item *) iterator;
859 OFCondition result = gotoItem(num, iterator);
860 if (result.good())
861 item = *iterator;
862 return result;
863 }
864
865
getItem(const size_t num)866 DRTIonRangeCompensatorSequence::Item &DRTIonRangeCompensatorSequence::getItem(const size_t num)
867 {
868 OFListIterator(Item *) iterator;
869 if (gotoItem(num, iterator).good())
870 return **iterator;
871 else
872 return EmptyItem;
873 }
874
875
getItem(const size_t num) const876 const DRTIonRangeCompensatorSequence::Item &DRTIonRangeCompensatorSequence::getItem(const size_t num) const
877 {
878 OFListConstIterator(Item *) iterator;
879 if (gotoItem(num, iterator).good())
880 return **iterator;
881 else
882 return EmptyItem;
883 }
884
885
operator [](const size_t num)886 DRTIonRangeCompensatorSequence::Item &DRTIonRangeCompensatorSequence::operator[](const size_t num)
887 {
888 return getItem(num);
889 }
890
891
operator [](const size_t num) const892 const DRTIonRangeCompensatorSequence::Item &DRTIonRangeCompensatorSequence::operator[](const size_t num) const
893 {
894 return getItem(num);
895 }
896
897
addItem(Item * & item)898 OFCondition DRTIonRangeCompensatorSequence::addItem(Item *&item)
899 {
900 OFCondition result = EC_IllegalCall;
901 if (!EmptyDefaultSequence)
902 {
903 item = new Item();
904 if (item != NULL)
905 {
906 SequenceOfItems.push_back(item);
907 result = EC_Normal;
908 } else
909 result = EC_MemoryExhausted;
910 }
911 return result;
912 }
913
914
insertItem(const size_t pos,Item * & item)915 OFCondition DRTIonRangeCompensatorSequence::insertItem(const size_t pos, Item *&item)
916 {
917 OFCondition result = EC_IllegalCall;
918 if (!EmptyDefaultSequence)
919 {
920 OFListIterator(Item *) iterator;
921 result = gotoItem(pos, iterator);
922 if (result.good())
923 {
924 item = new Item();
925 if (item != NULL)
926 {
927 SequenceOfItems.insert(iterator, 1, item);
928 result = EC_Normal;
929 } else
930 result = EC_MemoryExhausted;
931 } else
932 result = addItem(item);
933 }
934 return result;
935 }
936
937
removeItem(const size_t pos)938 OFCondition DRTIonRangeCompensatorSequence::removeItem(const size_t pos)
939 {
940 OFCondition result = EC_IllegalCall;
941 if (!EmptyDefaultSequence)
942 {
943 OFListIterator(Item *) iterator;
944 if (gotoItem(pos, iterator).good())
945 {
946 delete *iterator;
947 iterator = SequenceOfItems.erase(iterator);
948 result = EC_Normal;
949 } else
950 result = EC_IllegalParameter;
951 }
952 return result;
953 }
954
955
read(DcmItem & dataset,const OFString & card,const OFString & type,const char * moduleName)956 OFCondition DRTIonRangeCompensatorSequence::read(DcmItem &dataset,
957 const OFString &card,
958 const OFString &type,
959 const char *moduleName)
960 {
961 OFCondition result = EC_IllegalCall;
962 if (!EmptyDefaultSequence)
963 {
964 /* re-initialize object */
965 clear();
966 /* retrieve sequence element from dataset */
967 DcmSequenceOfItems *sequence;
968 result = dataset.findAndGetSequence(DCM_IonRangeCompensatorSequence, sequence);
969 if (sequence != NULL)
970 {
971 if (checkElementValue(*sequence, card, type, result, moduleName))
972 {
973 DcmStack stack;
974 OFBool first = OFTrue;
975 /* iterate over all sequence items */
976 while (result.good() && sequence->nextObject(stack, first /*intoSub*/).good())
977 {
978 DcmItem *ditem = OFstatic_cast(DcmItem *, stack.top());
979 if (ditem != NULL)
980 {
981 Item *item = new Item();
982 if (item != NULL)
983 {
984 result = item->read(*ditem);
985 if (result.good())
986 {
987 /* append new item to the end of the list */
988 SequenceOfItems.push_back(item);
989 first = OFFalse;
990 }
991 } else
992 result = EC_MemoryExhausted;
993 } else
994 result = EC_CorruptedData;
995 }
996 }
997 } else {
998 DcmSequenceOfItems element(DCM_IonRangeCompensatorSequence);
999 checkElementValue(element, card, type, result, moduleName);
1000 }
1001 }
1002 return result;
1003 }
1004
1005
write(DcmItem & dataset,const OFString & card,const OFString & type,const char * moduleName)1006 OFCondition DRTIonRangeCompensatorSequence::write(DcmItem &dataset,
1007 const OFString &card,
1008 const OFString &type,
1009 const char *moduleName)
1010 {
1011 OFCondition result = EC_IllegalCall;
1012 if (!EmptyDefaultSequence)
1013 {
1014 result = EC_MemoryExhausted;
1015 DcmSequenceOfItems *sequence = new DcmSequenceOfItems(DCM_IonRangeCompensatorSequence);
1016 if (sequence != NULL)
1017 {
1018 result = EC_Normal;
1019 /* an empty optional sequence is not written */
1020 if ((type == "2") || !SequenceOfItems.empty())
1021 {
1022 OFListIterator(Item *) iterator = SequenceOfItems.begin();
1023 const OFListConstIterator(Item *) last = SequenceOfItems.end();
1024 /* iterate over all sequence items */
1025 while (result.good() && (iterator != last))
1026 {
1027 DcmItem *item = new DcmItem();
1028 if (item != NULL)
1029 {
1030 /* append new item to the end of the sequence */
1031 result = sequence->append(item);
1032 if (result.good())
1033 {
1034 result = (*iterator)->write(*item);
1035 ++iterator;
1036 } else
1037 delete item;
1038 } else
1039 result = EC_MemoryExhausted;
1040 }
1041 if (result.good())
1042 {
1043 /* insert sequence element into the dataset */
1044 result = dataset.insert(sequence, OFTrue /*replaceOld*/);
1045 }
1046 if (DCM_dcmrtLogger.isEnabledFor(OFLogger::WARN_LOG_LEVEL))
1047 checkElementValue(*sequence, card, type, result, moduleName);
1048 if (result.good())
1049 {
1050 /* forget reference to sequence object (avoid deletion below) */
1051 sequence = NULL;
1052 }
1053 }
1054 else if (type == "1")
1055 {
1056 /* empty type 1 sequence not allowed */
1057 result = RT_EC_InvalidValue;
1058 if (DCM_dcmrtLogger.isEnabledFor(OFLogger::WARN_LOG_LEVEL))
1059 checkElementValue(*sequence, card, type, result, moduleName);
1060 }
1061 /* delete sequence (if not inserted into the dataset) */
1062 delete sequence;
1063 }
1064 }
1065 return result;
1066 }
1067
1068
1069 // end of source file
1070