1 /*
2 *
3 * Copyright (C) 2015-2018, Open Connections GmbH
4 * All rights reserved. See COPYRIGHT file for details.
5 *
6 * This software and supporting documentation are maintained by
7 *
8 * OFFIS e.V.
9 * R&D Division Health
10 * Escherweg 2
11 * D-26121 Oldenburg, Germany
12 *
13 *
14 * Module: dcmfg
15 *
16 * Author: Michael Onken
17 *
18 * Purpose: Class for managing Plane Orientation (Volume) Functional Group
19 *
20 */
21
22 #include "dcmtk/config/osconfig.h"
23
24 #include "dcmtk/dcmdata/dcdeftag.h"
25 #include "dcmtk/dcmdata/dcvrfd.h"
26 #include "dcmtk/dcmfg/fgplanorvol.h"
27 #include "dcmtk/dcmfg/fgtypes.h"
28 #include "dcmtk/dcmiod/iodutil.h"
29
30 // Constructor
FGPlaneOrientationVolume()31 FGPlaneOrientationVolume::FGPlaneOrientationVolume()
32 : FGBase(DcmFGTypes::EFG_PLANEORIENTVOLUME)
33 , m_ImageOrientationVolume(DCM_ImageOrientationVolume)
34 {
35 }
36
~FGPlaneOrientationVolume()37 FGPlaneOrientationVolume::~FGPlaneOrientationVolume()
38 {
39 // nothing to do
40 }
41
clone() const42 FGBase* FGPlaneOrientationVolume::clone() const
43 {
44 FGPlaneOrientationVolume* copy = new FGPlaneOrientationVolume();
45 if (copy)
46 {
47 copy->m_ImageOrientationVolume = this->m_ImageOrientationVolume;
48 }
49 return copy;
50 }
51
clearData()52 void FGPlaneOrientationVolume::clearData()
53 {
54 m_ImageOrientationVolume.clear();
55 }
56
check() const57 OFCondition FGPlaneOrientationVolume::check() const
58 {
59 // Checks in read() and write() are sufficient for now
60 return EC_Normal;
61 }
62
63 // --- get() functionality ---
64
getImageOrientationVolume(Float64 & value,const long unsigned int pos)65 OFCondition FGPlaneOrientationVolume::getImageOrientationVolume(Float64& value, const long unsigned int pos)
66 {
67 return m_ImageOrientationVolume.getFloat64(value, pos);
68 }
69
getImageOrientationVolume(Float64 & rowX,Float64 & rowY,Float64 & rowZ,Float64 & colX,Float64 & colY,Float64 & colZ)70 OFCondition FGPlaneOrientationVolume::getImageOrientationVolume(
71 Float64& rowX, Float64& rowY, Float64& rowZ, Float64& colX, Float64& colY, Float64& colZ)
72 {
73 OFCondition result = m_ImageOrientationVolume.getFloat64(rowX, 0);
74 if (result.good())
75 result = m_ImageOrientationVolume.getFloat64(rowY, 1);
76 if (result.good())
77 result = m_ImageOrientationVolume.getFloat64(rowZ, 2);
78 if (result.good())
79 result = m_ImageOrientationVolume.getFloat64(colX, 3);
80 if (result.good())
81 result = m_ImageOrientationVolume.getFloat64(colY, 4);
82 if (result.good())
83 result = m_ImageOrientationVolume.getFloat64(colZ, 5);
84 return result;
85 }
86
87 // --- set() functionality ---
88
setImageOrientationVolume(const Float64 & rowX,const Float64 & rowY,const Float64 & rowZ,const Float64 & colX,const Float64 & colY,const Float64 & colZ,const OFBool)89 OFCondition FGPlaneOrientationVolume::setImageOrientationVolume(const Float64& rowX,
90 const Float64& rowY,
91 const Float64& rowZ,
92 const Float64& colX,
93 const Float64& colY,
94 const Float64& colZ,
95 const OFBool)
96 {
97 OFCondition result = m_ImageOrientationVolume.putFloat64(rowX, 0);
98 if (result.good())
99 m_ImageOrientationVolume.putFloat64(rowY, 1);
100 if (result.good())
101 m_ImageOrientationVolume.putFloat64(rowZ, 2);
102 if (result.good())
103 m_ImageOrientationVolume.putFloat64(colX, 3);
104 if (result.good())
105 m_ImageOrientationVolume.putFloat64(colY, 4);
106 if (result.good())
107 m_ImageOrientationVolume.putFloat64(colZ, 5);
108 return result;
109 }
110
111 /// Read Plane Orientation (Volume) Sequence from given item
read(DcmItem & item)112 OFCondition FGPlaneOrientationVolume::read(DcmItem& item)
113 {
114 clearData();
115
116 DcmItem* seqItem = NULL;
117 OFCondition result = getItemFromFGSequence(item, DCM_PlaneOrientationVolumeSequence, 0, seqItem);
118 if (result.bad())
119 return result;
120
121 DcmIODUtil::getAndCheckElementFromDataset(*seqItem, m_ImageOrientationVolume, "6", "1", "PlaneOrientationVolume");
122
123 return EC_Normal;
124 }
125
126 /// Writes single Plane Orientation (Volume) Sequence into given item
write(DcmItem & item)127 OFCondition FGPlaneOrientationVolume::write(DcmItem& item)
128 {
129 DcmItem* seqItem = NULL;
130 OFCondition result = createNewFGSequence(item, DCM_PlaneOrientationVolumeSequence, 0, seqItem);
131 if (result.bad())
132 return result;
133
134 // --- write frame content macro attributes ---
135 DcmIODUtil::copyElementToDataset(result, *seqItem, m_ImageOrientationVolume, "6", "1", "PlaneOrientationVolume");
136 return result;
137 }
138
compare(const FGBase & rhs) const139 int FGPlaneOrientationVolume::compare(const FGBase& rhs) const
140 {
141 int result = FGBase::compare(rhs);
142 if (result != 0)
143 return result;
144
145 const FGPlaneOrientationVolume* myRhs = OFstatic_cast(const FGPlaneOrientationVolume*, &rhs);
146 if (!myRhs)
147 return -1;
148
149 // Compare all elements
150 result = m_ImageOrientationVolume.compare(myRhs->m_ImageOrientationVolume);
151 return result;
152 }
153