]> Creatis software - gdcm.git/commitdiff
To prepare use of progression bar in all types of Document
authorjpr <jpr>
Tue, 29 Nov 2005 17:21:33 +0000 (17:21 +0000)
committerjpr <jpr>
Tue, 29 Nov 2005 17:21:33 +0000 (17:21 +0000)
- move CallStartMethod, etc to Document
- begin frame by frame reading (not finished : only for uncompressed files,
right now)

14 files changed:
src/CMakeLists.txt
src/gdcmCallbackCommand.cxx
src/gdcmDebug.h
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDictEntry.cxx
src/gdcmDictEntry.h
src/gdcmDirList.cxx
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmFileHelper.cxx
src/gdcmFileHelper.h
src/gdcmPixelReadConvert.cxx
src/gdcmPixelReadConvert.h

index c7101a675db489ec67332c888d5ccea545e07abf..ef6f8fe138e54f029682c59d66798c503aa5d308 100644 (file)
@@ -35,7 +35,6 @@ SET(libgdcm_la_SOURCES
    gdcmDicomDirVisit.cxx
    gdcmDicomDirSerie.cxx
    gdcmDicomDirStudy.cxx
-   gdcmDicomEntry.cxx
    gdcmDict.cxx
    gdcmDictEntry.cxx
    gdcmDictGroupName.cxx
index 05189aa078dc07261470c71bc9134c7cd13d3e58..d8046f33ac53ba2492928d62103409a12257bad8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCallbackCommand.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 15:20:35 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2005/11/29 17:21:33 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -32,7 +32,6 @@ CallbackCommand::CallbackCommand()
    CallbackArg          = NULL;
 }
 
-
 /**
  * \brief   Canonical destructor.
  */
index 33d22690df1dd49e20cd718c074d08053b6e66e5..172464871634499bc06e3b3e4c4b2b663e141641 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDebug.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 16:50:32 $
-  Version:   $Revision: 1.51 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.52 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -88,7 +88,8 @@ public:
 
    static std::ostream &GetOutput ();
 
-   static void SendToOutput(unsigned int type,std::string const &msg,const Base *object = NULL);
+   static void SendToOutput(unsigned int type,std::string const &msg,
+                            const Base *object = NULL);
 
 private:
    static bool DebugFlag;
@@ -129,7 +130,7 @@ private:
  * \brief   Debug : To be used to help bug tracking developer
  * @param msg message part
  */
-#define gdcmMessageBodyMacro(type,obj,msg,adds)                \
+#define gdcmMessageBodyMacro(type, obj, msg, adds)             \
 {                                                              \
    std::ostringstream osmacro;                                 \
    osmacro << "In " __FILE__ ", line " << __LINE__             \
@@ -143,11 +144,11 @@ private:
  * @param msg message part
  */
 #ifdef NDEBUG
-#define gdcmDebugBodyMacro(obj,msg) {}
+#define gdcmDebugBodyMacro(obj, msg) {}
 #define gdcmDebugMacro(msg) {}
 #define gdcmStaticDebugMacro(msg) {}
 #else
-#define gdcmDebugBodyMacro(obj,msg)                            \
+#define gdcmDebugBodyMacro(obj, msg)                           \
 {                                                              \
    if( Debug::GetDebugFlag() )                                 \
    {                                                           \
@@ -172,7 +173,8 @@ private:
  * @param msg message part
  */
 // No NDEBUG test to always have a return of warnings !!!
-#define gdcmWarningBodyMacro(obj,msg)                          \
+// -> Rien compris! JPRx
+#define gdcmWarningBodyMacro(obj, msg)                         \
 {                                                              \
    if( Debug::GetWarningFlag() )                               \
       gdcmMessageBodyMacro(gdcm::CMD_WARNING,obj,msg,"");      \
@@ -188,7 +190,8 @@ private:
  * @param msg second message part 
  */
 // No NDEBUG test to always have a return of errors !!!
-#define gdcmErrorBodyMacro(obj,msg)                            \
+// -> Rien compris! JPRx
+#define gdcmErrorBodyMacro(obj, msg)                           \
 {                                                              \
    gdcmMessageBodyMacro(gdcm::CMD_ERROR,obj,msg,"");           \
 }
@@ -206,7 +209,8 @@ private:
  *        gdcmAssertMacro( "my message" && 2 < 3 )
  */
 // No NDEBUG test to always have a return of asserts !!!
-#define gdcmAssertBodyMacro(obj,arg)                           \
+// -> Rien compris! JPRx
+#define gdcmAssertBodyMacro(obj, arg)                          \
 {                                                              \
    if( !(arg) )                                                \
    {                                                           \
index 1a47080925328ad312a6fd473843c6a7315c4d0f..22670611d27a12c6d00d84631c9269cab1cb7a6e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/29 12:48:45 $
-  Version:   $Revision: 1.176 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.177 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -202,13 +202,13 @@ bool DicomDir::DoTheLoadingJob( )
          char buf[2048];
          const char *cwd = getcwd(buf, 2048);
          if( cwd )
-           {
+         {
            SetFileName( buf ); // will be converted into a string
-           }
+         }
          else
-           {
+         {
            gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
-           }
+         }
       }
       NewMeta();
       gdcmDebugMacro( "Parse directory and create the DicomDir : " 
@@ -523,32 +523,6 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
    }
 }
 
-/**
- * \brief   CallStartMethod
- */
-void DicomDir::CallStartMethod()
-{
-   Progress = 0.0f;
-   Abort    = false;
-   CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS);
-}
-
-/**
- * \brief   CallProgressMethod
- */
-void DicomDir::CallProgressMethod()
-{
-   CommandManager::ExecuteCommand(this,CMD_PROGRESS);
-}
-
-/**
- * \brief   CallEndMethod
- */
-void DicomDir::CallEndMethod()
-{
-   Progress = 1.0f;
-   CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS);
-}
 
 //-----------------------------------------------------------------------------
 // Private
@@ -1029,15 +1003,16 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
  * @param dst destination SQItem
  * @param src source SQItem
  */
-void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src)
+void DicomDir::MoveSQItem(DocEntrySet *dst, DocEntrySet *src)
 { 
    DocEntry *entry;
-
+// todo : rewrite the whole stuff, without using RemoveEntry an AddEntry,
+//        to save time
    entry = src->GetFirstEntry();
    while(entry)
    {
+      dst->AddEntry(entry);  // use it, *before* removing it!
       src->RemoveEntry(entry);
-      dst->AddEntry(entry);
       // we destroyed -> the current iterator is not longer valid
       entry = src->GetFirstEntry();
    }
index 15162e8d6e53add093968c7b606ad62b9fe5e176..11f379f9359f89652004cc44ba7632e914f622ca 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/29 12:48:46 $
-  Version:   $Revision: 1.72 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.73 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -117,9 +117,6 @@ protected:
    ~DicomDir();
 
    void CreateDicomDirChainedList(std::string const &path);
-   void CallStartMethod();
-   void CallProgressMethod();
-   void CallEndMethod();
 
 private:
    void Initialize();
@@ -147,12 +144,9 @@ private:
    ListDicomDirPatient Patients;
    ListDicomDirPatient::iterator ItPatient;
 
-   /// value of the ??? for any progress bar
-   float Progress;
    /// value of the ??? for any progress bar   
    bool ParseDir;
 
-   mutable bool Abort;
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index 08b9245be33bd0541fbeedc8c0c85d5ada0cf73d..345b99b7b4abf812f937f53cbf28c32fa4ce75bb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 18:01:25 $
-  Version:   $Revision: 1.57 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.58 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,13 +39,22 @@ namespace gdcm
 DictEntry::DictEntry(uint16_t group, uint16_t elem,
                      VRKey const &vr, 
                      TagName const &vm,
-                     TagName const &name):
-   DicomEntry(group,elem,vr)
+                     TagName const &name)
+
 {
+   Tag.SetGroup(group);
+   Tag.SetElement(elem);
+   VR      = vr;
    VM      = vm;
    Name    = name;
 }
 
+/**
+ * \brief   Destructor
+ */
+DictEntry::~DictEntry()
+{
+}
 //-----------------------------------------------------------------------------
 // Public
 /**
@@ -65,25 +74,18 @@ DictEntry *DictEntry::New(uint16_t group, uint16_t elem,
 }
 
 /**
- * \brief       If-and only if-the V(alue) R(epresentation)
- * \            is unset then overwrite it.
- * @param vr    New V(alue) R(epresentation) to be set.
- */
-void DictEntry::SetVR(VRKey const &vr) 
-{
-   //gdcmAssertMacro( IsVRUnknown() );
-   DicomEntry::SetVR(vr);
-}
-
-/**
- * \brief       If-and only if-the V(alue) M(ultiplicity)
- * \            is unset then overwrite it.
- * @param vm    New V(alue) M(ultiplicity) to be set.
+ * \brief   concatenates 2 uint16_t (supposed to be a Dicom group number 
+ *                                              and a Dicom element number)
+ * @param  group the Dicom group number used to build the tag
+ * @param  elem the Dicom element number used to build the tag
+ * @return the built tag
  */
-void DictEntry::SetVM(TagName const &vm) 
+TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem)
 {
-   gdcmAssertMacro( IsVMUnknown() );
-   VM = vm;
+   // according to 'Purify', TranslateToKey is one of the most
+   // time consuming methods.
+   // Let's try to shorten it !
+   return TagKey(group,elem);
 }
 
 //-----------------------------------------------------------------------------
@@ -101,7 +103,8 @@ void DictEntry::SetVM(TagName const &vm)
  */
 void DictEntry::Print(std::ostream &os, std::string const &indent )
 {
-   DicomEntry::Print(os,indent);
+   os << GetKey(); 
+   os << " [" << VR  << "] ";
 
    std::ostringstream s;
 
index e2cecb8fc17098b7ee3bd3348a1f768fea65d21e..b3e6ffa7f8a4c94fe6c23884933e09094109cb5e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/05 13:24:39 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #ifndef GDCMDICTENTRY_H
 #define GDCMDICTENTRY_H
 
-#include "gdcmDicomEntry.h"
+#include "gdcmRefCounter.h"
+#include "gdcmTagKey.h"
+#include "gdcmVRKey.h"
 
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
+class VRKey;
+class TagKey;
 /**
  * \brief
  * the DictEntry in an element contained by the Dict.
@@ -35,7 +39,7 @@ namespace gdcm
  *  - the VM (Value Multiplicity)
  *  - the corresponding name in english
  */
-class GDCM_EXPORT DictEntry : public DicomEntry
+class GDCM_EXPORT DictEntry : public RefCounter
 {
    gdcmTypeMacro(DictEntry);
 
@@ -48,13 +52,35 @@ public:
 // Print
    void Print(std::ostream &os = std::cout, std::string const &indent = "");
 
-// Content of DictEntry
-   virtual void SetVR(VRKey const &vr);
-   virtual void SetVM(TagName const &vm);
+   /// \brief  Returns the Dicom Group Number
+   /// @return the Dicom Group Number
+   const uint16_t &GetGroup() const { return Tag[0]; }
+
+   /// \brief  Returns the Dicom Element Number
+   /// @return the Dicom Element Number
+   const uint16_t &GetElement() const { return Tag[1]; }   
+
+   /// \brief  Set the Dicom Value Representation 
+   /// \param vr the Dicom Value Representation
+   virtual void SetVR(VRKey const &vr) { VR = vr; }
+   /// \brief  Returns the Dicom Value Representation 
+   /// @return the Dicom Value Representation
+   const VRKey &GetVR() const { return VR; }
+   /// \brief tells if the V(alue) R(epresentation) is known (?!)
+   /// @return 
+   bool IsVRUnknown() const { return VR == GDCM_VRUNKNOWN; }
+
+   const TagKey &GetKey() const { return Tag; }
+
+// Key creation
+   static TagKey TranslateToKey(uint16_t group, uint16_t elem);
+
    /// \brief   returns the VM field of the current DictEntry
    /// @return  The 'Value Multiplicity' field
    const TagName &GetVM() const { return VM; } 
-
+   /// \brief  Set the VM field of the current DictEntry
+   /// \param vm the'Value Multiplicity'
+   virtual void SetVM(TagName const &vm) { VM = vm; }
    /// \brief tells if the V(alue) M(ultiplicity) is known (?!)
    /// @return 
    bool IsVMUnknown() const { return VM == GDCM_UNKNOWN; }
@@ -70,7 +96,18 @@ protected:
              TagName const &vm     = GDCM_UNKNOWN,
              TagName const &name   = GDCM_UNKNOWN);
 
+   ~DictEntry();
+   
 private:
+   /// Dicom \ref TagKey. Contains Dicom Group number and Dicom Element number
+   TagKey Tag;
+
+   /// \brief Value Representation i.e. some clue about the nature
+   ///        of the data represented e.g. 
+   ///        - "FD" short for "Floating Point Double"(see \ref VR)
+   ///        - "PN" short for "Person Name"       
+   VRKey VR;
+   
    /// \brief Value Multiplicity (e.g. "1", "1-n", "2-n", "6")
    TagName VM; 
 
index 9bfa68fdde9fa60f38b55b8550dbf3550c20d4d2..caa8d7d52152ec2aa857ba188b9e7be55715d1a3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDirList.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 17:24:21 $
-  Version:   $Revision: 1.55 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.56 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -188,7 +188,7 @@ int DirList::Explore(std::string const &dirpath, bool recursive)
  * \brief   Print method
  * @param os ostream to write to 
  */
-void DirList::Print(std::ostream &os, std::string const &indent)
+void DirList::Print(std::ostream &os, std::string const &)
 {
    std::copy(Filenames.begin(), Filenames.end(), 
              std::ostream_iterator<std::string>(os, "\n"));
index 1a3f177c3525696ae6a6126d146b0625c3f84943..9459254d643901796c59548357e3937e74bddf50 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 16:28:06 $
-  Version:   $Revision: 1.331 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.332 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -91,16 +91,6 @@ bool Document::Load(  )
    return DoTheLoadingDocumentJob( );
 }
 
-/*
-//#ifndef GDCM_LEGACY_REMOVE 
-bool Document::Load( std::string const &fileName ) 
-{
-   Filename = fileName;
-   return DoTheLoadingDocumentJob( );
-}
-//#endif
-*/
-
 /**
  * \brief   Performs the Loading Job (internal use only)  
  * @return false if file cannot be open or no swap info was found,
@@ -993,6 +983,33 @@ int Document::ComputeGroup0002Length( )
    return groupLength; 
 }
 
+/**
+ * \brief   CallStartMethod
+ */
+void Document::CallStartMethod()
+{
+   Progress = 0.0f;
+   Abort    = false;
+   CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS);
+}
+
+/**
+ * \brief   CallProgressMethod
+ */
+void Document::CallProgressMethod()
+{
+   CommandManager::ExecuteCommand(this,CMD_PROGRESS);
+}
+
+/**
+ * \brief   CallEndMethod
+ */
+void Document::CallEndMethod()
+{
+   Progress = 1.0f;
+   CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS);
+}
+
 //-----------------------------------------------------------------------------
 // Private
 /**
index 76ed0956d54dd1c66fd2e56723a7b7259274b979..35271f9c647a313e0aa7658b2488a45a2efc690f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 16:28:06 $
-  Version:   $Revision: 1.136 $
+  Date:      $Date: 2005/11/29 17:21:34 $
+  Version:   $Revision: 1.137 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -24,6 +24,7 @@
 #include "gdcmElementSet.h"
 #include "gdcmException.h"
 #include "gdcmDebug.h"  // for LEGACY
+#include "gdcmCommandManager.h"
 
 #include <map>
 #include <list>
@@ -112,7 +113,11 @@ protected:
    // gdcm::DicomDir are meaningfull).
    Document();
    virtual ~Document();
-   
+
+   virtual void CallStartMethod();
+   virtual void CallProgressMethod();
+   virtual void CallEndMethod();
+      
    uint16_t ReadInt16() throw ( FormatError );
    uint32_t ReadInt32() throw ( FormatError );
    void     SkipBytes(uint32_t);
@@ -218,6 +223,11 @@ private:
    DocEntry *Backtrack(DocEntry *docEntry);
 
 // Variables
+protected:
+   /// value of the ??? for any progress bar
+   float Progress;
+   mutable bool Abort;
+   
    /// Public dictionary used to parse this header
    Dict *RefPubDict;
    /// \brief Optional "shadow dictionary" (private elements) used to parse
index a5381af6736f53ac1cfe798d841c790f9cea32a2..c44839ede63fad2fd032506a68d3eb7c7f13e641 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2005/11/21 09:46:26 $
-  Version:   $Revision: 1.83 $
+  Date:      $Date: 2005/11/29 17:21:35 $
+  Version:   $Revision: 1.84 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -159,7 +159,7 @@ FileHelper::FileHelper(File *header)
    Initialize();
    if ( FileInternal->IsReadable() )
    {
-      PixelReadConverter->GrabInformationsFromFile( FileInternal );
+      PixelReadConverter->GrabInformationsFromFile( FileInternal, this );
    }
 }
 
@@ -220,7 +220,7 @@ bool FileHelper::Load()
    if ( !FileInternal->Load() )
       return false;
 
-   PixelReadConverter->GrabInformationsFromFile( FileInternal );
+   PixelReadConverter->GrabInformationsFromFile( FileInternal, this );
    return true;
 }
 
index b5f50adc5c939dc8434aa0b92c4f85087b0d2fab..62bacd2b450cbcfdaec83455232537cb02ec38de 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 16:31:23 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2005/11/29 17:21:35 $
+  Version:   $Revision: 1.36 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -154,6 +154,10 @@ public:
    void SetKeepMediaStorageSOPClassUID (bool v) 
                               { KeepMediaStorageSOPClassUID = v; }
    // no GetKeepMediaStorageSOPClassUID() method, on purpose!
+
+   void CallStartMethod();
+   void CallProgressMethod();
+   void CallEndMethod();
    
 protected:
    FileHelper( );
index 38df35665ce194ed14117d4541c5bd5e34ad8ac8..c8c76c22d2f12747c805bd1fa1043d47c88423d7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelReadConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 16:50:32 $
-  Version:   $Revision: 1.105 $
+  Date:      $Date: 2005/11/29 17:21:35 $
+  Version:   $Revision: 1.106 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -82,7 +82,8 @@ bool PixelReadConvert::IsRawRGB()
  * \brief Gets various usefull informations from the file header
  * @param file gdcm::File pointer
  */
-void PixelReadConvert::GrabInformationsFromFile( File *file )
+void PixelReadConvert::GrabInformationsFromFile( File *file, 
+                                                 FileHelper *fileHelper )
 {
    // Number of Bits Allocated for storing a Pixel is defaulted to 16
    // when absent from the file.
@@ -227,7 +228,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       }
    }
    FileInternal = file;   
-
+   FH = fileHelper;
    ComputeRawAndRGBSizes();
 }
 
@@ -257,8 +258,18 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
    AllocateRaw();
 
    //////////////////////////////////////////////////
+   
+   CallStartMethod(); // for progress bar
+   unsigned int count = 0;
+   unsigned int frameSize;
+   unsigned int bitsAllocated = BitsAllocated;
+   if(bitsAllocated == 12)
+      bitsAllocated = 16;
+   frameSize = XSize*YSize*SamplesPerPixel*bitsAllocated/8;
+   
    //// Second stage: read from disk and decompress.
-   if ( BitsAllocated == 12 )
+   
+   if ( BitsAllocated == 12 ) // We suppose 'BitsAllocated' = 12 only exist for uncompressed files
    {
       ReadAndDecompress12BitsTo16Bits( fp);
    }
@@ -273,14 +284,38 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
          gdcmWarningMacro( "Mismatch between PixelReadConvert : "
                               << PixelDataLength << " and RawSize : " << RawSize );
       }
+      
+      //todo : is it the right patch?
+      char *raw = (char*)Raw;
+      uint32_t remainingLength;
+      unsigned int i; 
+      unsigned int lengthToRead;
+       
       if ( PixelDataLength > RawSize )
-      {
-         fp->read( (char*)Raw, RawSize);
-      }
+        lengthToRead =  RawSize;
       else
+        lengthToRead = PixelDataLength;
+      // perform a frame by frame reading
+      remainingLength = lengthToRead;
+      unsigned int nbFrames = lengthToRead / frameSize;
+      for (i=0;i<nbFrames; i++)
       {
-         fp->read( (char*)Raw, PixelDataLength);
+         fp->read( raw, frameSize);
+         raw +=  frameSize;
+         remainingLength -=  frameSize;
       }
+      if (remainingLength !=0 )
+        fp->read( raw, remainingLength);
+                 
+      //if ( PixelDataLength > RawSize )
+      //{
+      //   fp->read( (char*)Raw, RawSize); // Read all the frames with a single fread    
+      //}
+      //else
+      //{
+      //   fp->read( (char*)Raw, PixelDataLength); // Read all the frames with a single fread
+      //}
 
       if ( fp->fail() || fp->eof())
       {
@@ -1369,6 +1404,34 @@ void PixelReadConvert::Print( std::ostream &os, std::string const &indent )
    }
 }
 
+/**
+ * \brief   CallStartMethod
+ */
+void PixelReadConvert::CallStartMethod()
+{
+   Progress = 0.0f;
+   Abort    = false;
+   CommandManager::ExecuteCommand(FH,CMD_STARTPROGRESS);
+}
+
+/**
+ * \brief   CallProgressMethod
+ */
+void PixelReadConvert::CallProgressMethod()
+{
+   CommandManager::ExecuteCommand(FH,CMD_PROGRESS);
+}
+
+/**
+ * \brief   CallEndMethod
+ */
+void PixelReadConvert::CallEndMethod()
+{
+   Progress = 1.0f;
+   CommandManager::ExecuteCommand(FH,CMD_ENDPROGRESS);
+}
+
+
 //-----------------------------------------------------------------------------
 } // end namespace gdcm
 
index 384f09e32e2ad7d42ce06b9ee0d865de45412d38..3305788b01360385cf60d4694496f8f2622fba91 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelReadConvert.h,v $
   Language:  C++
-  Date:      $Date: 2005/11/28 10:32:05 $
-  Version:   $Revision: 1.27 $
+  Date:      $Date: 2005/11/29 17:21:35 $
+  Version:   $Revision: 1.28 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #define GDCMPIXELREADCONVERT_H
 
 #include "gdcmBase.h"
+#include "gdcmFileHelper.h"
 #include "gdcmException.h"
+#include "gdcmCommandManager.h"
+
 #include <fstream>
 
 namespace gdcm
@@ -67,7 +70,7 @@ private:
    bool IsRawRGB();
 
 // In progress
-   void GrabInformationsFromFile( File *file );
+   void GrabInformationsFromFile( File *file, FileHelper *fileHelper );
    bool ReadAndDecompressPixelData( std::ifstream *fp );
    void Squeeze();
    bool BuildRGBImage();
@@ -96,6 +99,10 @@ private:
    void AllocateRGB();
    void AllocateRaw();
 
+   void CallStartMethod();
+   void CallProgressMethod();
+   void CallEndMethod();
+   
 // Variables
 /**
  * \brief Pixel data represented as RGB after LUT color interpretation.
@@ -164,6 +171,10 @@ private:
    
    File *FileInternal; // must be passed to User Function
    VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
+   /// Needed for the progression bar stuff
+   FileHelper *FH;
+   mutable bool Abort;
+   float Progress;
 };
 } // end namespace gdcm