]> Creatis software - gdcm.git/commitdiff
upgrade GdcmHeaderEntry Print Method for DICOMDIR
authorjpr <jpr>
Wed, 28 Jan 2004 17:45:35 +0000 (17:45 +0000)
committerjpr <jpr>
Wed, 28 Jan 2004 17:45:35 +0000 (17:45 +0000)
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmHeader.cxx
src/gdcmHeader.h
src/gdcmHeaderEntry.cxx
src/gdcmParser.h

index f14f63e2d091b02633b7e01e619f159208e07cc6..a3441303ef220a83a36ce8074f886bc6be3f03ba 100644 (file)
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
+
+/*
+ * \ingroup gdcmDicomDir
+ * \brief   
+ * @param   Filename
+ * @param   exception_on_error
+ */
 gdcmDicomDir::gdcmDicomDir(std::string & FileName,
                            bool exception_on_error):
    gdcmParser(FileName.c_str(),exception_on_error, true )  
@@ -23,6 +30,19 @@ gdcmDicomDir::gdcmDicomDir(std::string & FileName,
 }
 
 
+/*
+ * \ingroup gdcmDicomDir
+ * \brief   
+ * @param   exception_on_error
+ */
+gdcmDicomDir::gdcmDicomDir(bool exception_on_error):                           
+   gdcmParser(exception_on_error )  
+{    
+
+}
+
+
+
 gdcmDicomDir::~gdcmDicomDir() 
 {
    for(ListPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
index d3fbc023ffc82c3a91fc8adddce77ef3ea3339f6..ed91ea9658282cab962a1eb682c6784b635a797e 100644 (file)
@@ -19,7 +19,9 @@ typedef std::list<gdcmPatient *> ListPatient;
 class GDCM_EXPORT gdcmDicomDir: public gdcmParser 
 {
 public:
+   gdcmDicomDir(bool exception_on_error = false);
    gdcmDicomDir(std::string &FileName,bool exception_on_error = false );
+   
    ~gdcmDicomDir(void);
 
    void SetPrintLevel(int level) { printLevel = level; };
index 1cbb7aac60104300053f3df47ced89f754be8c57..bfe4b672c6b97698329b972bbcbdd260bfac8e8e 100644 (file)
@@ -78,7 +78,6 @@ bool gdcmHeader::IsReadable(void) {
    std::string res = GetEntryByNumber(0x0028, 0x0005);
    if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) 
       return false; // Image Dimensions
-
    if ( !GetHeaderEntryByNumber(0x0028, 0x0100) )
       return false; // "Bits Allocated"
    if ( !GetHeaderEntryByNumber(0x0028, 0x0101) )
@@ -121,11 +120,7 @@ bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) {
    if ( !Element )
       return false;
    LoadHeaderEntrySafe(Element);
-
-   std::string Transfer = Element->GetValue();
-   if ( Transfer == "1.2.840.10008.1.2.4.51" )
-      return true;
-   return false;
+   return ( Element->GetValue() == "1.2.840.10008.1.2.4.51" );
 }
 
 /**
@@ -421,16 +416,17 @@ std::string gdcmHeader::GetPixelType(void) {
 /**
  * \ingroup gdcmHeader
  * \brief   Recover the offset (from the beginning of the file) 
- * \        of *image* pixels (not *icone* pixels, if any !)
+ * \        of *image* pixels (not *icone image* pixels, if any !)
  */
 size_t gdcmHeader::GetPixelOffset(void) {
-   // If this file complies with the norm we should encounter the
-   // "Image Location" tag (0x0028, 0x0200). This tag contains the
+   // We may encounter the 'RETired' (0x0028, 0x0200) tag
+   // (Image Location") . This Element contains the number of
    // the group that contains the pixel data (hence the "Pixel Data"
    // is found by indirection through the "Image Location").
    // Inside the group pointed by "Image Location" the searched element
    // is conventionally the element 0x0010 (when the norm is respected).
    // When the "Image Location" is absent we default to group 0x7fe0.
+   //
    // If the element (0x0088,0x0200) 'icone image sequence' is found
    // (grPixel,numPixel) is stored twice : the first one for the icon
    // the second one for the image ...
@@ -545,7 +541,7 @@ bool gdcmHeader::HasLUT(void) {
    if ( !GetHeaderEntryByNumber(0x0028,0x1103) )
       return false;
       
-   //  It is not enough
+   //  It is not enough :
    //  we check also 
    
    // Red Palette Color Lookup Table Data
@@ -687,7 +683,8 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) {
    // if it works, we shall have to check the 3 Palettes
    // to see which byte is ==0 (first one, or second one)
    // and fix the code
-   // We give up the checking to avoid some overhead 
+   // We give up the checking to avoid some (useless ?)overhead 
+   // (optimistic asumption)
    unsigned char *a;      
    int i;
 
@@ -713,7 +710,6 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) {
    } 
    
    //How to free the now useless LUTs?
-
    //free(LutR); free(LutB); free(LutG); // Seg Fault when used
    return(LUTRGBA);   
 } 
@@ -752,7 +748,9 @@ std::string gdcmHeader::GetTransfertSyntaxName(void) {
 void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
    std::string content1;
    char car[20];       
-   // Assumes HeaderEntry (0x7fe0, 0x0010) exists ...  
+   // Assumes HeaderEntry (0x7fe0, 0x0010) exists ...
+   // TODO define private members PixelGroupNumber, PicxelElementNumber
+   //      update them, use them (only necessary for ACR-NEMA, not DICOM)      
    sprintf(car,"%d",ImageDataSize);
  
    gdcmHeaderEntry *a = GetHeaderEntryByNumber(0x7fe0, 0x0010);
index feefcee8a0edac3d8b12053eeccaddf83ec4a8d1..1e67bc4f84bd5d18596bd54861d9f73c5773752d 100644 (file)
@@ -51,7 +51,7 @@ public:
 
    // Some heuristic based accessors, end user intended 
    // (to be move to gdcmHeaderHelper?) 
-   int GetXSize(void);  
+   int GetXSize(void);
    int GetYSize(void);
    int GetZSize(void);
    int GetBitsStored(void);
@@ -81,19 +81,22 @@ public:
    // TODO Swig int SetPubDict(std::string filename);
 
 // Entry
-   inline virtual std::string GetEntryByName    (std::string tagName) 
-      { return(gdcmParser::GetEntryByName(tagName)); }
-   inline virtual std::string GetEntryVRByName  (std::string tagName)
-      { return(gdcmParser::GetEntryVRByName(tagName)); }
+
    inline virtual std::string GetEntryByNumber  (guint16 group, guint16 element)
       { return(gdcmParser::GetEntryByNumber(group,element)); }
    inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
       { return(gdcmParser::GetEntryVRByNumber(group,element)); }
-
-   inline virtual bool SetEntryByName(std::string content,std::string tagName)
-      { return(gdcmParser::SetEntryByName(content,tagName)); }
+      
+   inline virtual std::string GetEntryByName    (std::string tagName) 
+      { return(gdcmParser::GetEntryByName(tagName)); }
+   inline virtual std::string GetEntryVRByName  (std::string tagName)
+      { return(gdcmParser::GetEntryVRByName(tagName)); }
+      
    inline virtual bool SetEntryByNumber(std::string content,guint16 group, guint16 element)
       { return(gdcmParser::SetEntryByNumber(content,group,element)); }
+   inline virtual bool SetEntryByName(std::string content,std::string tagName)
+      { return(gdcmParser::SetEntryByName(content,tagName)); }
+
 
    inline virtual void UpdateShaEntries(void)
       { gdcmParser::UpdateShaEntries(); }
index 5832ad315e8763c7b46c3c014a723fa40a099927..e53120744a3385ac0f75921753cd04a5ca6439f3 100644 (file)
@@ -92,6 +92,11 @@ void gdcmHeaderEntry::Print(std::ostream & os) {
       if (g == 0x0008) {
          if ( (e == 0x0016) || (e == 0x1150)  )
             s << "  ==>\t[" << ts->GetValue(v) << "]";
+      } else {
+         if (g == 0x0004) {
+           if ( (e == 0x1510) || (e == 0x1512)  )
+              s << "  ==>\t[" << ts->GetValue(v) << "]";
+        }     
       }
    }
    //if (e == 0x0000) {        // elem 0x0000 --> group length 
index 7165817e0a8ebe8822eb1fc4f0cfcf6c1dd0b09d..cf2cc9470c349f893c003850f03f0278294ab6a3 100644 (file)
@@ -29,8 +29,8 @@ typedef std::map<GroupKey, int> GroupHT;
 
 //-----------------------------------------------------------------------------
 /*
- * \defgroup gdcmHeader
- * \brief
+ * \defgroup gdcmParser
+ * \brief used by both gdcmHeader and gdcmDicomDir
  */
 class GDCM_EXPORT gdcmParser
 {
@@ -128,7 +128,6 @@ protected:
    IterHT           GetHeaderEntrySameNumber(guint16 group, guint16 element); 
 // IterHT           GetHeaderEntrySameName  (std::string Name); 
 
-
    void LoadHeaderEntrySafe(gdcmHeaderEntry *);
 
    void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
@@ -177,21 +176,22 @@ private:
    void SwitchSwapToBigEndian(void);
    void SetMaxSizeLoadEntry(long);
 
-   // Dict
+   // DictEntry  related utilities
    gdcmDictEntry *GetDictEntryByName  (std::string Name);
    gdcmDictEntry *GetDictEntryByNumber(guint16, guint16);
-
-   // HeaderEntry related utilities
-   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");
    gdcmDictEntry *NewVirtualDictEntry(gdcmHeaderEntry *);
+   
+   // HeaderEntry related utilities
+   gdcmHeaderEntry *ReadNextHeaderEntry   (void);
+   gdcmHeaderEntry *NewHeaderEntryByNumber(guint16 group, 
+                                           guint16 element);
+   gdcmHeaderEntry *NewHeaderEntryByName  (std::string Name);
+
 
    // Deprecated (Not used)
    gdcmHeaderEntry *NewManualHeaderEntryToPubDict(std::string NewTagName,