1 /*=========================================================================
4 Module: $RCSfile: gdcmBinEntry.cxx,v $
6 Date: $Date: 2005/01/08 23:14:05 $
7 Version: $Revision: 1.45 $
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.html 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 "gdcmBinEntry.h"
20 #include "gdcmDebug.h"
24 #include <iostream> // for std::ios_base, since <ios> does not exist on gcc/Solaris
29 //-----------------------------------------------------------------------------
30 // Constructor / Destructor
33 * \brief Constructor from a given BinEntry
35 BinEntry::BinEntry(DictEntry *e) : ValEntry(e)
42 * \brief Constructor from a given BinEntry
43 * @param e Pointer to existing Doc entry
45 BinEntry::BinEntry(DocEntry *e) : ValEntry(e->GetDictEntry())
48 /* Length = e->GetLength();
49 ReadLength = e->GetReadLength();
50 ImplicitVR = e->IsImplicitVR();
51 Offset = e->GetOffset();*/
54 //SQDepthLevel = e->GetDepthLevel();
56 BinArea = 0; // let's be carefull !
61 * \brief Canonical destructor.
65 if (BinArea && SelfArea)
68 BinArea = 0; // let's be carefull !
73 //-----------------------------------------------------------------------------
76 * \brief canonical Printer
79 void BinEntry::Print(std::ostream &os)
84 void* binArea = GetBinArea();
87 //s << " [" << GDCM_BINLOADED
88 s << " [" << GetValue()
89 << "; length = " << GetLength() << "]";
93 if ( GetLength() == 0 )
99 //s << " [gdcm::Binary data NOT loaded]";
100 s << " [" <<GetValue() << "]";
108 * \brief canonical Writer
109 * @param fp already open file pointer
110 * @param filetype type of the file to be written
112 void BinEntry::WriteContent(std::ofstream *fp, FileType filetype)
114 DocEntry::WriteContent(fp, filetype);
115 void* binArea = GetBinArea();
116 int lgr = GetLength();
119 // there is a 'non string' LUT, overlay, etc
120 fp->write ( (char*)binArea, lgr ); // Elem value
124 // nothing was loaded, but we need to skip space on disc
125 fp->seekp(lgr, std::ios::cur);
128 //-----------------------------------------------------------------------------
132 /// \brief Sets the value (non string) of the current Dicom Header Entry
133 void BinEntry::SetBinArea( uint8_t *area, bool self )
135 if (BinArea && SelfArea)
142 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
148 //-----------------------------------------------------------------------------
149 } // end namespace gdcm