]> Creatis software - gdcm.git/commitdiff
DICOMDIR utilities
authorjpr <jpr>
Thu, 22 Jan 2004 10:17:17 +0000 (10:17 +0000)
committerjpr <jpr>
Thu, 22 Jan 2004 10:17:17 +0000 (10:17 +0000)
15 files changed:
src/Makefile.am
src/gdcmHeaderHelper.cxx
src/gdcmHeaderHelper.h
src/gdcmImage.cxx
src/gdcmImage.h
src/gdcmObject.h
src/gdcmParser.cxx
src/gdcmParser.h
src/gdcmPatient.cxx
src/gdcmPatient.h
src/gdcmSerie.cxx
src/gdcmSerie.h
src/gdcmStudy.cxx
src/gdcmStudy.h
src/gdcmTS.cxx

index 4ce1544785e0ef9367dc306e9ef71bd7f8413a9a..9a2cb239c847fcd09173c710d1c021107e0761d4 100644 (file)
@@ -31,6 +31,7 @@ libgdcm_la_SOURCES=                \
    gdcmRLE.cxx                     \
    gdcmParsePixels.cxx             \
    gdcmDICOMDIR.cxx                \
+   gdcmObject.cxx                  \
    gdcmPatient.cxx                 \
    gdcmStudy.cxx                   \
    gdcmSerie.cxx                   \
index aeb83222b903773c2b60aea05300859cbd3d4b05..22ad729e7abc1c3ab9a231ccb00cee4cc30116ec 100644 (file)
@@ -768,6 +768,7 @@ bool gdcmSerieHeaderHelper::ImagePositionPatientOrdering()
 }
 
 //Based on Image Number
+
 bool gdcmSerieHeaderHelper::ImageNumberOrdering()
 {
   int min, max, pos;
@@ -800,7 +801,7 @@ bool gdcmSerieHeaderHelper::ImageNumberOrdering()
     partition[pos - min]++;
   }
   
-  unsigned char mult;
+  unsigned char mult = 1;
   for(int i=0; i<n ; i++)
   {
     mult *= partition[i];
index 1b9b5f396f985c2a8df33d6ad554aef4cb580de8..f635c81b049e3719a627ce8908d4cf19d5242500 100644 (file)
@@ -88,7 +88,7 @@ public:
    std::string GetInstanceUID();
    
    /**
-    * change GetXImagePosition -> GetXOrigin in order not to confused reader
+    * change GetXImagePosition -> GetXOrigin in order not to confuse reader
     * -# GetXOrigin can return default value (=0) if it was not ImagePosition
     * -# Image Position is different in dicomV3 <> ACR NEMA -> better use generic
     * name
index 245a6a462045d98ff0a3c7360c8d7bcbb9dfbaa0..382a74706bc220ed31464bfb286af2b06fce4b82 100644 (file)
@@ -11,14 +11,3 @@ gdcmImage::~gdcmImage() {
 
 }
 
-
-
-std::string gdcmImage::GetEntryByNumber(guint16 group, guint16 element) {
-    return "";
-}
-
-
-std::string gdcmImage::GetEntryByName(TagName name) {
-    return "";
-}
-
index 5b75aaec19d705b74c0b8f85794de0634ab84ded..0c138ffa3179b649b16efd603c64f226af412868 100644 (file)
@@ -16,10 +16,6 @@ public:
    gdcmImage();
    ~gdcmImage();
 
-   std::string GetEntryByNumber(guint16 group, guint16 element);
-   std::string GetEntryByName(TagName name);
-
-
 };
 
 //-----------------------------------------------------------------------------
index f2f65c064ec6212ac2ad95a4a8a2711bf113da52..77c2aab19db24f81dc3f3c33d2ed84aa49a59499 100644 (file)
@@ -6,29 +6,23 @@
 #include <string>
 #include <list>
 #include "gdcmCommon.h"
-
+#include "gdcmHeaderEntry.h"
+#include "gdcmParser.h"
 
 //-----------------------------------------------------------------------------
-
-typedef std::list<std::string> lstring;
+class gdcmObject;
+typedef std::list<gdcmObject *> ListContent;
 
 //-----------------------------------------------------------------------------
-
 class gdcmObject {
 public:
+   std::string GetEntryByNumber(guint16 group, guint16 element);
+   std::string GetEntryByName(TagName name);
 
-   virtual std::string GetEntryByNumber(guint16 group, guint16 element)=0;
-   virtual std::string GetEntryByName(TagName name)=0;
-
+   ListTag::iterator beginObj;
+   ListTag::iterator endObj;
+   
 protected:
-
-   //to modify (I don't know the list type) : both iterators (beginning and end)
-   lstring::iterator beginIter;
-   lstring::iterator endIter;
-
-   //pointer to the data list
-   lstring *objectData;
-
 };
 
 //-----------------------------------------------------------------------------
index 362ca03fc8a9b9d48a40b6270d2210b2f8f362e1..d987a847ed5cddf58dfbb055f2c34a98db2b665d 100644 (file)
@@ -52,12 +52,14 @@ gdcmParser::gdcmParser(const char *InFilename,
 
    if ( !OpenFile(exception_on_error))
       return;
+
    Parse();
    LoadHeaderEntries();
+
    CloseFile();
 
    wasUpdated = 0;  // will be set to 1 if user adds an entry
-   printLevel = 1;  // 'Heavy' header print by default
+   printLevel = 1;  // 'Medium' header print by default
 }
 
 /**
@@ -67,7 +69,7 @@ gdcmParser::gdcmParser(const char *InFilename,
  */
 gdcmParser::gdcmParser(bool exception_on_error) 
 {
-   enableSequences=0;
+   //enableSequences=0;
 
    SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE);
    Initialise();
@@ -98,7 +100,7 @@ void gdcmParser::PrintEntry(std::ostream & os)
 {
    std::ostringstream s;   
           
-   s << "------------ using listEntries ----------------" << std::endl; 
+   s << "------------ gdcmParser::Print, using listEntries ----------------" << std::endl; 
    for (ListTag::iterator i = listEntries.begin();  
           i != listEntries.end();
           ++i)
@@ -121,7 +123,7 @@ void gdcmParser::PrintPubDict(std::ostream & os)
 
 /**
   * \ingroup gdcmParser
-  * \brief   Prints The Dict Entries of THE shadow Dicom Dictionnry
+  * \brief   Prints The Dict Entries of the current shadow Dicom Dictionnry
   * @return
   */
 void gdcmParser::PrintShaDict(std::ostream & os) 
@@ -133,7 +135,7 @@ void gdcmParser::PrintShaDict(std::ostream & os)
 // Public
 /**
  * \ingroup gdcmParser
- * \brief   Get the public dictionary used
+ * \brief   Get THE public dictionary used
  */
 gdcmDict *gdcmParser::GetPubDict(void)
 {
@@ -142,7 +144,7 @@ gdcmDict *gdcmParser::GetPubDict(void)
 
 /**
  * \ingroup gdcmParser
- * \brief   Get the shadow dictionary used
+ * \brief   Get the current shadow dictionary 
  */
 gdcmDict *gdcmParser::GetShaDict(void)
 {
@@ -165,8 +167,7 @@ bool gdcmParser::SetShaDict(gdcmDict *dict)
  * \brief   Set the shadow dictionary used
  * \param   dictName name of the dictionary to use in shadow
  */
-bool gdcmParser::SetShaDict(DictKey dictName)
-{
+bool gdcmParser::SetShaDict(DictKey dictName) {
    RefShaDict=gdcmGlobal::GetDicts()->GetDict(dictName);
    return(!RefShaDict);
 }
@@ -183,19 +184,27 @@ bool gdcmParser::SetShaDict(DictKey dictName)
 bool gdcmParser::IsReadable(void) 
 {
    std::string res = GetEntryByNumber(0x0028, 0x0005);
-   if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) 
-   {
+   if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) {
+      //std::cout << "error on : 28 5" << std::endl;
       return false; // Image Dimensions
    }
 
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0100) )
+   if ( !GetHeaderEntryByNumber(0x0028, 0x0100) ) {
+      //std::cout << "error on : 28 100" << std::endl;
       return false; // "Bits Allocated"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0101) )
+   }
+   if ( !GetHeaderEntryByNumber(0x0028, 0x0101) ){ 
+        // std::cout << "error on : 28 101" << std::endl;
       return false; // "Bits Stored"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0102) )
+   }
+   if ( !GetHeaderEntryByNumber(0x0028, 0x0102) ) {
+         //std::cout << "error on : 28 102" << std::endl;
       return false; // "High Bit"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0103) )
+   }
+   if ( !GetHeaderEntryByNumber(0x0028, 0x0103) ) {
+         //std::cout << "error on : 28 103" << std::endl;
       return false; // "Pixel Representation"
+   }
    return true;
 }
 
@@ -206,8 +215,7 @@ bool gdcmParser::IsReadable(void)
  *
  * @return  True when ImplicitVRLittleEndian found. False in all other cases.
  */
-bool gdcmParser::IsImplicitVRLittleEndianTransferSyntax(void) 
-{
+bool gdcmParser::IsImplicitVRLittleEndianTransferSyntax(void) {
    gdcmHeaderEntry *Element = GetHeaderEntryByNumber(0x0002, 0x0010);
    if ( !Element )
       return false;
@@ -490,7 +498,6 @@ int gdcmParser::CheckIfEntryExistByNumber(guint16 group, guint16 element )
  * \brief   Searches within Header Entries (Dicom Elements) parsed with 
  *          the public and private dictionaries 
  *          for the element value of a given tag.
- * \warning Don't use any longer : use GetPubEntryByName
  * @param   tagName name of the searched element.
  * @return  Corresponding element value when it exists,
  *          and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
@@ -2257,11 +2264,11 @@ gdcmHeaderEntry *gdcmParser::NewHeaderEntryByName(std::string Name)
 /**
  * \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
+ * @param   group   group   of the underlying DictEntry
+ * @param   element 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,
index 2ca4a793f1c21136b6854d139f9b4a474644fcf4..8e9e5af6bb704c8dd2baca1b44e262c272ed87be 100644 (file)
@@ -136,7 +136,8 @@ protected:
 
    static const unsigned int HEADER_LENGTH_TO_READ; 
    static const unsigned int MAX_SIZE_LOAD_ELEMENT_VALUE;
-
+protected:
+   int enableSequences;
 private:
    // Read
    void Parse(bool exception_on_error = false) throw(gdcmFormatError);
@@ -195,7 +196,7 @@ private:
 
    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;
index 4e952e4045f414b5275bf1558acf7d2e4344aef1..45781881b3fe81ea9e2e5cf681c3b3c77fed3c32 100644 (file)
@@ -8,17 +8,10 @@ gdcmPatient::gdcmPatient() {
 
 
 gdcmPatient::~gdcmPatient() {
-
-}
-
-
-
-std::string gdcmPatient::GetEntryByNumber(guint16 group, guint16 element) {
-    return "";
-}
-
-
-std::string gdcmPatient::GetEntryByName(TagName name) {
-    return "";
+   lStudy::iterator cc = GetStudies().begin();
+   while  (cc != GetStudies().end() ) {
+      delete *cc;
+      ++cc;
+   }
 }
 
index 6640a5f835e11eaf370606f55154e28acd9303c1..662bca15a3a0bc40df85be8c8dab24dfa11b480f 100644 (file)
@@ -8,7 +8,7 @@
 
 //-----------------------------------------------------------------------------
 
-typedef std::list<gdcmStudy> lStudy;
+typedef std::list<gdcmStudy *> lStudy;
 
 //-----------------------------------------------------------------------------
 
@@ -18,14 +18,11 @@ public:
    gdcmPatient();
    ~gdcmPatient();
 
-   std::string GetEntryByNumber(guint16 group, guint16 element);
-   std::string GetEntryByName(TagName name);
-
-   inline lStudy GetStudies() {return studies;};
-
+   inline lStudy &GetStudies() {return studies;};
+       
+   lStudy studies;
 private:
 
-   lStudy studies;
 
 };
 
index 18508e7249aa7a49c016e21e2ae84ea4bd3a67ef..9e4a275b759267ff222c6917d19c52cbfc945df2 100644 (file)
@@ -8,17 +8,10 @@ gdcmSerie::gdcmSerie() {
 
 
 gdcmSerie::~gdcmSerie() {
-
-}
-
-
-
-std::string gdcmSerie::GetEntryByNumber(guint16 group, guint16 element) {
-    return "";
-}
-
-
-std::string gdcmSerie::GetEntryByName(TagName name) {
-    return "";
+   lImage::iterator cc = GetImages().begin();
+   while  (cc != GetImages().end() ) {
+      delete *cc;
+      ++cc;
+   }
 }
 
index ed73cda1f899e123e6527795350ddd6d927dbfda..02fe496d13ccbf7b2965ef21ee18da3284666cc5 100644 (file)
@@ -8,7 +8,7 @@
 
 //-----------------------------------------------------------------------------
 
-typedef std::list<gdcmImage> lImage;
+typedef std::list<gdcmImage *> lImage;
 
 //-----------------------------------------------------------------------------
 
@@ -18,14 +18,12 @@ public:
    gdcmSerie();
    ~gdcmSerie();
 
-   std::string GetEntryByNumber(guint16 group, guint16 element);
-   std::string GetEntryByName(TagName name);
-
-   inline lImage GetImages() {return images;};
-
+   inline lImage &GetImages() {return images;};
+   
+   lImage images;
+   
 private:
 
-   lImage images;
 
 };
 
index bcfb0e34ca8151ab56ba0ff8fd0311786fb36bb6..9380f51935b9a8537acb6bf1b60da5d6456adb99 100644 (file)
@@ -8,17 +8,9 @@ gdcmStudy::gdcmStudy() {
 
 
 gdcmStudy::~gdcmStudy() {
-
-}
-
-
-
-std::string gdcmStudy::GetEntryByNumber(guint16 group, guint16 element) {
-    return "";
+   lSerie::iterator cc = GetSeries().begin();
+   while  (cc != GetSeries().end() ) {
+      delete *cc;
+      ++cc;
+   }
 }
-
-
-std::string gdcmStudy::GetEntryByName(TagName name) {
-    return "";
-}
-
index c595f054768c893b4701af835c31f79526ec4650..f08f709fddbc4faebcc43792991199dedd93d225 100644 (file)
@@ -8,7 +8,7 @@
 
 //-----------------------------------------------------------------------------
 
-typedef std::list<gdcmSerie> lSerie;
+typedef std::list<gdcmSerie *> lSerie;
 
 //-----------------------------------------------------------------------------
 
@@ -18,14 +18,12 @@ public:
    gdcmStudy();
    ~gdcmStudy();
 
-   std::string GetEntryByNumber(guint16 group, guint16 element);
-   std::string GetEntryByName(TagName name);
-
-   inline lSerie GetSeries() {return series;};
-
+   inline lSerie &GetSeries() {return series;};
+   
+   lSerie series;
+   
 private:
 
-   lSerie series;
 
 };
 
index 531c4ee76e04d7781002a7ad2b044261190395ed..7445b59c4787afe02cdccb6b3b5f742b66e93d6a 100644 (file)
@@ -34,6 +34,9 @@ gdcmTS::gdcmTS(void)
       eatwhite(from);
       from.getline(buff, 1024, ' ');
       key = buff;
+      if(key.size()%2==1)
+       key.push_back(0);
+       
       eatwhite(from);
       from.getline(buff, 1024, '\n');
       name = buff;