1 /*=========================================================================
4 Module: $RCSfile: gdcmBinEntry.cxx,v $
6 Date: $Date: 2004/11/16 16:20:23 $
7 Version: $Revision: 1.37 $
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"
26 //-----------------------------------------------------------------------------
27 // Constructor / Destructor
30 * \brief Constructor from a given BinEntry
32 BinEntry::BinEntry(DictEntry* e) : ValEntry(e)
39 * \brief Constructor from a given BinEntry
40 * @param e Pointer to existing Doc entry
42 BinEntry::BinEntry(DocEntry* e) : ValEntry(e->GetDictEntry())
44 UsableLength = e->GetLength();
45 ReadLength = e->GetReadLength();
46 ImplicitVR = e->IsImplicitVR();
47 Offset = e->GetOffset();
48 PrintLevel = e->GetPrintLevel();
50 //SQDepthLevel = e->GetDepthLevel();
52 BinArea = 0; // let's be carefull !
57 * \brief Canonical destructor.
61 if (BinArea && SelfArea)
64 BinArea = 0; // let's be carefull !
69 //-----------------------------------------------------------------------------
72 * \brief canonical Printer
75 void BinEntry::Print(std::ostream &os)
79 void* binArea = GetBinArea();
82 //s << " [" << GDCM_BINLOADED
83 s << " [" << GetValue()
84 << "; length = " << GetLength() << "]";
88 if ( GetLength() == 0 )
94 //s << " [gdcm::Binary data NOT loaded]";
95 s << " [" <<GetValue() << "]";
103 * \brief canonical Writer
104 * @param fp already open file pointer
105 * @param filetype type of the file to be written
107 void BinEntry::Write(std::ofstream* fp, FileType filetype)
109 DocEntry::Write(fp, filetype);
110 void* binArea = GetBinArea();
111 int lgr = GetLength();
114 // there is a 'non string' LUT, overlay, etc
115 fp->write ( (char*)binArea, lgr ); // Elem value
116 //assert( strlen((char*)binArea) == lgr );
121 // nothing was loaded, but we need to skip space on disc
122 fp->seekp(lgr, std::ios_base::cur);
125 //-----------------------------------------------------------------------------
129 /// \brief Sets the value (non string) of the current Dicom Header Entry
130 void BinEntry::SetBinArea( uint8_t* area, bool self )
132 if (BinArea && SelfArea)
139 //-----------------------------------------------------------------------------
142 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
146 } // end namespace gdcm