SET(libgdcm_la_SOURCES
gdcmBase.cxx
gdcmBinEntry.cxx
+ gdcmContentEntry.cxx
gdcmDebug.cxx
gdcmDicomDir.cxx
gdcmDicomDirElement.cxx
Program: gdcm
Module: $RCSfile: gdcmBinEntry.cxx,v $
Language: C++
- Date: $Date: 2005/01/24 16:10:52 $
- Version: $Revision: 1.56 $
+ Date: $Date: 2005/01/25 15:21:20 $
+ Version: $Revision: 1.57 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
#include "gdcmBinEntry.h"
+#include "gdcmContentEntry.h"
+
#include "gdcmDebug.h"
#include <fstream>
/**
* \brief Constructor from a given BinEntry
*/
-BinEntry::BinEntry(DictEntry *e) : ValEntry(e)
+BinEntry::BinEntry(DictEntry *e) : ContentEntry(e)
{
BinArea = 0;
SelfArea = true;
* \brief Constructor from a given BinEntry
* @param e Pointer to existing Doc entry
*/
-BinEntry::BinEntry(DocEntry *e) : ValEntry(e->GetDictEntry())
+BinEntry::BinEntry(DocEntry *e) : ContentEntry(e->GetDictEntry())
{
Copy(e);
Program: gdcm
Module: $RCSfile: gdcmBinEntry.h,v $
Language: C++
- Date: $Date: 2005/01/21 11:40:55 $
- Version: $Revision: 1.32 $
+ Date: $Date: 2005/01/25 15:21:20 $
+ Version: $Revision: 1.33 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#ifndef GDCMBINENTRY_H
#define GDCMBINENTRY_H
-#include "gdcmValEntry.h"
+#include "gdcmContentEntry.h"
#include <iostream>
namespace gdcm
//-----------------------------------------------------------------------------
/**
* \brief Any Dicom Document (File or DicomDir) contains
- * a set of DocEntry entries
- * (when successfuly parsed against a given Dicom dictionary)
- * BinEntry is a specialisation of ValEntry (for non std::string
- * representable values)
+ * a set of DocEntry - Dicom entries -
+ * BinEntry is an elementary DocEntry (i.e. a ContentEntry,
+ * as opposite to SeqEntry) whose content is non std::string
+ * representable
+ * BinEntry is a specialisation of ContentEntry
*/
-class GDCM_EXPORT BinEntry : public ValEntry
+class GDCM_EXPORT BinEntry : public ContentEntry
{
public:
BinEntry( DictEntry *e );
void WriteContent( std::ofstream *fp, FileType ft);
/// \brief Returns the area value of the current Dicom Entry
- /// when it's not string-translatable (e.g : a LUT table)
+ /// when it's not string-translatable (e.g : LUT table, overlay, icon)
uint8_t *GetBinArea() { return BinArea; }
+
void SetBinArea( uint8_t *area, bool self = true );
- /// Sets the value (string) of the current Dicom Entry
- virtual void SetValue(std::string const &val) { SetValueOnly(val); };
private:
- /// \brief unsecure memory area to hold 'non string' values
+ /// \brief memory area to hold 'non std::string' representable values
/// (ie : Lookup Tables, overlays, icons)
uint8_t *BinArea;
bool SelfArea;
};
+
} // end namespace gdcm
//-----------------------------------------------------------------------------
#endif
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmContentEntry.cxx,v $
+ Language: C++
+ Date: $Date: 2005/01/25 15:21:20 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#include "gdcmContentEntry.h"
+#include "gdcmVR.h"
+#include "gdcmTS.h"
+#include "gdcmGlobal.h"
+#include "gdcmUtil.h"
+#include "gdcmDebug.h"
+
+#include <fstream>
+
+namespace gdcm
+{
+
+// CLEAN ME
+#define MAX_SIZE_PRINT_ELEMENT_VALUE 128
+
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \brief Constructor from a given DictEntry
+ * @param e Pointer to existing dictionary entry
+ */
+ContentEntry::ContentEntry(DictEntry *e) : DocEntry(e)
+{
+}
+
+/**
+ * \brief Constructor from a given DocEntry
+ * @param e Pointer to existing Doc entry
+ */
+ContentEntry::ContentEntry(DocEntry *e)
+ : DocEntry(e->GetDictEntry())
+{
+ Copy(e);
+}
+
+
+/**
+ * \brief Canonical destructor.
+ */
+ContentEntry::~ContentEntry ()
+{
+}
+
+//-----------------------------------------------------------------------------
+// Public
+
+/**
+ * \brief Writes the std::string representable' value of a ContentEntry
+ * @param fp already open ofstream pointer
+ * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
+ */
+void ContentEntry::WriteContent(std::ofstream *fp, FileType filetype)
+{
+ DocEntry::WriteContent(fp, filetype);
+
+ if ( GetGroup() == 0xfffe )
+ {
+ return; //delimitors have NO value
+ }
+
+ const VRKey &vr = GetVR();
+ unsigned int lgr = GetLength();
+ if (vr == "US" || vr == "SS")
+ {
+ // some 'Short integer' fields may be multivaluated
+ // each single value is separated from the next one by '\'
+ // we split the string and write each value as a short int
+ std::vector<std::string> tokens;
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Util::Tokenize (GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
+ uint16_t val_uint16 = atoi(tokens[i].c_str());
+ binary_write( *fp, val_uint16);
+ }
+ tokens.clear();
+ return;
+ }
+ if (vr == "UL" || vr == "SL")
+ {
+ // Some 'Integer' fields may be multivaluated (multiple instances
+ // of integer). But each single integer value is separated from the
+ // next one by '\' (backslash character). Hence we split the string
+ // along the '\' and write each value as an int:
+ std::vector<std::string> tokens;
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Util::Tokenize (GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
+ uint32_t val_uint32 = atoi(tokens[i].c_str());
+ binary_write( *fp, val_uint32);
+ }
+ tokens.clear();
+ return;
+ }
+
+ gdcmAssertMacro( lgr == GetValue().length() );
+ binary_write(*fp, GetValue());
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
+
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmContentEntry.h,v $
+ Language: C++
+ Date: $Date: 2005/01/25 15:21:20 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef GDCMCONTENTENTRY_H
+#define GDCMCONTENTENTRY_H
+
+#include "gdcmDocEntry.h"
+
+#include <iostream>
+
+namespace gdcm
+{
+//-----------------------------------------------------------------------------
+/**
+ * \brief Any Dicom Document (File or DicomDir) contains
+ * a set of DocEntry - Dicom entries -
+ * (when successfuly parsed against a given Dicom dictionary)
+ * ContentEntry is an elementary DocEntry (as opposed to SeqEntry).
+ * Depending on the type of its content,
+ * ContentEntry is specialized as a ValEntry or a BinEntry
+ */
+class GDCM_EXPORT ContentEntry : public DocEntry
+{
+public:
+ virtual void WriteContent(std::ofstream *fp, FileType filetype) = 0;
+
+ // Accessors are protected, not to be invoked by end user
+ /// Sets the value (string) of the current Dicom entry
+ virtual void SetValue(std::string const &val) { Value = val; };
+
+ void SetValueOnly(std::string const &val) { Value = val; };
+
+ /// \brief Returns the 'Value' (e.g. "Dupond Marcel") converted
+ /// into a 'string', event if it's physically stored on disk as an integer
+ std::string const &GetValue() const { return Value; };
+
+protected:
+
+ // Contructors are protected, not to be invoked by end user.
+ ContentEntry(DictEntry *e);
+ ContentEntry(DocEntry *d);
+ // Destructor is protected, not to be invoked by end user.
+ ~ContentEntry();
+
+private:
+// Members :
+
+ /// \brief Dicom entry value, internaly represented as a std::string.
+ /// The Value Representation (\ref VR) is independently used
+ /// in order to interpret (decode) this field.
+ std::string Value;
+};
+
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif
+
Program: gdcm
Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2005/01/24 16:44:54 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2005/01/25 15:21:20 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmDebug.h"
#include "gdcmUtil.h"
#include "gdcmBinEntry.h"
+#include "gdcmValEntry.h"
+#include "gdcmContentEntry.h"
#include "gdcmFile.h"
#include "gdcmPixelReadConvert.h"
#include "gdcmPixelWriteConvert.h"
case WMODE_RAW :
if( decSize!=PixelWriteConverter->GetUserDataSize() )
{
- gdcmVerboseMacro( "Data size is incorrect (Raw)" << decSize
- << " / " << PixelWriteConverter->GetUserDataSize() );
+ gdcmVerboseMacro( "Data size (Raw) is incorrect. Should be "
+ << decSize << " / Found :"
+ << PixelWriteConverter->GetUserDataSize() );
return false;
}
break;
case WMODE_RGB :
if( rgbSize!=PixelWriteConverter->GetUserDataSize() )
{
- gdcmVerboseMacro( "Data size is incorrect (RGB)" << decSize
- << " / " << PixelWriteConverter->GetUserDataSize() );
+ gdcmVerboseMacro( "Data size (RGB) is incorrect. Should be "
+ << decSize << " / Found "
+ << PixelWriteConverter->GetUserDataSize() );
return false;
}
break;
Program: gdcm
Module: $RCSfile: gdcmValEntry.cxx,v $
Language: C++
- Date: $Date: 2005/01/24 16:10:53 $
- Version: $Revision: 1.50 $
+ Date: $Date: 2005/01/25 15:21:20 $
+ Version: $Revision: 1.51 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief Constructor from a given DictEntry
* @param e Pointer to existing dictionary entry
*/
-ValEntry::ValEntry(DictEntry *e) : DocEntry(e)
+ValEntry::ValEntry(DictEntry *e) : ContentEntry(e)
{
}
* @param e Pointer to existing Doc entry
*/
ValEntry::ValEntry(DocEntry *e)
- : DocEntry(e->GetDictEntry())
+ : ContentEntry(e->GetDictEntry())
{
Copy(e);
}
Program: gdcm
Module: $RCSfile: gdcmValEntry.h,v $
Language: C++
- Date: $Date: 2005/01/21 11:40:56 $
- Version: $Revision: 1.37 $
+ Date: $Date: 2005/01/25 15:21:20 $
+ Version: $Revision: 1.38 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#define GDCMVALENTRY_H
#include "gdcmDocEntry.h"
+#include "gdcmContentEntry.h"
#include <iostream>
namespace gdcm
{
//-----------------------------------------------------------------------------
+
/**
- * \brief Any Dicom Document (File header or DicomDir) contains
+ * \brief Any Dicom Document (File or DicomDir) contains
* a set of DocEntry - Dicom entries -
- * (when successfuly parsed against a given Dicom dictionary)
- * ValEntry is an elementary DocEntry (as opposed to SeqEntry)
- */
-class GDCM_EXPORT ValEntry : public DocEntry
+ * ValEntry is an elementary DocEntry (i.e. a ContentEntry,
+ * as opposed to SeqEntry)
+ * whose content is 'std::string representable' : characters,
+ * or integers (loaded in memory as a std::string)
+ * ValEntry is a specialisation of ContentEntry
+ */
+
+class GDCM_EXPORT ValEntry : public ContentEntry
{
public:
+
+ // Contructors and Destructor are public.
ValEntry(DictEntry *e);
ValEntry(DocEntry *d);
+
~ValEntry();
- /// \brief Returns the 'Value' (e.g. "Dupond Marcel") converted into a
- /// 'string', event if it's physically stored as an integer in the header of the
- /// current Document (File or DicomDir)
- std::string const &GetValue() const { return Value; };
-
- /// Sets the value (string) of the current Dicom entry.
- /// The size is updated
- virtual void SetValue(std::string const &val);
+ // Other accessors are inherited from gdcm::ContentEntry
- virtual void Print(std::ostream &os = std::cout, std::string const & indent = "");
+ void Print(std::ostream &os = std::cout,
+ std::string const & indent = "");
- virtual void WriteContent(std::ofstream *fp, FileType filetype);
+ void WriteContent(std::ofstream *fp, FileType filetype);
+
+ /// Sets the value (string) of the current Dicom entry.
+ /// The size is updated
+ void SetValue(std::string const &val);
protected:
- /// Sets the value (string) of the current Dicom entry
- void SetValueOnly(std::string const &val) { Value = val; };
private:
-// Members :
-
- /// \brief Dicom entry value, internaly represented as a std::string.
- /// The Value Representation (\ref VR) is independently used
- /// in order to interpret (decode) this field.
- std::string Value;
+
};
+
} // end namespace gdcm
//-----------------------------------------------------------------------------