+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
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
# 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
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());
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";
}
}
+/**
+ * \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);
}
#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:
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
// 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);
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
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.