From a4cff04fcd2023f798a9f1ef6bc9307269abd185 Mon Sep 17 00:00:00 2001 From: regrain Date: Wed, 26 Jan 2005 11:42:01 +0000 Subject: [PATCH] * FIX : remove so many friend between classes -- BeNours --- ChangeLog | 3 +++ src/gdcmDocEntry.h | 8 +++--- src/gdcmDocEntryArchive.cxx | 46 +++++++++++++++++++++++++++-------- src/gdcmDocEntryArchive.h | 9 ++++--- src/gdcmDocEntrySet.cxx | 8 +++--- src/gdcmDocEntrySet.h | 9 ++++--- src/gdcmDocument.cxx | 14 +++++------ src/gdcmElementSet.h | 8 +++--- src/gdcmJPEGFragment.cxx | 6 ++--- src/gdcmJPEGFragment.h | 22 ++++++++--------- src/gdcmJPEGFragmentsInfo.cxx | 12 ++++----- src/gdcmJPEGFragmentsInfo.h | 12 ++++----- src/gdcmJpeg.cxx | 12 ++++----- src/gdcmPixelReadConvert.cxx | 16 ++++++------ src/gdcmRLEFrame.cxx | 29 ++++++++++++++++++++-- src/gdcmRLEFrame.h | 22 +++++++++++------ src/gdcmRLEFramesInfo.h | 17 +++++++------ src/jdatasrc.cxx | 6 ++--- 18 files changed, 160 insertions(+), 99 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2eb054f6..0201f1a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2005-01-26 Benoit Regrain + * FIX : remove so many friend between classes + 2005-01-25 Benoit Regrain * src/gdcmDocEntrySet.cxx : Bug fix when getting the value * src/gdcmContentEntry.[h|cxx], gdcmValEntry.cxx : amelioration of code diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index 2a5ddc89..886a5abe 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:55 $ - Version: $Revision: 1.40 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.41 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -166,9 +166,7 @@ protected: TagKey Key; private: - // FIXME: In fact we should be more specific and use : - // friend DocEntry *File::ReadNextElement(void); - friend class File; + friend class File; // To use SetDictEntry }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDocEntryArchive.cxx b/src/gdcmDocEntryArchive.cxx index 2a47352d..eb27dff0 100644 --- a/src/gdcmDocEntryArchive.cxx +++ b/src/gdcmDocEntryArchive.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntryArchive.cxx,v $ Language: C++ - Date: $Date: 2005/01/26 10:29:17 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -28,9 +28,9 @@ namespace gdcm /** * \brief Constructor */ -DocEntryArchive::DocEntryArchive(File *header): - HeaderHT(header->TagHT) +DocEntryArchive::DocEntryArchive(File *file) { + ArchFile = file; } //----------------------------------------------------------------------------- @@ -74,13 +74,22 @@ bool DocEntryArchive::Push(DocEntry *newEntry) if(!newEntry) return false; - uint16_t gr = newEntry->GetDictEntry()->GetGroup(); - uint16_t elt = newEntry->GetDictEntry()->GetElement(); - std::string key = DictEntry::TranslateToKey(gr,elt); + uint16_t group = newEntry->GetDictEntry()->GetGroup(); + uint16_t elem = newEntry->GetDictEntry()->GetElement(); + std::string key = DictEntry::TranslateToKey(group,elem); if( Archive.find(key)==Archive.end() ) { // Save the old DocEntry if any + DocEntry *old = ArchFile->GetDocEntry(group,elem); + Archive[key] = old; + if( old ) + ArchFile->RemoveEntryNoDestroy(old); + + // Set the new DocEntry + ArchFile->AddEntry(newEntry); + +/* // Save the old DocEntry if any TagDocEntryHT::iterator it = HeaderHT.find(key); if( it!=HeaderHT.end() ) { @@ -92,7 +101,7 @@ bool DocEntryArchive::Push(DocEntry *newEntry) } // Set the new DocEntry - HeaderHT[key] = newEntry; + HeaderHT[key] = newEntry;*/ return true; } @@ -114,12 +123,18 @@ bool DocEntryArchive::Push(uint16_t group,uint16_t elem) if( Archive.find(key)==Archive.end() ) { // Save the old DocEntry if any + DocEntry *old = ArchFile->GetDocEntry(group,elem); + Archive[key] = old; + if( old ) + ArchFile->RemoveEntryNoDestroy(old); + +/* // Save the old DocEntry if any TagDocEntryHT::iterator it = HeaderHT.find(key); if( it!=HeaderHT.end() ) { Archive[key] = it->second; HeaderHT.erase(it); - } + }*/ return true; } @@ -141,12 +156,23 @@ bool DocEntryArchive::Restore(uint16_t group,uint16_t elem) TagDocEntryHT::iterator restoreIt=Archive.find(key); if( restoreIt!=Archive.end() ) { + // Delete the new value + DocEntry *rem = ArchFile->GetDocEntry(group,elem); + if( rem ) + ArchFile->RemoveEntry(rem); + + // Restore the old value + if( Archive[key] ) + ArchFile->AddEntry(Archive[key]); + +/* // Delete the new value TagDocEntryHT::iterator restorePos = HeaderHT.find(key); if( restorePos!=HeaderHT.end() ) { delete restorePos->second; } + // Restore the old value if( Archive[key] ) { HeaderHT[key] = Archive[key]; @@ -154,7 +180,7 @@ bool DocEntryArchive::Restore(uint16_t group,uint16_t elem) else { HeaderHT.erase(restorePos); - } + }*/ Archive.erase(restoreIt); diff --git a/src/gdcmDocEntryArchive.h b/src/gdcmDocEntryArchive.h index 1c6b4c58..660d255c 100644 --- a/src/gdcmDocEntryArchive.h +++ b/src/gdcmDocEntryArchive.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntryArchive.h,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:55 $ - Version: $Revision: 1.6 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,7 +37,7 @@ namespace gdcm class GDCM_EXPORT DocEntryArchive { public: - DocEntryArchive(File *f); + DocEntryArchive(File *file); ~DocEntryArchive(); void Print(std::ostream &os = std::cout); @@ -49,7 +49,8 @@ public: void ClearArchive(void); private: - TagDocEntryHT &HeaderHT; // we keep the name HeaderHT +// TagDocEntryHT &HeaderHT; // we keep the name HeaderHT + File *ArchFile; TagDocEntryHT Archive; }; } // end namespace gdcm diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index 97bef68a..9be0a71f 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2005/01/26 10:29:17 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -445,8 +445,6 @@ DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,uint16_t elem, return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name); } -//----------------------------------------------------------------------------- -// Protected /** * \brief Build a new Val Entry from all the low level arguments. * Check for existence of dictionary entry, and build @@ -515,6 +513,8 @@ SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group,uint16_t elem) return newEntry; } +//----------------------------------------------------------------------------- +// Protected /** * \brief Searches [both] the public [and the shadow dictionary (when they * exist)] for the presence of the DictEntry with given diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index df5c2fd4..9eaa474b 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2005/01/25 15:44:23 $ - Version: $Revision: 1.44 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.45 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -57,7 +57,6 @@ typedef std::string BaseTagKey; */ class GDCM_EXPORT DocEntrySet : public Base { -friend class FileHelper; public: DocEntrySet() {}; virtual ~DocEntrySet() {}; @@ -114,7 +113,6 @@ public: TagName const &vm = GDCM_UNKNOWN, TagName const &name = GDCM_UNKNOWN ); -protected: // DocEntry related utilities ValEntry *NewValEntry(uint16_t group,uint16_t elem, TagName const &vr = GDCM_UNKNOWN); @@ -122,10 +120,13 @@ protected: TagName const &vr = GDCM_UNKNOWN); SeqEntry *NewSeqEntry(uint16_t group,uint16_t elem); +protected: // DictEntry related utilities DictEntry *GetDictEntry(uint16_t group, uint16_t elem); DictEntry *GetDictEntry(uint16_t group, uint16_t elem, TagName const &vr); + +private: }; } // end namespace gdcm diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 5a66053d..7686c6b1 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/01/26 09:49:54 $ - Version: $Revision: 1.211 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.212 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -2331,11 +2331,11 @@ void Document::ComputeRLEInfo() // Store the collected info RLEFrame *newFrameInfo = new RLEFrame; - newFrameInfo->NumberFragments = nbRleSegments; + newFrameInfo->SetNumberOfFragments(nbRleSegments); for( unsigned int uk = 1; uk <= nbRleSegments; uk++ ) { - newFrameInfo->Offset[uk] = frameOffset + rleSegmentOffsetTable[uk]; - newFrameInfo->Length[uk] = rleSegmentLength[uk]; + newFrameInfo->SetOffset(uk,frameOffset + rleSegmentOffsetTable[uk]); + newFrameInfo->SetLength(uk,rleSegmentLength[uk]); } RLEInfo->Frames.push_back( newFrameInfo ); } @@ -2374,8 +2374,8 @@ void Document::ComputeJPEGFragmentInfo() // Store the collected info JPEGFragment *newFragment = new JPEGFragment; - newFragment->Offset = fragmentOffset; - newFragment->Length = fragmentLength; + newFragment->SetOffset(fragmentOffset); + newFragment->SetLength(fragmentLength); JPEGInfo->Fragments.push_back( newFragment ); SkipBytes( fragmentLength ); diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index 626a85e2..aa2995ba 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2005/01/26 10:29:17 $ - Version: $Revision: 1.39 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.40 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -68,11 +68,9 @@ protected: private: // Variables /// Hash Table (map), to provide fast access - TagDocEntryHT TagHT; + TagDocEntryHT TagHT; /// Hash Table (map) iterator, used to visit the TagHT variable TagDocEntryHT::iterator ItTagHT; - - friend class DocEntryArchive; //For accessing private TagHT }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmJPEGFragment.cxx b/src/gdcmJPEGFragment.cxx index f1fba57a..8ba7dad4 100644 --- a/src/gdcmJPEGFragment.cxx +++ b/src/gdcmJPEGFragment.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragment.cxx,v $ Language: C++ - Date: $Date: 2005/01/25 15:37:51 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -60,7 +60,7 @@ JPEGFragment::JPEGFragment() // StateSuspension = 0; // void *SampBuffer; - pimage = 0; + pImage = 0; } diff --git a/src/gdcmJPEGFragment.h b/src/gdcmJPEGFragment.h index 987da56d..b2862aa6 100644 --- a/src/gdcmJPEGFragment.h +++ b/src/gdcmJPEGFragment.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragment.h,v $ Language: C++ - Date: $Date: 2005/01/24 14:52:50 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -53,17 +53,17 @@ public: bool gdcm_read_JPEG_file12 (std::ifstream* fp, void* image_buffer, int & statesuspension ); bool gdcm_read_JPEG_file16 (std::ifstream* fp, void* image_buffer, int & statesuspension ); -//private: - uint32_t Offset; - uint32_t Length; + void SetLength(uint32_t length) { Length = length; }; + uint32_t GetLength() { return Length;}; + void SetOffset(uint32_t offset) { Offset = offset; }; + uint32_t GetOffset() { return Offset;}; + uint8_t *GetImage() { return pImage;}; - uint8_t *pimage; +private: + uint32_t Offset; + uint32_t Length; - -friend class Document; -friend class FileHelper; -friend class PixelReadConvert; -friend class JPEGFragmentsInfo; + uint8_t *pImage; }; } // end namespace gdcm diff --git a/src/gdcmJPEGFragmentsInfo.cxx b/src/gdcmJPEGFragmentsInfo.cxx index f503f388..77532a69 100644 --- a/src/gdcmJPEGFragmentsInfo.cxx +++ b/src/gdcmJPEGFragmentsInfo.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $ Language: C++ - Date: $Date: 2005/01/24 14:52:50 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -79,7 +79,7 @@ size_t JPEGFragmentsInfo::GetFragmentsLength() it != Fragments.end(); ++it ) { - totalLength += (*it)->Length; + totalLength += (*it)->GetLength(); } return totalLength; } @@ -97,8 +97,8 @@ void JPEGFragmentsInfo::ReadAllFragments(std::ifstream *fp, JOCTET *buffer ) it != Fragments.end(); ++it ) { - fp->seekg( (*it)->Offset, std::ios::beg); - size_t len = (*it)->Length; + fp->seekg( (*it)->GetOffset(), std::ios::beg); + size_t len = (*it)->GetLength(); fp->read((char *)p,len); p += len; } @@ -119,7 +119,7 @@ void JPEGFragmentsInfo::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t //(*it)->pimage = localRaw; (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension); // update pointer to image after some scanlines read: - localRaw = (*it)->pimage; + localRaw = (*it)->GetImage(); // Advance to next free location in Raw // for next fragment decompression (if any) diff --git a/src/gdcmJPEGFragmentsInfo.h b/src/gdcmJPEGFragmentsInfo.h index 72b7b6e3..4f2f4301 100644 --- a/src/gdcmJPEGFragmentsInfo.h +++ b/src/gdcmJPEGFragmentsInfo.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragmentsInfo.h,v $ Language: C++ - Date: $Date: 2005/01/24 14:52:50 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -49,6 +49,7 @@ public: void ReadAllFragments(std::ifstream *fp, JOCTET *buffer ); void DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int numBytes, int length); + private: typedef std::list< JPEGFragment* > JPEGFragmentsList; @@ -56,11 +57,10 @@ private: int StateSuspension; void *SampBuffer; char* pimage; - JPEGFragmentsList Fragments; + JPEGFragmentsList Fragments; -friend class Document; -friend class FileHelper; -friend class PixelReadConvert; + friend class Document; + friend class PixelReadConvert; }; } // end namespace gdcm diff --git a/src/gdcmJpeg.cxx b/src/gdcmJpeg.cxx index a5b1d6cc..d18fa4d9 100644 --- a/src/gdcmJpeg.cxx +++ b/src/gdcmJpeg.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg.cxx,v $ Language: C++ - Date: $Date: 2005/01/24 14:52:50 $ - Version: $Revision: 1.36 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.37 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -384,7 +384,7 @@ bool JPEGFragment::gdcm_read_JPEG_file (std::ifstream* fp, void* image_buffer , { //static int fragimage = 0; //std::cerr << "Image Fragment:" << fragimage++ << std::endl; - pimage = (uint8_t*)image_buffer; + pImage = (uint8_t*)image_buffer; /* This struct contains the JPEG decompression parameters and pointers to * working space (which is allocated as needed by the JPEG library). */ @@ -592,13 +592,13 @@ bool JPEGFragment::gdcm_read_JPEG_file (std::ifstream* fp, void* image_buffer , // The ijg has no notion of big endian, therefore always swap the jpeg stream #if defined(GDCM_WORDS_BIGENDIAN) && (CMAKE_BITS_IN_JSAMPLE != 8) uint16_t *buffer16 = (uint16_t*)*buffer; - uint16_t *pimage16 = (uint16_t*)pimage; + uint16_t *pimage16 = (uint16_t*)pImage; for(unsigned int i=0;i> 8) | (buffer16[i] << 8 ); #else - memcpy( pimage, *buffer,rowsize); + memcpy( pImage, *buffer,rowsize); #endif //GDCM_WORDS_BIGENDIAN - pimage+=rowsize; + pImage+=rowsize; } /* Step 7: Finish decompression */ diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 83db9d6b..b94a76a8 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/01/24 16:03:58 $ - Version: $Revision: 1.34 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.35 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -257,11 +257,11 @@ bool PixelReadConvert::ReadAndDecompressRLEFile( std::ifstream *fp ) ++it ) { // Loop on the fragments - for( unsigned int k = 1; k <= (*it)->NumberFragments; k++ ) + for( unsigned int k = 1; k <= (*it)->GetNumberOfFragments(); k++ ) { - fp->seekg( (*it)->Offset[k] , std::ios::beg ); + fp->seekg( (*it)->GetOffset(k) , std::ios::beg ); (void)ReadAndDecompressRLEFragment( subRaw, - (*it)->Length[k], + (*it)->GetLength(k), RawSegmentSize, fp ); subRaw += RawSegmentSize; @@ -471,7 +471,7 @@ ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream *fp ) (it != JPEGInfo->Fragments.end()) && (howManyRead < totalLength); ++it ) { - fragmentLength += (*it)->Length; + fragmentLength += (*it)->GetLength(); if (howManyRead > fragmentLength) continue; @@ -498,7 +498,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp ) if ( IsJPEG2000 ) { gdcmVerboseMacro( "Sorry, JPEG2000 not yet taken into account" ); - fp->seekg( (*JPEGInfo->Fragments.begin())->Offset, std::ios::beg); + fp->seekg( (*JPEGInfo->Fragments.begin())->GetOffset(), std::ios::beg); // if ( ! gdcm_read_JPEG2000_file( fp,Raw ) ) gdcmVerboseMacro( "Wrong Blue LUT descriptor" ); return false; @@ -507,7 +507,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp ) if ( IsJPEGLS ) { gdcmVerboseMacro( "Sorry, JPEG-LS not yet taken into account" ); - fp->seekg( (*JPEGInfo->Fragments.begin())->Offset, std::ios::beg); + fp->seekg( (*JPEGInfo->Fragments.begin())->GetOffset(), std::ios::beg); // if ( ! gdcm_read_JPEGLS_file( fp,Raw ) ) return false; } diff --git a/src/gdcmRLEFrame.cxx b/src/gdcmRLEFrame.cxx index 8ebb8f61..7ed3a0a9 100644 --- a/src/gdcmRLEFrame.cxx +++ b/src/gdcmRLEFrame.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFrame.cxx,v $ Language: C++ - Date: $Date: 2005/01/16 04:50:42 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -17,6 +17,7 @@ =========================================================================*/ #include "gdcmRLEFrame.h" +#include "gdcmDebug.h" namespace gdcm { @@ -40,5 +41,29 @@ void RLEFrame::Print( std::ostream &os, std::string indent ) } } +void RLEFrame::SetOffset(unsigned int id,long offset) +{ + gdcmAssertMacro(id<15); + Offset[id] = offset; +} + +long RLEFrame::GetOffset(unsigned int id) +{ + gdcmAssertMacro(id<15); + return Offset[id]; +} + +void RLEFrame::SetLength(unsigned int id,long length) +{ + gdcmAssertMacro(id<15); + Length[id] = length; +} + +long RLEFrame::GetLength(unsigned int id) +{ + gdcmAssertMacro(id<15); + return Length[id]; +} + } // end namespace gdcm diff --git a/src/gdcmRLEFrame.h b/src/gdcmRLEFrame.h index bffdbea8..adac8f92 100644 --- a/src/gdcmRLEFrame.h +++ b/src/gdcmRLEFrame.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFrame.h,v $ Language: C++ - Date: $Date: 2005/01/16 04:50:42 $ - Version: $Revision: 1.11 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.12 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -44,15 +44,21 @@ namespace gdcm */ class GDCM_EXPORT RLEFrame { -friend class Document; -friend class PixelReadConvert; - unsigned int NumberFragments; - long Offset[15]; - long Length[15]; public: RLEFrame() { NumberFragments = 0; } void Print( std::ostream &os = std::cout, std::string indent = "" ); - + + void SetNumberOfFragments(unsigned int number) { NumberFragments = number; }; + unsigned int GetNumberOfFragments() { return NumberFragments; }; + void SetOffset(unsigned int id,long offset); + long GetOffset(unsigned int id); + void SetLength(unsigned int id,long length); + long GetLength(unsigned int id); + +private: + unsigned int NumberFragments; + long Offset[15]; + long Length[15]; }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmRLEFramesInfo.h b/src/gdcmRLEFramesInfo.h index a83be408..a448b69a 100644 --- a/src/gdcmRLEFramesInfo.h +++ b/src/gdcmRLEFramesInfo.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFramesInfo.h,v $ Language: C++ - Date: $Date: 2005/01/20 16:17:00 $ - Version: $Revision: 1.10 $ + Date: $Date: 2005/01/26 11:42:02 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -43,14 +43,17 @@ namespace gdcm */ class GDCM_EXPORT RLEFramesInfo { - typedef std::list< RLEFrame* > RLEFrameList; -friend class Document; -friend class FileHelper; -friend class PixelReadConvert; - RLEFrameList Frames; public: ~RLEFramesInfo(); void Print( std::ostream &os = std::cout, std::string indent = "" ); + +private: + typedef std::list< RLEFrame* > RLEFrameList; + + RLEFrameList Frames; + + friend class Document; + friend class PixelReadConvert; }; } // end namespace gdcm diff --git a/src/jdatasrc.cxx b/src/jdatasrc.cxx index 199431c3..1573e740 100644 --- a/src/jdatasrc.cxx +++ b/src/jdatasrc.cxx @@ -91,17 +91,17 @@ fill_input_buffer (j_decompress_ptr cinfo) my_src_ptr src = (my_src_ptr) cinfo->src; //std::cerr << "Before comp:" << src->bytes_read << " / " << src->frag->Length << std::endl; - if( src->bytes_read == src->frag->Length ) + if( src->bytes_read == src->frag->GetLength() ) { //std::cerr << "Sweet finished this fragment" << std::endl; return FALSE; } size_t input_buf_size = INPUT_BUF_SIZE; - if( (src->bytes_read + INPUT_BUF_SIZE) > src->frag->Length ) + if( (src->bytes_read + INPUT_BUF_SIZE) > src->frag->GetLength() ) { //std::cerr << "Woula error:" << src->bytes_read << " / " << src->frag->Length << std::endl; - input_buf_size = src->frag->Length - src->bytes_read; + input_buf_size = src->frag->GetLength() - src->bytes_read; //std::cerr << "Ok only reading: " << input_buf_size << " / " << INPUT_BUF_SIZE << std::endl; } -- 2.45.1