1 /*=========================================================================
4 Module: $RCSfile: gdcmBinEntry.cxx,v $
6 Date: $Date: 2004/11/03 20:52:12 $
7 Version: $Revision: 1.35 $
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)
38 * \brief Constructor from a given BinEntry
39 * @param e Pointer to existing Doc entry
41 BinEntry::BinEntry(DocEntry* e) : ValEntry(e->GetDictEntry())
43 UsableLength = e->GetLength();
44 ReadLength = e->GetReadLength();
45 ImplicitVR = e->IsImplicitVR();
46 Offset = e->GetOffset();
47 PrintLevel = e->GetPrintLevel();
49 //SQDepthLevel = e->GetDepthLevel();
51 BinArea = 0; // let's be carefull !
55 * \brief Canonical destructor.
62 BinArea = 0; // let's be carefull !
67 //-----------------------------------------------------------------------------
70 * \brief canonical Printer
73 void BinEntry::Print(std::ostream &os)
77 void* binArea = GetBinArea();
80 //s << " [" << GDCM_BINLOADED
81 s << " [" << GetValue()
82 << "; length = " << GetLength() << "]";
86 if ( GetLength() == 0 )
92 //s << " [gdcm::Binary data NOT loaded]";
93 s << " [" <<GetValue() << "]";
101 * \brief canonical Writer
102 * @param fp already open file pointer
103 * @param filetype type of the file to be written
105 void BinEntry::Write(std::ofstream* fp, FileType filetype)
107 DocEntry::Write(fp, filetype);
108 void* binArea = GetBinArea();
109 int lgr = GetLength();
112 // there is a 'non string' LUT, overlay, etc
113 fp->write ( (char*)binArea, lgr ); // Elem value
114 //assert( strlen((char*)binArea) == lgr );
119 // nothing was loaded, but we need to skip space on disc
120 fp->seekp(lgr, std::ios_base::cur);
123 //-----------------------------------------------------------------------------
127 /// \brief Sets the value (non string) of the current Dicom Header Entry
128 void BinEntry::SetBinArea( uint8_t* area )
135 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------
141 //-----------------------------------------------------------------------------
142 } // end namespace gdcm