1 /*=========================================================================
4 Module: $RCSfile: gdcmBinEntry.cxx,v $
6 Date: $Date: 2005/01/07 16:45:51 $
7 Version: $Revision: 1.44 $
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"
22 #include <iostream> // for std::ios_base, since <ios> does not exist on gcc/Solaris
27 //-----------------------------------------------------------------------------
28 // Constructor / Destructor
31 * \brief Constructor from a given BinEntry
33 BinEntry::BinEntry(DictEntry *e) : ValEntry(e)
40 * \brief Constructor from a given BinEntry
41 * @param e Pointer to existing Doc entry
43 BinEntry::BinEntry(DocEntry *e) : ValEntry(e->GetDictEntry())
46 /* Length = e->GetLength();
47 ReadLength = e->GetReadLength();
48 ImplicitVR = e->IsImplicitVR();
49 Offset = e->GetOffset();*/
52 //SQDepthLevel = e->GetDepthLevel();
54 BinArea = 0; // let's be carefull !
59 * \brief Canonical destructor.
63 if (BinArea && SelfArea)
66 BinArea = 0; // let's be carefull !
71 //-----------------------------------------------------------------------------
74 * \brief canonical Printer
77 void BinEntry::Print(std::ostream &os)
82 void* binArea = GetBinArea();
85 //s << " [" << GDCM_BINLOADED
86 s << " [" << GetValue()
87 << "; length = " << GetLength() << "]";
91 if ( GetLength() == 0 )
97 //s << " [gdcm::Binary data NOT loaded]";
98 s << " [" <<GetValue() << "]";
106 * \brief canonical Writer
107 * @param fp already open file pointer
108 * @param filetype type of the file to be written
110 void BinEntry::WriteContent(std::ofstream *fp, FileType filetype)
112 DocEntry::WriteContent(fp, filetype);
113 void* binArea = GetBinArea();
114 int lgr = GetLength();
117 // there is a 'non string' LUT, overlay, etc
118 fp->write ( (char*)binArea, lgr ); // Elem value
122 // nothing was loaded, but we need to skip space on disc
123 fp->seekp(lgr, std::ios::cur);
126 //-----------------------------------------------------------------------------
130 /// \brief Sets the value (non string) of the current Dicom Header Entry
131 void BinEntry::SetBinArea( uint8_t *area, bool self )
133 if (BinArea && SelfArea)
140 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------
146 //-----------------------------------------------------------------------------
147 } // end namespace gdcm