Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2005/02/01 10:29:55 $
- Version: $Revision: 1.71 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.72 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
-/**
- * \brief Remove all Dicom Dictionary Entries
- */
-void Dict::ClearEntry()
-{
- // we assume all the pointed DictEntries are already cleaned-up
- // when we clean KeyHt.
- KeyHt.clear();
-}
-
/**
* \brief adds a new Dicom Dictionary Entry
* @param newEntry entry to add
* @param key (group|element)
* @return false if Dicom Dictionary Entry doesn't exist
*/
-bool Dict::RemoveEntry (TagKey const &key)
+bool Dict::RemoveEntry(TagKey const &key)
{
TagKeyHT::const_iterator it = KeyHt.find(key);
if(it != KeyHt.end())
* @param elem Dicom element number of the Dicom Element
* @return false if Dicom Dictionary Entry doesn't exist
*/
-bool Dict::RemoveEntry (uint16_t group, uint16_t elem)
+bool Dict::RemoveEntry(uint16_t group, uint16_t elem)
{
return RemoveEntry(DictEntry::TranslateToKey(group, elem));
}
+/**
+ * \brief Remove all Dicom Dictionary Entries
+ */
+void Dict::ClearEntry()
+{
+ // we assume all the pointed DictEntries are already cleaned-up
+ // when we clean KeyHt.
+ KeyHt.clear();
+}
+
/**
* \brief Get the dictionary entry identified by a given tag (group,element)
* @param group group of the entry to be found
{
gdcmAssertMacro (ItKeyHt != KeyHt.end());
- {
- ++ItKeyHt;
- if (ItKeyHt != KeyHt.end())
- return &(ItKeyHt->second);
- }
+ ++ItKeyHt;
+ if (ItKeyHt != KeyHt.end())
+ return &(ItKeyHt->second);
return NULL;
}
Program: gdcm
Module: $RCSfile: gdcmDict.h,v $
Language: C++
- Date: $Date: 2005/01/31 12:19:33 $
- Version: $Revision: 1.36 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.37 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void Print(std::ostream &os = std::cout, std::string const &indent = "");
// Entries
- void ClearEntry ();
- bool AddEntry (DictEntry const &newEntry);
+ bool AddEntry(DictEntry const &newEntry);
bool ReplaceEntry(DictEntry const &newEntry);
bool RemoveEntry (TagKey const &key);
bool RemoveEntry (uint16_t group, uint16_t elem);
+ void ClearEntry();
// Tag
DictEntry *GetEntry(uint16_t group, uint16_t elem);
Program: gdcm
Module: $RCSfile: gdcmDictEntry.cxx,v $
Language: C++
- Date: $Date: 2005/02/01 10:29:55 $
- Version: $Revision: 1.44 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.45 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
-/**
- * \brief concatenates 2 uint16_t (supposed to be a Dicom group number
- * and a Dicom element number)
- * @param group the Dicom group number used to build the tag
- * @param elem the Dicom element number used to build the tag
- * @return the built tag
- */
-TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem)
-{
- return Util::Format("%04x|%04x", group, elem);
-}
-
/**
* \brief If-and only if-the V(alue) R(epresentation)
* \ is unset then overwrite it.
gdcmErrorMacro( "Overwriting VM might compromise a dictionary");
}
}
+
+/**
+ * \brief concatenates 2 uint16_t (supposed to be a Dicom group number
+ * and a Dicom element number)
+ * @param group the Dicom group number used to build the tag
+ * @param elem the Dicom element number used to build the tag
+ * @return the built tag
+ */
+TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem)
+{
+ return Util::Format("%04x|%04x", group, elem);
+}
+
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmDictEntry.h,v $
Language: C++
- Date: $Date: 2005/02/01 13:11:49 $
- Version: $Revision: 1.33 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.34 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Print
void Print(std::ostream &os = std::cout, std::string const &indent = "");
-// Key creation
- static TagKey TranslateToKey(uint16_t group, uint16_t elem);
-
// Content of DictEntry
void SetVR(TagName const &vr);
void SetVM(TagName const &vm);
/// @return the key.
const TagName &GetKey() const { return Key; }
+// Key creation
+ static TagKey TranslateToKey(uint16_t group, uint16_t elem);
+
private:
/// \todo FIXME
/// where are the group and elem used except from building up
Program: gdcm
Module: $RCSfile: gdcmDictSet.cxx,v $
Language: C++
- Date: $Date: 2005/02/02 10:02:16 $
- Version: $Revision: 1.58 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.59 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
return entry;
}
+/**
+ * \brief Get the first entry while visiting the DictSet
+ * \return The first Dict if found, otherwhise NULL
+ */
+Dict *DictSet::GetFirstEntry()
+{
+ ItDictHt = Dicts.begin();
+ if( ItDictHt != Dicts.end() )
+ return ItDictHt->second;
+ return NULL;
+}
+
+/**
+ * \brief Get the next entry while visiting the Hash table (DictSetHT)
+ * \note : meaningfull only if GetFirstEntry already called
+ * \return The next Dict if found, otherwhise NULL
+ */
+Dict *DictSet::GetNextEntry()
+{
+ gdcmAssertMacro (ItDictHt != Dicts.end());
+
+ ++ItDictHt;
+ if ( ItDictHt != Dicts.end() )
+ return ItDictHt->second;
+ return NULL;
+}
+
/**
* \brief Obtain from the GDCM_DICT_PATH environnement variable the
* path to directory containing the dictionaries. When
return resultPath;
}
-/**
- * \brief Get the first entry while visiting the DictSet
- * \return The first Dict if found, otherwhise NULL
- */
-Dict *DictSet::GetFirstEntry()
-{
- ItDictHt = Dicts.begin();
- if( ItDictHt != Dicts.end() )
- return ItDictHt->second;
- return NULL;
-}
-
-/**
- * \brief Get the next entry while visiting the Hash table (DictSetHT)
- * \note : meaningfull only if GetFirstEntry already called
- * \return The next Dict if found, otherwhise NULL
- */
-Dict *DictSet::GetNextEntry()
-{
- gdcmAssertMacro (ItDictHt != Dicts.end());
-
- ++ItDictHt;
- if ( ItDictHt != Dicts.end() )
- return ItDictHt->second;
- return NULL;
-}
-
//-----------------------------------------------------------------------------
// Protected
/**
Program: gdcm
Module: $RCSfile: gdcmDictSet.h,v $
Language: C++
- Date: $Date: 2005/02/01 13:11:49 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.41 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
TagName vm = GDCM_UNKNOWN,
TagName name = GDCM_UNKNOWN);
- static std::string BuildDictPath();
-
Dict *GetFirstEntry();
Dict *GetNextEntry();
+ static std::string BuildDictPath();
+
protected:
bool AppendDict(Dict *NewDict, DictKey const &name);
Program: gdcm
Module: $RCSfile: gdcmDirList.cxx,v $
Language: C++
- Date: $Date: 2005/02/01 10:29:55 $
- Version: $Revision: 1.42 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.43 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
-/**
- * \brief Print method
- * @param os ostream to write to
- */
-void DirList::Print(std::ostream &os)
+bool DirList::IsDirectory(std::string const &dirName)
{
- std::copy(Filenames.begin(), Filenames.end(),
- std::ostream_iterator<std::string>(os, "\n"));
+#ifndef _MSC_VER
+ struct stat buf;
+ stat(dirName.c_str(), &buf);
+ return S_ISDIR(buf.st_mode);
+#else
+ return (GetFileAttributes(dirName.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
+#endif
}
//-----------------------------------------------------------------------------
return numberOfFiles;
}
-bool DirList::IsDirectory(std::string const &dirName)
-{
-#ifndef _MSC_VER
- struct stat buf;
- stat(dirName.c_str(), &buf);
- return S_ISDIR(buf.st_mode);
-#else
- return (GetFileAttributes(dirName.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
-#endif
-}
-
//-----------------------------------------------------------------------------
// Print
+/**
+ * \brief Print method
+ * @param os ostream to write to
+ */
+void DirList::Print(std::ostream &os)
+{
+ std::copy(Filenames.begin(), Filenames.end(),
+ std::ostream_iterator<std::string>(os, "\n"));
+}
//-----------------------------------------------------------------------------
} // end namespace gdcm
Program: gdcm
Module: $RCSfile: gdcmDirList.h,v $
Language: C++
- Date: $Date: 2005/02/01 13:11:49 $
- Version: $Revision: 1.22 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.23 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
DirList(std::string const &dirName, bool recursive=false);
~DirList();
+ void Print(std::ostream &os = std::cout);
+
/// Return the name of the directory
std::string const &GetDirName() const { return DirName; }
/// Return the file names
DirListType const &GetFilenames() const { return Filenames; };
- /// Print all element of the DirList
- void Print(std::ostream &os = std::cout);
-
static bool IsDirectory(std::string const &dirName);
private :
int Explore(std::string const &dirName, bool recursive=false);
+ /// List of file names
DirListType Filenames;
-
/// name of the root directory to explore
std::string DirName;
};
Program: gdcm
Module: $RCSfile: gdcmGlobal.cxx,v $
Language: C++
- Date: $Date: 2005/02/01 10:29:55 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.18 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
+/**
+ * \brief returns a pointer to Dictionaries Table
+ */
+DictSet *Global::GetDicts()
+{
+ return Dicts;
+}
+
/**
* \brief returns a pointer to the 'Value Representation Table'
*/
{
return ValRes;
}
+
/**
* \brief returns a pointer to the 'Transfer Syntax Table'
*/
{
return TranSyn;
}
-/**
- * \brief returns a pointer to Dictionaries Table
- */
-DictSet *Global::GetDicts()
-{
- return Dicts;
-}
+
/**
* \brief returns a pointer to the DicomDir related elements Table
*/
Program: gdcm
Module: $RCSfile: gdcmTS.cxx,v $
Language: C++
- Date: $Date: 2005/02/02 10:02:18 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.41 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
return r;
}
+
/**
* \brief Determines if the Transfer Syntax was already encountered
* and if it corresponds to a JPEG2000 one
Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2005/02/02 10:02:18 $
- Version: $Revision: 1.129 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.130 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::string Util::RootUID = GDCM_UID;
//-------------------------------------------------------------------------
+// Public
/**
* \brief Provide a better 'c++' approach for sprintf
* For example c code is:
return r;
}
+unsigned int Util::GetCurrentThreadID()
+{
+// FIXME the implementation is far from complete
+#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
+ return (unsigned int)GetCurrentThreadId();
+#endif
+#ifdef __linux__
+ return 0;
+ // Doesn't work on fedora, but is in the man page...
+ //return (unsigned int)gettid();
+#endif
+#ifdef __sun
+ return (unsigned int)thr_self();
+#else
+ //default implementation
+ return 0;
+#endif
+}
+
+unsigned int Util::GetCurrentProcessID()
+{
+#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
+ // NOTE: There is also a _getpid()...
+ return (unsigned int)GetCurrentProcessId();
+#else
+ // get process identification, POSIX
+ return (unsigned int)getpid();
+#endif
+}
+
+/**
+ * \brief tells us if the processor we are working with is BigEndian or not
+ */
+bool Util::IsCurrentProcessorBigEndian()
+{
+#ifdef GDCM_WORDS_BIGENDIAN
+ return true;
+#else
+ return false;
+#endif
+}
+
/**
* \brief Create a /DICOM/ string:
* It should a of even length (no odd length ever)
return s1_even == s2_even;
}
-/**
- * \brief tells us if the processor we are working with is BigEndian or not
- */
-bool Util::IsCurrentProcessorBigEndian()
-{
-#ifdef GDCM_WORDS_BIGENDIAN
- return true;
-#else
- return false;
-#endif
-}
-
#ifdef _WIN32
typedef BOOL(WINAPI * pSnmpExtensionInit) (
IN DWORD dwTimeZeroReference,
}
}
-/**
- * \brief Return the IP adress of the machine writting the DICOM image
- */
-std::string Util::GetIPAddress()
-{
- // This is a rip from
- // http://www.codeguru.com/Cpp/I-N/internet/network/article.php/c3445/
-#ifndef HOST_NAME_MAX
- // SUSv2 guarantees that `Host names are limited to 255 bytes'.
- // POSIX 1003.1-2001 guarantees that `Host names (not including the
- // terminating NUL) are limited to HOST_NAME_MAX bytes'.
-#define HOST_NAME_MAX 255
- // In this case we should maybe check the string was not truncated.
- // But I don't known how to check that...
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
- // with WinSock DLL we need to initialize the WinSock before using gethostname
- WORD wVersionRequested = MAKEWORD(1,0);
- WSADATA WSAData;
- int err = WSAStartup(wVersionRequested,&WSAData);
- if (err != 0)
- {
- // Tell the user that we could not find a usable
- // WinSock DLL.
- WSACleanup();
- return "127.0.0.1";
- }
-#endif
-
-#endif //HOST_NAME_MAX
-
- std::string str;
- char szHostName[HOST_NAME_MAX+1];
- int r = gethostname(szHostName, HOST_NAME_MAX);
-
- if( r == 0 )
- {
- // Get host adresses
- struct hostent *pHost = gethostbyname(szHostName);
-
- for( int i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ )
- {
- for( int j = 0; j<pHost->h_length; j++ )
- {
- if( j > 0 ) str += ".";
-
- str += Util::Format("%u",
- (unsigned int)((unsigned char*)pHost->h_addr_list[i])[j]);
- }
- // str now contains one local IP address
-
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
- WSACleanup();
-#endif
-
- }
- }
- // If an error occur r == -1
- // Most of the time it will return 127.0.0.1...
- return str;
-}
-
-unsigned int Util::GetCurrentThreadID()
-{
-// FIXME the implementation is far from complete
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
- return (unsigned int)GetCurrentThreadId();
-#endif
-#ifdef __linux__
- return 0;
- // Doesn't work on fedora, but is in the man page...
- //return (unsigned int)gettid();
-#endif
-#ifdef __sun
- return (unsigned int)thr_self();
-#else
- //default implementation
- return 0;
-#endif
-}
-
-unsigned int Util::GetCurrentProcessID()
-{
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
- // NOTE: There is also a _getpid()...
- return (unsigned int)GetCurrentProcessId();
-#else
- // get process identification, POSIX
- return (unsigned int)getpid();
-#endif
-}
-
/**
* \brief Creates a new UID. As stipulate in the DICOM ref
* each time a DICOM image is create it should have
return os.write(val.c_str(), val.size());
}
+//-------------------------------------------------------------------------
+// Protected
+
+//-------------------------------------------------------------------------
+// Private
+/**
+ * \brief Return the IP adress of the machine writting the DICOM image
+ */
+std::string Util::GetIPAddress()
+{
+ // This is a rip from
+ // http://www.codeguru.com/Cpp/I-N/internet/network/article.php/c3445/
+#ifndef HOST_NAME_MAX
+ // SUSv2 guarantees that `Host names are limited to 255 bytes'.
+ // POSIX 1003.1-2001 guarantees that `Host names (not including the
+ // terminating NUL) are limited to HOST_NAME_MAX bytes'.
+#define HOST_NAME_MAX 255
+ // In this case we should maybe check the string was not truncated.
+ // But I don't known how to check that...
+#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
+ // with WinSock DLL we need to initialize the WinSock before using gethostname
+ WORD wVersionRequested = MAKEWORD(1,0);
+ WSADATA WSAData;
+ int err = WSAStartup(wVersionRequested,&WSAData);
+ if (err != 0)
+ {
+ // Tell the user that we could not find a usable
+ // WinSock DLL.
+ WSACleanup();
+ return "127.0.0.1";
+ }
+#endif
+
+#endif //HOST_NAME_MAX
+
+ std::string str;
+ char szHostName[HOST_NAME_MAX+1];
+ int r = gethostname(szHostName, HOST_NAME_MAX);
+
+ if( r == 0 )
+ {
+ // Get host adresses
+ struct hostent *pHost = gethostbyname(szHostName);
+
+ for( int i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ )
+ {
+ for( int j = 0; j<pHost->h_length; j++ )
+ {
+ if( j > 0 ) str += ".";
+
+ str += Util::Format("%u",
+ (unsigned int)((unsigned char*)pHost->h_addr_list[i])[j]);
+ }
+ // str now contains one local IP address
+
+#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__)
+ WSACleanup();
+#endif
+
+ }
+ }
+ // If an error occur r == -1
+ // Most of the time it will return 127.0.0.1...
+ return str;
+}
+
//-------------------------------------------------------------------------
} // end namespace gdcm
Program: gdcm
Module: $RCSfile: gdcmUtil.h,v $
Language: C++
- Date: $Date: 2005/02/01 13:11:49 $
- Version: $Revision: 1.52 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.53 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
static std::string GetCurrentDateTime();
static unsigned int GetCurrentThreadID();
static unsigned int GetCurrentProcessID();
+ static bool IsCurrentProcessorBigEndian();
static std::string DicomString(const char *s, size_t l);
static std::string DicomString(const char *s);
static bool DicomStringEqual(const std::string &s1, const char *s2);
- static bool IsCurrentProcessorBigEndian();
static std::string GetMACAddress();
static const std::string GDCM_UID;
};
- template <class T>
- GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const T &val);
- GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val);
- GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val);
- GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val);
- GDCM_EXPORT std::ostream &binary_write(std::ostream &os, std::string const &val);
+template <class T>
+GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const T &val);
+GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val);
+GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val);
+GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val);
+GDCM_EXPORT std::ostream &binary_write(std::ostream &os, std::string const &val);
} // end namespace gdcm
//-----------------------------------------------------------------------------
#endif