#include "gdcmHeaderHelper.h"
#include "gdcmFile.h"
+#include "gdcmUtil.h"
+
//-----------------------------------------------------------------------------
#endif // #ifndef GDCM_H
//-----------------------------------------------------------------------------
#include "gdcmDict.h"
#include "gdcmUtil.h"
+
#include <fstream>
+#include <iostream>
+#include <iomanip>
+
#ifdef GDCM_NO_ANSI_STRING_STREAM
# include <strstream>
# define ostringstream ostrstream
* @param FileName from which to build the dictionary.
*/
gdcmDict::gdcmDict(std::string & FileName) {
- std::ifstream from(FileName.c_str());
- dbg.Error(!from, "gdcmDict::gdcmDict: can't open dictionary",
- FileName.c_str());
guint16 group, element;
- // CLEANME : use defines for all those constants
char buff[1024];
- TagKey key;
TagName vr;
TagName fourth;
TagName name;
+ std::ifstream from(FileName.c_str());
+ dbg.Error(!from, "gdcmDict::gdcmDict: can't open dictionary",
+ FileName.c_str());
+
while (!from.eof()) {
from >> std::hex >> group >> element;
eatwhite(from);
fourth = buff;
from.getline(buff, 256, '\n');
name = buff;
+
gdcmDictEntry * newEntry = new gdcmDictEntry(group, element,
vr, fourth, name);
- // FIXME: use AddNewEntry
- NameHt[name] = newEntry;
- KeyHt[gdcmDictEntry::TranslateToKey(group, element)] = newEntry;
+ AddNewEntry(newEntry);
}
from.close();
+
+ filename=FileName;
}
/**
* @param os The output stream to be written to.
*/
void gdcmDict::Print(std::ostream &os) {
+ os<<"Dict file name : "<<filename<<std::endl;
PrintByKey(os);
}
std::ostringstream s;
for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag){
- s << "Tag : ";
- s << "(" << std::hex << tag->second->GetGroup() << ',';
- s << std::hex << tag->second->GetElement() << ") = " << std::dec;
+ s << "Entry : ";
+ s << "(" << std::hex << std::setw(4) << tag->second->GetGroup() << ',';
+ s << std::hex << std::setw(4) << tag->second->GetElement() << ") = " << std::dec;
s << tag->second->GetVR() << ", ";
s << tag->second->GetFourth() << ", ";
s << tag->second->GetName() << "." << std::endl;
std::ostringstream s;
for (TagNameHT::iterator tag = NameHt.begin(); tag != NameHt.end(); ++tag){
- s << "Tag : ";
+ s << "Entry : ";
s << tag->second->GetName() << ",";
s << tag->second->GetVR() << ", ";
s << tag->second->GetFourth() << ", ";
- s << "(" << std::hex << tag->second->GetGroup() << ',';
- s << std::hex << tag->second->GetElement() << ") = " << std::dec << std::endl;
+ s << "(" << std::hex << std::setw(4) << tag->second->GetGroup() << ',';
+ s << std::hex << std::setw(4) << tag->second->GetElement() << ") = ";
+ s << std::dec << std::endl;
}
os << s.str();
}
inline TagKeyHT & gdcmDict::GetEntries(void) { return KeyHt; }
private:
- std::string name;
std::string filename;
/// Access through TagKey (see alternate access with NameHt)
* @param Name Symbolic name that be used as identifier of the newly
* created dictionary.
*/
-void gdcmDictSet::LoadDictFromFile(std::string FileName, DictKey Name)
+gdcmDict *gdcmDictSet::LoadDictFromFile(std::string FileName, DictKey Name)
{
gdcmDict *NewDict = new gdcmDict(FileName);
AppendDict(NewDict,Name);
+ return(NewDict);
}
/**
std::string name)
{
gdcmDictEntry *entry;
- std::string tag=gdcmDictEntry::TranslateToKey(group,element)+vr;
+ std::string tag=gdcmDictEntry::TranslateToKey(group,element)+"#"+vr+"#"+fourth+"#"+name;
std::map<std::string,gdcmDictEntry *>::iterator it;
it=virtualEntry.find(tag);
std::map<std::string, std::list<std::string> > *
GetPubDictEntryNamesByCategory(void);
- void LoadDictFromFile(std::string FileName, DictKey Name);
+ gdcmDict *LoadDictFromFile(std::string FileName, DictKey Name);
gdcmDict *GetDict(DictKey DictName);
gdcmDict *GetDefaultPubDict(void);
#include <stdio.h>
#include <cerrno>
-/*// For nthos:
-#ifdef _MSC_VER
- #include <winsock.h>
-#else
- #include <netinet/in.h>
-#endif*/
#include <cctype> // for isalpha
-/*#ifdef GDCM_NO_ANSI_STRING_STREAM
-# include <strstream>
-# define ostringstream ostrstream
-# else
-# include <sstream>
-#endif*/
-
#include "gdcmUtil.h"
#include "gdcmTS.h"
* @param in Pointer to existing dictionary entry
*/
gdcmHeaderEntry::gdcmHeaderEntry(gdcmDictEntry* in) {
- ImplicitVr = false;
+ ImplicitVR = false;
entry = in;
}
guint32 lgth;
char greltag[10]; //group element tag
- g = GetGroup();
- e = GetElement();
- v = GetValue();
- o = GetOffset();
- sprintf(greltag,"%04x|%04x ",g,e);
- d2 = _CreateCleanString(v); // replace non printable characters by '.'
- s << greltag ;
-
- if (printLevel>=2) {
- s << "lg : ";
- lgth = GetReadLength();
- if (lgth == 0xffffffff) {
- sprintf(st,"x(%ff)");
- s.setf(std::ios::left);
- s << std::setw(10-strlen(st)) << " ";
- s << st << " ";
- s.setf(std::ios::left);
- s << std::setw(8) << "-1";
- } else {
- sprintf(st,"x(%x)",lgth);
- s.setf(std::ios::left);
- s << std::setw(10-strlen(st)) << " ";
- s << st << " ";
- s.setf(std::ios::left);
- s << std::setw(8) << lgth;
- }
- s << " Off.: ";
- sprintf(st,"x(%x)",o);
- s << std::setw(10-strlen(st)) << " ";
+ g = GetGroup();
+ e = GetElement();
+ v = GetValue();
+ o = GetOffset();
+ sprintf(greltag,"%04x|%04x ",g,e);
+ d2 = _CreateCleanString(v); // replace non printable characters by '.'
+ s << greltag ;
+
+ if (printLevel>=2) {
+ s << "lg : ";
+ lgth = GetReadLength();
+ if (lgth == 0xffffffff) {
+ sprintf(st,"x(%ff)");
+ s.setf(std::ios::left);
+ s << std::setw(10-strlen(st)) << " ";
s << st << " ";
- s << std::setw(8) << o;
- }
- if (printLevel>=1) {
- s << "[" << GetVR() << "] ";
s.setf(std::ios::left);
- s << std::setw(66-GetName().length()) << " ";
- }
-
- s << "[" << GetName()<< "]";
- s << " [" << d2 << "]";
- // Display the UID value (instead of displaying the rough code)
- if (g == 0x0002) { // Any more to be displayed ?
- if ( (e == 0x0010) || (e == 0x0002) )
- s << " ==>\t[" << ts->GetValue(v) << "]";
+ s << std::setw(8) << "-1";
} else {
- if (g == 0x0008) {
- if ( (e == 0x0016) || (e == 0x1150) )
- s << " ==>\t[" << ts->GetValue(v) << "]";
- }
- }
- if (e == 0x0000) { // elem 0x0000 --> group length
- if (v == "4294967295") // to avoid troubles in convertion
- sprintf (st," x(ffffffff)");
- else
- sprintf(st," x(%08x)",atoi(v.c_str()));
- s << st;
- }
- s << std::endl;
- os << s.str();
+ sprintf(st,"x(%x)",lgth);
+ s.setf(std::ios::left);
+ s << std::setw(10-strlen(st)) << " ";
+ s << st << " ";
+ s.setf(std::ios::left);
+ s << std::setw(8) << lgth;
+ }
+ s << " Off.: ";
+ sprintf(st,"x(%x)",o);
+ s << std::setw(10-strlen(st)) << " ";
+ s << st << " ";
+ s << std::setw(8) << o;
+ }
+
+ s << "[" << GetVR() << "] ";
+
+ if (printLevel>=1) {
+ s.setf(std::ios::left);
+ s << std::setw(66-GetName().length()) << " ";
+ }
+
+ s << "[" << GetName()<< "]";
+ s << " [" << d2 << "]";
+ // Display the UID value (instead of displaying the rough code)
+ if (g == 0x0002) { // Any more to be displayed ?
+ if ( (e == 0x0010) || (e == 0x0002) )
+ s << " ==>\t[" << ts->GetValue(v) << "]";
+ } else {
+ if (g == 0x0008) {
+ if ( (e == 0x0016) || (e == 0x1150) )
+ s << " ==>\t[" << ts->GetValue(v) << "]";
+ }
+ }
+ if (e == 0x0000) { // elem 0x0000 --> group length
+ if (v == "4294967295") // to avoid troubles in convertion
+ sprintf (st," x(ffffffff)");
+ else
+ sprintf(st," x(%08x)",atoi(v.c_str()));
+ s << st;
+ }
+ s << std::endl;
+ os << s.str();
}
//-----------------------------------------------------------------------------
* \ingroup gdcmHeaderEntry
* \brief Sets to TRUE the ImplicitVr flag of the current Dicom Element
*/
- inline void gdcmHeaderEntry::SetImplicitVr(void) {
- ImplicitVr = true;
- };
+ inline void gdcmHeaderEntry::SetImplicitVR(void) { ImplicitVR = true; };
/**
* \ingroup gdcmHeaderEntry
* \brief tells us if the current Dicom Element was checked as ImplicitVr
* @return true if the current Dicom Element was checked as ImplicitVr
*/
- inline bool gdcmHeaderEntry::IsImplicitVr(void) {
- return ImplicitVr;
- };
+ inline bool gdcmHeaderEntry::IsImplicitVR(void) { return ImplicitVR; };
/**
* \ingroup gdcmHeaderEntry
* \brief tells us if the VR of the current Dicom Element is Unkonwn
* @return true if the VR is unkonwn
*/
- inline bool gdcmHeaderEntry::IsVRUnknown(void) {
- return entry->IsVRUnknown();
- };
+ inline bool gdcmHeaderEntry::IsVRUnknown(void) { return entry->IsVRUnknown(); };
/**
* \ingroup gdcmHeaderEntry
* \brief Gets the DicEntry of the current Dicom Element
* @return the DicEntry of the current Dicom Element
*/
- gdcmDictEntry * gdcmHeaderEntry::GetDictEntry(void) {
- return entry;
- };
+ gdcmDictEntry * gdcmHeaderEntry::GetDictEntry(void) { return entry; };
/**
* \ingroup gdcmHeaderEntry
* \brief Sets the print level for the Dicom Header Elements
* \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
*/
- void SetPrintLevel(int level) { printLevel = level; };
- void Print (std::ostream & os = std::cout);
+ void SetPrintLevel(int level) { printLevel = level; };
+ void Print (std::ostream & os = std::cout);
private:
// FIXME: In fact we should be more specific and use :
// going on.
// *for internal* use only
- bool ImplicitVr; // Even when reading explicit vr files, some
+ bool ImplicitVR; // Even when reading explicit vr files, some
// elements happen to be implicit. Flag them here
// since we can't use the entry->vr without breaking
// the underlying dictionary.
# else
# include <sstream>
#endif
+# include <iomanip>
//-----------------------------------------------------------------------------
// Refer to gdcmParser::CheckSwap()
* both from the H Table and the chained list
* @return
*/
-void gdcmParser::PrintPubEntry(std::ostream & os)
+void gdcmParser::PrintEntry(std::ostream & os)
{
std::ostringstream s;
dbg.Verbose(0, "gdcmParser::gdcmParser not DICOM/ACR", filename.c_str());
}
else {
- std::cerr<<filename.c_str()<<std::endl;
dbg.Verbose(0, "gdcmParser::gdcmParser cannot open file", filename.c_str());
}
return(NULL);
*/
void gdcmParser::UpdateShaEntries(void)
{
- if(!RefShaDict)
- return;
-
gdcmDictEntry *entry;
std::string vr;
++it)
{
// Odd group => from public dictionary
- if((*it)->GetGroup()%1==0)
+ if((*it)->GetGroup()%2==0)
continue;
// Peer group => search the corresponding dict entry
- entry=RefShaDict->GetDictEntryByNumber((*it)->GetGroup(),(*it)->GetElement());
+ if(RefShaDict)
+ entry=RefShaDict->GetDictEntryByNumber((*it)->GetGroup(),(*it)->GetElement());
+ else
+ entry=NULL;
+
+ if((*it)->IsImplicitVR())
+ vr="Implicit";
+ else
+ vr=(*it)->GetVR();
+
if(entry)
{
+ // Set the new entry and the new value
(*it)->SetDictEntry(entry);
- vr=(*it)->GetVR();
CheckHeaderEntryVR(*it,vr);
+
+ (*it)->SetValue(GetHeaderEntryValue(*it));
+ }
+ else
+ {
+ // Remove precedent value transformation
+ (*it)->SetValue(GetHeaderEntryUnvalue(*it));
+ (*it)->SetDictEntry(NewVirtualDictEntry((*it)->GetGroup(),(*it)->GetElement(),vr));
}
}
}
return(a);
}
+/**
+ * \ingroup gdcmParser
+ * \brief Unswaps back the bytes of 4-byte long integer accordingly to
+ * processor order.
+ * @return The properly unswaped 32 bits integer.
+ */
+guint32 gdcmParser::UnswapLong(guint32 a)
+{
+ return (SwapLong(a));
+}
+
/**
* \ingroup gdcmParser
* \brief Swaps the bytes so they agree with the processor order
return (a);
}
+/**
+ * \ingroup gdcmParser
+ * \brief Unswaps the bytes so they agree with the processor order
+ * @return The properly unswaped 16 bits integer.
+ */
+guint16 gdcmParser::UnswapShort(guint16 a)
+{
+ return (SwapShort(a));
+}
+
//-----------------------------------------------------------------------------
// Private
/**
i != GetListEntry().end();
++i)
{
- LoadHeaderEntry(*i);
- }
+ LoadHeaderEntry(*i);
+ }
rewind(fp);
guint32 NewInt;
std::ostringstream s;
int nbInt;
- if (vr == "US" || vr == "SS")
+ if (vr == "US" || vr == "SS")
{
nbInt = length / 2;
NewInt = ReadInt16();
}
}
- }
+ }
else if (vr == "UL" || vr == "SL")
{
nbInt = length / 4;
s << NewInt;
}
}
- }
+ }
#ifdef GDCM_NO_ANSI_STRING_STREAM
s << std::ends; // to avoid oddities on Solaris
#endif //GDCM_NO_ANSI_STRING_STREAM
* \ when position to be taken care of
* @param newHeaderEntry
*/
-void gdcmParser::AddHeaderEntry(gdcmHeaderEntry * newHeaderEntry)
+void gdcmParser::AddHeaderEntry(gdcmHeaderEntry *newHeaderEntry)
{
tagHT.insert( PairHT( newHeaderEntry->GetKey(),newHeaderEntry) );
listEntries.push_back(newHeaderEntry);
* @return
*/
- void gdcmParser::FindHeaderEntryLength (gdcmHeaderEntry * Entry)
+ void gdcmParser::FindHeaderEntryLength (gdcmHeaderEntry *Entry)
{
guint16 element = Entry->GetElement();
guint16 group = Entry->GetGroup();
"we reached 7fe0 0010");
}
- if ( (filetype == ExplicitVR) && ! Entry->IsImplicitVr() )
+ if ( (filetype == ExplicitVR) && (! Entry->IsImplicitVR()) )
{
if ( (vr=="OB") || (vr=="OW") || (vr=="SQ") || (vr=="UN") )
{
FixHeaderEntryFoundLength(Entry, (guint32)length16);
return;
}
-
- // Either implicit VR or a non DICOM conformal (see not below) explicit
- // VR that ommited the VR of (at least) this element. Farts happen.
- // [Note: according to the part 5, PS 3.5-2001, section 7.1 p25
- // on Data elements "Implicit and Explicit VR Data Elements shall
- // not coexist in a Data Set and Data Sets nested within it".]
- // Length is on 4 bytes.
- FixHeaderEntryFoundLength(Entry, ReadInt32());
- return;
+ else
+ {
+ // Either implicit VR or a non DICOM conformal (see not below) explicit
+ // VR that ommited the VR of (at least) this element. Farts happen.
+ // [Note: according to the part 5, PS 3.5-2001, section 7.1 p25
+ // on Data elements "Implicit and Explicit VR Data Elements shall
+ // not coexist in a Data Set and Data Sets nested within it".]
+ // Length is on 4 bytes.
+ FixHeaderEntryFoundLength(Entry, ReadInt32());
+ return;
+ }
}
/**
// avoid .
if ( Entry->IsVRUnknown() )
Entry->SetVR("Implicit");
- Entry->SetImplicitVr();
+ Entry->SetImplicitVR();
}
}
* @return false if the VR is incorrect of if the VR isn't referenced
* otherwise, it returns true
*/
-bool gdcmParser::CheckHeaderEntryVR (gdcmHeaderEntry *Entry, VRKey vr)
+bool gdcmParser::CheckHeaderEntryVR(gdcmHeaderEntry *Entry, VRKey vr)
{
char msg[100]; // for sprintf
bool RealExplicit = true;
// be unwise to overwrite the VR of a dictionary (since it would
// compromise it's next user), we need to clone the actual DictEntry
// and change the VR for the read one.
- gdcmDictEntry* NewTag = NewVirtualDictEntry(Entry->GetGroup(),
- Entry->GetElement(),
- vr,
- "FIXME",
- Entry->GetName());
- Entry->SetDictEntry(NewTag);
+ gdcmDictEntry* NewEntry = NewVirtualDictEntry(
+ Entry->GetGroup(),Entry->GetElement(),
+ vr,"FIXME",Entry->GetName());
+ Entry->SetDictEntry(NewEntry);
}
return(true);
}
/**
* \ingroup gdcmParser
- * \brief Skip a given Header Entry
+ * \brief Get the transformed value of the header entry. The VR value
+ * is used to define the transformation to operate on the value
* \warning NOT end user intended method !
- * @param entry
- * @return
+ * @param Entry
+ * @return Transformed entry value
+ */
+std::string gdcmParser::GetHeaderEntryValue(gdcmHeaderEntry *Entry)
+{
+ if ( (IsHeaderEntryAnInteger(Entry)) && (Entry->IsImplicitVR()) )
+ {
+ std::string val=Entry->GetValue();
+ std::string vr=Entry->GetVR();
+ guint32 length = Entry->GetLength();
+ std::ostringstream s;
+ int nbInt;
+
+ if (vr == "US" || vr == "SS")
+ {
+ guint16 NewInt16;
+
+ nbInt = length / 2;
+ for (int i=0; i < nbInt; i++)
+ {
+ if(i!=0)
+ s << '\\';
+ NewInt16 = (val[2*i+0]&0xFF)+((val[2*i+1]&0xFF)<<8);
+ NewInt16 = SwapShort(NewInt16);
+ s << NewInt16;
+ }
+ }
+
+ else if (vr == "UL" || vr == "SL")
+ {
+ guint32 NewInt32;
+
+ nbInt = length / 4;
+ for (int i=0; i < nbInt; i++)
+ {
+ if(i!=0)
+ s << '\\';
+ NewInt32=(val[4*i+0]&0xFF)+((val[4*i+1]&0xFF)<<8)+((val[4*i+2]&0xFF)<<16)+((val[4*i+3]&0xFF)<<24);
+ NewInt32=SwapLong(NewInt32);
+ s << NewInt32;
+ }
+ }
+
+#ifdef GDCM_NO_ANSI_STRING_STREAM
+ s << std::ends; // to avoid oddities on Solaris
+#endif //GDCM_NO_ANSI_STRING_STREAM
+ return(s.str());
+ }
+
+ return(Entry->GetValue());
+}
+
+/**
+ * \ingroup gdcmParser
+ * \brief Get the reverse transformed value of the header entry. The VR
+ * value is used to define the reverse transformation to operate on
+ * the value
+ * \warning NOT end user intended method !
+ * @param Entry
+ * @return Reverse transformed entry value
+ */
+std::string gdcmParser::GetHeaderEntryUnvalue(gdcmHeaderEntry *Entry)
+{
+ if ( (IsHeaderEntryAnInteger(Entry)) && (Entry->IsImplicitVR()) )
+ {
+ std::string vr=Entry->GetVR();
+ std::ostringstream s;
+ std::vector<std::string> tokens;
+ unsigned char *ptr;
+
+ if (vr == "US" || vr == "SS")
+ {
+ guint16 NewInt16;
+
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Tokenize (Entry->GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
+ NewInt16 = atoi(tokens[i].c_str());
+ s<<(NewInt16&0xFF)<<((NewInt16>>8)&0xFF);
+ }
+ tokens.clear();
+ }
+ if (vr == "UL" || vr == "SL")
+ {
+ guint32 NewInt32;
+
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Tokenize (Entry->GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
+ NewInt32 = atoi(tokens[i].c_str());
+ s<<(char)(NewInt32&0xFF)<<(char)((NewInt32>>8)&0xFF)
+ <<(char)((NewInt32>>16)&0xFF)<<(char)((NewInt32>>24)&0xFF);
+ }
+ tokens.clear();
+ }
+
+#ifdef GDCM_NO_ANSI_STRING_STREAM
+ s << std::ends; // to avoid oddities on Solaris
+#endif //GDCM_NO_ANSI_STRING_STREAM
+ return(s.str());
+ }
+
+ return(Entry->GetValue());
+}
+
+/**
+ * \ingroup gdcmParser
+ * \brief Skip a given Header Entry
+ * \warning NOT end user intended method !
+ * @param entry
*/
void gdcmParser::SkipHeaderEntry(gdcmHeaderEntry *entry)
{
gdcmHeaderEntry *gdcmParser::NewHeaderEntryByNumber(guint16 Group, guint16 Elem)
{
// Find out if the tag we encountered is in the dictionaries:
- gdcmDictEntry *NewTag = GetDictEntryByNumber(Group, Elem);
- if (!NewTag)
- NewTag = NewVirtualDictEntry(Group, Elem);
+ gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
+ if (!DictEntry)
+ DictEntry = NewVirtualDictEntry(Group, Elem);
- gdcmHeaderEntry* NewEntry = new gdcmHeaderEntry(NewTag);
+ gdcmHeaderEntry *NewEntry = new gdcmHeaderEntry(DictEntry);
if (!NewEntry)
{
dbg.Verbose(1, "gdcmParser::NewHeaderEntryByNumber",
* \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
*/
void SetPrintLevel(int level) { printLevel = level; };
- virtual void PrintPubEntry(std::ostream &os = std::cout);
+ virtual void PrintEntry(std::ostream &os = std::cout);
virtual void PrintPubDict (std::ostream &os = std::cout);
virtual void PrintShaDict (std::ostream &os = std::cout);
// System access
inline int GetSwapCode(void) { return sw; }
guint16 SwapShort(guint16); // needed by gdcmFile
- guint32 SwapLong(guint32); // for JPEG Files
+ guint32 SwapLong(guint32); // needed by gdcmFile
+ guint16 UnswapShort(guint16); // needed by gdcmFile
+ guint32 UnswapLong(guint32); // needed by gdcmFile
protected:
// Entry
gdcmHeaderEntry *GetHeaderEntryByName (std::string Name);
gdcmHeaderEntry *GetHeaderEntryByNumber(guint16 group, guint16 element);
- void LoadHeaderEntrySafe (gdcmHeaderEntry *);
+ void LoadHeaderEntrySafe(gdcmHeaderEntry *);
void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
void WriteEntries(FileType type, FILE *);
void FindHeaderEntryVR (gdcmHeaderEntry *);
bool CheckHeaderEntryVR (gdcmHeaderEntry *, VRKey);
+ std::string GetHeaderEntryValue (gdcmHeaderEntry *);
+ std::string GetHeaderEntryUnvalue(gdcmHeaderEntry *);
+
void SkipHeaderEntry (gdcmHeaderEntry *);
void FixHeaderEntryFoundLength(gdcmHeaderEntry *, guint32);
bool IsHeaderEntryAnInteger (gdcmHeaderEntry *);
std::string vr = "Unknown",
std::string fourth = "Unknown",
std::string name = "Unknown");
+ gdcmDictEntry *NewVirtualDictEntry(gdcmHeaderEntry *);
// Deprecated (Not used)
gdcmHeaderEntry *NewManualHeaderEntryToPubDict(std::string NewTagName,
#endif
#define DICT_TS "dicomTS.dic"
+#include <iostream>
+#ifdef GDCM_NO_ANSI_STRING_STREAM
+# include <strstream>
+# define ostringstream ostrstream
+# else
+# include <sstream>
+#endif
+
//-----------------------------------------------------------------------------
// Constructor / Destructor
-gdcmTS::gdcmTS(void) {
+gdcmTS::gdcmTS(void)
+{
std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_TS);
std::ifstream from(filename.c_str());
dbg.Error(!from, "gdcmTS::gdcmTS: can't open dictionary",filename.c_str());
from.getline(buff, 1024, '\n');
name = buff;
- if(key!="") {
+ if(key!="")
+ {
ts[key]=name;
}
}
from.close();
}
-gdcmTS::~gdcmTS() {
+gdcmTS::~gdcmTS()
+{
ts.clear();
}
//-----------------------------------------------------------------------------
// Print
+/**
+ * \ingroup gdcmVR
+ * \brief Print all
+ * @param os The output stream to be written to.
+ */
+void gdcmTS::Print(std::ostream &os)
+{
+ std::ostringstream s;
+
+ for (TSHT::iterator it = ts.begin(); it != ts.end(); ++it)
+ {
+ s << "TS : "<<it->first<<" = "<<it->second<<std::endl;
+ }
+ os << s.str();
+}
//-----------------------------------------------------------------------------
// Public
-int gdcmTS::Count(TSKey key) {
+int gdcmTS::Count(TSKey key)
+{
return ts.count(key);
}
-std::string gdcmTS::GetValue(TSKey key) {
+std::string gdcmTS::GetValue(TSKey key)
+{
if (ts.count(key) == 0)
return (GDCM_UNFOUND);
return ts[key];
#include "gdcmCommon.h"
#include <map>
#include <string>
+#include <iostream>
//-----------------------------------------------------------------------------
typedef std::string TSKey;
public:
gdcmTS(void);
~gdcmTS();
+
+ void Print(std::ostream &os = std::cout);
+
int Count(TSKey key);
std::string GetValue(TSKey key);
}
//-----------------------------------------------------------------------------
-gdcmVR * gdcmGlobal::VR = (gdcmVR*)0;
-gdcmTS * gdcmGlobal::TS = (gdcmTS*)0;
-gdcmDictSet * gdcmGlobal::Dicts = (gdcmDictSet*)0;
+gdcmVR *gdcmGlobal::VR = (gdcmVR *)0;
+gdcmTS *gdcmGlobal::TS = (gdcmTS *)0;
+gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0;
gdcmGlobal gdcmGlob;
gdcmGlobal::gdcmGlobal(void) {
delete Dicts;
}
-gdcmVR * gdcmGlobal::GetVR(void) {
+gdcmVR *gdcmGlobal::GetVR(void) {
return VR;
}
-gdcmTS * gdcmGlobal::GetTS(void) {
+gdcmTS *gdcmGlobal::GetTS(void) {
return TS;
}
-gdcmDictSet * gdcmGlobal::GetDicts(void) {
+gdcmDictSet *gdcmGlobal::GetDicts(void) {
return Dicts;
}
///////////////////////////////////////////////////////////////////////////
// to prevent a flashing screen when non-printable character
-char * _cleanString(char *v) {
+char *_cleanString(char *v) {
char *d;
int i, l;
l = strlen(v);
* This class contains all globals elements that might be
* instanciated only one time
*/
-class gdcmGlobal {
+class GDCM_EXPORT gdcmGlobal {
public:
gdcmGlobal(void);
~gdcmGlobal();
- static gdcmVR * GetVR(void);
- static gdcmTS * GetTS(void);
- static gdcmDictSet * GetDicts(void);
+ static gdcmVR *GetVR(void);
+ static gdcmTS *GetTS(void);
+ static gdcmDictSet *GetDicts(void);
private:
static gdcmVR *VR;
extern gdcmDebug dbg;
-char * _cleanString(char *v);
+char *_cleanString(char *v);
std::string _CreateCleanString(std::string s);
//-----------------------------------------------------------------------------
#endif
#define DICT_VR "dicomVR.dic"
+#include <iostream>
+#ifdef GDCM_NO_ANSI_STRING_STREAM
+# include <strstream>
+# define ostringstream ostrstream
+# else
+# include <sstream>
+#endif
+
//-----------------------------------------------------------------------------
// Constructor / Destructor
-gdcmVR::gdcmVR(void) {
+gdcmVR::gdcmVR(void)
+{
std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR);
std::ifstream from(filename.c_str());
dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str());
std::string key;
std::string name;
- while (!from.eof()) {
+ while (!from.eof())
+ {
eatwhite(from);
from.getline(buff, 1024, ' ');
key = buff;
//-----------------------------------------------------------------------------
// Print
+/**
+ * \ingroup gdcmVR
+ * \brief Print all
+ * @param os The output stream to be written to.
+ */
+void gdcmVR::Print(std::ostream &os)
+{
+ std::ostringstream s;
+
+ for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it)
+ {
+ s << "VR : "<<it->first<<" = "<<it->second<<std::endl;
+ }
+ os << s.str();
+}
//-----------------------------------------------------------------------------
// Public
-int gdcmVR::Count(VRKey key) {
+/**
+ * \ingroup gdcmVR
+ * \brief Get the count for an element
+ * @param Key key to count
+ */
+int gdcmVR::Count(VRKey key)
+{
return vr.count(key);
}
#include "gdcmCommon.h"
#include <map>
#include <string>
+#include <iostream>
//-----------------------------------------------------------------------------
typedef std::string VRKey;
* Container for dicom Value Representation Hash Table
* \note This is a singleton
*/
-class GDCM_EXPORT gdcmVR {
+class GDCM_EXPORT gdcmVR
+{
public:
gdcmVR(void);
~gdcmVR();
+
+ void Print(std::ostream &os = std::cout);
+
int Count(VRKey key);
private: