]> Creatis software - gdcm.git/commitdiff
* gdcmPython/__init__.py doesn't crash anymore when running in
authorfrog <frog>
Mon, 10 Mar 2003 10:16:40 +0000 (10:16 +0000)
committerfrog <frog>
Mon, 10 Mar 2003 10:16:40 +0000 (10:16 +0000)
        in InstallMode or PreInstallMode but with an environement given
        value of GDCM_DICT_PATH.
      * src/gdcmDictSet.[cxx/h] coding style.  --- Frog

ChangeLog
TODO
gdcmPython/__init__.py
src/gdcmDictSet.cxx
src/gdcmDictSet.h
src/gdcmHeader.h

index 38d0686c37b49737001ea988becdadf8bdeb115c..8fc0034d7dfa8c3edbf7340f3e84a303cc7268bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-03-10 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+      * gdcmPython/__init__.py doesn't crash anymore when running in
+        in InstallMode or PreInstallMode but with an environement given
+        value of GDCM_DICT_PATH.
+      * src/gdcmDictSet.[cxx/h] coding style.
+
 2003-03-06 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
       * src/gdcmHeader.h and gdcmHeader.cxx Coding style + doxigenation.
       * src/gdcm.h general comments moved to TODO, and README
diff --git a/TODO b/TODO
index 5ca3f531ee1babd33810d7b7d861cc353bc9ee7b..420485aefda6dc4d0e1a3ee16aef7cfcd292e6a0 100644 (file)
--- a/TODO
+++ b/TODO
@@ -30,3 +30,7 @@
   sous forme d'une liste.
 * gdcmHeader::CheckSwap() dans le cas ACR pas propre, degager tout de suite 
   si on a deduit que c'en est pas...
+* python /usr/lib/python2.2/site-packages/DaVaW/demo/dvwDcmReader.py
+  and load image /home/frog/cvs/DCMlib/Data/CT-MONO2-16-ankle.dcm
+  will yield wrong coloring scheme as opposed to 
+  affim filein=/home/frog/cvs/DCMlib/Data/CT-MONO2-16-ankle.dcm
index f454cdb11588aea64801f45d87923e65654962ad..34ce06f7522ea717c194369e76944213e7dc525a 100644 (file)
@@ -8,54 +8,56 @@ import os, sys
 #   the standard dictionary i.e. the file dicomV3.dic.
 
 try:
-       ### First consider the environnement variable.
-       os.environ["GDCM_DICT_PATH"]
-       if not os.path.isfile(os.path.join(os.environ["GDCM_DICT_PATH"],
-                                          "dicomV3.dic")):
-               raise KeyError
+   ### First consider the environnement variable.
+   os.environ["GDCM_DICT_PATH"]
+   if not os.path.isfile(os.path.join(os.environ["GDCM_DICT_PATH"],
+                                      "dicomV3.dic")):
+      raise KeyError
 except KeyError:
-       # When environnement variable is unavailable assume the package was
-       # properly installed i.e. the layout is such that the directory containing
-       # the dictionaries is BELOW (the root is at the top) the current file.
-       # Note: when importing this __init__ file the pathes are relative to the
-       #       invocation directory. In order to get them relative to the package
-       #       (or more simply to this file) we rely on the __path__ variable.
-       InstallModePath = os.path.join(__path__[0], "Dicts/")
-       if os.path.isfile(os.path.join(InstallModePath, "dicomV3.dic")):
-               os.environ["GDCM_DICT_PATH"] = InstallModePath
-               PreInstallModePath = None
-       else:
-               # When both environnement variable and proper package installation 
-               # strategy fail we eventually consider the pre-installation mode
-               # i.e. when developpers are toying in a CVS tree. In this case
-               # the layout is such that the directory containing the dictionaries is
-               # ABOVE (the root is at the top) the current directory.
-               PreInstallModePath = os.path.join(__path__[0], "..", "Dicts/")
-               if os.path.isfile(os.path.join(PreInstallModePath, "dicomV3.dic")):
-                       os.environ["GDCM_DICT_PATH"] = PreInstallModePath
-                       InstallModePath = None
-               else:
-                       print "Unfound gdcm dictionaries path"
-                       sys.exit(1)
+   # When environnement variable is unavailable assume the package was
+   # properly installed i.e. the layout is such that the directory containing
+   # the dictionaries is BELOW (the root is at the top) the current file.
+   # Note: when importing this __init__ file the pathes are relative to the
+   #       invocation directory. In order to get them relative to the package
+   #       (or more simply to this file) we rely on the __path__ variable.
+   InstallModePath = os.path.join(__path__[0], "Dicts/")
+   if os.path.isfile(os.path.join(InstallModePath, "dicomV3.dic")):
+      os.environ["GDCM_DICT_PATH"] = InstallModePath
+      PreInstallModePath = None
+   else:
+      # When both environnement variable and proper package installation 
+      # strategy fail we eventually consider the pre-installation mode
+      # i.e. when developpers are toying in a CVS tree. In this case
+      # the layout is such that the directory containing the dictionaries is
+      # ABOVE (the root is at the top) the current directory.
+      PreInstallModePath = os.path.join(__path__[0], "..", "Dicts/")
+      if os.path.isfile(os.path.join(PreInstallModePath, "dicomV3.dic")):
+         os.environ["GDCM_DICT_PATH"] = PreInstallModePath
+         InstallModePath = None
+      else:
+         print "Unfound gdcm dictionaries path"
+         sys.exit(1)
 
 ### Set up the path to the data images (for the test suite and the demo
 #   examples). As for GDCM_DICT_PATH we offer both proper python package
 #   installation scheme and the pre-install mode (see above).
-if InstallModePath:
-       GDCM_DATA_PATH = os.path.join(__path__[0], "Data")
+InstallModePath = os.path.join(__path__[0], "Data")
+if os.path.isfile(os.path.join(InstallModePath, "test.acr")):
+   os.environ["GDCM_DATA_PATH"] = InstallModePath
 else:
-       if PreInstallModePath:
-               GDCM_DATA_PATH = os.path.join(__path__[0], "..","Data")
-       else:
-               print "Unfound data path"
-               sys.exit(1)
+   PreInstallModePath = os.path.join(__path__[0], "..", "Data")
+   if os.path.isfile(os.path.join(PreInstallModePath, "test.acr")):
+      os.environ["GDCM_DATA_PATH"] = PreInstallModePath
+   else:
+      print "Unfound data path"
+      sys.exit(1)
 
 ### Import the swig generated shadow classes.
 try:
-       import gdcm
+   import gdcm
 except ImportError,e:
-       print e
-       raise ImportError, "gdcm extension not imported."
+   print e
+   raise ImportError, "gdcm extension not imported."
 
 ### Expose only the necessary stuff
 gdcmHeader = gdcm.gdcmHeader
index 41a39c3f6ac9a2cb5b14fbb24e169a9216bde05e..2d6d95fab70f4063fb0c9355f491d2074da9df9c 100644 (file)
@@ -78,6 +78,11 @@ string gdcmDictSet::BuildDictPath(void) {
    return ResultPath;
 }
 
+/**
+ * \ingroup gdcmDictSet
+ * \brief   Loads the default public DICOM V3 dictionary as a gdcmDict.
+ * \return  The newly build reference public dictionary.
+ */
 gdcmDict* gdcmDictSet::LoadDefaultPubDict(void) {
    string PubDictFile = gdcmDictSet::DictPath + PUB_DICT_FILENAME;
    return new gdcmDict(PubDictFile.c_str());
@@ -92,11 +97,26 @@ gdcmDictSet::gdcmDictSet(void) {
    dicts[PUB_DICT_NAME] = DefaultPubDict;
 }
 
+/**
+ * \ingroup gdcmDictSet
+ * \brief   Loads a dictionary from a specified file, and add it
+ *          to allready the existing ones contained in this gdcmDictSet.
+ * @param   FileName Absolute or relative filename containing the
+ *          dictionary to load.
+ * @param   Name Symbolic name that be used as identifier of the newly 
+ *          created dictionary.
+ */
 void gdcmDictSet::LoadDictFromFile(string FileName, DictKey Name) {
    gdcmDict *NewDict = new gdcmDict(FileName.c_str());
    dicts[Name] = NewDict;
 }
 
+/**
+ * \ingroup gdcmDictSet
+ * \brief   Print, in an informal fashion, the list of all the dictionaries
+ *          contained is this gdcmDictSet, along with their respective content.
+ * @param   os Output stream used for printing.
+ */
 void gdcmDictSet::Print(ostream& os) {
    for (DictSetHT::iterator dict = dicts.begin(); dict != dicts.end(); ++dict){
       os << "Printing dictionary " << dict->first << " \n";
@@ -104,11 +124,23 @@ void gdcmDictSet::Print(ostream& os) {
    }
 }
 
+/**
+ * \ingroup gdcmDictSet
+ * \brief   Retrieve the specified dictionary (when existing) from this
+ *          gdcmDictSet.
+ * @param   DictName The synbolic name of the searched dictionary.
+ * \result  The retrieved dictionary.
+ */
 gdcmDict * gdcmDictSet::GetDict(DictKey DictName) {
    DictSetHT::iterator dict = dicts.find(DictName);
    return dict->second;
 }
 
+/**
+ * \ingroup gdcmDictSet
+ * \brief   Retrieve the default reference DICOM V3 public dictionary.
+ * \result  The retrieved default dictionary.
+ */
 gdcmDict * gdcmDictSet::GetDefaultPubDict() {
    return GetDict(PUB_DICT_NAME);
 }
index 0e2aed0b3a39a207fc4c6dface09f26b3f28b9fd..3ccc09d97f26fbcc36953643644b4d9f0e428100 100644 (file)
@@ -5,25 +5,27 @@
 
 #include <map>
 #include <list>
-#include "gdcmCommon.h"
 #include "gdcmDict.h"
 
-////////////////////////////////////////////////////////////////////////////
-// Container for managing a set of loaded dictionaries. Sharing dictionaries
-// should avoid :
-// * reloading an allready loaded dictionary,
-// * having many in memory representations of the same dictionary.
-
 typedef string DictKey;
 typedef map<DictKey, gdcmDict*> DictSetHT;
 
+/*
+ * \defgroup gdcmDictSet
+ * \brief  Container for managing a set of loaded dictionaries.
+ * \note   Hopefully, sharing dictionaries should avoid
+ * \par    reloading an allready loaded dictionary (saving time)
+ * \par    having many in memory representations of the same dictionary
+ *        (saving memory).
+ */
 class GDCM_EXPORT gdcmDictSet {
 private:
        DictSetHT dicts;
        int AppendDict(gdcmDict* NewDict);
        void LoadDictFromFile(string filename, DictKey);
 private:
-       static string DictPath;      // Directory path to dictionaries
+   /// Directory path to dictionaries
+       static string DictPath;
        static string BuildDictPath(void);
        static gdcmDict* DefaultPubDict;
 public:
@@ -31,7 +33,6 @@ public:
        static map<string, list<string> >* GetPubDictTagNamesByCategory(void);
        static gdcmDict* LoadDefaultPubDict(void);
 
-       gdcmDictSet(void);
        // TODO Swig int LoadDictFromFile(string filename);
    // QUESTION: the following function might not be thread safe !? Maybe
    //           we need some mutex here, to avoid concurent creation of
@@ -39,7 +40,7 @@ public:
        // TODO Swig int LoadDictFromName(string filename);
        // TODO Swig int LoadAllDictFromDirectory(string DirectoryName);
        // TODO Swig string* GetAllDictNames();
-       //
+       gdcmDictSet(void);
        void Print(ostream&);
        gdcmDict* GetDict(DictKey DictName);
        gdcmDict* GetDefaultPubDict(void);
index f46a12c64961f49b7575ebffdc394e4acac864e6..6b665031b543194347bd62945e8c25d05895f001 100644 (file)
@@ -14,10 +14,10 @@ typedef string VRKey;
 typedef string VRAtr;
 typedef map<VRKey, VRAtr> VRHT;    // Value Representation Hash Table
 
-/// \brief The purpous of an instance of gdcmHeader is to act as a container of
-///        all the DICOM elements and their corresponding values (and
-///        additionaly the corresponding DICOM dictionary entry) of the header
-///        of a DICOM file.
+/// The purpose of an instance of gdcmHeader is to act as a container of
+/// all the DICOM elements and their corresponding values (and
+/// additionaly the corresponding DICOM dictionary entry) of the header
+/// of a DICOM file.
 ///
 /// The typical usage of instances of class gdcmHeader is to classify a set of
 /// dicom files according to header information e.g. to create a file hierarchy
@@ -42,7 +42,8 @@ private:
    gdcmDictSet* Dicts;
    /// 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;
 
    /// ELement VALueS parsed with the PUBlic dictionary.