1 /*=========================================================================
4 Module: $RCSfile: gdcmBinEntry.cxx,v $
6 Date: $Date: 2004/11/30 16:29:01 $
7 Version: $Revision: 1.41 $
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())
45 UsableLength = e->GetLength();
46 ReadLength = e->GetReadLength();
47 ImplicitVR = e->IsImplicitVR();
48 Offset = e->GetOffset();
49 PrintLevel = e->GetPrintLevel();
51 //SQDepthLevel = e->GetDepthLevel();
53 BinArea = 0; // let's be carefull !
58 * \brief Canonical destructor.
62 if (BinArea && SelfArea)
65 BinArea = 0; // let's be carefull !
70 //-----------------------------------------------------------------------------
73 * \brief canonical Printer
76 void BinEntry::Print(std::ostream &os)
81 void* binArea = GetBinArea();
84 //s << " [" << GDCM_BINLOADED
85 s << " [" << GetValue()
86 << "; length = " << GetLength() << "]";
90 if ( GetLength() == 0 )
96 //s << " [gdcm::Binary data NOT loaded]";
97 s << " [" <<GetValue() << "]";
105 * \brief canonical Writer
106 * @param fp already open file pointer
107 * @param filetype type of the file to be written
109 void BinEntry::WriteContent(std::ofstream* fp, FileType filetype)
111 DocEntry::WriteContent(fp, filetype);
112 void* binArea = GetBinArea();
113 int lgr = GetLength();
116 // there is a 'non string' LUT, overlay, etc
117 fp->write ( (char*)binArea, lgr ); // Elem value
118 //assert( strlen((char*)binArea) == lgr );
123 // nothing was loaded, but we need to skip space on disc
124 fp->seekp(lgr, std::ios::cur);
127 //-----------------------------------------------------------------------------
131 /// \brief Sets the value (non string) of the current Dicom Header Entry
132 void BinEntry::SetBinArea( uint8_t* area, bool self )
134 if (BinArea && SelfArea)
141 //-----------------------------------------------------------------------------
144 //-----------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------
148 } // end namespace gdcm