]> 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 4ce1544..9a2cb23 100644 (file)
@@ -31,6 +31,7 @@ libgdcm_la_SOURCES=                \
    gdcmRLE.cxx                     \
    gdcmParsePixels.cxx             \
    gdcmDICOMDIR.cxx                \
+   gdcmObject.cxx                  \
    gdcmPatient.cxx                 \
    gdcmStudy.cxx                   \
    gdcmSerie.cxx                   \
index aeb8322..22ad729 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 1b9b5f3..f635c81 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 245a6a4..382a747 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 5b75aae..0c138ff 100644 (file)
@@ -16,10 +16,6 @@ public:
    gdcmImage();
    ~gdcmImage();
 
-   std::string GetEntryByNumber(guint16 group, guint16 element);
-   std::string GetEntryByName(TagName name);
-
-
 };
 
 //-----------------------------------------------------------------------------
index f2f65c0..77c2aab 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 362ca03..d987a84 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 2ca4a79..8e9e5af 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 4e952e4..4578188 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 6640a5f..662bca1 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 18508e7..9e4a275 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 ed73cda..02fe496 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 bcfb0e3..9380f51 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 c595f05..f08f709 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 531c4ee..7445b59 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;