]> Creatis software - gdcm.git/commitdiff
* bug fix under python
authorregrain <regrain>
Mon, 19 Jan 2004 14:28:24 +0000 (14:28 +0000)
committerregrain <regrain>
Mon, 19 Jan 2004 14:28:24 +0000 (14:28 +0000)
     -- BeNours

15 files changed:
ChangeLog
gdcmPython/__init__.py
gdcmPython/gdcm.i
gdcmPython/win32/_vtkGdcm.dsp
gdcmPython/win32/gdcmpyembedded.dsp
src/gdcmDict.cxx
src/gdcmDict.h
src/gdcmDictEntry.cxx
src/gdcmDictEntry.h
src/gdcmDictSet.cxx
src/gdcmDictSet.h
src/gdcmParser.cxx
src/gdcmParser.h
src/win32/gdcmdll.dsp
vtk/win32/vtkgdcm.dsp

index bac4695fcf00310540d3d9e43b8653df06ea9d25..9e14294f3344ffe2ecdc6abd4af5674095db01a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
     * split class gdcmHeader into gdcmParser and gdcmHeader, with gdcmHeader
       inheriting from gdcmParser. This split is to prepare the integration
       of dicom dir parsing
+    * bug fix under python
 
 2004-01-16 Jean-Pierre Roux
     * removal of class gdcmHeaderEntrySet
index 7d6390e70f892dcbc3bb862a1355b81caa2f21d9..cb32100c5d098b1133ff5ea284458bf682222572 100644 (file)
@@ -70,6 +70,7 @@ except ImportError,e:
    raise ImportError, "gdcm extension not imported."
 
 ### Expose only the necessary stuff
+gdcmGlobal       = gdcm.gdcmGlobal
 gdcmDictSet      = gdcm.gdcmDictSet
 gdcmHeader       = gdcm.gdcmHeader
 gdcmHeaderHelper = gdcm.gdcmHeaderHelper
index 3f68d08e7dc016692befdc50704fc9fd2987cee5..0f3fea6bf0ce34a9bcf243c0eee059082b739d67 100644 (file)
@@ -98,13 +98,14 @@ extern gdcmGlobal gdcmGlob;
 
 ////////////////////////////////////////////////////////////////////////////
 // Deals with function returning a C++ string.
-%typemap(out) string  {
-    $result = PyString_FromString(($1).c_str());
-}
-%typemap(out) std::string  {
+%typemap(out) string, std::string  {
     $result = PyString_FromString(($1).c_str());
 }
 
+%typemap(python, in) const std::string, std::string
+{
+  $1 = PyString_AsString($input);
+}
 ////////////////////////////////////////////////////////////////////////////
 %include "gdcmCommon.h"
 %include "gdcmDictEntry.h"
index f62367706e0f504181231a36e5e244777995bf9b..be158e8391e4236be70982eedccf3ed0b1754024 100644 (file)
@@ -86,10 +86,6 @@ SOURCE=..\..\src\gdcmHeaderEntry.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\src\gdcmHeaderEntrySet.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
 SOURCE=..\..\src\gdcmHeaderHelper.cxx\r
 # End Source File\r
 # Begin Source File\r
@@ -106,7 +102,11 @@ SOURCE=..\..\src\gdcmJpeg2000.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\src\gdcmParse.cxx\r
+SOURCE=..\..\src\gdcmParsePixels.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\src\gdcmParser.cxx\r
 # End Source File\r
 # Begin Source File\r
 \r
index 29e42f31fce3df503ca8d0ee27871bd3d91bfd02..ea230953373b9f80a5348cb174c5dc08186c1246 100644 (file)
@@ -53,7 +53,7 @@ LINK32=link.exe
 # Begin Special Build Tool\r
 ProjDir=.\r
 SOURCE="$(InputPath)"\r
-PostBuild_Cmds=move                  $(ProjDir)\gdcm.py                  $(ProjDir)\..\ \r
+PostBuild_Cmds=move                   $(ProjDir)\gdcm.py                   $(ProjDir)\..\ \r
 # End Special Build Tool\r
 # Begin Target\r
 \r
@@ -108,10 +108,6 @@ SOURCE=..\..\src\gdcmHeaderEntry.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\src\gdcmHeaderEntrySet.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
 SOURCE=..\..\src\gdcmHeaderHelper.cxx\r
 # End Source File\r
 # Begin Source File\r
@@ -128,7 +124,11 @@ SOURCE=..\..\src\gdcmJpeg2000.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\src\gdcmParse.cxx\r
+SOURCE=..\..\src\gdcmParsePixels.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\src\gdcmParser.cxx\r
 # End Source File\r
 # Begin Source File\r
 \r
index 725d2d6c85d566f884de9b8acfc0a7f16fbad846..085de51420dd22073027ba550f68acf215677c66 100644 (file)
@@ -58,10 +58,11 @@ gdcmDict::~gdcmDict() {
       if ( EntryToDelete )
          delete EntryToDelete;
    }
-   KeyHt.clear();
+
    // Since AddNewEntry adds symetrical in both KeyHt and NameHT we can
    // assume all the pointed gdcmDictEntries are already cleaned-up when
    // we cleaned KeyHt.
+   KeyHt.clear();
    NameHt.clear();
 }
 
@@ -72,7 +73,7 @@ gdcmDict::~gdcmDict() {
  *          Entries will be sorted by tag i.e. the couple (group, element).
  * @param   os The output stream to be written to.
  */
-void gdcmDict::Print(std::ostreamos) {
+void gdcmDict::Print(std::ostream &os) {
    PrintByKey(os);
 }
 
@@ -82,7 +83,7 @@ void gdcmDict::Print(std::ostream& os) {
  *          Entries will be sorted by tag i.e. the couple (group, element).
  * @param   os The output stream to be written to.
  */
-void gdcmDict::PrintByKey(std::ostreamos) {
+void gdcmDict::PrintByKey(std::ostream &os) {
    std::ostringstream s;
 
    for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag){
@@ -126,15 +127,20 @@ void gdcmDict::PrintByName(std::ostream& os) {
  * @param   NewEntry 
  * @return  false if Dicom Element already existed
  */
- bool gdcmDict::AddNewEntry(gdcmDictEntry* NewEntry) {
+bool gdcmDict::AddNewEntry(gdcmDictEntry *NewEntry) 
+{
    TagKey key;
    key = NewEntry->GetKey();
        
-   if(KeyHt.count(key) == 1) {
+   if(KeyHt.count(key) == 1)
+   {
       dbg.Verbose(1, "gdcmDict::AddNewEntry already present", key.c_str());
       return(false);
-   } else {
+   } 
+   else 
+   {
       KeyHt[NewEntry->GetKey()] = NewEntry;
+      NameHt[NewEntry->GetName()] = NewEntry;
       return(true);
    }
 }
@@ -145,9 +151,10 @@ void gdcmDict::PrintByName(std::ostream& os) {
  * @param   NewEntry
  * @return  false if Dicom Element doesn't exist
  */
-bool gdcmDict::ReplaceEntry(gdcmDictEntryNewEntry) {
+bool gdcmDict::ReplaceEntry(gdcmDictEntry *NewEntry) {
    if ( RemoveEntry(NewEntry->gdcmDictEntry::GetKey()) ) {
-       KeyHt[ NewEntry->GetKey()] = NewEntry;
+       KeyHt[NewEntry->GetKey()] = NewEntry;
+       NameHt[NewEntry->GetName()] = NewEntry;
        return (true);
    } 
    return (false);
@@ -160,14 +167,23 @@ bool gdcmDict::ReplaceEntry(gdcmDictEntry* NewEntry) {
  * @param   key (group|element)
  * @return  false if Dicom Dictionary Entry doesn't exist
  */
-bool gdcmDict::RemoveEntry(TagKey key) {
-   if(KeyHt.count(key) == 1) {
+bool gdcmDict::RemoveEntry(TagKey key) 
+{
+   if(KeyHt.count(key) == 1) 
+   {
       gdcmDictEntry* EntryToDelete = KeyHt.find(key)->second;
+
       if ( EntryToDelete )
+      {
+         NameHt.erase(EntryToDelete->GetName());
          delete EntryToDelete;
+      }
+
       KeyHt.erase(key);
       return (true);
-   } else {
+   } 
+   else 
+   {
       dbg.Verbose(1, "gdcmDict::RemoveEntry unfound entry", key.c_str());
       return (false);
   }
@@ -186,6 +202,21 @@ bool gdcmDict::RemoveEntry (guint16 group, guint16 element) {
        return( RemoveEntry(gdcmDictEntry::TranslateToKey(group, element)) );
 }
 
+/**
+ * \ingroup gdcmDict
+ * \brief   Get the dictionnary entry identified by it's name.
+ * @param   name element of the ElVal to modify
+ * \warning : NEVER use it !
+ *            the 'name' IS NOT an identifier within the Dicom Dicom Dictionary
+ *            the name MAY CHANGE between two versions !
+ * @return  the corresponding dictionnary entry when existing, NULL otherwise
+ */
+gdcmDictEntry *gdcmDict::GetTagByName(TagName name) {
+   if ( ! NameHt.count(name))
+      return NULL; 
+   return NameHt.find(name)->second;
+}
+
 /**
  * \ingroup gdcmDict
  * \brief   Get the dictionnary entry identified by a given tag (group,element)
@@ -193,26 +224,63 @@ bool gdcmDict::RemoveEntry (guint16 group, guint16 element) {
  * @param   element element of the entry to be found
  * @return  the corresponding dictionnary entry when existing, NULL otherwise
  */
-gdcmDictEntry * gdcmDict::GetTagByNumber(guint16 group, guint16 element) {
+gdcmDictEntry *gdcmDict::GetTagByNumber(guint16 group, guint16 element) {
    TagKey key = gdcmDictEntry::TranslateToKey(group, element);
    if ( ! KeyHt.count(key))
-      return (gdcmDictEntry*)0
+      return NULL
    return KeyHt.find(key)->second;
 }
 
-/**
+/** 
  * \ingroup gdcmDict
- * \brief   Get the dictionnary entry identified by it's name.
- * @param   name element of the ElVal to modify
- * \warning : NEVER use it !
- *            the 'name' IS NOT an identifier within the Dicom Dicom Dictionary
- *            the name MAY CHANGE between two versions !
- * @return  the corresponding dictionnary entry when existing, NULL otherwise
+ * \brief   Consider all the entries of the public dicom dictionnary. 
+ *          Build all list of all the tag names of all those entries.
+ * \sa      gdcmDictSet::GetPubDictTagNamesByCategory
+ * @return  A list of all entries of the public dicom dictionnary.
  */
-gdcmDictEntry * gdcmDict::GetTagByName(TagName name) {
-   if ( ! NameHt.count(name))
-      return (gdcmDictEntry*)0; 
-   return NameHt.find(name)->second;
+std::list<std::string> *gdcmDict::GetTagNames(void) 
+{
+   std::list<std::string> *Result = new std::list<std::string>;
+   for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
+   {
+      Result->push_back( tag->second->GetName() );
+   }
+   return Result;
+}
+
+/** 
+ * \ingroup gdcmDict
+ * \brief   Consider all the entries of the public dicom dictionnary.
+ *          Build an hashtable whose keys are the names of the groups
+ *          (fourth field in each line of dictionary) and whose corresponding
+ *          values are lists of all the dictionnary entries among that
+ *          group. Note that apparently the Dicom standard doesn't explicitely
+ *          define a name (as a string) for each group.
+ *          A typical usage of this method would be to enable a dynamic
+ *          configuration of a Dicom file browser: the admin/user can
+ *          select in the interface which Dicom tags should be displayed.
+ * \warning Dicom *doesn't* define any name for any 'categorie'
+ *          (the dictionnary fourth field was formerly NIH defined
+ *           - and no longer he is-
+ *           and will be removed when Dicom provides us a text file
+ *           with the 'official' Dictionnary, that would be more friendly
+ *           than asking us to perform a line by line check of the dictionnary
+ *           at the beginning of each year to -try to- guess the changes)
+ *           Therefore : please NEVER use that fourth field :-(
+ * *
+ * @return  An hashtable: whose keys are the names of the groups and whose
+ *          corresponding values are lists of all the dictionnary entries
+ *          among that group.
+ */
+std::map<std::string, std::list<std::string> > *gdcmDict::GetTagNamesByCategory(void) 
+{
+   std::map<std::string, std::list<std::string> > *Result = new std::map<std::string, std::list<std::string> >;
+
+   for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag)
+   {
+      (*Result)[tag->second->GetFourth()].push_back(tag->second->GetName());
+   }
+   return Result;
 }
 
 //-----------------------------------------------------------------------------
index cf34024488841ec8ff7bdbebd896281bc2a3bb37..8add2a6bfe75bda9e4ae4b21f89599e1b36a9561 100644 (file)
@@ -5,6 +5,9 @@
 
 #include "gdcmCommon.h"
 #include "gdcmDictEntry.h"
+
+#include <iostream>
+#include <list>
 #include <map>
 
 //-----------------------------------------------------------------------------
@@ -27,35 +30,40 @@ public:
    gdcmDict(std::string & FileName);
        ~gdcmDict();
 
-       void Print(std::ostream&);
-       void PrintByKey(std::ostream&);
-       void PrintByName(std::ostream&);        
+// Print
+       void Print(std::ostream &os = std::cout);
+       void PrintByKey(std::ostream &os = std::cout);
+       void PrintByName(std::ostream &os = std::cout); 
 
-   bool AddNewEntry (gdcmDictEntry* NewEntry);
-       bool ReplaceEntry(gdcmDictEntry* NewEntry);
+// Entries
+   bool AddNewEntry (gdcmDictEntry *NewEntry);
+       bool ReplaceEntry(gdcmDictEntry *NewEntry);
        bool RemoveEntry (TagKey key);
        bool RemoveEntry (guint16 group, guint16 element);
 
-       gdcmDictEntry * GetTagByNumber(guint16 group, guint16 element);
+// Tag
        gdcmDictEntry * GetTagByName(TagName name);
+       gdcmDictEntry * GetTagByNumber(guint16 group, guint16 element);
+
+   std::list<std::string> *GetTagNames(void);
+   std::map<std::string, std::list<std::string> > *
+        GetTagNamesByCategory(void);
 
    /**
     * \ingroup gdcmDict
     * \brief   returns a ref to the Dicom Dictionary H table (map)
     * return the Dicom Dictionary H table
     */
-   inline TagKeyHT & gdcmDict::GetEntries(void)  {
-    return KeyHt; 
-   }
+   inline TagKeyHT & gdcmDict::GetEntries(void)  { return KeyHt; }
  
 private:
    std::string name;
    std::string filename;
+
    /// Access through TagKey (see alternate access with NameHt)
        TagKeyHT  KeyHt;
    /// Access through TagName (see alternate access with KeyHt)
        TagNameHT NameHt;
-
 };
 
 //-----------------------------------------------------------------------------
index ee04a0c62a7f3a036df8394e5b2defb9da9787d1..0bc2afa901276bded0774da7b48255373a2a723b 100644 (file)
@@ -60,10 +60,12 @@ TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) {
  *              is unset then overwrite it.
  * @param NewVr New V(alue) R(epresentation) to be set.
  */
-void gdcmDictEntry::SetVR(std::string NewVr) {
+void gdcmDictEntry::SetVR(std::string NewVr) 
+{
        if ( IsVRUnknown() )
                vr = NewVr;
-       else {
+       else 
+   {
                dbg.Error(true, "gdcmDictEntry::SetVR",
                          "Overwriting vr might compromise a dictionary");
        }
index 115ed7acb5e2e5c9b740e9dbcecec1ea4eca0606..f729d9b7c7888d659721082ce706b0e0a4f56aea 100644 (file)
@@ -16,7 +16,8 @@
  *  - the owner group
  *  - etc.
  */
-class GDCM_EXPORT gdcmDictEntry {
+class GDCM_EXPORT gdcmDictEntry 
+{
 public:
    gdcmDictEntry(guint16 group, 
                  guint16 element,
@@ -25,6 +26,7 @@ public:
                  std::string name   = "Unknown");
        
    static TagKey TranslateToKey(guint16 group, guint16 element);
+
    void SetVR(std::string);
 
    /**
@@ -33,47 +35,35 @@ public:
     *              
     * @return 
     */
-   inline bool gdcmDictEntry::IsVRUnknown() {
-          if ( vr == "Unknown" )
-                  return true;
-          return false;
-   }
+   inline bool IsVRUnknown() {return vr == "Unknown"; }
 
    /**
     * \ingroup gdcmDictEntry
     * \brief   returns the Dicom Group Number of the current gdcmDictEntry
     * return the Dicom Group Number
     */
-   inline guint16 gdcmDictEntry::GetGroup(void)  {
-    return group; 
-   }
+   inline guint16 GetGroup(void) { return group; }
   
    /**
     * \ingroup gdcmDictEntry
     * \brief   returns the Dicom Element Number of the current gdcmDictEntry
     * return the Dicom Element Number
     */
-   inline guint16 gdcmDictEntry::GetElement(void)  {
-    return element; 
-   }
+   inline guint16 GetElement(void) { return element; }
  
    /**
     * \ingroup gdcmDictEntry
     * \brief   returns the Dicom Value Representation of the current gdcmDictEntry
     * return the Dicom Value Representation
     */
-   inline std::string gdcmDictEntry::GetVR(void)  {
-    return vr; 
-   }
+   inline std::string GetVR(void) { return vr; }
  
    /**
     * \ingroup gdcmDictEntry
     * \brief   sets the key of the current gdcmDictEntry
     * @param k New key to be set.
     */
-   inline void gdcmDictEntry::SetKey(std::string k)  {
-    key = k; 
-   }
+   inline void SetKey(std::string k)  { key = k; }
  
    /**
     * \ingroup gdcmDictEntry
@@ -83,9 +73,7 @@ public:
     * \        NEVER use it
     * return the Fourth field
     */
-   inline std::string gdcmDictEntry::GetFourth(void)  {
-    return fourth; 
-   } 
+   inline std::string GetFourth(void) { return fourth; } 
 
    /**
     * \ingroup gdcmDictEntry
@@ -93,34 +81,30 @@ public:
     * \        e.g. "Patient Name" for Dicom Tag (0x0010, 0x0010) 
     * return the Dicom Name
     */
-   inline std::string gdcmDictEntry::GetName(void)  {
-    return name; 
-   } 
+   inline std::string GetName(void) { return name; } 
  
    /**
     * \ingroup gdcmDictEntry
     * \brief   Gets the key of the current gdcmDictEntry
     * @return the key .
     */
-   inline std::string gdcmDictEntry::GetKey(void)  {
-    return key; 
-   }
+   inline std::string GetKey(void) { return key; }
 
 private:
    // FIXME : were are the group and element used except from building up
    //         a TagKey. If the answer is nowhere then there is no need
    //         to store the group and element independently.
-   guint16 group;       // e.g. 0x0010
-   guint16 element;     // e.g. 0x0103
-   std::string  vr;     // Value Representation i.e. some clue about the nature
+   guint16 group;   // e.g. 0x0010
+   guint16 element; // e.g. 0x0103
+   std::string vr; // Value Representation i.e. some clue about the nature
                        // of the data represented e.g. "FD" short for
                        // "Floating Point Double"
        // CLEANME: find the official dicom name for this field !
-   std::string  fourth; // Fourth field containing some semantics.
-                        //(Group Name abbr.)
-   std::string  name;   // e.g. "Patient_Name"
-   TagKey  key;         // Redundant with (group, element) but we add it
-                        // on efficiency purposes.
+   std::string fourth; // Fourth field containing some semantics.
+                       //(Group Name abbr.)
+   std::string name; // e.g. "Patient_Name"
+   TagKey  key;      // Redundant with (group, element) but we add it
+                     // on efficiency purposes.
 
        // DCMTK has many fields for handling a DictEntry (see below). What are the
        // relevant ones for gdcmlib ?
index fe95d73a8b8da1be1080219f1ebfd82663e9c1d0..82962d6e677c05291a608b1b4fa82d0f1f4203e9 100644 (file)
@@ -80,14 +80,7 @@ void gdcmDictSet::Print(std::ostream& os)
  */
 std::list<std::string> *gdcmDictSet::GetPubDictTagNames(void) 
 {
-   std::list<std::string> *Result = new std::list<std::string>;
-   TagKeyHT entries = GetDefaultPubDict()->GetEntries();
-   
-   for (TagKeyHT::iterator tag = entries.begin(); tag != entries.end(); ++tag)
-   {
-      Result->push_back( tag->second->GetName() );
-   }
-   return Result;
+   return(GetDefaultPubDict()->GetTagNames());
 }
 
 /** 
@@ -116,14 +109,7 @@ std::list<std::string> *gdcmDictSet::GetPubDictTagNames(void)
  */
 std::map<std::string, std::list<std::string> > *gdcmDictSet::GetPubDictTagNamesByCategory(void) 
 {
-   std::map<std::string, std::list<std::string> > *Result = new std::map<std::string, std::list<std::string> >;
-   TagKeyHT entries = GetDefaultPubDict()->GetEntries();
-
-   for (TagKeyHT::iterator tag = entries.begin(); tag != entries.end(); ++tag)
-   {
-      (*Result)[tag->second->GetFourth()].push_back(tag->second->GetName());
-   }
-   return Result;
+   return(GetDefaultPubDict()->GetTagNamesByCategory());
 }
 
 /**
index 86abe1cdf1946ba9e7a6ff0e05dca4bc67fedc8f..8ef38e959f3b52ed3733dc8e161707fefc7a6d47 100644 (file)
@@ -33,8 +33,8 @@ public:
 
    void Print(std::ostream& os);
 
-   std::list<std::string> * GetPubDictTagNames(void);
-   std::map<std::string, std::list<std::string> >*
+   std::list<std::string> *GetPubDictTagNames(void);
+   std::map<std::string, std::list<std::string> > *
        GetPubDictTagNamesByCategory(void);
 
    void LoadDictFromFile(std::string FileName, DictKey Name);
@@ -43,7 +43,7 @@ public:
    gdcmDict *GetDefaultPubDict(void);
 
    gdcmDictEntry *NewVirtualDictEntry(guint16 group, guint16 element,
-                                      std::string vr = "Unknown",
+                                      std::string vr     = "Unknown",
                                       std::string fourth = "Unknown",
                                       std::string name   = "Unknown");
 
index 797d50c8c7227cec8a124730e060e6279c977f17..8e2c0a075aea80161a55c53076e00d308e2da271 100644 (file)
@@ -81,10 +81,8 @@ gdcmParser::gdcmParser(bool exception_on_error)
  */
 gdcmParser::~gdcmParser (void) 
 {
-   dicom_vr =   (gdcmVR*)0; 
-   Dicts    =   (gdcmDictSet*)0;
-   RefPubDict = (gdcmDict*)0;
-   RefShaDict = (gdcmDict*)0;
+   RefPubDict = NULL;
+   RefShaDict = NULL;
 }
 
 //-----------------------------------------------------------------------------
@@ -99,12 +97,7 @@ void gdcmParser::PrintPubEntry(std::ostream & os)
 {
    std::ostringstream s;   
           
-//   guint32 lgth;
-//   char greltag[10];  //group element tag
    s << "------------ using listEntries ----------------" << std::endl; 
-
-//   char st[20];
    for (ListTag::iterator i = listEntries.begin();  
           i != listEntries.end();
           ++i)
@@ -137,6 +130,46 @@ void gdcmParser::PrintShaDict(std::ostream & os)
 
 //-----------------------------------------------------------------------------
 // Public
+/**
+ * \ingroup gdcmParser
+ * \brief   Get the public dictionary used
+ */
+gdcmDict *gdcmParser::GetPubDict(void)
+{
+   return(RefPubDict);
+}
+
+/**
+ * \ingroup gdcmParser
+ * \brief   Get the shadow dictionary used
+ */
+gdcmDict *gdcmParser::GetShaDict(void)
+{
+   return(RefShaDict);
+}
+
+/**
+ * \ingroup gdcmParser
+ * \brief   Set the shadow dictionary used
+ * \param   dict dictionary to use in shadow
+ */
+bool gdcmParser::SetShaDict(gdcmDict *dict)
+{
+   RefShaDict=dict;
+   return(!RefShaDict);
+}
+
+/**
+ * \ingroup gdcmParser
+ * \brief   Set the shadow dictionary used
+ * \param   dictName name of the dictionary to use in shadow
+ */
+bool gdcmParser::SetShaDict(DictKey dictName)
+{
+   RefShaDict=gdcmGlobal::GetDicts()->GetDict(dictName);
+   return(!RefShaDict);
+}
+
 /**
  * \ingroup gdcmParser
  * \brief  This predicate, based on hopefully reasonable heuristics,
@@ -569,40 +602,6 @@ bool gdcmParser::SetEntryByName(std::string content,std::string tagName)
 
    return(SetEntryByNumber(content,dictEntry->GetGroup(),
                                    dictEntry->GetElement()));
-/*   TagKey key = gdcmDictEntry::TranslateToKey(dictEntry->GetGroup(), 
-                                              dictEntry->GetElement());
-   if ( GetPubEntry().count(key) == 0 )
-      return false;
-
-   int l = content.length();
-   if(l%2) // Odd length are padded with a space (020H).
-   {  
-      l++;
-      content = content + '\0';
-   }
-      
-   //tagHt[key]->SetValue(content);   
-   gdcmHeaderEntry * a;
-   IterHT p;
-   TagHeaderEntryHT::iterator p2;
-   // DO NOT remove the following lines : they explain how the stuff works 
-   //p= tagHt.equal_range(key); // get a pair of iterators first-last synonym
-   //p2=p.first;                // iterator on the first synonym 
-   //a=p2->second;              // H Table target column (2-nd col)    
-   // or, easier :
-   a = ((GetPubEntry().equal_range(key)).first)->second;       
-   a-> SetValue(content);   
-   std::string vr = a->GetVR();
-   
-   guint32 lgr;
-   if( (vr == "US") || (vr == "SS") ) 
-      lgr = 2;
-   else if( (vr == "UL") || (vr == "SL") )
-      lgr = 4;
-   else
-      lgr = l;    
-   a->SetLength(lgr);   
-   return true;*/
 }
 
 /**
@@ -1370,7 +1369,7 @@ void gdcmParser::AddHeaderEntry(gdcmHeaderEntry * newHeaderEntry)
          if (!NewTag) 
          {
             // This correct tag is not in the dictionary. Create a new one.
-            NewTag = Dicts->NewVirtualDictEntry(CorrectGroup, CorrectElem);
+            NewTag = NewVirtualDictEntry(CorrectGroup, CorrectElem);
          }
          // FIXME this can create a memory leaks on the old entry that be
          // left unreferenced.
@@ -1444,7 +1443,7 @@ void gdcmParser::FindHeaderEntryVR( gdcmHeaderEntry *ElVal)
    // CLEANME searching the dicom_vr at each occurence is expensive.
    // PostPone this test in an optional integrity check at the end
    // of parsing or only in debug mode.
-   if ( RealExplicit && !dicom_vr->Count(vr) )
+   if ( RealExplicit && !gdcmGlobal::GetVR()->Count(vr) )
       RealExplicit= false;
 
    if ( RealExplicit ) 
@@ -1465,7 +1464,7 @@ void gdcmParser::FindHeaderEntryVR( gdcmHeaderEntry *ElVal)
       // 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 = Dicts->NewVirtualDictEntry(ElVal->GetGroup(),
+      gdcmDictEntry* NewTag = NewVirtualDictEntry(ElVal->GetGroup(),
                                  ElVal->GetElement(),
                                  vr,
                                  "FIXME",
@@ -1725,10 +1724,7 @@ void gdcmParser::SkipBytes(guint32 NBytes)
  */
 void gdcmParser::Initialise(void) 
 {
-   dicom_vr = gdcmGlobal::GetVR();
-   dicom_ts = gdcmGlobal::GetTS();
-   Dicts    = gdcmGlobal::GetDicts();
-   RefPubDict = Dicts->GetDefaultPubDict();
+   RefPubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict();
    RefShaDict = (gdcmDict*)0;
 }
 
@@ -2065,7 +2061,7 @@ gdcmHeaderEntry *gdcmParser::NewHeaderEntryByName(std::string Name)
 {
    gdcmDictEntry *NewTag = GetDictEntryByName(Name);
    if (!NewTag)
-      NewTag = Dicts->NewVirtualDictEntry(0xffff, 0xffff, "LO", "Unknown", Name);
+      NewTag = NewVirtualDictEntry(0xffff, 0xffff, "LO", "Unknown", Name);
 
    gdcmHeaderEntry* NewElVal = new gdcmHeaderEntry(NewTag);
    if (!NewElVal) 
@@ -2077,6 +2073,23 @@ gdcmHeaderEntry *gdcmParser::NewHeaderEntryByName(std::string Name)
    return NewElVal;
 }  
 
+/**
+ * \ingroup gdcmParser
+ * \brief   Request a new virtual dict entry to the dict set
+ * @param   Group  group   of the underlying DictEntry
+ * @param   Elem   element of the underlying DictEntry
+ * @param   VR     VR of the underlying DictEntry
+ * @param   Fourth owner group
+ * @param   Name   english name
+ */
+gdcmDictEntry *gdcmParser::NewVirtualDictEntry(guint16 group, guint16 element,
+                                               std::string vr,
+                                               std::string fourth,
+                                               std::string name)
+{
+   return gdcmGlobal::GetDicts()->NewVirtualDictEntry(group,element,vr,fourth,name);
+}
+
 /**
  * \ingroup gdcmParser
  * \brief   Build a new Element Value from all the low level arguments. 
@@ -2090,7 +2103,7 @@ 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 = Dicts->NewVirtualDictEntry(Group, Elem);
+      NewTag = NewVirtualDictEntry(Group, Elem);
 
    gdcmHeaderEntry* NewElVal = new gdcmHeaderEntry(NewTag);
    if (!NewElVal) 
@@ -2128,7 +2141,7 @@ gdcmHeaderEntry *gdcmParser::NewManualHeaderEntryToPubDict(std::string NewTagNam
       return NULL;
    }
 
-   NewEntry = Dicts->NewVirtualDictEntry(StuffGroup, FreeElem,
+   NewEntry = NewVirtualDictEntry(StuffGroup, FreeElem,
                                 VR, "GDCM", NewTagName);
    NewElVal = new gdcmHeaderEntry(NewEntry);
    AddHeaderEntry(NewElVal);
index 054c158a6d5ce80f7da0680e77d90aa48eab9c70..61f125fa30683599865b11e53e14e083cfa04e6c 100644 (file)
@@ -48,13 +48,20 @@ public:
     * \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 PrintPubDict (std::ostream & os = std::cout);
-   virtual void PrintShaDict (std::ostream & os = std::cout);
+   virtual void PrintPubEntry(std::ostream &os = std::cout);
+   virtual void PrintPubDict (std::ostream &os = std::cout);
+   virtual void PrintShaDict (std::ostream &os = std::cout);
 
-// Standard values and informations contained in the header
+// Standard values
    inline std::string GetFileName(void) {return filename;}
 
+// Dictionnaries
+   gdcmDict *GetPubDict(void);
+   gdcmDict *GetShaDict(void);
+   bool SetShaDict(gdcmDict *dict);
+   bool SetShaDict(DictKey dictName);
+
+// Informations contained in the parser
    bool IsReadable(void);
    bool IsImplicitVRLittleEndianTransferSyntax(void);
    bool IsExplicitVRLittleEndianTransferSyntax(void);
@@ -158,6 +165,10 @@ private:
    gdcmHeaderEntry *ReadNextHeaderEntry   (void);
    gdcmHeaderEntry *NewHeaderEntryByNumber(guint16 group, guint16 element);
    gdcmHeaderEntry *NewHeaderEntryByName  (std::string Name);
+   gdcmDictEntry *NewVirtualDictEntry(guint16 group, guint16 element,
+                                      std::string vr = "Unknown",
+                                      std::string fourth = "Unknown",
+                                      std::string name   = "Unknown");
 
    // Deprecated (Not used)
    gdcmHeaderEntry *NewManualHeaderEntryToPubDict(std::string NewTagName,
@@ -167,33 +178,17 @@ private:
    // Refering underlying filename.
    std::string filename; 
 
-   // Pointer to the Value Representation Hash Table which contains all
-   // the VR of the DICOM version3 public dictionary. 
-   gdcmVR *dicom_vr;     // Not a class member for thread-safety reasons
-   
-   // Pointer to the Transfert Syntax Hash Table which contains all
-   // the TS of the DICOM version3 public dictionary. 
-   gdcmTS *dicom_ts;     // Not a class member for thread-safety reasons 
-     
-   // Pointer to global dictionary container
-   gdcmDictSet *Dicts;   // Not a class member for thread-safety reasons
-   
    // Public dictionary used to parse this header
    gdcmDict *RefPubDict;
-   
-   // Optional "shadow dictionary" (private elements) used to parse this
-   // header
+   // Optional "shadow dictionary" (private elements) used to parse this header
    gdcmDict *RefShaDict;
 
    TagHeaderEntryHT tagHT; // H Table (multimap), to provide fast access
    ListTag listEntries;    // chained list, to keep the 'spacial' ordering 
+   int enableSequences;
 
    // true if a gdcmHeaderEntry was added post parsing 
    int wasUpdated;
-   // for PrintHeader
-   int printLevel;
-
-   int enableSequences;
 
    // Swap code e.g. little, big, bad-big, bad-little endian). Warning:
    // this code is not fixed during header parsing.
@@ -204,6 +199,9 @@ private:
    // this upper bound is fixed to 1024 bytes (which might look reasonable
    // when one considers the definition of the various VR contents).
    guint32 MaxSizeLoadEntry;
+
+   // for PrintHeader
+   int printLevel;
 };
 
 //-----------------------------------------------------------------------------
index be1f6b4541fd567aff66baa7d529cadeba255045..9581a86a12fbc9cb8629a29b1bde1ce07265d42d 100644 (file)
@@ -58,7 +58,7 @@ LINK32=link.exe
 # Begin Special Build Tool\r
 SOURCE="$(InputPath)"\r
 PostBuild_Desc=Copy for test\r
-PostBuild_Cmds=copy                ..\..\lib\gdcmdll.dll                ..\..\gdcmPython\              copy                ..\..\lib\gdcmdll.dll                ..\..\test\                    copy             Release\gdcmdll.lib             ..\..\lib\ \r
+PostBuild_Cmds=copy                 ..\..\lib\gdcmdll.dll                 ..\..\gdcmPython\                    copy                 ..\..\lib\gdcmdll.dll                 ..\..\test\                  copy              Release\gdcmdll.lib              ..\..\lib\ \r
 # End Special Build Tool\r
 \r
 !ELSEIF  "$(CFG)" == "gdcmdll - Win32 Debug"\r
@@ -90,7 +90,7 @@ LINK32=link.exe
 # Begin Special Build Tool\r
 SOURCE="$(InputPath)"\r
 PostBuild_Desc=Copy for test\r
-PostBuild_Cmds=copy                ..\..\lib\gdcmdll.dll                ..\..\gdcmPython\              copy                ..\..\lib\gdcmdll.dll                ..\..\test\                    copy             Debug\gdcmdll.lib             ..\..\lib\ \r
+PostBuild_Cmds=copy                 ..\..\lib\gdcmdll.dll                 ..\..\gdcmPython\                    copy                 ..\..\lib\gdcmdll.dll                 ..\..\test\                  copy              Debug\gdcmdll.lib              ..\..\lib\ \r
 # End Special Build Tool\r
 \r
 !ENDIF \r
@@ -132,10 +132,6 @@ SOURCE=..\gdcmHeaderEntry.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\gdcmHeaderEntrySet.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
 SOURCE=..\gdcmHeaderHelper.cxx\r
 # End Source File\r
 # Begin Source File\r
@@ -152,7 +148,11 @@ SOURCE=..\gdcmJpeg2000.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\gdcmParse.cxx\r
+SOURCE=..\gdcmParsePixels.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\gdcmParser.cxx\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -212,11 +212,11 @@ SOURCE=..\gdcmHeaderEntry.h
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\gdcmHeaderEntrySet.h\r
+SOURCE=..\gdcmHeaderHelper.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\gdcmHeaderHelper.h\r
+SOURCE=..\gdcmParser.h\r
 # End Source File\r
 # Begin Source File\r
 \r
index 17907c60f7651a5d912255f089b4ce3a81eb5e12..9a90affee5f7a76166f9d93a2900a8d797005da3 100644 (file)
@@ -128,10 +128,6 @@ SOURCE=..\..\src\gdcmHeaderEntry.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\src\gdcmHeaderEntrySet.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
 SOURCE=..\..\src\gdcmHeaderHelper.cxx\r
 # End Source File\r
 # Begin Source File\r
@@ -148,7 +144,11 @@ SOURCE=..\..\src\gdcmJpeg2000.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=..\..\src\gdcmParse.cxx\r
+SOURCE=..\..\src\gdcmParsePixels.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\src\gdcmParser.cxx\r
 # End Source File\r
 # Begin Source File\r
 \r