1 /*=========================================================================
4 Module: $RCSfile: gdcmDocEntry.cxx,v $
6 Date: $Date: 2004/06/20 18:08:47 $
7 Version: $Revision: 1.7 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmDocEntry.h"
21 #include "gdcmGlobal.h"
24 #include <iomanip> // for std::ios::left, ...
27 #define MAX_SIZE_PRINT_ELEMENT_VALUE 64
29 //-----------------------------------------------------------------------------
30 // Constructor / Destructor
32 * \ingroup gdcmDocEntry
33 * \brief Constructor from a given gdcmDictEntry
34 * @param in Pointer to existing dictionary entry
36 gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) {
42 * \ingroup gdcmDocEntry
43 * \brief Canonical Printer
44 * @param os ostream we want to print in
46 void gdcmDocEntry::Print(std::ostream & os) {
53 //-----------------------------------------------------------------------------
56 * \ingroup gdcmDocEntry
57 * \brief Prints the common part of gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
59 void gdcmDocEntry::PrintCommonPart(std::ostream & os) {
61 printLevel=2; // FIXME
64 unsigned short int g, e;
70 char greltag[10]; //group element tag
76 sprintf(greltag,"%04x|%04x ",g,e);
81 lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
82 if (lgth == 0xffffffff) {
83 sprintf(st,"x(ffff)"); // I said : "x(ffff)" !
84 s.setf(std::ios::left);
85 s << std::setw(10-strlen(st)) << " ";
87 s.setf(std::ios::left);
88 s << std::setw(8) << "-1";
90 sprintf(st,"x(%x)",lgth);
91 s.setf(std::ios::left);
92 s << std::setw(10-strlen(st)) << " ";
94 s.setf(std::ios::left);
95 s << std::setw(8) << lgth;
98 sprintf(st,"x(%x)",o);
99 s << std::setw(10-strlen(st)) << " ";
101 s << std::setw(8) << o;
104 s << "[" << vr << "] ";
107 s.setf(std::ios::left);
108 s << std::setw(66-GetName().length()) << " ";
111 s << "[" << GetName()<< "]";
115 //-----------------------------------------------------------------------------
119 * \ingroup gdcmDocEntry
120 * \brief Gets the full length of the elementary DocEntry (not only value length)
122 guint32 gdcmDocEntry::GetFullLength(void) {
125 if ( IsImplicitVR() )
126 l = l + 8; // 2 (gr) + 2 (el) + 4 (lgth)
128 if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" )
129 l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth)
131 l = l + 8; // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth)
136 * \ingroup gdcmDocEntry
137 * \brief Copies all the attributes from an other DocEntry
139 void gdcmDocEntry::Copy (gdcmDocEntry* e) {
140 this->entry = e->entry;
141 this->UsableLength = e->UsableLength;
142 this->ReadLength = e->ReadLength;
143 this->ImplicitVR = e->ImplicitVR;
144 this->Offset = e->Offset;
145 this->printLevel = e->printLevel;
146 // TODO : remove gdcmDocEntry SQDepth
150 * \ingroup gdcmDocEntry
151 * \brief tells us if entry is the first one of a Sequence Item (fffe,e00d)
153 bool gdcmDocEntry::isItemDelimitor() {
154 if ( (GetGroup() == 0xfffe) && (GetElement() == 0xe00d) )
160 * \ingroup gdcmDocEntry
161 * \brief tells us if entry is the last one of a 'no length' Sequence fffe,e0dd)
163 bool gdcmDocEntry::isSequenceDelimitor() {
164 if (GetGroup() == 0xfffe && GetElement() == 0xe0dd)
170 //-----------------------------------------------------------------------------
174 //-----------------------------------------------------------------------------
177 //-----------------------------------------------------------------------------