From 33b1eec26f02131242fbfdef52184b24763cf4e6 Mon Sep 17 00:00:00 2001 From: jpr Date: Tue, 29 Nov 2005 17:21:33 +0000 Subject: [PATCH] To prepare use of progression bar in all types of Document - move CallStartMethod, etc to Document - begin frame by frame reading (not finished : only for uncompressed files, right now) --- src/CMakeLists.txt | 1 - src/gdcmCallbackCommand.cxx | 5 +-- src/gdcmDebug.h | 22 ++++++---- src/gdcmDicomDir.cxx | 45 +++++--------------- src/gdcmDicomDir.h | 10 +---- src/gdcmDictEntry.cxx | 47 +++++++++++---------- src/gdcmDictEntry.h | 53 +++++++++++++++++++---- src/gdcmDirList.cxx | 6 +-- src/gdcmDocument.cxx | 41 ++++++++++++------ src/gdcmDocument.h | 16 +++++-- src/gdcmFileHelper.cxx | 8 ++-- src/gdcmFileHelper.h | 8 +++- src/gdcmPixelReadConvert.cxx | 81 ++++++++++++++++++++++++++++++++---- src/gdcmPixelReadConvert.h | 17 ++++++-- 14 files changed, 238 insertions(+), 122 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7101a67..ef6f8fe1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,7 +35,6 @@ SET(libgdcm_la_SOURCES gdcmDicomDirVisit.cxx gdcmDicomDirSerie.cxx gdcmDicomDirStudy.cxx - gdcmDicomEntry.cxx gdcmDict.cxx gdcmDictEntry.cxx gdcmDictGroupName.cxx diff --git a/src/gdcmCallbackCommand.cxx b/src/gdcmCallbackCommand.cxx index 05189aa0..d8046f33 100644 --- a/src/gdcmCallbackCommand.cxx +++ b/src/gdcmCallbackCommand.cxx @@ -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. */ diff --git a/src/gdcmDebug.h b/src/gdcmDebug.h index 33d22690..17246487 100644 --- a/src/gdcmDebug.h +++ b/src/gdcmDebug.h @@ -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) ) \ { \ diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 1a470809..22670611 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -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(); } diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 15162e8d..11f379f9 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -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 //----------------------------------------------------------------------------- diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index 08b9245b..345b99b7 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -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; diff --git a/src/gdcmDictEntry.h b/src/gdcmDictEntry.h index e2cecb8f..b3e6ffa7 100644 --- a/src/gdcmDictEntry.h +++ b/src/gdcmDictEntry.h @@ -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 @@ -19,11 +19,15 @@ #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; diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 9bfa68fd..caa8d7d5 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -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(os, "\n")); diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 1a3f177c..9459254d 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -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 /** diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 76ed0956..35271f9c 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -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 #include @@ -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 diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index a5381af6..c44839ed 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -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; } diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index b5f50adc..62bacd2b 100644 --- a/src/gdcmFileHelper.h +++ b/src/gdcmFileHelper.h @@ -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( ); diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 38df3566..c8c76c22 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -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;iread( (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 diff --git a/src/gdcmPixelReadConvert.h b/src/gdcmPixelReadConvert.h index 384f09e3..3305788b 100644 --- a/src/gdcmPixelReadConvert.h +++ b/src/gdcmPixelReadConvert.h @@ -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 @@ -21,7 +21,10 @@ #define GDCMPIXELREADCONVERT_H #include "gdcmBase.h" +#include "gdcmFileHelper.h" #include "gdcmException.h" +#include "gdcmCommandManager.h" + #include 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 -- 2.45.1