1 /*=========================================================================
4 Module: $RCSfile: gdcmBinEntry.cxx,v $
6 Date: $Date: 2004/12/16 13:46:36 $
7 Version: $Revision: 1.42 $
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();
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)
80 void* binArea = GetBinArea();
83 //s << " [" << GDCM_BINLOADED
84 s << " [" << GetValue()
85 << "; length = " << GetLength() << "]";
89 if ( GetLength() == 0 )
95 //s << " [gdcm::Binary data NOT loaded]";
96 s << " [" <<GetValue() << "]";
104 * \brief canonical Writer
105 * @param fp already open file pointer
106 * @param filetype type of the file to be written
108 void BinEntry::WriteContent(std::ofstream* fp, FileType filetype)
110 DocEntry::WriteContent(fp, filetype);
111 void* binArea = GetBinArea();
112 int lgr = GetLength();
115 // there is a 'non string' LUT, overlay, etc
116 fp->write ( (char*)binArea, lgr ); // Elem value
117 //assert( strlen((char*)binArea) == lgr );
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