From 1d69b92978803204089d270599133917d944c651 Mon Sep 17 00:00:00 2001 From: malaterre Date: Tue, 12 Oct 2004 04:35:40 +0000 Subject: [PATCH] ENH: Adding 'gdcm' namespace. Be nice with me this was a ~13000 lines patch. Also commit consequent modifications --- Example/BuildUpDicomDir.cxx | 20 +- Example/FindTags.cxx | 6 +- Example/FlatHashTablePrint.cxx | 6 +- Example/PrintDicomDir.cxx | 14 +- Example/PrintDocument.cxx | 4 +- Example/PrintFile.cxx | 8 +- Example/PrintHeader.cxx | 4 +- Example/TestChangeHeader.cxx | 8 +- Example/TestCopyDicom.cxx | 14 +- Example/TestDcm2Acr.cxx | 6 +- Example/TestReadWriteReadCompare.cxx | 6 +- Example/TestWrite.cxx | 8 +- Example/TestWriteSimple.cxx | 4 +- Example/Write.cxx | 8 +- Example/WriteDicom.cxx | 4 +- Example/WriteRead.cxx | 12 +- Example/makeDicomDir.cxx | 6 +- Testing/TestAllEntryVerify.cxx | 247 ++++++----- Testing/TestAllReadCompareDicom.cxx | 4 +- Testing/TestBug.cxx | 6 +- Testing/TestCopyDicom.cxx | 16 +- Testing/TestDicomDir.cxx | 14 +- Testing/TestReadWriteReadCompare.cxx | 6 +- gdcmPython/Makefile.am | 84 ---- gdcmPython/gdcm.i | 44 +- src/gdcmBinEntry.cxx | 27 +- src/gdcmBinEntry.h | 19 +- src/gdcmCommon.h | 26 +- src/gdcmDebug.cxx | 23 +- src/gdcmDebug.h | 19 +- src/gdcmDicomDir.cxx | 251 +++++------ src/gdcmDicomDir.h | 80 ++-- src/gdcmDicomDirElement.cxx | 36 +- src/gdcmDicomDirElement.h | 51 ++- src/gdcmDicomDirImage.cxx | 42 +- src/gdcmDicomDirImage.h | 16 +- src/gdcmDicomDirMeta.cxx | 25 +- src/gdcmDicomDirMeta.h | 14 +- src/gdcmDicomDirObject.cxx | 38 +- src/gdcmDicomDirObject.h | 34 +- src/gdcmDicomDirPatient.cxx | 42 +- src/gdcmDicomDirPatient.h | 23 +- src/gdcmDicomDirSerie.cxx | 44 +- src/gdcmDicomDirSerie.h | 28 +- src/gdcmDicomDirStudy.cxx | 54 ++- src/gdcmDicomDirStudy.h | 27 +- src/gdcmDict.cxx | 66 +-- src/gdcmDict.h | 35 +- src/gdcmDictEntry.cxx | 18 +- src/gdcmDictEntry.h | 41 +- src/gdcmDictSet.cxx | 72 +-- src/gdcmDictSet.h | 33 +- src/gdcmDirList.cxx | 27 +- src/gdcmDirList.h | 16 +- src/gdcmDocEntry.cxx | 60 +-- src/gdcmDocEntry.h | 58 +-- src/gdcmDocEntrySet.cxx | 116 ++--- src/gdcmDocEntrySet.h | 90 ++-- src/gdcmDocument.cxx | 634 ++++++++++++++------------- src/gdcmDocument.h | 109 ++--- src/gdcmElementSet.cxx | 52 ++- src/gdcmElementSet.h | 30 +- src/gdcmException.cxx | 38 +- src/gdcmException.h | 36 +- src/gdcmFile.cxx | 296 +++++++------ src/gdcmFile.h | 48 +- src/gdcmGlobal.cxx | 62 +-- src/gdcmGlobal.h | 31 +- src/gdcmHeader.cxx | 201 ++++----- src/gdcmHeader.h | 39 +- src/gdcmHeaderHelper.cxx | 50 ++- src/gdcmHeaderHelper.h | 25 +- src/gdcmJPEGFragment.h | 21 +- src/gdcmJPEGFragmentsInfo.cxx | 10 +- src/gdcmJPEGFragmentsInfo.h | 27 +- src/gdcmJpeg12.cxx | 13 +- src/gdcmJpeg2000.cxx | 8 +- src/gdcmJpeg8.cxx | 12 +- src/gdcmParsePixels.cxx | 97 ++-- src/gdcmPixelConvert.cxx | 78 ++-- src/gdcmPixelConvert.h | 27 +- src/gdcmRLEFrame.h | 23 +- src/gdcmRLEFramesInfo.cxx | 10 +- src/gdcmRLEFramesInfo.h | 27 +- src/gdcmSQItem.cxx | 67 +-- src/gdcmSQItem.h | 50 ++- src/gdcmSeqEntry.cxx | 38 +- src/gdcmSeqEntry.h | 30 +- src/gdcmTS.cxx | 25 +- src/gdcmTS.h | 13 +- src/gdcmUtil.cxx | 28 +- src/gdcmUtil.h | 10 +- src/gdcmVR.cxx | 43 +- src/gdcmVR.h | 27 +- src/gdcmValEntry.cxx | 43 +- src/gdcmValEntry.h | 19 +- vtk/vtkGdcmReader.cxx | 6 +- 97 files changed, 2347 insertions(+), 2166 deletions(-) delete mode 100644 gdcmPython/Makefile.am diff --git a/Example/BuildUpDicomDir.cxx b/Example/BuildUpDicomDir.cxx index 5259293b..0f84a446 100644 --- a/Example/BuildUpDicomDir.cxx +++ b/Example/BuildUpDicomDir.cxx @@ -50,31 +50,31 @@ int main(int argc, char* argv[]) dirName = argv[1]; } - gdcmDicomDir *dcmdir; - dcmdir=new gdcmDicomDir(); + gdcm::DicomDir *dcmdir; + dcmdir = new gdcm::DicomDir(); printf( "\n------- BuildUpDicomDir: Test Print Meta only -----\n"); - ((gdcmDocument *)dcmdir)->Print(); + ((gdcm::Document *)dcmdir)->Print(); - gdcmDicomDirPatient *p1=dcmdir->NewPatient(); + gdcm::DicomDirPatient *p1=dcmdir->NewPatient(); p1->SetEntryByNumber("patientONE",0x0010, 0x0010); - gdcmDicomDirPatient *p2=dcmdir->NewPatient(); + gdcm::DicomDirPatient *p2=dcmdir->NewPatient(); p2->SetEntryByNumber("patientTWO",0x0010, 0x0010); - gdcmDicomDirStudy *s21=p2->NewStudy(); + gdcm::DicomDirStudy *s21=p2->NewStudy(); s21->SetEntryByNumber("StudyDescrTwo.One",0x0008, 0x1030); - gdcmDicomDirSerie *s211=s21->NewSerie(); - gdcmDicomDirImage *s2111=s211->NewImage(); + gdcm::DicomDirSerie *s211=s21->NewSerie(); + gdcm::DicomDirImage *s2111=s211->NewImage(); (void)s2111; //not used - gdcmDicomDirStudy *s11=p1->NewStudy(); + gdcm::DicomDirStudy *s11=p1->NewStudy(); s11->SetEntryByNumber("StudyDescrOne.One",0x0008, 0x1030); // Name of the physician reading study // Header Entry to be created s11->SetEntryByNumber("Dr Mabuse",0x0008, 0x1060); - gdcmDicomDirPatient *p3 = dcmdir->NewPatient(); + gdcm::DicomDirPatient *p3 = dcmdir->NewPatient(); p3->SetEntryByNumber("patientTHREE",0x0010, 0x0010); std::cout << "\n------- BuildUpDicomDir: Test Print of Patient ONE -----\n"; diff --git a/Example/FindTags.cxx b/Example/FindTags.cxx index 8439e9f9..20a3d52a 100644 --- a/Example/FindTags.cxx +++ b/Example/FindTags.cxx @@ -6,14 +6,14 @@ int main(int argc, char* argv[]) { std::string toto, titi; - gdcmFile * f1; + gdcm::File * f1; if(argc > 1 ) - f1 = new gdcmFile(argv[1]); + f1 = new gdcm::File(argv[1]); else { toto = GDCM_DATA_ROOT; toto += "/test.acr"; - f1 = new gdcmFile(toto); + f1 = new gdcm::File(toto); } std::string ManufacturerName="SIEMENS "; diff --git a/Example/FlatHashTablePrint.cxx b/Example/FlatHashTablePrint.cxx index 96703649..cda66333 100644 --- a/Example/FlatHashTablePrint.cxx +++ b/Example/FlatHashTablePrint.cxx @@ -13,10 +13,10 @@ int main(int argc, char* argv[]) return 1; } - gdcmHeader* header = new gdcmHeader( argv[1] ); - TagDocEntryHT* Ht = header->BuildFlatHashTable(); + gdcm::Header* header = new gdcm::Header( argv[1] ); + gdcm::TagDocEntryHT* Ht = header->BuildFlatHashTable(); - for (TagDocEntryHT::iterator tag = Ht->begin(); tag != Ht->end(); ++tag) + for (gdcm::TagDocEntryHT::iterator tag = Ht->begin(); tag != Ht->end(); ++tag) { tag->second->Print(); std::cout << std::endl; diff --git a/Example/PrintDicomDir.cxx b/Example/PrintDicomDir.cxx index 852ba533..c3060c92 100644 --- a/Example/PrintDicomDir.cxx +++ b/Example/PrintDicomDir.cxx @@ -10,13 +10,13 @@ using namespace std; int main(int argc, char* argv[]) { - gdcmDicomDir *e1; + gdcm::DicomDir *e1; - ListDicomDirPatient::iterator itPatient; - ListDicomDirStudy::iterator itStudy; - ListDicomDirSerie::iterator itSerie; - ListDicomDirImage::iterator itImage; - TSKey v; + gdcm::ListDicomDirPatient::iterator itPatient; + gdcm::ListDicomDirStudy::iterator itStudy; + gdcm::ListDicomDirSerie::iterator itSerie; + gdcm::ListDicomDirImage::iterator itImage; + gdcm::TSKey v; std::string file; if (argc > 1) @@ -26,7 +26,7 @@ int main(int argc, char* argv[]) file += "/DICOMDIR"; } - e1 = new gdcmDicomDir( file ); + e1 = new gdcm::DicomDir( file ); if (argc > 2) { int level = atoi(argv[2]); diff --git a/Example/PrintDocument.cxx b/Example/PrintDocument.cxx index 09305c57..8e9bba04 100644 --- a/Example/PrintDocument.cxx +++ b/Example/PrintDocument.cxx @@ -4,7 +4,7 @@ int main(int argc, char* argv[]) { - gdcmHeader *e1; + gdcm::Header *e1; std::string fileName; if (argc != 2) { @@ -21,7 +21,7 @@ int main(int argc, char* argv[]) fileName += "/test.acr"; } - e1= new gdcmHeader( fileName.c_str() ); + e1= new gdcm::Header( fileName.c_str() ); e1->SetPrintLevel(2); diff --git a/Example/PrintFile.cxx b/Example/PrintFile.cxx index 0e780d21..48bc00a0 100644 --- a/Example/PrintFile.cxx +++ b/Example/PrintFile.cxx @@ -4,8 +4,8 @@ int main(int argc, char* argv[]) { - gdcmHeader *e1; - gdcmFile *f1; + gdcm::Header *e1; + gdcm::File *f1; std::string fileName; if (argc != 2) { std::cout << " usage : PrintDocument fileName" << std::endl; @@ -18,9 +18,9 @@ int main(int argc, char* argv[]) fileName += "/test.acr"; } - e1= new gdcmHeader( fileName.c_str() ); + e1= new gdcm::Header( fileName.c_str() ); - f1 = new gdcmFile(e1); + f1 = new gdcm::File(e1); e1->SetPrintLevel(2); diff --git a/Example/PrintHeader.cxx b/Example/PrintHeader.cxx index 1c3fb8cd..e29f0879 100644 --- a/Example/PrintHeader.cxx +++ b/Example/PrintHeader.cxx @@ -20,8 +20,8 @@ int main(int argc, char* argv[]) fileName += "/test.acr"; } - gdcmFile *e2 = new gdcmFile( fileName.c_str() ); - gdcmHeader *e1 = e2->GetHeader(); + gdcm::File *e2 = new gdcm::File( fileName.c_str() ); + gdcm::Header *e1 = e2->GetHeader(); if (argc > 2) { int level = atoi(argv[2]); diff --git a/Example/TestChangeHeader.cxx b/Example/TestChangeHeader.cxx index c0982e6d..1ad0e782 100644 --- a/Example/TestChangeHeader.cxx +++ b/Example/TestChangeHeader.cxx @@ -14,12 +14,12 @@ std::endl; return 1; } - gdcmHeader *h1 = new gdcmHeader( argv[1] ); - gdcmFile *f1 = new gdcmFile( h1 ); - gdcmFile *f2 = new gdcmFile( argv[2] ); + gdcm::Header *h1 = new gdcm::Header( argv[1] ); + gdcm::File *f1 = new gdcm::File( h1 ); + gdcm::File *f2 = new gdcm::File( argv[2] ); // 0018 1310 US ACQ Acquisition Matrix - gdcmDictEntry *dictEntry = + gdcm::DictEntry *dictEntry = f2->GetHeader()->GetPubDict()->GetDictEntryByName( "Acquisition Matrix" ); std::cerr << std::hex << dictEntry->GetGroup() << "," << dictEntry->GetElement() << std::endl; diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index 2edc47f8..cc42d86c 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -63,14 +63,14 @@ int main(int argc, char* argv[]) return 1; } } - gdcmFile *original = new gdcmFile( filename ); + gdcm::File *original = new gdcm::File( filename ); std::cout << "--- Original ----------------------" << std::endl; //original->GetHeader()->Print(); - gdcmFile *copy = new gdcmFile( output ); + gdcm::File *copy = new gdcm::File( output ); - TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); size_t dataSize = original->GetImageDataSize(); uint8_t* imageData = original->GetImageData(); @@ -82,13 +82,13 @@ int main(int argc, char* argv[]) // (the user does NOT have to know the way we implemented the Header !) // Waiting for a 'clean' solution, I keep the method ...JPRx - gdcmDocEntry* d; + gdcm::DocEntry* d; - for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) + for (gdcm::TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) { d = tag->second; d->Print(); std::cout << std::endl; - if ( gdcmBinEntry* b = dynamic_cast(d) ) + if ( gdcm::BinEntry* b = dynamic_cast(d) ) { copy->GetHeader()->ReplaceOrCreateByNumber( b->GetBinArea(), @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) b->GetElement(), b->GetVR() ); } - else if ( gdcmValEntry* v = dynamic_cast(d) ) + else if ( gdcm::ValEntry* v = dynamic_cast(d) ) { copy->GetHeader()->ReplaceOrCreateByNumber( v->GetValue(), diff --git a/Example/TestDcm2Acr.cxx b/Example/TestDcm2Acr.cxx index 8a2996b5..59282f0b 100644 --- a/Example/TestDcm2Acr.cxx +++ b/Example/TestDcm2Acr.cxx @@ -6,18 +6,18 @@ int main(int argc, char* argv[]) std::string toto; char zozo[100]; - gdcmFile * f1; + gdcm::File * f1; printf (" Before gdcmFile() \n"); printf ("\n\n---------------------------------------\n\n"); if (argc > 1) { toto = argv[1]; - f1 = new gdcmFile(toto); + f1 = new gdcm::File(toto); } else { std::string filename = GDCM_DATA_ROOT; filename += "/test.acr"; - f1 = new gdcmFile(filename.c_str()); + f1 = new gdcm::File(filename.c_str()); } printf (" Sortie gdcmFile() \n"); diff --git a/Example/TestReadWriteReadCompare.cxx b/Example/TestReadWriteReadCompare.cxx index 3732918a..cf484034 100644 --- a/Example/TestReadWriteReadCompare.cxx +++ b/Example/TestReadWriteReadCompare.cxx @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) //////////////// Step 1 (see above description): - gdcmHeader *header = new gdcmHeader( filename ); + gdcm::Header *header = new gdcm::Header( filename ); if( !header->IsReadable() ) { std::cerr << "Test::TestReadWriteReadCompare: Image not gdcm compatible:" @@ -52,7 +52,7 @@ int main(int argc, char* argv[]) //////////////// Step 2: - gdcmFile* file = new gdcmFile( header ); + gdcm::File* file = new gdcm::File( header ); int dataSize = file->GetImageDataSize(); uint8_t* imageData = file->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) //////////////// Step 3: - gdcmFile* reread = new gdcmFile( "TestReadWriteReadCompare.dcm" ); + gdcm::File* reread = new gdcm::File( "TestReadWriteReadCompare.dcm" ); if( !reread->GetHeader()->IsReadable() ) { std::cerr << "Test::TestReadWriteReadCompare: Could not reread image " diff --git a/Example/TestWrite.cxx b/Example/TestWrite.cxx index 1793b4d9..0d7e1db4 100644 --- a/Example/TestWrite.cxx +++ b/Example/TestWrite.cxx @@ -8,8 +8,8 @@ int main(int argc, char* argv[]) char zozo[200]; - gdcmHeader* e1; - gdcmFile * f1; + gdcm::Header* e1; + gdcm::File * f1; //gdcmDocument * d; //not used void* imageData; @@ -49,7 +49,7 @@ int main(int argc, char* argv[]) toto = argv[1]; - e1 = new gdcmHeader( toto.c_str() ); + e1 = new gdcm::Header( toto.c_str() ); if (!e1->IsReadable()) { std::cerr << "Sorry, not a Readable DICOM / ACR File" <Print(); - f1 = new gdcmFile(e1); + f1 = new gdcm::File(e1); // --- dataSize = f1->GetImageDataSize(); diff --git a/Example/TestWriteSimple.cxx b/Example/TestWriteSimple.cxx index 37965869..0c03379c 100644 --- a/Example/TestWriteSimple.cxx +++ b/Example/TestWriteSimple.cxx @@ -13,8 +13,8 @@ int main(int argc, char* argv[]) std::string header = argv[1]; const char *output = argv[2]; - gdcmHeader *f1 = new gdcmHeader( header ); - gdcmFile *f2 = new gdcmFile( f1 ); + gdcm::Header *f1 = new gdcm::Header( header ); + gdcm::File *f2 = new gdcm::File( f1 ); // If the following call is important, then the API sucks. Why is it // required to allocate PixelData when we are not using it !? diff --git a/Example/Write.cxx b/Example/Write.cxx index 43e37687..16c6c139 100644 --- a/Example/Write.cxx +++ b/Example/Write.cxx @@ -7,8 +7,8 @@ int main(int argc, char* argv[]) std::string toto; char zozo[200]; - gdcmHeader* e1; - gdcmFile * f1; + gdcm::Header* e1; + gdcm::File * f1; //gdcmDocument * d; //not used void* imageData; @@ -45,14 +45,14 @@ int main(int argc, char* argv[]) toto = argv[1]; - e1 = new gdcmHeader( toto.c_str() ); + e1 = new gdcm::Header( toto.c_str() ); if (!e1->IsReadable()) { std::cerr << "Sorry, not a Readable DICOM / ACR File" <Print(); - f1 = new gdcmFile(e1); + f1 = new gdcm::File(e1); // --- dataSize = f1->GetImageDataSize(); diff --git a/Example/WriteDicom.cxx b/Example/WriteDicom.cxx index 18d798fd..3f8658aa 100644 --- a/Example/WriteDicom.cxx +++ b/Example/WriteDicom.cxx @@ -14,10 +14,10 @@ int main(int argc, char* argv[]) } const char *first = argv[1]; - gdcmFile *f1 = new gdcmFile( first ); + gdcm::File *f1 = new gdcm::File( first ); const char *second = argv[2]; - gdcmFile *f2 = new gdcmFile( second ); + gdcm::File *f2 = new gdcm::File( second ); // We assume that DICOM fields of second file actually exists : diff --git a/Example/WriteRead.cxx b/Example/WriteRead.cxx index 803d8e10..54f9140a 100644 --- a/Example/WriteRead.cxx +++ b/Example/WriteRead.cxx @@ -7,8 +7,8 @@ int main(int argc, char* argv[]) std::string toto; char zozo[200]; - gdcmHeader* e1, *e2; - gdcmFile * f1, *f2; + gdcm::Header* e1, *e2; + gdcm::File * f1, *f2; void* imageData, *imageData2; int dataSize, dataSize2; @@ -25,14 +25,14 @@ int main(int argc, char* argv[]) std::cout << argv[1] << std::endl; - e1 = new gdcmHeader( toto ); + e1 = new gdcm::Header( toto ); if (!e1->IsReadable()) { std::cerr << "Sorry, " << toto <<" not a Readable DICOM / ACR File" <GetImageData(); dataSize = f1->GetImageDataSize(); @@ -44,13 +44,13 @@ int main(int argc, char* argv[]) // --------------------- we read the written image - e2 = new gdcmHeader( zozo ); + e2 = new gdcm::Header( zozo ); if (!e2->IsReadable()) { std::cerr << "Sorry, " << zozo << " not a Readable DICOM / ACR File" <GetImageData(); dataSize2 = f2->GetImageDataSize(); diff --git a/Example/makeDicomDir.cxx b/Example/makeDicomDir.cxx index a1feba5c..cc9804f1 100644 --- a/Example/makeDicomDir.cxx +++ b/Example/makeDicomDir.cxx @@ -52,7 +52,7 @@ void EndMethod(void *toto) { */ int main(int argc, char* argv[]) { - gdcmDicomDir *dcmdir; + gdcm::DicomDir *dcmdir; std::string dirName; if (argc > 1) @@ -60,12 +60,12 @@ int main(int argc, char* argv[]) { else dirName = GDCM_DATA_ROOT; - dcmdir=new gdcmDicomDir(dirName, true); // we ask for Directory parsing + dcmdir = new gdcm::DicomDir(dirName, true); // we ask for Directory parsing dcmdir->SetStartMethod(StartMethod, (void *) NULL); dcmdir->SetEndMethod(EndMethod); - ListDicomDirPatient lp = dcmdir->GetDicomDirPatients(); + gdcm::ListDicomDirPatient lp = dcmdir->GetDicomDirPatients(); if (! lp.size() ) { std::cout << "makeDicomDir: no patient list present. Exiting." diff --git a/Testing/TestAllEntryVerify.cxx b/Testing/TestAllEntryVerify.cxx index 9069a132..6daec820 100644 --- a/Testing/TestAllEntryVerify.cxx +++ b/Testing/TestAllEntryVerify.cxx @@ -1,4 +1,5 @@ #include "gdcmHeader.h" + #include #include #include @@ -7,77 +8,75 @@ //Generated file: #include "gdcmDataImages.h" -using namespace std; - -typedef string EntryValueType; // same type as gdcmValEntry::value -typedef map< gdcmTagKey, EntryValueType > MapEntryValues; +typedef std::string EntryValueType; // same type as ValEntry::value +typedef std::map< TagKey, EntryValueType > MapEntryValues; typedef MapEntryValues* MapEntryValuesPtr; -typedef string FileNameType; -typedef map< FileNameType, MapEntryValuesPtr > MapFileValuesType; +typedef std::string FileNameType; +typedef std::map< FileNameType, MapEntryValuesPtr > MapFileValuesType; struct ParserException { - string error; - static string Indent; + std::string error; + static std::string Indent; - static string GetIndent() { return ParserException::Indent; } - ParserException( string ErrorMessage ) + static std::string GetIndent() { return ParserException::Indent; } + ParserException( std::string ErrorMessage ) { error = ErrorMessage; Indent = " "; } - void Print() { cerr << Indent << error << endl; } + void Print() { std::cerr << Indent << error << std::endl; } }; -string ParserException::Indent = " "; +std::string ParserException::Indent = " "; class ReferenceFileParser { - bool AddKeyValuePairToMap( string& key, string& value ); + bool AddKeyValuePairToMap( std::string& key, std::string& value ); - istream& eatwhite(istream& is); - void eatwhite(string& toClean); - string ExtractFirstString(string& toSplit); - void CleanUpLine( string& line ); + std::istream& eatwhite(std::istream& is); + void eatwhite(std::string& toClean); + std::string ExtractFirstString(std::string& toSplit); + void CleanUpLine( std::string& line ); - string ExtractValue(string& toSplit) throw ( ParserException ); - void ParseRegularLine( string& line ) throw ( ParserException ); + std::string ExtractValue(std::string& toSplit) throw ( ParserException ); + void ParseRegularLine( std::string& line ) throw ( ParserException ); void FirstPassReferenceFile() throw ( ParserException ); bool SecondPassReferenceFile() throw ( ParserException ); - void HandleFileName( string& line ) throw ( ParserException ); - void HandleKey( string& line ) throw ( ParserException ); - bool HandleValue( string& line ) throw ( ParserException ); + void HandleFileName( std::string& line ) throw ( ParserException ); + void HandleKey( std::string& line ) throw ( ParserException ); + bool HandleValue( std::string& line ) throw ( ParserException ); static uint16_t axtoi( char* ); public: ReferenceFileParser(); - bool Open( string& referenceFileName ); + bool Open( std::string& referenceFileName ); void Print(); - void SetDataPath(string&); + void SetDataPath(std::string&); bool Check(); private: /// The directory containing the images to check: - string DataPath; + std::string DataPath; /// The product of the parser: MapFileValuesType ProducedMap; /// The ifstream attached to the file we parse: - ifstream from; + std::ifstream from; /// String prefixing every output - string Indent; + std::string Indent; /// The current line position within the stream: int lineNumber; /// The currently parsed filename: - string CurrentFileName; + std::string CurrentFileName; /// The currently parsed key: - string CurrentKey; + std::string CurrentKey; /// The currently parsed value: - string CurrentValue; + std::string CurrentValue; /// The current MapEntryValues pointer: MapEntryValues* CurrentMapEntryValuesPtr; @@ -114,15 +113,15 @@ uint16_t ReferenceFileParser::axtoi(char *hexStg) { m--; // adjust the position to set n++; // next digit to process } - return (intValue); + return intValue; } -void ReferenceFileParser::SetDataPath( string& inDataPath ) +void ReferenceFileParser::SetDataPath( std::string& inDataPath ) { DataPath = inDataPath; } -bool ReferenceFileParser::AddKeyValuePairToMap( string& key, string& value ) +bool ReferenceFileParser::AddKeyValuePairToMap( std::string& key, std::string& value ) { if ( !CurrentMapEntryValuesPtr ) return false; @@ -139,20 +138,20 @@ void ReferenceFileParser::Print() i != ProducedMap.end(); ++i) { - cout << Indent << "FileName: " << i->first << endl; + std::cout << Indent << "FileName: " << i->first << std::endl; MapEntryValuesPtr KeyValues = i->second; for (MapEntryValues::iterator j = KeyValues->begin(); j != KeyValues->end(); ++j) { - cout << Indent + std::cout << Indent << " Key: " << j->first << " Value: " << j->second - << endl; + << std::endl; } - cout << Indent << endl; + std::cout << Indent << std::endl; } - cout << Indent << endl; + std::cout << Indent << std::endl; } bool ReferenceFileParser::Check() @@ -161,13 +160,13 @@ bool ReferenceFileParser::Check() i != ProducedMap.end(); ++i) { - string fileName = DataPath + i->first; - cout << Indent << "FileName: " << fileName << endl; - gdcmHeader* tested = new gdcmHeader( fileName.c_str() ); + std::string fileName = DataPath + i->first; + std::cout << Indent << "FileName: " << fileName << std::endl; + gdcm::Header* tested = new gdcm::Header( fileName.c_str() ); if( !tested->IsReadable() ) { - cerr << Indent << "Image not gdcm compatible:" - << fileName << endl; + std::cerr << Indent << "Image not gdcm compatible:" + << fileName << std::endl; delete tested; return false; } @@ -177,14 +176,14 @@ bool ReferenceFileParser::Check() j != KeyValues->end(); ++j) { - string key = j->first; + std::string key = j->first; - string groupString = key.substr( 0, 4 ); + std::string groupString = key.substr( 0, 4 ); char* groupCharPtr; groupCharPtr = new char(groupString.length() + 1); strcpy( groupCharPtr, groupString.c_str() ); - string groupElement = key.substr( key.find_first_of( "|" ) + 1, 4 ); + std::string groupElement = key.substr( key.find_first_of( "|" ) + 1, 4 ); char* groupElementPtr; groupElementPtr = new char(groupElement.length() + 1); strcpy( groupElementPtr, groupElement.c_str() ); @@ -192,24 +191,24 @@ bool ReferenceFileParser::Check() uint16_t group = axtoi( groupCharPtr ); uint16_t element = axtoi( groupElementPtr ); - string testedValue = tested->GetEntryByNumber(group, element); + std::string testedValue = tested->GetEntryByNumber(group, element); if ( testedValue != j->second ) { - cout << Indent << "Uncorrect value for key " << key << endl - << Indent << " read value [" << testedValue << "]" << endl + std::cout << Indent << "Uncorrect value for key " << key << std::endl + << Indent << " read value [" << testedValue << "]" << std::endl << Indent << " reference value [" << j->second << "]" - << endl; + << std::endl; return false; } } delete tested; - cout << Indent << " OK" << endl; + std::cout << Indent << " OK" << std::endl; } - cout << Indent << endl; + std::cout << Indent << std::endl; return true; } -istream& ReferenceFileParser::eatwhite( istream& is ) +std::istream& ReferenceFileParser::eatwhite( std::istream& is ) { char c; while (is.get(c)) { @@ -221,17 +220,17 @@ istream& ReferenceFileParser::eatwhite( istream& is ) return is; } -void ReferenceFileParser::eatwhite( string& toClean ) +void ReferenceFileParser::eatwhite( std::string& toClean ) { while( toClean.find_first_of( " " ) == 0 ) toClean.erase( 0, toClean.find_first_of( " " ) + 1 ); } -string ReferenceFileParser::ExtractFirstString( string& toSplit ) +std::string ReferenceFileParser::ExtractFirstString( std::string& toSplit ) { std::string firstString; eatwhite( toSplit ); - if ( toSplit.find( " " ) == string::npos ) { + if ( toSplit.find( " " ) == std::string::npos ) { firstString = toSplit; toSplit.erase(); return firstString; @@ -242,30 +241,30 @@ string ReferenceFileParser::ExtractFirstString( string& toSplit ) return firstString; } -string ReferenceFileParser::ExtractValue( string& toSplit ) +std::string ReferenceFileParser::ExtractValue( std::string& toSplit ) throw ( ParserException ) { eatwhite( toSplit ); - string::size_type beginPos = toSplit.find_first_of( '"' ); - string::size_type endPos = toSplit.find_last_of( '"' ); + std::string::size_type beginPos = toSplit.find_first_of( '"' ); + std::string::size_type endPos = toSplit.find_last_of( '"' ); // Make sure we have at most two " in toSplit: - string noQuotes = toSplit.substr( beginPos + 1, endPos - beginPos - 1); - if ( noQuotes.find_first_of( '"' ) != string::npos ) + std::string noQuotes = toSplit.substr( beginPos + 1, endPos - beginPos - 1); + if ( noQuotes.find_first_of( '"' ) != std::string::npos ) throw ParserException( "more than two quote character" ); // No leading quote means this is not a value: - if ( beginPos == string::npos ) + if ( beginPos == std::string::npos ) { - return string(); + return std::string(); } - if ( ( endPos == string::npos ) || ( beginPos == endPos ) ) + if ( ( endPos == std::string::npos ) || ( beginPos == endPos ) ) throw ParserException( "unmatched \" (quote character)" ); if ( beginPos != 0 ) { - ostringstream error; + std::ostringstream error; error << "leading character [" << toSplit.substr(beginPos -1, 1) << "] before opening \" "; @@ -277,14 +276,14 @@ string ReferenceFileParser::ExtractValue( string& toSplit ) if ( ( endPos != toSplit.length() - 1 ) && ( toSplit.substr(endPos + 1, 1) != " " ) ) { - ostringstream error; + std::ostringstream error; error << "trailing character [" << toSplit.substr(endPos + 1, 1) << "] after value closing \" "; throw ParserException( error.str() ); } - string value = toSplit.substr( beginPos + 1, endPos - beginPos - 1 ); + std::string value = toSplit.substr( beginPos + 1, endPos - beginPos - 1 ); toSplit.erase( beginPos, endPos - beginPos + 1); eatwhite( toSplit ); return value; @@ -300,10 +299,10 @@ string ReferenceFileParser::ExtractValue( string& toSplit ) /// \warning The underlying file pointer is not preseved. void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException ) { - string line; + std::string line; lineNumber = 1; bool inBlock = false; - from.seekg( 0, ios::beg ); + from.seekg( 0, std::ios::beg ); while ( ! from.eof() ) { @@ -319,7 +318,7 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException ) } // Don't try to parse comments (weed out anything after first "#"): - if ( line.find_first_of( "#" ) != string::npos ) + if ( line.find_first_of( "#" ) != std::string::npos ) { line.erase( line.find_first_of( "#" ) ); } @@ -328,11 +327,11 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException ) // blocks which is illegal: if ( line.find_first_of( "[" ) != line.find_last_of( "[" ) ) { - ostringstream error; + std::ostringstream error; error << "Syntax error: nested block (open) in reference file" - << endl + << std::endl << ParserException::GetIndent() - << " at line " << lineNumber << endl; + << " at line " << lineNumber << std::endl; throw ParserException( error.str() ); } @@ -340,32 +339,32 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException ) // blocks which is illegal: if ( line.find_first_of( "]" ) != line.find_last_of( "]" ) ) { - ostringstream error; + std::ostringstream error; error << "Syntax error: nested block (close) in reference file" - << endl + << std::endl << ParserException::GetIndent() - << " at line " << lineNumber << endl; + << " at line " << lineNumber << std::endl; throw ParserException( error.str() ); } - bool beginBlock ( line.find_first_of("[") != string::npos ); - bool endBlock ( line.find_last_of("]") != string::npos ); + bool beginBlock ( line.find_first_of("[") != std::string::npos ); + bool endBlock ( line.find_last_of("]") != std::string::npos ); // Opening and closing of block on same line: if ( beginBlock && endBlock ) { - ostringstream error; + std::ostringstream error; error << "Syntax error: opening and closing on block on same line " - << lineNumber++ << endl; + << lineNumber++ << std::endl; throw ParserException( error.str() ); } // Illegal closing block when block not open: if ( !inBlock && endBlock ) { - ostringstream error; + std::ostringstream error; error << "Syntax error: unexpected end of block at line " - << lineNumber++ << endl; + << lineNumber++ << std::endl; throw ParserException( error.str() ); } @@ -377,9 +376,9 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException ) if ( inBlock && beginBlock ) { - ostringstream error; + std::ostringstream error; error << " Syntax error: illegal opening of nested block at line " - << lineNumber++ << endl; + << lineNumber++ << std::endl; throw ParserException( error.str() ); } @@ -404,7 +403,7 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException ) // We need rewinding: from.clear(); - from.seekg( 0, ios::beg ); + from.seekg( 0, std::ios::beg ); } ReferenceFileParser::ReferenceFileParser() @@ -413,12 +412,12 @@ ReferenceFileParser::ReferenceFileParser() Indent = " "; } -bool ReferenceFileParser::Open( string& referenceFileName ) +bool ReferenceFileParser::Open( std::string& referenceFileName ) { - from.open( referenceFileName.c_str(), ios::in ); + from.open( referenceFileName.c_str(), std::ios::in ); if ( !from.is_open() ) { - cerr << Indent << "Can't open reference file." << endl; + std::cerr << Indent << "Can't open reference file." << std::endl; } try @@ -436,21 +435,21 @@ bool ReferenceFileParser::Open( string& referenceFileName ) return true; //?? } -void ReferenceFileParser::CleanUpLine( string& line ) +void ReferenceFileParser::CleanUpLine( std::string& line ) { // Cleanup from comments: - if ( line.find_first_of( "#" ) != string::npos ) + if ( line.find_first_of( "#" ) != std::string::npos ) line.erase( line.find_first_of( "#" ) ); // Cleanup everything after end block delimiter: - if ( line.find_last_of( "]" ) != string::npos ) + if ( line.find_last_of( "]" ) != std::string::npos ) line.erase( line.find_last_of( "]" ) + 1 ); // Cleanup leading whites and skip empty lines: eatwhite( line ); } -void ReferenceFileParser::HandleFileName( string& line ) +void ReferenceFileParser::HandleFileName( std::string& line ) throw ( ParserException ) { if ( line.length() == 0 ) @@ -462,22 +461,22 @@ void ReferenceFileParser::HandleFileName( string& line ) CurrentFileName = ExtractFirstString(line); } -void ReferenceFileParser::HandleKey( string& line ) +void ReferenceFileParser::HandleKey( std::string& line ) throw ( ParserException ) { if ( CurrentKey.length() != 0 ) return; CurrentKey = ExtractFirstString(line); - if ( CurrentKey.find_first_of( "|" ) == string::npos ) + if ( CurrentKey.find_first_of( "|" ) == std::string::npos ) { - ostringstream error; + std::ostringstream error; error << "uncorrect key:" << CurrentKey; throw ParserException( error.str() ); } } -bool ReferenceFileParser::HandleValue( string& line ) +bool ReferenceFileParser::HandleValue( std::string& line ) throw ( ParserException ) { if ( line.length() == 0 ) @@ -485,22 +484,22 @@ bool ReferenceFileParser::HandleValue( string& line ) if ( CurrentKey.length() == 0 ) { - cout << Indent << "No key present:" << CurrentKey << endl; + std::cout << Indent << "No key present:" << CurrentKey << std::endl; return false; } - string newCurrentValue = ExtractValue(line); + std::string newCurrentValue = ExtractValue(line); if ( newCurrentValue.length() == 0 ) { - cout << Indent << "Warning: empty value for key:" - << CurrentKey << endl; + std::cout << Indent << "Warning: empty value for key:" + << CurrentKey << std::endl; } CurrentValue += newCurrentValue; return true; } -void ReferenceFileParser::ParseRegularLine(string& line) +void ReferenceFileParser::ParseRegularLine( std::string& line) throw ( ParserException ) { if ( line.length() == 0 ) @@ -534,9 +533,9 @@ void ReferenceFileParser::ParseRegularLine(string& line) bool ReferenceFileParser::SecondPassReferenceFile() throw ( ParserException ) { - gdcmTagKey key; + TagKey key; EntryValueType value; - string line; + std::string line; bool inBlock = false; lineNumber = 0; @@ -551,8 +550,8 @@ bool ReferenceFileParser::SecondPassReferenceFile() if ( line.length() == 0 ) continue; - bool beginBlock ( line.find_first_of("[") != string::npos ); - bool endBlock ( line.find_last_of("]") != string::npos ); + bool beginBlock ( line.find_first_of("[") != std::string::npos ); + bool endBlock ( line.find_last_of("]") != std::string::npos ); // Waiting for a block to be opened. Meanwhile, drop everything: if ( !inBlock && !beginBlock ) @@ -588,34 +587,34 @@ int TestAllEntryVerify(int argc, char* argv[]) { if ( argc > 1 ) { - cerr << " Usage: " << argv[0] - << " (no arguments needed)." << endl; + std::cerr << " Usage: " << argv[0] + << " (no arguments needed)." << std::endl; return 1; } - string referenceDir = GDCM_DATA_ROOT; + std::string referenceDir = GDCM_DATA_ROOT; referenceDir += "/"; - string referenceFilename = referenceDir + "TestAllEntryVerifyReference.txt"; + std::string referenceFilename = referenceDir + "TestAllEntryVerifyReference.txt"; - cout << " Description (Test::TestAllEntryVerify): " - << endl; - cout << " For all images (not blacklisted in gdcm/Test/CMakeLists.txt)" - << endl; - cout << " encountered in directory: " << GDCM_DATA_ROOT << endl; - cout << " apply the following tests : "<< endl; - cout << " step 1: parse the image and call IsReadable(). " << endl; - cout << " step 2: look for the entry corresponding to the image" << endl; - cout << " in the reference file: " << referenceFilename << endl; - cout << " step 3: check that each reference tag value listed for this" - << endl; - cout << " entry matches the tag encountered at parsing step 1." - << endl << endl; + std::cout << " Description (Test::TestAllEntryVerify): " + << std::endl; + std::cout << " For all images (not blacklisted in gdcm/Test/CMakeLists.txt)" + << std::endl; + std::cout << " encountered in directory: " << GDCM_DATA_ROOT << std::endl; + std::cout << " apply the following tests : "<< std::endl; + std::cout << " step 1: parse the image and call IsReadable(). " << std::endl; + std::cout << " step 2: look for the entry corresponding to the image" << std::endl; + std::cout << " in the reference file: " << referenceFilename << std::endl; + std::cout << " step 3: check that each reference tag value listed for this" + << std::endl; + std::cout << " entry matches the tag encountered at parsing step 1." + << std::endl << std::endl; ReferenceFileParser Parser; if ( !Parser.Open(referenceFilename) ) { - cout << " Corrupted reference file name: " - << referenceFilename << endl; + std::cout << " Corrupted reference file name: " + << referenceFilename << std::endl; return 1; } Parser.SetDataPath(referenceDir); diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index 3f111658..7ed852ec 100644 --- a/Testing/TestAllReadCompareDicom.cxx +++ b/Testing/TestAllReadCompareDicom.cxx @@ -8,7 +8,7 @@ int InternalTest(std::string const & filename, std::string const & referenceFile { std::cout << " Testing: " << filename << std::endl; - gdcmFile* tested = new gdcmFile( filename ); + gdcm::File* tested = new gdcm::File( filename ); if( !tested->GetHeader()->IsReadable() ) { std::cout << " Image not gdcm compatible:" @@ -44,7 +44,7 @@ int InternalTest(std::string const & filename, std::string const & referenceFile ////// When reference file is not gdcm readable test is failed: - gdcmFile* reference = new gdcmFile( referenceFileName ); + gdcm::File* reference = new gdcm::File( referenceFileName ); if( !reference->GetHeader()->IsReadable() ) { std::cout << " Reference image " << std::endl diff --git a/Testing/TestBug.cxx b/Testing/TestBug.cxx index 6f87e0ad..157360c1 100644 --- a/Testing/TestBug.cxx +++ b/Testing/TestBug.cxx @@ -6,14 +6,14 @@ int TestBug(int argc, char* argv[]) { - gdcmHeader* e1; + gdcm::Header* e1; if (argc > 1) - e1 = new gdcmHeader( argv[1] ); + e1 = new gdcm::Header( argv[1] ); else { std::string filename = GDCM_DATA_ROOT; filename += "/test.acr"; - e1 = new gdcmHeader( filename.c_str() ); + e1 = new gdcm::Header( filename.c_str() ); } //e1->PrintPubDict(); //e1->GetPubDict()->GetEntriesByKey(); diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 62e1a727..29588aef 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -66,10 +66,10 @@ int TestCopyDicom(int , char* []) } } - gdcmFile *original = new gdcmFile( filename ); - gdcmFile *copy = new gdcmFile( output ); + gdcm::File *original = new gdcm::File( filename ); + gdcm::File *copy = new gdcm::File( output ); - TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); size_t dataSize = original->GetImageDataSize(); uint8_t* imageData = original->GetImageData(); @@ -81,12 +81,12 @@ int TestCopyDicom(int , char* []) // (the user does NOT have to know the way we implemented the Header !) // Waiting for a 'clean' solution, I keep the method ...JPRx - gdcmDocEntry* d; + gdcm::DocEntry* d; - for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) + for (gdcm::TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag) { d = tag->second; - if ( gdcmBinEntry* b = dynamic_cast(d) ) + if ( gdcm::BinEntry* b = dynamic_cast(d) ) { copy->GetHeader()->ReplaceOrCreateByNumber( b->GetBinArea(), @@ -95,7 +95,7 @@ int TestCopyDicom(int , char* []) b->GetElement(), b->GetVR() ); } - else if ( gdcmValEntry* v = dynamic_cast(d) ) + else if ( gdcm::ValEntry* v = dynamic_cast(d) ) { copy->GetHeader()->ReplaceOrCreateByNumber( v->GetValue(), @@ -121,7 +121,7 @@ int TestCopyDicom(int , char* []) delete original; delete copy; - copy = new gdcmFile( output ); + copy = new gdcm::File( output ); //Is the file written still gdcm parsable ? if ( !copy->GetHeader()->IsReadable() ) diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index de6219b0..e0ca32ab 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -7,13 +7,13 @@ int TestDicomDir(int argc, char* argv[]) { - gdcmDicomDir *e1; + gdcm::DicomDir *e1; - ListDicomDirPatient::iterator itPatient; - ListDicomDirStudy::iterator itStudy; - ListDicomDirSerie::iterator itSerie; - ListDicomDirImage::iterator itImage; - TSKey v; + gdcm::ListDicomDirPatient::iterator itPatient; + gdcm::ListDicomDirStudy::iterator itStudy; + gdcm::ListDicomDirSerie::iterator itSerie; + gdcm::ListDicomDirImage::iterator itImage; + gdcm::TSKey v; std::string file; if (argc > 1) @@ -23,7 +23,7 @@ int TestDicomDir(int argc, char* argv[]) file += "/DICOMDIR"; } - e1 = new gdcmDicomDir(file); + e1 = new gdcm::DicomDir(file); if (argc > 2) { int level = atoi(argv[2]); e1->SetPrintLevel(level); diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index d3eb11b5..61fe20ee 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -39,7 +39,7 @@ int TestReadWriteReadCompare(int argc, char* argv[]) //////////////// Step 1 (see above description): - gdcmHeader *header = new gdcmHeader( filename ); + gdcm::Header *header = new gdcm::Header( filename ); if( !header->IsReadable() ) { std::cerr << "Test::TestReadWriteReadCompare: Image not gdcm compatible:" @@ -51,7 +51,7 @@ int TestReadWriteReadCompare(int argc, char* argv[]) //////////////// Step 2: - gdcmFile* file = new gdcmFile( header ); + gdcm::File* file = new gdcm::File( header ); int dataSize = file->GetImageDataSize(); uint8_t* imageData = file->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to @@ -81,7 +81,7 @@ int TestReadWriteReadCompare(int argc, char* argv[]) //////////////// Step 3: - gdcmFile* reread = new gdcmFile( "TestReadWriteReadCompare.dcm" ); + gdcm::File* reread = new gdcm::File( "TestReadWriteReadCompare.dcm" ); if( !reread->GetHeader()->IsReadable() ) { std::cerr << "Test::TestReadWriteReadCompare: Could not reread image " diff --git a/gdcmPython/Makefile.am b/gdcmPython/Makefile.am deleted file mode 100644 index b2a47f35..00000000 --- a/gdcmPython/Makefile.am +++ /dev/null @@ -1,84 +0,0 @@ -## Process this file with automake to produce Makefile.in - -### VTK related -VTK_INC = -I/usr/include/vtk -LIBS_VTK=-L/usr/lib/vtk \ - -lvtkCommon -lvtkIO -lvtkFiltering -lvtkRendering -lvtkGraphics \ - -lvtkImaging -lvtkpng -lvtkzlib -lvtkjpeg -lvtkexpat -lvtktiff \ - -lvtkftgl -lvtkfreetype -LIBS_VTK_PYTHON= $(LIBS_VTK) \ - -lvtkCommonPython -lvtkIOPython -lvtkFilteringPython \ - -lvtkRenderingPython -lvtkGraphicsPython -lvtkImagingPython -### Gdcm itself: -GDCM_INC = -I$(top_srcdir)/src -I$(top_builddir) -### Vtk wrappers of gdcm relate: -VTKGDCM_DIR = $(top_srcdir)/vtk/ -VTKGDCM_INC = -I$(VTKGDCM_DIR) -### Swig related (for wrapping Gdcm): -SWIG_INC = $(PYTHON_INCLUDES) $(GDCM_INC) - -### The resulting include path: -INCLUDES = $(GDCM_INC) $(PYTHON_INCLUDES) $(VTK_INC) $(VTKGDCM_INC) - -### Since maude_LDFLAGS cannot be defined conditionaly: -pygdcm_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/.libs -vtkgdcmPython_la_LDFLAGS = -module -avoid-version - -############################################################ -if BUILD_PYTHON -pythondir = $(prefix)/lib/python${PYTHON_VERSION}/site-packages/gdcm -if BUILD_VTK -GDCMVTKLIB = vtkgdcmPython.la -endif -python_LTLIBRARIES = pygdcm.la $(GDCMVTKLIB) - -############ Gdcm python wrappers: -pygdcm_la_SOURCES = gdcm_wrap.cxx -pygdcm_la_LIBADD = $(top_builddir)/src/libgdcm.la -lstdc++ -gdcm_wrap.cxx: $(srcdir)/gdcm.i - $(SWIG) -python -c++ $(SWIG_INC) -o $@ $< - -############ Vtk wrappers of Gdcm wrapped for python -if BUILD_VTK -PYTHON_LIB_BASENAME=vtkgdcmPython - -# Python wrappers -PYTHON_WRAPPER = vtkWrapPython -PYTHON_WRAPPER_INIT=./vtkWrapPythonInit -PWFLAGS=hints - -vtkgdcmPython_la_SOURCES = \ - vtkGdcmReaderPython.cxx \ - vtkGdcmInit.cxx -vtkgdcmPython_la_LIBADD = $(top_builddir)/vtk/libvtkgdcm.la \ - $(LIBS_VTK_PYTHON) - -vtkGdcmReaderPython.cxx: $(VTKGDCM_DIR)/vtkGdcmReader.h - $(PYTHON_WRAPPER) $< $(PWFLAGS) $@ - -vtkGdcmInit.cxx : $(VTKGDCM_DIR)/vtkGdcmReader.h $(PYTHON_WRAPPER_INIT) - $(PYTHON_WRAPPER_INIT) $(PYTHON_LIB_BASENAME) \ - vtkGdcmReader.h \ - > $@ - -$(PYTHON_WRAPPER_INIT) : vtkWrapPythonInit.c - gcc -o $@ $< -endif### BUILD_PYTHON ####################################### - -############ Automake general usage classics: -MOSTLYCLEANFILES = $(pygdcm_la_SOURCES) $(vtkgdcmPython_la_SOURCES) -BUILT_SOURCES = $(pygdcm_la_SOURCES) $(vtkgdcmPython_la_SOURCES) -CLEANFILES = gdcm_wrap.cxx gdcm.py gdcm.pyc $(PYTHON_WRAPPER_INIT) - -dist-hook: - rm -f $(distdir)/gdcm_wrap.cxx - -install-data-local: - @INSTALL@ -m 0644 gdcm.py $(DESTDIR)$(pythondir) - @INSTALL@ -m 0644 __init__.py $(DESTDIR)$(pythondir) - cp -a $(DESTDIR)$(pythondir)/pygdcm.so $(DESTDIR)$(pythondir)/_gdcm.so -else -all: -endif - -EXTRA_DIST = gdcm.i __init__.py testSuite.py diff --git a/gdcmPython/gdcm.i b/gdcmPython/gdcm.i index bed16974..cdd38532 100644 --- a/gdcmPython/gdcm.i +++ b/gdcmPython/gdcm.i @@ -116,14 +116,14 @@ typedef unsigned int guint32; //////////////////////////////////////////////////////////////////////////// // Convert a c++ hash table in a python native dictionary -%typemap(out) TagDocEntryHT & { +%typemap(out) gdcm::TagDocEntryHT & { PyObject* NewDict = PyDict_New(); // The result of this typemap std::string RawName; // Element name as gotten from gdcm PyObject* NewKey = (PyObject*)0; // Associated name as python object std::string RawValue; // Element value as gotten from gdcm PyObject* NewVal = (PyObject*)0; // Associated value as python object - for (TagDocEntryHT::iterator tag = $1->begin(); tag != $1->end(); ++tag) + for (gdcm::TagDocEntryHT::iterator tag = $1->begin(); tag != $1->end(); ++tag) { // The element name shall be the key: RawName = tag->second->GetName(); @@ -135,8 +135,8 @@ typedef unsigned int guint32; NewKey = PyString_FromString(RawName.c_str()); // Element values are striped from leading/trailing spaces - if (gdcmValEntry* ValEntryPtr = - dynamic_cast< gdcmValEntry* >(tag->second) ) + if (gdcm::ValEntry* ValEntryPtr = + dynamic_cast< gdcm::ValEntry* >(tag->second) ) { RawValue = ValEntryPtr->GetValue(); } @@ -154,9 +154,9 @@ typedef unsigned int guint32; PyObject* NewItem = (PyObject*)0; $result = PyList_New(0); // The result of this typemap - for (std::list::iterator New = ($1)->begin(); + for (std::list::iterator New = ($1)->begin(); New != ($1)->end(); ++New) { - NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmDicomDirPatient,1); + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_DicomDirPatient,1); PyList_Append($result, NewItem); } } @@ -165,9 +165,9 @@ typedef unsigned int guint32; PyObject* NewItem = (PyObject*)0; $result = PyList_New(0); // The result of this typemap - for (std::list::iterator New = ($1)->begin(); + for (std::list::iterator New = ($1)->begin(); New != ($1)->end(); ++New) { - NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmDicomDirStudy,1); + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_DicomDirStudy,1); PyList_Append($result, NewItem); } } @@ -176,9 +176,9 @@ typedef unsigned int guint32; PyObject* NewItem = (PyObject*)0; $result = PyList_New(0); // The result of this typemap - for (std::list::iterator New = ($1)->begin(); + for (std::list::iterator New = ($1)->begin(); New != ($1)->end(); ++New) { - NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmDicomDirSerie,1); + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_DicomDirSerie,1); PyList_Append($result, NewItem); } } @@ -187,16 +187,16 @@ typedef unsigned int guint32; PyObject* NewItem = (PyObject*)0; $result = PyList_New(0); // The result of this typemap - for (std::list::iterator New = ($1)->begin(); + for (std::list::iterator New = ($1)->begin(); New != ($1)->end(); ++New) { - NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_gdcmDicomDirImage,1); + NewItem = SWIG_NewPointerObj(*New,SWIGTYPE_p_DicomDirImage,1); PyList_Append($result, NewItem); } } //////////////////////////////////////////////////////////////////////////// // Deals with function returning a C++ string. -%typemap(python, in) (gdcmMethod *,void * =NULL,gdcmMethod * =NULL) { +%typemap(python, in) (gdcm::Method *,void * =NULL,gdcm::Method * =NULL) { if($input!=Py_None) { Py_INCREF($input); @@ -229,21 +229,25 @@ typedef unsigned int guint32; %include "gdcmCommon.h" %include "gdcmDictEntry.h" %include "gdcmDict.h" -%include "gdcmDictSet.h" +%include "gdcmDocEntry.h" %include "gdcmDocEntrySet.h" %include "gdcmElementSet.h" -%include "gdcmDocument.h" +%include "gdcmDictSet.h" +%include "gdcmTS.h" +%include "gdcmVR.h" %include "gdcmSQItem.h" +%include "gdcmDicomDirObject.h" +%include "gdcmDicomDirStudy.h" +%include "gdcmDicomDirPatient.h" +%include "gdcmDicomDirSerie.h" +%include "gdcmDicomDirElement.h" +%include "gdcmDicomDirMeta.h" +%include "gdcmDocument.h" %include "gdcmHeader.h" %include "gdcmHeaderHelper.h" %include "gdcmFile.h" %include "gdcmUtil.h" %include "gdcmGlobal.h" -%include "gdcmDicomDirObject.h" %include "gdcmDicomDir.h" %include "gdcmDicomDirElement.h" -%include "gdcmDicomDirMeta.h" -%include "gdcmDicomDirPatient.h" -%include "gdcmDicomDirStudy.h" -%include "gdcmDicomDirSerie.h" %include "gdcmDicomDirImage.h" diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx index f336472c..ce75c594 100644 --- a/src/gdcmBinEntry.cxx +++ b/src/gdcmBinEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:05 $ - Version: $Revision: 1.32 $ + Date: $Date: 2004/10/12 04:35:44 $ + Version: $Revision: 1.33 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,23 +19,25 @@ #include "gdcmBinEntry.h" #include "gdcmDebug.h" +namespace gdcm +{ //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \brief Constructor from a given gdcmBinEntry + * \brief Constructor from a given BinEntry */ -gdcmBinEntry::gdcmBinEntry(gdcmDictEntry* e) : gdcmValEntry(e) +BinEntry::BinEntry(DictEntry* e) : ValEntry(e) { BinArea = 0; } /** - * \brief Constructor from a given gdcmBinEntry + * \brief Constructor from a given BinEntry * @param e Pointer to existing Doc entry */ -gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry()) +BinEntry::BinEntry(DocEntry* e) : ValEntry(e->GetDictEntry()) { UsableLength = e->GetLength(); ReadLength = e->GetReadLength(); @@ -51,7 +53,7 @@ gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry()) /** * \brief Canonical destructor. */ -gdcmBinEntry::~gdcmBinEntry() +BinEntry::~BinEntry() { if (BinArea) { @@ -67,9 +69,9 @@ gdcmBinEntry::~gdcmBinEntry() * \brief canonical Printer */ -void gdcmBinEntry::Print(std::ostream &os) +void BinEntry::Print(std::ostream &os) { - gdcmDocEntry::Print(os); + DocEntry::Print(os); std::ostringstream s; void* binArea = GetBinArea(); if (binArea) @@ -99,9 +101,9 @@ void gdcmBinEntry::Print(std::ostream &os) * @param fp already open file pointer * @param filetype type of the file to be written */ -void gdcmBinEntry::Write(FILE* fp, FileType filetype) +void BinEntry::Write(FILE* fp, FileType filetype) { - gdcmDocEntry::Write(fp, filetype); + DocEntry::Write(fp, filetype); void* binArea = GetBinArea(); int lgr = GetLength(); if (binArea) @@ -120,7 +122,7 @@ void gdcmBinEntry::Write(FILE* fp, FileType filetype) /// \brief Sets the value (non string) of the current Dicom Header Entry -void gdcmBinEntry::SetBinArea( uint8_t* area ) +void BinEntry::SetBinArea( uint8_t* area ) { if (BinArea) delete[] BinArea; @@ -134,3 +136,4 @@ void gdcmBinEntry::SetBinArea( uint8_t* area ) // Private //----------------------------------------------------------------------------- +} // end namespace gdcm diff --git a/src/gdcmBinEntry.h b/src/gdcmBinEntry.h index 70e79087..6ba0cba2 100644 --- a/src/gdcmBinEntry.h +++ b/src/gdcmBinEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.h,v $ Language: C++ - Date: $Date: 2004/10/07 21:05:39 $ - Version: $Revision: 1.21 $ + Date: $Date: 2004/10/12 04:35:44 $ + Version: $Revision: 1.22 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,21 +23,24 @@ #include +namespace gdcm +{ + //----------------------------------------------------------------------------- /** - * \ingroup gdcmBinEntry + * \ingroup BinEntry * \brief The dicom header of a Dicom file contains a set of such entries * (when successfuly parsed against a given Dicom dictionary) * This one contains a 'string value'. */ -class GDCM_EXPORT gdcmBinEntry : public gdcmValEntry +class GDCM_EXPORT BinEntry : public ValEntry { public: - gdcmBinEntry(gdcmDictEntry* e); - gdcmBinEntry(gdcmDocEntry* d); + BinEntry(DictEntry* e); + BinEntry(DocEntry* d); - ~gdcmBinEntry(); + ~BinEntry(); void Print(std::ostream &os = std::cout); void Write(FILE*, FileType); @@ -58,7 +61,7 @@ private: uint8_t* BinArea; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index 4de3dee0..36ceb573 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmCommon.h,v $ Language: C++ - Date: $Date: 2004/10/08 08:41:04 $ - Version: $Revision: 1.35 $ + Date: $Date: 2004/10/12 04:35:44 $ + 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 @@ -98,8 +98,8 @@ const std::string GDCM_BINLOADED = "gdcm::Binary data loaded"; const std::string GDCM_NOTLOADED = "gdcm::NotLoaded"; const std::string GDCM_UNREAD = "gdcm::UnRead"; -/// \brief gdcmTagKey is made to hold an "universal" (as in URL, Universal -/// Ressource Locator) key to a gdcmDocEntry i.e. a dicom tag. +/// \brief TagKey is made to hold an "universal" (as in URL, Universal +/// Ressource Locator) key to a DocEntry i.e. a dicom tag. /// A dicom tag always has a group and an element, but a set of tags /// embeded in various (optionally nested) sequences and sharing /// the same group and element all share the same (group, element) @@ -115,25 +115,25 @@ const std::string GDCM_UNREAD = "gdcm::UnRead"; /// the form: /// /ItemNumber#Group|Element /// where "/", "#" and "|" are characters acting as separators. -/// Then the general form of a gdcmTagKey is given by: +/// Then the general form of a TagKey is given by: /// Group|Element[SeqTag] /// where [SeqTag] means NO or many instances of SeqTag. -/// Hence the gdcmTagKey of a tag not "leaving" in a sequence is the +/// Hence the TagKey of a tag not "leaving" in a sequence is the /// string e.g. /// 0028|1201 -/// but the gdcmTagKey of a tag "embeded" is the first item of +/// but the TagKey of a tag "embeded" is the first item of /// a sequence, itself nested in the third item of a sequence is the /// string e.g. /// 0004|1220/2#0008|0082/0#0008|0090 -typedef std::string gdcmTagKey; +typedef std::string TagKey; typedef std::string TagName; enum FileType { - gdcmUnknown = 0, - gdcmExplicitVR, // gdcmDicomDir is in this case - gdcmImplicitVR, - gdcmACR, - gdcmACR_LIBIDO + Unknown = 0, + ExplicitVR, // DicomDir is in this case + ImplicitVR, + ACR, + ACR_LIBIDO }; //----------------------------------------------------------------------------- diff --git a/src/gdcmDebug.cxx b/src/gdcmDebug.cxx index ebcc95c2..a2e8f3d3 100644 --- a/src/gdcmDebug.cxx +++ b/src/gdcmDebug.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDebug.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:05 $ - Version: $Revision: 1.7 $ + Date: $Date: 2004/10/12 04:35:44 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,12 +19,15 @@ #include #include "gdcmDebug.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- /** * \brief constructor * @param level debug level */ -gdcmDebug::gdcmDebug(int level) +Debug::Debug(int level) { DebugLevel = level; } @@ -33,7 +36,7 @@ gdcmDebug::gdcmDebug(int level) * \brief Accessor * @param level Set the debug level */ -void gdcmDebug::SetDebug(int level) +void Debug::SetDebug(int level) { DebugLevel = level; } @@ -44,7 +47,7 @@ void gdcmDebug::SetDebug(int level) * @param msg1 first message part * @param msg2 second message part */ -void gdcmDebug::Verbose(int level, const char * msg1, const char * msg2) +void Debug::Verbose(int level, const char * msg1, const char * msg2) { if (level > DebugLevel) { @@ -59,7 +62,7 @@ void gdcmDebug::Verbose(int level, const char * msg1, const char * msg2) * @param msg1 first message part * @param msg2 second message part */ -void gdcmDebug::Error(bool test, const char * msg1, const char * msg2) +void Debug::Error(bool test, const char * msg1, const char * msg2) { if (!test) { @@ -75,7 +78,7 @@ void gdcmDebug::Error(bool test, const char * msg1, const char * msg2) * @param msg2 second message part * @param msg3 Third message part */ -void gdcmDebug::Error(const char* msg1, const char* msg2, +void Debug::Error(const char* msg1, const char* msg2, const char* msg3) { std::cerr << msg1 << ' ' << msg2 << ' ' << msg3 << std::endl; @@ -89,7 +92,7 @@ void gdcmDebug::Error(const char* msg1, const char* msg2, * @param msg1 first message part * @param msg2 second message part */ -void gdcmDebug::Assert(int level, bool test, const char * msg1, +void Debug::Assert(int level, bool test, const char * msg1, const char * msg2) { if (level > DebugLevel) @@ -106,7 +109,7 @@ void gdcmDebug::Assert(int level, bool test, const char * msg1, * \brief Exit * @param a return code */ -void gdcmDebug::Exit(int a) +void Debug::Exit(int a) { #ifdef __GNUC__ std::exit(a); @@ -115,3 +118,5 @@ void gdcmDebug::Exit(int a) exit(a); // Found in #include #endif } + +} // end namespace gdcm diff --git a/src/gdcmDebug.h b/src/gdcmDebug.h index 67d49f9e..83939678 100644 --- a/src/gdcmDebug.h +++ b/src/gdcmDebug.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDebug.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:05 $ - Version: $Revision: 1.7 $ + Date: $Date: 2004/10/12 04:35:44 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,12 +20,14 @@ #define GDCMDEBUG_H #include "gdcmCommon.h" +namespace gdcm +{ //----------------------------------------------------------------------------- /** - * \ingroup gdcmDebug - * \brief gdcmDebug is an object for debugging in program. + * \ingroup Debug + * \brief Debug is an object for debugging in program. * It has 2 debugging modes : * - error : for bad library use * - debug : for debugging messages @@ -34,10 +36,10 @@ * Shown only when the debug level is higher than the * message level. */ -class GDCM_EXPORT gdcmDebug +class GDCM_EXPORT Debug { public: - gdcmDebug(int level = -1); + Debug(int level = -1); void SetDebug (int level); void Verbose(int level, const char* msg1, const char* msg2 = "") ; @@ -47,7 +49,7 @@ public: void Assert(int level, bool test, const char * msg1, const char * msg2); void Exit(int a); - static gdcmDebug &GetReference(); + static Debug &GetReference(); private: /// warning message level to be displayed @@ -55,7 +57,8 @@ private: }; +} // end namespace gdcm /// Instance of debugging utility. -static gdcmDebug dbg; +static gdcm::Debug dbg; #endif diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index a9fdca41..35726eac 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:54 $ - Version: $Revision: 1.72 $ + Date: $Date: 2004/10/12 04:35:44 $ + 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 @@ -38,6 +38,8 @@ #else #include #endif +namespace gdcm +{ //----------------------------------------------------------------------------- // For full DICOMDIR description, see: @@ -46,11 +48,11 @@ // Constructor / Destructor /** - * \ingroup gdcmDicomDir - * \brief Constructor : creates an empty gdcmDicomDir + * \ingroup DicomDir + * \brief Constructor : creates an empty DicomDir */ -gdcmDicomDir::gdcmDicomDir() - :gdcmDocument( ) +DicomDir::DicomDir() + :Document( ) { Initialize(); // sets all private fields to NULL std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ... @@ -69,19 +71,19 @@ gdcmDicomDir::gdcmDicomDir() * - false if user passed an already built DICOMDIR file * and wants to use it */ -gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir ): - gdcmDocument( fileName ) +DicomDir::DicomDir(std::string const & fileName, bool parseDir ): + Document( fileName ) { // Whatever user passed (a root directory or a DICOMDIR) // and whatever the value of parseDir was, - // gdcmDocument is already executed + // Document is already executed Initialize(); // sets all private fields to NULL // if user passed a root directory, sure we didn't get anything if ( TagHT.begin() == TagHT.end() ) // when user passed a Directory to parse { - dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty"); + dbg.Verbose(0, "DicomDir::DicomDir : entry HT empty"); if ( fileName.size() == 1 && fileName[0] == '.' ) { @@ -96,7 +98,7 @@ gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir ): { MetaElems = NewMeta(); - dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory" + dbg.Verbose(0, "DicomDir::DicomDir : Parse directory" " and create the DicomDir"); ParseDirectory(); } @@ -110,10 +112,10 @@ gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir ): else // Only if user passed a DICOMDIR { // Directory record sequence - gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); + DocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); if ( !e ) { - dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record" + dbg.Verbose(0, "DicomDir::DicomDir : NO Directory record" " sequence (0x0004,0x1220)"); /// \todo FIXME : what do we do when the parsed file IS NOT a /// DICOMDIR file ? @@ -125,7 +127,7 @@ gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir ): /** * \brief Canonical destructor */ -gdcmDicomDir::~gdcmDicomDir() +DicomDir::~DicomDir() { SetStartMethod(NULL); SetProgressMethod(NULL); @@ -147,7 +149,7 @@ gdcmDicomDir::~gdcmDicomDir() /** * \brief Canonical Printer */ -void gdcmDicomDir::Print(std::ostream &os) +void DicomDir::Print(std::ostream &os) { if( MetaElems ) { @@ -170,12 +172,12 @@ void gdcmDicomDir::Print(std::ostream &os) * decides whether or not the current header was properly parsed * and contains the mandatory information for being considered as * a well formed and usable DicomDir. - * @return true when gdcmDocument is the one of a reasonable DicomDir, + * @return true when Document is the one of a reasonable DicomDir, * false otherwise. */ -bool gdcmDicomDir::IsReadable() +bool DicomDir::IsReadable() { - if( !gdcmDocument::IsReadable() ) + if( !Document::IsReadable() ) { return false; } @@ -195,7 +197,7 @@ bool gdcmDicomDir::IsReadable() * \brief Sets all fields to NULL */ -void gdcmDicomDir::Initialize() +void DicomDir::Initialize() { StartMethod = NULL; ProgressMethod = NULL; @@ -215,25 +217,25 @@ void gdcmDicomDir::Initialize() /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief fills the whole structure, starting from a root Directory */ -void gdcmDicomDir::ParseDirectory() +void DicomDir::ParseDirectory() { CreateDicomDirChainedList( GetFileName() ); CreateDicomDir(); } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief Set the start method to call when the parsing of the directory starts * @param method Method to call * @param arg Argument to pass to the method * @param argDelete Argument * \warning In python : the arg parameter isn't considered */ -void gdcmDicomDir::SetStartMethod(gdcmMethod* method, void* arg, - gdcmMethod* argDelete ) +void DicomDir::SetStartMethod(Method* method, void* arg, + Method* argDelete ) { if( StartArg && StartMethodArgDelete ) { @@ -246,27 +248,27 @@ void gdcmDicomDir::SetStartMethod(gdcmMethod* method, void* arg, } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief Set the method to delete the argument * The argument is destroyed when the method is changed or when the * class is destroyed * @param method Method to call to delete the argument */ -void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod* method) +void DicomDir::SetStartMethodArgDelete(Method* method) { StartMethodArgDelete = method; } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief Set the progress method to call when the parsing of the directory progress * @param method Method to call * @param arg Argument to pass to the method * @param argDelete Argument * \warning In python : the arg parameter isn't considered */ -void gdcmDicomDir::SetProgressMethod(gdcmMethod* method, void* arg, - gdcmMethod* argDelete ) +void DicomDir::SetProgressMethod(Method* method, void* arg, + Method* argDelete ) { if( ProgressArg && ProgressMethodArgDelete ) { @@ -279,27 +281,27 @@ void gdcmDicomDir::SetProgressMethod(gdcmMethod* method, void* arg, } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief Set the method to delete the argument * The argument is destroyed when the method is changed or when the * class is destroyed * @param method Method to call to delete the argument */ -void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod* method) +void DicomDir::SetProgressMethodArgDelete(Method* method) { ProgressMethodArgDelete = method; } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief Set the end method to call when the parsing of the directory ends * @param method Method to call * @param arg Argument to pass to the method * @param argDelete Argument * \warning In python : the arg parameter isn't considered */ -void gdcmDicomDir::SetEndMethod(gdcmMethod* method, void* arg, - gdcmMethod* argDelete ) +void DicomDir::SetEndMethod(Method* method, void* arg, + Method* argDelete ) { if( EndArg && EndMethodArgDelete ) { @@ -312,19 +314,19 @@ void gdcmDicomDir::SetEndMethod(gdcmMethod* method, void* arg, } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief Set the method to delete the argument * The argument is destroyed when the method is changed or when the class * is destroyed * @param method Method to call to delete the argument */ -void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod* method) +void DicomDir::SetEndMethodArgDelete(Method* method) { EndMethodArgDelete = method; } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief writes on disc a DICOMDIR * \ warning does NOT add the missing elements in the header : * it's up to the user doing it ! @@ -335,7 +337,7 @@ void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod* method) * @return false only when fail to open */ -bool gdcmDicomDir::WriteDicomDir(std::string const& fileName) +bool DicomDir::WriteDicomDir(std::string const& fileName) { uint16_t sq[4] = { 0x0004, 0x1220, 0xffff, 0xffff }; uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff }; @@ -352,17 +354,17 @@ bool gdcmDicomDir::WriteDicomDir(std::string const& fileName) fwrite(filePreamble,128,1,fp); fwrite("DICM",4,1,fp); - gdcmDicomDirMeta *ptrMeta = GetDicomDirMeta(); - ptrMeta->Write(fp, gdcmExplicitVR); + DicomDirMeta *ptrMeta = GetDicomDirMeta(); + ptrMeta->Write(fp, ExplicitVR); - // force writing 0004|1220 [SQ ], that CANNOT exist within gdcmDicomDirMeta + // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta fwrite(&sq[0],8,1,fp); // 0004 1220 ffff ffff for(ListDicomDirPatient::iterator cc = Patients.begin(); cc != Patients.end(); ++cc ) { - (*cc)->Write( fp, gdcmExplicitVR ); + (*cc)->Write( fp, ExplicitVR ); } // force writing Sequence Delimitation Item @@ -376,22 +378,22 @@ bool gdcmDicomDir::WriteDicomDir(std::string const& fileName) // Protected /** - * \ingroup gdcmDicomDir - * \brief create a gdcmDocument-like chained list from a root Directory + * \ingroup DicomDir + * \brief create a Document-like chained list from a root Directory * @param path entry point of the tree-like structure */ -void gdcmDicomDir::CreateDicomDirChainedList(std::string const & path) +void DicomDir::CreateDicomDirChainedList(std::string const & path) { CallStartMethod(); - gdcmDirList fileList(path,1); // gets recursively the file list + DirList fileList(path,1); // gets recursively the file list unsigned int count = 0; VectDocument list; - gdcmHeader *header; + Header *header; TagHT.clear(); Patients.clear(); - for( gdcmDirList::iterator it = fileList.begin(); + for( DirList::iterator it = fileList.begin(); it != fileList.end(); ++it ) { @@ -402,11 +404,11 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string const & path) break; } - header = new gdcmHeader( it->c_str() ); + header = new Header( it->c_str() ); if( !header ) { dbg.Verbose( 1, - "gdcmDicomDir::CreateDicomDirChainedList: " + "DicomDir::CreateDicomDirChainedList: " "failure in new Header ", it->c_str() ); } @@ -416,7 +418,7 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string const & path) // Add the file header to the chained list: list.push_back(header); dbg.Verbose( 1, - "gdcmDicomDir::CreateDicomDirChainedList: readable ", + "DicomDir::CreateDicomDirChainedList: readable ", it->c_str() ); } @@ -427,7 +429,7 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string const & path) count++; } // sorts Patient/Study/Serie/ - std::sort(list.begin(), list.end(), gdcmDicomDir::HeaderLessThan ); + std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan ); std::string tmp = fileList.GetDirName(); //for each Header of the chained list, add/update the Patient/Study/Serie/Image info @@ -436,13 +438,13 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string const & path) } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief adds *the* Meta to a partially created DICOMDIR */ -gdcmDicomDirMeta * gdcmDicomDir::NewMeta() +DicomDirMeta * DicomDir::NewMeta() { - gdcmDicomDirMeta *m = new gdcmDicomDirMeta( &TagHT ); + DicomDirMeta *m = new DicomDirMeta( &TagHT ); if ( TagHT.begin() != TagHT.end() ) // after Document Parsing { @@ -459,8 +461,8 @@ gdcmDicomDirMeta * gdcmDicomDir::NewMeta() } else // after root directory parsing { - std::list elemList; - elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements(); + std::list elemList; + elemList=Global::GetDicomDirElements()->GetDicomDirMetaElements(); m->FillObject(elemList); } m->SetSQItemNumber(0); // To avoid further missprinting @@ -470,16 +472,16 @@ gdcmDicomDirMeta * gdcmDicomDir::NewMeta() /** * \brief adds a new Patient (with the basic elements) to a partially created DICOMDIR */ -gdcmDicomDirPatient * gdcmDicomDir::NewPatient() +DicomDirPatient * DicomDir::NewPatient() { - std::list::iterator it; + std::list::iterator it; uint16_t tmpGr,tmpEl; - gdcmDictEntry *dictEntry; - gdcmValEntry *entry; + DictEntry *dictEntry; + ValEntry *entry; - std::list elemList; - elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); - gdcmSQItem *s = new gdcmSQItem(0); + std::list elemList; + elemList=Global::GetDicomDirElements()->GetDicomDirPatientElements(); + SQItem *s = new SQItem(0); // for all the DicomDirPatient Elements for( it = elemList.begin(); it != elemList.end(); ++it ) @@ -487,7 +489,7 @@ gdcmDicomDirPatient * gdcmDicomDir::NewPatient() tmpGr = it->Group; tmpEl = it->Elem; dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl); - entry = new gdcmValEntry( dictEntry ); + entry = new ValEntry( dictEntry ); entry->SetOffset(0); // just to avoid further missprinting entry->SetValue( it->Value ); @@ -516,7 +518,7 @@ gdcmDicomDirPatient * gdcmDicomDir::NewPatient() s->AddDocEntry( entry ); } - gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &TagHT); + DicomDirPatient *p = new DicomDirPatient(s, &TagHT); Patients.push_front( p ); return p; @@ -524,42 +526,42 @@ gdcmDicomDirPatient * gdcmDicomDir::NewPatient() /** * \brief adds to the HTable - * the gdcmEntries (Dicom Elements) corresponding to the given type + * the Entries (Dicom Elements) corresponding to the given type * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE - * @param type gdcmDicomDirObject type to create (GDCM_DICOMDIR_PATIENT, + * @param type DicomDirObject type to create (GDCM_DICOMDIR_PATIENT, * GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...) - * @param header gdcmHeader of the current file + * @param header Header of the current file */ -void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, - gdcmDocument *header) +void DicomDir::SetElement(std::string &path,DicomDirType type, + Document *header) { - std::list elemList; - std::list::iterator it; + std::list elemList; + std::list::iterator it; uint16_t tmpGr, tmpEl; - gdcmDictEntry *dictEntry; - gdcmValEntry *entry; + DictEntry *dictEntry; + ValEntry *entry; std::string val; - gdcmSQItem *si = new gdcmSQItem(0); // all the items will be at level 1 + SQItem *si = new SQItem(0); // all the items will be at level 1 switch( type ) { case GDCM_DICOMDIR_IMAGE: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements(); + elemList = Global::GetDicomDirElements()->GetDicomDirImageElements(); break; case GDCM_DICOMDIR_SERIE: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements(); + elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements(); break; case GDCM_DICOMDIR_STUDY: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements(); + elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements(); break; case GDCM_DICOMDIR_PATIENT: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); + elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements(); break; case GDCM_DICOMDIR_META: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements(); + elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements(); break; default: @@ -581,7 +583,7 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, tmpEl = it->Elem; dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl); - entry = new gdcmValEntry( dictEntry ); // Be sure it's never a BinEntry ! + entry = new ValEntry( dictEntry ); // Be sure it's never a BinEntry ! entry->SetOffset(0); // just to avoid further missprinting entry->SetLength(0); // just to avoid further missprinting @@ -602,13 +604,13 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, if( tmpGr == 0x0004 && tmpEl == 0x1130 ) // File-set ID { // force to the *end* File Name - val = gdcmUtil::GetName( path ); + val = Util::GetName( path ); } else if( tmpGr == 0x0004 && tmpEl == 0x1500 ) // Only used for image { if( header->GetFileName().substr(0, path.length()) != path ) { - dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path" + dbg.Verbose(0, "DicomDir::SetElement : the base path" " of file name is incorrect"); val = header->GetFileName(); } @@ -692,7 +694,7 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, /** * \brief CallStartMethod */ -void gdcmDicomDir::CallStartMethod() +void DicomDir::CallStartMethod() { Progress = 0.0f; Abort = false; @@ -703,10 +705,10 @@ void gdcmDicomDir::CallStartMethod() } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief CallProgressMethod */ -void gdcmDicomDir::CallProgressMethod() +void DicomDir::CallProgressMethod() { if( ProgressMethod ) { @@ -715,10 +717,10 @@ void gdcmDicomDir::CallProgressMethod() } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief CallEndMethod */ -void gdcmDicomDir::CallEndMethod() +void DicomDir::CallEndMethod() { Progress = 1.0f; if( EndMethod ) @@ -730,10 +732,10 @@ void gdcmDicomDir::CallEndMethod() //----------------------------------------------------------------------------- // Private /** - * \ingroup gdcmDicomDir - * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader + * \ingroup DicomDir + * \brief create a 'DicomDir' from a DICOMDIR Header */ -void gdcmDicomDir::CreateDicomDir() +void DicomDir::CreateDicomDir() { // The list is parsed. // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found : @@ -744,63 +746,63 @@ void gdcmDicomDir::CreateDicomDir() // + loop to 1 - // Directory record sequence - gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); + DocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); if ( !e ) { - dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record" + dbg.Verbose(0, "DicomDir::DicomDir : NO Directory record" " sequence (0x0004,0x1220)"); /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ? return; } - gdcmSeqEntry* s = dynamic_cast(e); + SeqEntry* s = dynamic_cast(e); if ( !s ) { - dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: no SeqEntry present"); + dbg.Verbose(0, "DicomDir::CreateDicomDir: no SeqEntry present"); // useless : (0x0004,0x1220) IS a Sequence ! return; } - gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META; + DicomDirType type = DicomDir::GDCM_DICOMDIR_META; MetaElems = NewMeta(); ListSQItem listItems = s->GetSQItems(); - gdcmDocEntry * d; + DocEntry * d; std::string v; for( ListSQItem::iterator i = listItems.begin(); i !=listItems.end(); ++i ) { d = (*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type - if ( gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(d) ) + if ( ValEntry* valEntry = dynamic_cast< ValEntry* >(d) ) { - v = ValEntry->GetValue(); + v = valEntry->GetValue(); } else { - dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: not a ValEntry."); + dbg.Verbose(0, "DicomDir::CreateDicomDir: not a ValEntry."); continue; } if( v == "PATIENT " ) { AddDicomDirPatientToEnd( *i ); - type = gdcmDicomDir::GDCM_DICOMDIR_PATIENT; + type = DicomDir::GDCM_DICOMDIR_PATIENT; } else if( v == "STUDY " ) { AddDicomDirStudyToEnd( *i ); - type = gdcmDicomDir::GDCM_DICOMDIR_STUDY; + type = DicomDir::GDCM_DICOMDIR_STUDY; } else if( v == "SERIES" ) { AddDicomDirSerieToEnd( *i ); - type = gdcmDicomDir::GDCM_DICOMDIR_SERIE; + type = DicomDir::GDCM_DICOMDIR_SERIE; } else if( v == "IMAGE " ) { AddDicomDirImageToEnd( *i ); - type = gdcmDicomDir::GDCM_DICOMDIR_IMAGE; + type = DicomDir::GDCM_DICOMDIR_IMAGE; } else { @@ -812,49 +814,49 @@ void gdcmDicomDir::CreateDicomDir() } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief Well ... there is only one occurence */ -void gdcmDicomDir::AddDicomDirMeta() +void DicomDir::AddDicomDirMeta() { if( MetaElems ) { delete MetaElems; } - MetaElems = new gdcmDicomDirMeta( &TagHT ); + MetaElems = new DicomDirMeta( &TagHT ); } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief AddDicomDirPatientToEnd * @param s SQ Item to enqueue to the DicomPatient chained List */ -void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s) +void DicomDir::AddDicomDirPatientToEnd(SQItem *s) { - Patients.push_back(new gdcmDicomDirPatient(s, &TagHT)); + Patients.push_back(new DicomDirPatient(s, &TagHT)); } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief AddDicomDirStudyToEnd * @param s SQ Item to enqueue to the DicomDirStudy chained List */ - void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s) + void DicomDir::AddDicomDirStudyToEnd(SQItem *s) { if( Patients.size() > 0 ) { ListDicomDirPatient::iterator itp = Patients.end(); itp--; - (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &TagHT)); + (*itp)->AddDicomDirStudy(new DicomDirStudy(s, &TagHT)); } } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief AddDicomDirSerieToEnd * @param s SQ Item to enqueue to the DicomDirSerie chained List */ -void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s) +void DicomDir::AddDicomDirSerieToEnd(SQItem *s) { if( Patients.size() > 0 ) { @@ -865,17 +867,17 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s) { ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end(); itst--; - (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &TagHT)); + (*itst)->AddDicomDirSerie(new DicomDirSerie(s, &TagHT)); } } } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief AddDicomDirImageToEnd * @param s SQ Item to enqueue to the DicomDirImage chained List */ - void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s) + void DicomDir::AddDicomDirImageToEnd(SQItem *s) { if( Patients.size() > 0 ) { @@ -891,19 +893,19 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s) { ListDicomDirSerie::iterator its = (*itst)->GetDicomDirSeries().end(); its--; - (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &TagHT)); + (*its)->AddDicomDirImage(new DicomDirImage(s, &TagHT)); } } } } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief for each Header of the chained list, add/update the Patient/Study/Serie/Image info * @param path path of the root directory * @param list chained list of Headers */ -void gdcmDicomDir::SetElements(std::string &path, VectDocument &list) +void DicomDir::SetElements(std::string &path, VectDocument &list) { std::string patPrevName = "", patPrevID = ""; std::string studPrevInstanceUID = "", studPrevID = ""; @@ -954,12 +956,13 @@ void gdcmDicomDir::SetElements(std::string &path, VectDocument &list) } /** - * \ingroup gdcmDicomDir + * \ingroup DicomDir * \brief compares two dgcmHeaders */ -bool gdcmDicomDir::HeaderLessThan(gdcmDocument *header1, gdcmDocument *header2) +bool DicomDir::HeaderLessThan(Document *header1, Document *header2) { return *header1 < *header2; } +} // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 40772ca8..c7605f62 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.h,v $ Language: C++ - Date: $Date: 2004/10/09 03:21:55 $ - Version: $Revision: 1.33 $ + Date: $Date: 2004/10/12 04:35:44 $ + Version: $Revision: 1.34 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -27,26 +27,28 @@ #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- -typedef std::list ListDicomDirPatient; -typedef std::vector VectDocument; +typedef std::list ListDicomDirPatient; +typedef std::vector VectDocument; -typedef GDCM_EXPORT void(gdcmMethod)(void* = NULL); +typedef GDCM_EXPORT void(Method)(void* = NULL); //----------------------------------------------------------------------------- /** - * \ingroup gdcmDicomDir - * \brief gdcmDicomDir defines an object representing a DICOMDIR in memory. + * \ingroup DicomDir + * \brief DicomDir defines an object representing a DICOMDIR in memory. * */ -class GDCM_EXPORT gdcmDicomDir: public gdcmDocument +class GDCM_EXPORT DicomDir: public Document { public: - gdcmDicomDir( std::string const & fileName, bool parseDir = false ); - gdcmDicomDir(); + DicomDir( std::string const & fileName, bool parseDir = false ); + DicomDir(); - ~gdcmDicomDir(); + ~DicomDir(); /// \brief canonical Printer /// \sa SetPrintLevel @@ -55,8 +57,8 @@ public: /// Informations contained in the parser virtual bool IsReadable(); - /// Returns a pointer to the gdcmDicomDirMeta for this DICOMDIR. - gdcmDicomDirMeta* GetDicomDirMeta() { return MetaElems; }; + /// Returns a pointer to the DicomDirMeta for this DICOMDIR. + DicomDirMeta* GetDicomDirMeta() { return MetaElems; }; /// Returns the PATIENT chained List for this DICOMDIR. ListDicomDirPatient &GetDicomDirPatients() { return Patients; }; @@ -64,12 +66,12 @@ public: /// Parsing void ParseDirectory(); - void SetStartMethod(gdcmMethod*, void* = NULL, gdcmMethod* = NULL); - void SetStartMethodArgDelete(gdcmMethod*); - void SetProgressMethod(gdcmMethod* ,void* = NULL, gdcmMethod* = NULL); - void SetProgressMethodArgDelete(gdcmMethod*); - void SetEndMethod(gdcmMethod*, void* = NULL,gdcmMethod* = NULL); - void SetEndMethodArgDelete(gdcmMethod*); + void SetStartMethod(Method*, void* = NULL, Method* = NULL); + void SetStartMethodArgDelete(Method*); + void SetProgressMethod(Method* ,void* = NULL, Method* = NULL); + void SetProgressMethodArgDelete(Method*); + void SetEndMethod(Method*, void* = NULL,Method* = NULL); + void SetEndMethodArgDelete(Method*); /// GetProgress GetProgress float GetProgress() { return Progress; }; @@ -81,13 +83,13 @@ public: bool IsAborted() { return Abort; }; /// Adding - gdcmDicomDirMeta* NewMeta(); - gdcmDicomDirPatient* NewPatient(); + DicomDirMeta* NewMeta(); + DicomDirPatient* NewPatient(); /// Write bool WriteDicomDir(std::string const & fileName); - /// Types of the gdcmDicomDirObject within the gdcmDicomDir + /// Types of the DicomDirObject within the DicomDir typedef enum { GDCM_DICOMDIR_NONE, @@ -96,7 +98,7 @@ public: GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE, GDCM_DICOMDIR_IMAGE - } gdcmDicomDirType; + } DicomDirType; protected: void CreateDicomDirChainedList(std::string const & path); @@ -108,37 +110,37 @@ private: void Initialize(); void CreateDicomDir(); void AddDicomDirMeta(); - void AddDicomDirPatientToEnd(gdcmSQItem* s); - void AddDicomDirStudyToEnd (gdcmSQItem* s); - void AddDicomDirSerieToEnd (gdcmSQItem* s); - void AddDicomDirImageToEnd (gdcmSQItem* s); + void AddDicomDirPatientToEnd(SQItem* s); + void AddDicomDirStudyToEnd (SQItem* s); + void AddDicomDirSerieToEnd (SQItem* s); + void AddDicomDirImageToEnd (SQItem* s); void SetElements(std::string &path, VectDocument &list); - void SetElement (std::string &path,gdcmDicomDirType type, - gdcmDocument* header); + void SetElement (std::string &path,DicomDirType type, + Document* header); - static bool HeaderLessThan(gdcmDocument* header1,gdcmDocument* header2); + static bool HeaderLessThan(Document* header1,Document* header2); // Variables - /// Pointer on *the* gdcmDicomDirObject 'DicomDirMeta Elements' - gdcmDicomDirMeta* MetaElems; + /// Pointer on *the* DicomDirObject 'DicomDirMeta Elements' + DicomDirMeta* MetaElems; /// Chained list of DicomDirPatient (to be exploited recursively) ListDicomDirPatient Patients; /// pointer to the initialisation method for any progress bar - gdcmMethod* StartMethod; + Method* StartMethod; /// pointer to the incrementation method for any progress bar - gdcmMethod* ProgressMethod; + Method* ProgressMethod; /// pointer to the termination method for any progress bar - gdcmMethod* EndMethod; + Method* EndMethod; /// pointer to the ??? method for any progress bar - gdcmMethod* StartMethodArgDelete; + Method* StartMethodArgDelete; /// pointer to the ??? method for any progress bar - gdcmMethod* ProgressMethodArgDelete; + Method* ProgressMethodArgDelete; /// pointer to the ??? method for any progress bar - gdcmMethod* EndMethodArgDelete; + Method* EndMethodArgDelete; /// pointer to the ??? for any progress bar void* StartArg; /// pointer to the ??? for any progress bar @@ -150,6 +152,6 @@ private: /// value of the ??? for any progress bar bool Abort; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index d4831c9b..aefcd12d 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirElement.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:54 $ - Version: $Revision: 1.19 $ + Date: $Date: 2004/10/12 04:35:44 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,6 +23,8 @@ #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- // Constructor / Destructor @@ -31,16 +33,16 @@ * \brief constructor : populates the chained lists * from the file 'Dicts/DicomDir.dic' */ -gdcmDicomDirElement::gdcmDicomDirElement() +DicomDirElement::DicomDirElement() { - std::string filename = gdcmDictSet::BuildDictPath() + std::string(DICT_ELEM); + std::string filename = DictSet::BuildDictPath() + std::string(DICT_ELEM); std::ifstream from(filename.c_str()); - dbg.Error(!from, "gdcmDicomDirElement::gdcmDicomDirElement: can't open dictionary", + dbg.Error(!from, "DicomDirElement::DicomDirElement: can't open dictionary", filename.c_str()); char buff[1024]; std::string type; - gdcmElement elem; + Element elem; while (!from.eof()) { @@ -87,10 +89,10 @@ gdcmDicomDirElement::gdcmDicomDirElement() } /** - * \ingroup gdcmDicomDirElement + * \ingroup DicomDirElement * \brief canonical destructor */ -gdcmDicomDirElement::~gdcmDicomDirElement() +DicomDirElement::~DicomDirElement() { DicomDirMetaList.clear(); DicomDirPatientList.clear(); @@ -102,50 +104,50 @@ gdcmDicomDirElement::~gdcmDicomDirElement() //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmDicomDirElement + * \ingroup DicomDirElement * \brief Print all * \todo add a 'Print Level' check * @param os The output stream to be written to. */ -void gdcmDicomDirElement::Print(std::ostream &os) +void DicomDirElement::Print(std::ostream &os) { std::ostringstream s; - std::list::iterator it; + std::list::iterator it; //char greltag[10]; //group element tag std::string greltag; s << "Meta Elements :"<Group,it->Elem); + greltag = Util::Format("%04x|%04x ",it->Group,it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Patient Elements :"<Group,it->Elem); + greltag = Util::Format("%04x|%04x ",it->Group,it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Study Elements :"<Group, it->Elem); + greltag = Util::Format("%04x|%04x ", it->Group, it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Serie Elements :"<Group, it->Elem); + greltag = Util::Format("%04x|%04x ", it->Group, it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Image Elements :"<Group, it->Elem); + greltag = Util::Format("%04x|%04x ", it->Group, it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } @@ -162,3 +164,5 @@ void gdcmDicomDirElement::Print(std::ostream &os) // Private //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmDicomDirElement.h b/src/gdcmDicomDirElement.h index 6ab62e9d..551ca61e 100644 --- a/src/gdcmDicomDirElement.h +++ b/src/gdcmDicomDirElement.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirElement.h,v $ Language: C++ - Date: $Date: 2004/10/09 03:21:55 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/10/12 04:35:44 $ + 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 @@ -23,6 +23,9 @@ #include +namespace gdcm +{ + //----------------------------------------------------------------------------- typedef struct { @@ -32,25 +35,25 @@ typedef struct unsigned short int Elem; /// value (coded as a std::string) of the Element std::string Value; -} gdcmElement; +} Element; -typedef std::list ListDicomDirMetaElem; -typedef std::list ListDicomDirPatientElem; -typedef std::list ListDicomDirStudyElem; -typedef std::list ListDicomDirSerieElem; -typedef std::list ListDicomDirImageElem; +typedef std::list ListDicomDirMetaElem; +typedef std::list ListDicomDirPatientElem; +typedef std::list ListDicomDirStudyElem; +typedef std::list ListDicomDirSerieElem; +typedef std::list ListDicomDirImageElem; //----------------------------------------------------------------------------- /** - * \ingroup gdcmDicomDirElement - * \brief gdcmDicomDirElement represents elements contained in a dicom dir + * \ingroup DicomDirElement + * \brief DicomDirElement represents elements contained in a dicom dir * Class for the chained lists from the file 'Dicts/DicomDir.dic' */ -class GDCM_EXPORT gdcmDicomDirElement +class GDCM_EXPORT DicomDirElement { public: - gdcmDicomDirElement(); - ~gdcmDicomDirElement(); + DicomDirElement(); + ~DicomDirElement(); /** * \brief canonical Printer @@ -59,7 +62,7 @@ public: void Print(std::ostream &os); /** - * \ingroup gdcmDicomDirElement + * \ingroup DicomDirElement * \brief returns a reference to the chained List * related to the META Elements of a DICOMDIR. */ @@ -67,7 +70,7 @@ public: { return DicomDirMetaList; }; /** - * \ingroup gdcmDicomDirElement + * \ingroup DicomDirElement * \brief returns a reference to the chained List * related to the PATIENT Elements of a DICOMDIR. */ @@ -75,7 +78,7 @@ public: { return DicomDirPatientList; }; /** - * \ingroup gdcmDicomDirElement + * \ingroup DicomDirElement * \brief returns a reference to the chained List * related to the STUDY Elements of a DICOMDIR. */ @@ -83,7 +86,7 @@ public: { return DicomDirStudyList; }; /** - * \ingroup gdcmDicomDirElement + * \ingroup DicomDirElement * \brief returns a reference to the chained List * related to the SERIE Elements of a DICOMDIR. */ @@ -91,7 +94,7 @@ public: { return DicomDirSerieList; }; /** - * \ingroup gdcmDicomDirElement + * \ingroup DicomDirElement * \brief returns a reference to the chained List * related to the IMAGE Elements of a DICOMDIR. */ @@ -99,18 +102,18 @@ public: { return DicomDirImageList; }; private: - /// gdcmElements chained list, related to the MetaElements of DICOMDIR + /// Elements chained list, related to the MetaElements of DICOMDIR ListDicomDirMetaElem DicomDirMetaList; - /// gdcmElements chained list, related to the PatientElements of DICOMDIR + /// Elements chained list, related to the PatientElements of DICOMDIR ListDicomDirPatientElem DicomDirPatientList; - /// gdcmElements chained list, related to the StudyElements of DICOMDIR + /// Elements chained list, related to the StudyElements of DICOMDIR ListDicomDirStudyElem DicomDirStudyList; - /// gdcmElements chained list, related to the SerieElements of DICOMDIR + /// Elements chained list, related to the SerieElements of DICOMDIR ListDicomDirSerieElem DicomDirSerieList; - /// gdcmElements chained list, related to the ImageElements of DICOMDIR + /// Elements chained list, related to the ImageElements of DICOMDIR ListDicomDirImageElem DicomDirImageList; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDicomDirImage.cxx b/src/gdcmDicomDirImage.cxx index aaae71b8..7cbb2c0a 100644 --- a/src/gdcmDicomDirImage.cxx +++ b/src/gdcmDicomDirImage.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirImage.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/10/12 04:35:44 $ + 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 @@ -18,60 +18,64 @@ #include "gdcmDicomDirImage.h" #include "gdcmValEntry.h" + +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmDicomDirImage + * \ingroup DicomDirImage * \brief Constructor * @param s SQ Item holding the elements - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmDocEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the DocEntries) */ -gdcmDicomDirImage::gdcmDicomDirImage(gdcmSQItem *s, TagDocEntryHT *ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirImage::DicomDirImage(SQItem *s, TagDocEntryHT *ptagHT): + DicomDirObject(ptagHT) { docEntries = s->GetDocEntries(); } /** - * \ingroup gdcmDicomDirImage + * \ingroup DicomDirImage * \brief Constructor - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmDocEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the DocEntries) */ -gdcmDicomDirImage::gdcmDicomDirImage(TagDocEntryHT *ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirImage::DicomDirImage(TagDocEntryHT *ptagHT): + DicomDirObject(ptagHT) { } /** - * \ingroup gdcmDicomDirImage + * \ingroup DicomDirImage * \brief Canonical destructor. */ -gdcmDicomDirImage::~gdcmDicomDirImage() +DicomDirImage::~DicomDirImage() { } //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmDicomDirImage + * \ingroup DicomDirImage * \brief Prints the Object * @return */ -void gdcmDicomDirImage::Print(std::ostream &os) +void DicomDirImage::Print(std::ostream &os) { os << "IMAGE : "; for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) { if( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 ) { - os << ((gdcmValEntry *)(*i))->GetValue(); //FIXME + os << ((ValEntry *)(*i))->GetValue(); //FIXME } } os << std::endl; - gdcmDicomDirObject::Print(os); + DicomDirObject::Print(os); } //----------------------------------------------------------------------------- @@ -84,3 +88,5 @@ void gdcmDicomDirImage::Print(std::ostream &os) // Private //----------------------------------------------------------------------------- +} // end namespace gdcm + diff --git a/src/gdcmDicomDirImage.h b/src/gdcmDicomDirImage.h index b2a496ec..59a9cbc6 100644 --- a/src/gdcmDicomDirImage.h +++ b/src/gdcmDicomDirImage.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirImage.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.9 $ + Date: $Date: 2004/10/12 04:35:44 $ + 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 @@ -20,18 +20,20 @@ #define GDCMDICOMIMAGE_H #include "gdcmDicomDirObject.h" +namespace gdcm +{ //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmDicomDirImage : public gdcmDicomDirObject +class GDCM_EXPORT DicomDirImage : public DicomDirObject { public: - gdcmDicomDirImage(gdcmSQItem *s, TagDocEntryHT *ptagHT); - gdcmDicomDirImage(TagDocEntryHT *ptagHT); + DicomDirImage(SQItem *s, TagDocEntryHT *ptagHT); + DicomDirImage(TagDocEntryHT *ptagHT); - ~gdcmDicomDirImage(); + ~DicomDirImage(); virtual void Print(std::ostream &os = std::cout); }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDicomDirMeta.cxx b/src/gdcmDicomDirMeta.cxx index 3bb33b3a..f0657a5c 100644 --- a/src/gdcmDicomDirMeta.cxx +++ b/src/gdcmDicomDirMeta.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirMeta.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/10/12 04:35:44 $ + 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 @@ -19,24 +19,27 @@ #include "gdcmDicomDirMeta.h" #include "gdcmDocument.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmMeta + * \ingroup DicomDirMeta * \brief Constructor */ -gdcmDicomDirMeta::gdcmDicomDirMeta(TagDocEntryHT* ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirMeta::DicomDirMeta(TagDocEntryHT* ptagHT): + DicomDirObject(ptagHT) { } /** - * \ingroup gdcmDicomDirMeta + * \ingroup DicomDirMeta * \brief Canonical destructor. */ -gdcmDicomDirMeta::~gdcmDicomDirMeta() +DicomDirMeta::~DicomDirMeta() { } @@ -46,10 +49,10 @@ gdcmDicomDirMeta::~gdcmDicomDirMeta() /** * \brief Prints the Meta Elements */ -void gdcmDicomDirMeta::Print(std::ostream& os) +void DicomDirMeta::Print(std::ostream& os) { os << "META" << std::endl; - // warning : META doesn't behave exactly like a gdcmObjet + // warning : META doesn't behave exactly like a Objet for (ListDocEntry::iterator i = docEntries.begin(); i != docEntries.end(); ++i) @@ -65,7 +68,7 @@ void gdcmDicomDirMeta::Print(std::ostream& os) * \brief Writes the Meta Elements * @return */ -void gdcmDicomDirMeta::Write(FILE* fp, FileType t) +void DicomDirMeta::Write(FILE* fp, FileType t) { for (ListDocEntry::iterator i = docEntries.begin(); i != docEntries.end(); @@ -80,3 +83,5 @@ void gdcmDicomDirMeta::Write(FILE* fp, FileType t) // Private //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmDicomDirMeta.h b/src/gdcmDicomDirMeta.h index 37111f3b..0e665a59 100644 --- a/src/gdcmDicomDirMeta.h +++ b/src/gdcmDicomDirMeta.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirMeta.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.8 $ + Date: $Date: 2004/10/12 04:35:44 $ + 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 @@ -20,18 +20,20 @@ #define GDCMDICOMDIRMETA_H #include "gdcmDicomDirObject.h" +namespace gdcm +{ //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmDicomDirMeta : public gdcmDicomDirObject +class GDCM_EXPORT DicomDirMeta : public DicomDirObject { public: - gdcmDicomDirMeta(TagDocEntryHT *ptagHT); + DicomDirMeta(TagDocEntryHT *ptagHT); - ~gdcmDicomDirMeta(); + ~DicomDirMeta(); virtual void Print(std::ostream &os = std::cout); virtual void Write(FILE * fp, FileType t); }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDicomDirObject.cxx b/src/gdcmDicomDirObject.cxx index 5bbdbc02..bf3ff5ec 100644 --- a/src/gdcmDicomDirObject.cxx +++ b/src/gdcmDicomDirObject.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 03:21:55 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,29 +20,31 @@ #include "gdcmGlobal.h" #include "gdcmDebug.h" #include "gdcmValEntry.h" +namespace gdcm +{ //----------------------------------------------------------------------------- /** - * \ingroup gdcmDicomDirObject + * \ingroup DicomDirObject * \brief Constructor * - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmDocEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the DocEntries) * @param depth Sequence depth level */ -gdcmDicomDirObject::gdcmDicomDirObject(TagDocEntryHT *ptagHT, int depth) - : gdcmSQItem (depth) +DicomDirObject::DicomDirObject(TagDocEntryHT *ptagHT, int depth) + : SQItem (depth) { PtagHT = ptagHT; } /** - * \ingroup gdcmDicomDirObject + * \ingroup DicomDirObject * \brief Canonical destructor. */ -gdcmDicomDirObject::~gdcmDicomDirObject() +DicomDirObject::~DicomDirObject() { } @@ -53,13 +55,13 @@ gdcmDicomDirObject::~gdcmDicomDirObject() /** - * \ingroup gdcmDicomDirObject + * \ingroup DicomDirObject * \brief Builds a hash table (multimap) containing * pointers to all Header Entries (i.e Dicom Element) * related to this 'object' * @return */ -TagDocEntryHT gdcmDicomDirObject::GetEntry() +TagDocEntryHT DicomDirObject::GetEntry() { TagDocEntryHT HT; docEntries=GetDocEntries(); @@ -77,22 +79,22 @@ TagDocEntryHT gdcmDicomDirObject::GetEntry() * \brief add the 'Object' related Dicom Elements to the listEntries * of a partially created DICOMDIR */ -void gdcmDicomDirObject::FillObject(std::list elemList) +void DicomDirObject::FillObject(std::list elemList) { // FillObject rempli le SQItem qui sera accroche au bon endroit - std::list::iterator it; + std::list::iterator it; uint16_t tmpGr,tmpEl; - gdcmDictEntry *dictEntry; - gdcmValEntry *entry; + DictEntry *dictEntry; + ValEntry *entry; // for all the Elements found in they own part of the DicomDir dict. for(it = elemList.begin(); it != elemList.end(); ++it) { tmpGr = it->Group; tmpEl = it->Elem; - dictEntry = gdcmGlobal::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl); - entry = new gdcmValEntry(dictEntry); + dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl); + entry = new ValEntry(dictEntry); entry->SetOffset(0); // just to avoid further missprinting entry->SetValue(it->Value); @@ -121,3 +123,5 @@ void gdcmDicomDirObject::FillObject(std::list elemList) AddDocEntry(entry); } } +} // end namespace gdcm + diff --git a/src/gdcmDicomDirObject.h b/src/gdcmDicomDirObject.h index f1ee45cc..9695adaa 100644 --- a/src/gdcmDicomDirObject.h +++ b/src/gdcmDicomDirObject.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.h,v $ Language: C++ - Date: $Date: 2004/10/07 21:05:40 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -16,32 +16,33 @@ =========================================================================*/ -#ifndef GDCMOBJECT_H -#define GDCMOBJECT_H +#ifndef GDCMDICOMDIROBJECT_H +#define GDCMDICOMDIROBJECT_H -#include "gdcmCommon.h" -#include "gdcmDocEntry.h" -#include "gdcmDocument.h" -#include "gdcmDicomDirElement.h" #include "gdcmSQItem.h" +#include "gdcmDicomDirElement.h" + #include #include +namespace gdcm +{ + //----------------------------------------------------------------------------- -class gdcmDicomDirObject; -typedef std::list ListContent; +class DicomDirObject; +typedef std::list ListContent; //----------------------------------------------------------------------------- /** - * \ingroup gdcmDicomDirObject + * \ingroup DicomDirObject * \brief Base object */ -class GDCM_EXPORT gdcmDicomDirObject : public gdcmSQItem +class GDCM_EXPORT DicomDirObject : public SQItem { public: - gdcmDicomDirObject(TagDocEntryHT *ptagHT, int depth = 0); - virtual ~gdcmDicomDirObject(); + DicomDirObject(TagDocEntryHT *ptagHT, int depth = 0); + virtual ~DicomDirObject(); /** * \brief Sets the print level for the Dicom Header * \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy @@ -49,18 +50,19 @@ public: void SetPrintLevel(int level) { PrintLevel = level; }; TagDocEntryHT GetEntry(); - void FillObject(std::list elemList); + void FillObject(std::list elemList); protected: // Constructor and destructor are protected to avoid end user to // instanciate from this class. - // NO ! gdcmDicomDir needs to instanciate it! + // NO ! DicomDir needs to instanciate it! // Members : ///\brief detail level to be printed int PrintLevel; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDicomDirPatient.cxx b/src/gdcmDicomDirPatient.cxx index d918485c..d6673ac7 100644 --- a/src/gdcmDicomDirPatient.cxx +++ b/src/gdcmDicomDirPatient.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.14 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.15 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,33 +19,35 @@ #include "gdcmDicomDirPatient.h" #include "gdcmDicomDirElement.h" #include "gdcmGlobal.h" +namespace gdcm +{ //----------------------------------------------------------------------------- // Constructor / Destructor /** * \brief Constructor * @param s SQ Item holding the elements related to this "PATIENT" part - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmHeaderEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the HeaderEntries) */ -gdcmDicomDirPatient::gdcmDicomDirPatient(gdcmSQItem *s, TagDocEntryHT *ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirPatient::DicomDirPatient(SQItem *s, TagDocEntryHT *ptagHT): + DicomDirObject(ptagHT) { docEntries = s->GetDocEntries(); } /** * \brief Constructor - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmHeaderEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the HeaderEntries) */ -gdcmDicomDirPatient::gdcmDicomDirPatient(TagDocEntryHT* ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirPatient::DicomDirPatient(TagDocEntryHT* ptagHT): + DicomDirObject(ptagHT) { } /** * \brief Canonical destructor. */ -gdcmDicomDirPatient::~gdcmDicomDirPatient() +DicomDirPatient::~DicomDirPatient() { for(ListDicomDirStudy::iterator cc = studies.begin(); cc != studies.end(); ++cc) @@ -60,10 +62,10 @@ gdcmDicomDirPatient::~gdcmDicomDirPatient() * \brief Prints the Object * @return */ -void gdcmDicomDirPatient::Print(std::ostream& os) +void DicomDirPatient::Print(std::ostream& os) { os << "PATIENT" << std::endl; - gdcmDicomDirObject::Print(os); + DicomDirObject::Print(os); for(ListDicomDirStudy::iterator cc = studies.begin(); cc != studies.end(); ++cc) @@ -77,9 +79,9 @@ void gdcmDicomDirPatient::Print(std::ostream& os) * \brief Writes the Object * @return */ -void gdcmDicomDirPatient::Write(FILE* fp, FileType t) +void DicomDirPatient::Write(FILE* fp, FileType t) { - gdcmDicomDirObject::Write(fp, t); + DicomDirObject::Write(fp, t); for(ListDicomDirStudy::iterator cc = studies.begin();cc!=studies.end();++cc) { @@ -93,12 +95,12 @@ void gdcmDicomDirPatient::Write(FILE* fp, FileType t) * \brief adds a new Patient at the begining of the PatientList * of a partially created DICOMDIR */ -gdcmDicomDirStudy* gdcmDicomDirPatient::NewStudy() +DicomDirStudy* DicomDirPatient::NewStudy() { - std::list elemList = - gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements(); + std::list elemList = + Global::GetDicomDirElements()->GetDicomDirStudyElements(); - gdcmDicomDirStudy* st = new gdcmDicomDirStudy( PtagHT ); + DicomDirStudy* st = new DicomDirStudy( PtagHT ); st->FillObject(elemList); studies.push_front(st); @@ -112,3 +114,5 @@ gdcmDicomDirStudy* gdcmDicomDirPatient::NewStudy() // Private //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmDicomDirPatient.h b/src/gdcmDicomDirPatient.h index 906c0a63..d203a629 100644 --- a/src/gdcmDicomDirPatient.h +++ b/src/gdcmDicomDirPatient.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.9 $ + Date: $Date: 2004/10/12 04:35:45 $ + 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 @@ -22,17 +22,21 @@ #include "gdcmDicomDirObject.h" #include "gdcmDicomDirStudy.h" #include "gdcmSQItem.h" + +namespace gdcm +{ + //----------------------------------------------------------------------------- -typedef std::list ListDicomDirStudy; +typedef std::list ListDicomDirStudy; //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmDicomDirPatient : public gdcmDicomDirObject +class GDCM_EXPORT DicomDirPatient : public DicomDirObject { public: - gdcmDicomDirPatient(gdcmSQItem *s, TagDocEntryHT *ptagHT); - gdcmDicomDirPatient(TagDocEntryHT *ptagHT); + DicomDirPatient(SQItem *s, TagDocEntryHT *ptagHT); + DicomDirPatient(TagDocEntryHT *ptagHT); - ~gdcmDicomDirPatient(); + ~DicomDirPatient(); virtual void Print(std::ostream &os = std::cout); virtual void Write(FILE *fp, FileType t); @@ -40,16 +44,17 @@ public: ListDicomDirStudy &GetDicomDirStudies() { return studies; }; /// adds the passed STUDY to the STUDY chained List for this PATIENT. - void AddDicomDirStudy(gdcmDicomDirStudy *obj) { studies.push_back(obj); }; + void AddDicomDirStudy(DicomDirStudy *obj) { studies.push_back(obj); }; /// TODO - gdcmDicomDirStudy* NewStudy(); + DicomDirStudy* NewStudy(); private: /// chained list of DicomDirStudy ListDicomDirStudy studies; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index aadec9e8..62396da1 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.16 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,33 +20,36 @@ #include "gdcmDicomDirElement.h" #include "gdcmGlobal.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** * \brief Constructor * @param s SQ Item holding the elements related to this "SERIE" part - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmDocEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the DocEntries) */ -gdcmDicomDirSerie::gdcmDicomDirSerie(gdcmSQItem* s, TagDocEntryHT* ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirSerie::DicomDirSerie(SQItem* s, TagDocEntryHT* ptagHT): + DicomDirObject(ptagHT) { docEntries = s->GetDocEntries(); } /** * \brief Constructor - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmDocEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the DocEntries) */ -gdcmDicomDirSerie::gdcmDicomDirSerie(TagDocEntryHT* ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirSerie::DicomDirSerie(TagDocEntryHT* ptagHT): + DicomDirObject(ptagHT) { } /** * \brief Canonical destructor. */ -gdcmDicomDirSerie::~gdcmDicomDirSerie() +DicomDirSerie::~DicomDirSerie() { for(ListDicomDirImage::iterator cc = images.begin(); cc != images.end(); @@ -62,10 +65,10 @@ gdcmDicomDirSerie::~gdcmDicomDirSerie() * \brief Prints the Object * @return */ -void gdcmDicomDirSerie::Print(std::ostream& os) +void DicomDirSerie::Print(std::ostream& os) { os << "SERIE" << std::endl; - gdcmDicomDirObject::Print(os); + DicomDirObject::Print(os); for(ListDicomDirImage::iterator cc = images.begin(); cc != images.end(); @@ -83,9 +86,9 @@ void gdcmDicomDirSerie::Print(std::ostream& os) * \brief Writes the Object * @return */ -void gdcmDicomDirSerie::Write(FILE* fp, FileType t) +void DicomDirSerie::Write(FILE* fp, FileType t) { - gdcmDicomDirObject::Write(fp, t); + DicomDirObject::Write(fp, t); for(ListDicomDirImage::iterator cc = images.begin();cc!=images.end();++cc) { @@ -96,12 +99,12 @@ void gdcmDicomDirSerie::Write(FILE* fp, FileType t) /** * \brief adds a new Image (with the basic elements) to a partially created DICOMDIR */ -gdcmDicomDirImage* gdcmDicomDirSerie::NewImage() +DicomDirImage* DicomDirSerie::NewImage() { - std::list elemList = - gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements(); + std::list elemList = + Global::GetDicomDirElements()->GetDicomDirImageElements(); - gdcmDicomDirImage* st = new gdcmDicomDirImage(PtagHT); + DicomDirImage* st = new DicomDirImage(PtagHT); FillObject(elemList); images.push_front(st); @@ -114,3 +117,6 @@ gdcmDicomDirImage* gdcmDicomDirSerie::NewImage() // Private //----------------------------------------------------------------------------- +} // end namespace gdcm + + diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h index 308045a8..8e26cff3 100644 --- a/src/gdcmDicomDirSerie.h +++ b/src/gdcmDicomDirSerie.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.9 $ + Date: $Date: 2004/10/12 04:35:45 $ + 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 @@ -21,37 +21,39 @@ #include "gdcmDicomDirObject.h" #include "gdcmDicomDirImage.h" +namespace gdcm +{ //----------------------------------------------------------------------------- -typedef std::list ListDicomDirImage; +typedef std::list ListDicomDirImage; //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmDicomDirSerie : public gdcmDicomDirObject +class GDCM_EXPORT DicomDirSerie : public DicomDirObject { public: - gdcmDicomDirSerie(gdcmSQItem *s, TagDocEntryHT *ptagHT); - gdcmDicomDirSerie(TagDocEntryHT *ptagHT); + DicomDirSerie(SQItem *s, TagDocEntryHT *ptagHT); + DicomDirSerie(TagDocEntryHT *ptagHT); - ~gdcmDicomDirSerie(); + ~DicomDirSerie(); virtual void Print(std::ostream &os = std::cout); virtual void Write(FILE *fp, FileType t); /** - * \ingroup gdcmDicomDirSerie + * \ingroup DicomDirSerie * \brief returns the IMAGE chained List for this SERIE. */ ListDicomDirImage &GetDicomDirImages() { return images; }; /** - * \ingroup gdcmDicomDirSerie + * \ingroup DicomDirSerie * \brief adds the passed IMAGE to the IMAGE chained List for this SERIE. */ - void AddDicomDirImage(gdcmDicomDirImage *obj) { images.push_back(obj); }; + void AddDicomDirImage(DicomDirImage *obj) { images.push_back(obj); }; /** - * \ingroup gdcmDicomDirSerie + * \ingroup DicomDirSerie * \brief TODO */ - gdcmDicomDirImage* NewImage(); + DicomDirImage* NewImage(); private: /** @@ -59,6 +61,6 @@ private: */ ListDicomDirImage images; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index c725a4e8..ea468830 100644 --- a/src/gdcmDicomDirStudy.cxx +++ b/src/gdcmDicomDirStudy.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirStudy.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.13 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.14 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,36 +19,40 @@ #include "gdcmDicomDirStudy.h" #include "gdcmDicomDirElement.h" #include "gdcmGlobal.h" + +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmDicomDirStudy + * \ingroup DicomDirStudy * \brief constructor * @param s SQ Item holding the elements related to this "STUDY" part - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmHeaderEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the HeaderEntries) */ -gdcmDicomDirStudy::gdcmDicomDirStudy(gdcmSQItem* s, TagDocEntryHT* ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirStudy::DicomDirStudy(SQItem* s, TagDocEntryHT* ptagHT): + DicomDirObject(ptagHT) { docEntries = s->GetDocEntries(); } /** - * \ingroup gdcmDicomDirStudy + * \ingroup DicomDirStudy * \brief constructor - * @param ptagHT pointer to the HTable (gdcmDicomDirObject needs it - * to build the gdcmHeaderEntries) + * @param ptagHT pointer to the HTable (DicomDirObject needs it + * to build the HeaderEntries) */ -gdcmDicomDirStudy::gdcmDicomDirStudy(TagDocEntryHT* ptagHT): - gdcmDicomDirObject(ptagHT) +DicomDirStudy::DicomDirStudy(TagDocEntryHT* ptagHT): + DicomDirObject(ptagHT) { } /** - * \ingroup gdcmDicomDirStudy + * \ingroup DicomDirStudy * \brief Canonical destructor. */ -gdcmDicomDirStudy::~gdcmDicomDirStudy() +DicomDirStudy::~DicomDirStudy() { for(ListDicomDirSerie::iterator cc = series.begin();cc != series.end();++cc) { @@ -59,14 +63,14 @@ gdcmDicomDirStudy::~gdcmDicomDirStudy() //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmDicomDirStudy + * \ingroup DicomDirStudy * \brief Prints the Object * @return */ -void gdcmDicomDirStudy::Print(std::ostream& os) +void DicomDirStudy::Print(std::ostream& os) { os << "STUDY" << std::endl; - gdcmDicomDirObject::Print(os); + DicomDirObject::Print(os); for(ListDicomDirSerie::iterator cc = series.begin(); cc != series.end(); @@ -84,9 +88,9 @@ void gdcmDicomDirStudy::Print(std::ostream& os) * \brief Writes the Object * @return */ -void gdcmDicomDirStudy::Write(FILE* fp, FileType t) +void DicomDirStudy::Write(FILE* fp, FileType t) { - gdcmDicomDirObject::Write(fp, t); + DicomDirObject::Write(fp, t); for(ListDicomDirSerie::iterator cc = series.begin();cc!=series.end();++cc) { @@ -95,16 +99,16 @@ void gdcmDicomDirStudy::Write(FILE* fp, FileType t) } /** - * \ingroup gdcmDicomStudy + * \ingroup DicomDirStudy * \brief adds a new Serie at the begining of the SerieList * of a partially created DICOMDIR */ -gdcmDicomDirSerie* gdcmDicomDirStudy::NewSerie() +DicomDirSerie* DicomDirStudy::NewSerie() { - std::list elemList = - gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements(); + std::list elemList = + Global::GetDicomDirElements()->GetDicomDirSerieElements(); - gdcmDicomDirSerie* st = new gdcmDicomDirSerie(PtagHT); + DicomDirSerie* st = new DicomDirSerie(PtagHT); FillObject(elemList); series.push_front(st); @@ -117,3 +121,5 @@ gdcmDicomDirSerie* gdcmDicomDirStudy::NewSerie() // Private //----------------------------------------------------------------------------- +} // end namespace gdcm + diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h index 705788b9..91e798c2 100644 --- a/src/gdcmDicomDirStudy.h +++ b/src/gdcmDicomDirStudy.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirStudy.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.9 $ + Date: $Date: 2004/10/12 04:35:45 $ + 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 @@ -21,37 +21,39 @@ #include "gdcmDicomDirObject.h" #include "gdcmDicomDirSerie.h" +namespace gdcm +{ //----------------------------------------------------------------------------- -typedef std::list ListDicomDirSerie; +typedef std::list ListDicomDirSerie; //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmDicomDirStudy : public gdcmDicomDirObject +class GDCM_EXPORT DicomDirStudy : public DicomDirObject { public: - gdcmDicomDirStudy(gdcmSQItem *s, TagDocEntryHT *ptagHT); - gdcmDicomDirStudy(TagDocEntryHT *ptagHT); + DicomDirStudy(SQItem *s, TagDocEntryHT *ptagHT); + DicomDirStudy(TagDocEntryHT *ptagHT); - ~gdcmDicomDirStudy(); + ~DicomDirStudy(); virtual void Print(std::ostream &os = std::cout); virtual void Write(FILE *fp, FileType t); /** - * \ingroup gdcmDicomDirStudy + * \ingroup DicomDirStudy * \brief returns the SERIE chained List for this STUDY. */ ListDicomDirSerie &GetDicomDirSeries() { return series; }; /** - * \ingroup gdcmDicomDirStudy + * \ingroup DicomDirStudy * \brief adds the passed SERIE to the SERIE chained List for this STUDY. */ - void AddDicomDirSerie(gdcmDicomDirSerie *obj) { series.push_back(obj); }; + void AddDicomDirSerie(DicomDirSerie *obj) { series.push_back(obj); }; /** - * \ingroup gdcmDicomDirStudy + * \ingroup DicomDirStudy * \brief TODO */ - gdcmDicomDirSerie* NewSerie(); + DicomDirSerie* NewSerie(); private: /** @@ -59,6 +61,7 @@ private: */ ListDicomDirSerie series; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index c72dd48b..bb6bd72e 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.cxx,v $ Language: C++ - Date: $Date: 2004/10/08 04:43:38 $ - Version: $Revision: 1.44 $ + Date: $Date: 2004/10/12 04:35:45 $ + 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 @@ -23,6 +23,8 @@ #include #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- // Constructor / Destructor @@ -30,7 +32,7 @@ * \brief Construtor * @param filename from which to build the dictionary. */ -gdcmDict::gdcmDict(std::string const & filename) +Dict::Dict(std::string const & filename) { uint16_t group; uint16_t element; @@ -39,7 +41,7 @@ gdcmDict::gdcmDict(std::string const & filename) TagName name; std::ifstream from( filename.c_str() ); - dbg.Error(!from, "gdcmDict::gdcmDict: can't open dictionary", + dbg.Error(!from, "Dict::Dict: can't open dictionary", filename.c_str()); while (!from.eof()) @@ -52,7 +54,7 @@ gdcmDict::gdcmDict(std::string const & filename) from >> std::ws; // used to be eatwhite(from); std::getline(from, name); /// MEMORY LEAK in std::getline<> - gdcmDictEntry * newEntry = new gdcmDictEntry(group, element, + DictEntry * newEntry = new DictEntry(group, element, vr, fourth, name); AddNewEntry(newEntry); } @@ -64,18 +66,18 @@ gdcmDict::gdcmDict(std::string const & filename) /** * \brief Destructor */ -gdcmDict::~gdcmDict() +Dict::~Dict() { for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag) { - gdcmDictEntry* entryToDelete = tag->second; + DictEntry* entryToDelete = tag->second; if ( entryToDelete ) { delete entryToDelete; } } // Since AddNewEntry adds symetrical in both KeyHt and NameHT we can - // assume all the pointed gdcmDictEntries are already cleaned-up when + // assume all the pointed DictEntries are already cleaned-up when // we cleaned KeyHt. KeyHt.clear(); NameHt.clear(); @@ -88,7 +90,7 @@ gdcmDict::~gdcmDict() * Entries will be sorted by tag i.e. the couple (group, element). * @param os The output stream to be written to. */ -void gdcmDict::Print(std::ostream &os) +void Dict::Print(std::ostream &os) { os << "Dict file name : " << Filename << std::endl; PrintByKey(os); @@ -99,7 +101,7 @@ void gdcmDict::Print(std::ostream &os) * Entries will be sorted by tag i.e. the couple (group, element). * @param os The output stream to be written to. */ -void gdcmDict::PrintByKey(std::ostream &os) +void Dict::PrintByKey(std::ostream &os) { std::ostringstream s; @@ -123,7 +125,7 @@ void gdcmDict::PrintByKey(std::ostream &os) * unpredictable result * @param os The output stream to be written to. */ -void gdcmDict::PrintByName(std::ostream& os) +void Dict::PrintByName(std::ostream& os) { std::ostringstream s; @@ -143,18 +145,18 @@ void gdcmDict::PrintByName(std::ostream& os) //----------------------------------------------------------------------------- // Public /** - * \ingroup gdcmDict + * \ingroup Dict * \brief adds a new Dicom Dictionary Entry * @param newEntry entry to add * @return false if Dicom Element already exists */ -bool gdcmDict::AddNewEntry(gdcmDictEntry *newEntry) +bool Dict::AddNewEntry(DictEntry *newEntry) { - gdcmTagKey key = newEntry->GetKey(); + TagKey key = newEntry->GetKey(); if(KeyHt.count(key) == 1) { - dbg.Verbose(1, "gdcmDict::AddNewEntry already present", key.c_str()); + dbg.Verbose(1, "Dict::AddNewEntry already present", key.c_str()); return false; } else @@ -166,14 +168,14 @@ bool gdcmDict::AddNewEntry(gdcmDictEntry *newEntry) } /** - * \ingroup gdcmDict + * \ingroup Dict * \brief replaces an already existing Dicom Element by a new one * @param newEntry new entry (overwrites any previous one with same tag) * @return false if Dicom Element doesn't exist */ -bool gdcmDict::ReplaceEntry(gdcmDictEntry *newEntry) +bool Dict::ReplaceEntry(DictEntry *newEntry) { - if ( RemoveEntry(newEntry->gdcmDictEntry::GetKey()) ) + if ( RemoveEntry(newEntry->DictEntry::GetKey()) ) { KeyHt[newEntry->GetKey()] = newEntry; NameHt[newEntry->GetName()] = newEntry; @@ -183,17 +185,17 @@ bool gdcmDict::ReplaceEntry(gdcmDictEntry *newEntry) } /** - * \ingroup gdcmDict + * \ingroup Dict * \brief removes an already existing Dicom Dictionary Entry, * identified by its Tag * @param key (group|element) * @return false if Dicom Dictionary Entry doesn't exist */ -bool gdcmDict::RemoveEntry(gdcmTagKey key) +bool Dict::RemoveEntry(TagKey key) { if(KeyHt.count(key) == 1) { - gdcmDictEntry* entryToDelete = KeyHt.find(key)->second; + DictEntry* entryToDelete = KeyHt.find(key)->second; if ( entryToDelete ) { @@ -206,7 +208,7 @@ bool gdcmDict::RemoveEntry(gdcmTagKey key) } else { - dbg.Verbose(1, "gdcmDict::RemoveEntry unfound entry", key.c_str()); + dbg.Verbose(1, "Dict::RemoveEntry unfound entry", key.c_str()); return false; } } @@ -218,9 +220,9 @@ bool gdcmDict::RemoveEntry(gdcmTagKey key) * @param element Dicom element number of the Dicom Element * @return false if Dicom Dictionary Entry doesn't exist */ -bool gdcmDict::RemoveEntry (uint16_t group, uint16_t element) +bool Dict::RemoveEntry (uint16_t group, uint16_t element) { - return RemoveEntry(gdcmDictEntry::TranslateToKey(group, element)); + return RemoveEntry(DictEntry::TranslateToKey(group, element)); } /** @@ -231,7 +233,7 @@ bool gdcmDict::RemoveEntry (uint16_t group, uint16_t element) * the name MAY CHANGE between two versions ! * @return the corresponding dictionnary entry when existing, NULL otherwise */ -gdcmDictEntry* gdcmDict::GetDictEntryByName(TagName name) +DictEntry* Dict::GetDictEntryByName(TagName name) { if ( !NameHt.count(name)) { @@ -246,9 +248,9 @@ gdcmDictEntry* gdcmDict::GetDictEntryByName(TagName name) * @param element element of the entry to be found * @return the corresponding dictionnary entry when existing, NULL otherwise */ -gdcmDictEntry* gdcmDict::GetDictEntryByNumber(uint16_t group, uint16_t element) +DictEntry* Dict::GetDictEntryByNumber(uint16_t group, uint16_t element) { - gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element); + TagKey key = DictEntry::TranslateToKey(group, element); if ( !KeyHt.count(key) ) { return 0; @@ -259,10 +261,10 @@ gdcmDictEntry* gdcmDict::GetDictEntryByNumber(uint16_t group, uint16_t element) /** * \brief Consider all the entries of the public dicom dictionnary. * Build all list of all the tag names of all those entries. - * \sa gdcmDictSet::GetPubDictTagNamesByCategory + * \sa DictSet::GetPubDictTagNamesByCategory * @return A list of all entries of the public dicom dictionnary. */ -std::list* gdcmDict::GetDictEntryNames() +std::list* Dict::GetDictEntryNames() { std::list *result = new std::list; for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag) @@ -273,7 +275,7 @@ std::list* gdcmDict::GetDictEntryNames() } /** - * \ingroup gdcmDict + * \ingroup Dict * \brief Consider all the entries of the public dicom dictionnary. * Build an hashtable whose keys are the names of the groups * (fourth field in each line of dictionary) and whose corresponding @@ -296,7 +298,7 @@ std::list* gdcmDict::GetDictEntryNames() * corresponding values are lists of all the dictionnary entries * among that group. */ -std::map > *gdcmDict::GetDictEntryNamesByCategory(void) +std::map > *Dict::GetDictEntryNamesByCategory(void) { std::map > *result = new std::map >; @@ -315,3 +317,5 @@ std::map > *gdcmDict::GetDictEntryNamesByCat // Private //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmDict.h b/src/gdcmDict.h index 961d245f..6fcfd93a 100644 --- a/src/gdcmDict.h +++ b/src/gdcmDict.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.18 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,27 +25,29 @@ #include #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- -typedef std::map TagKeyHT; -typedef std::map TagNameHT; +typedef std::map TagKeyHT; +typedef std::map TagNameHT; //----------------------------------------------------------------------------- /* - * \defgroup gdcmDict - * \brief gdcmDict acts a memory representation of a dicom dictionary i.e. + * \defgroup Dict + * \brief Dict acts a memory representation of a dicom dictionary i.e. * it is a container for a collection of dictionary entries. The * dictionary is loaded from in an ascii file. * There should be a single public dictionary (THE dictionary of * the actual DICOM v3) but as many shadow dictionaries as imagers * combined with all software versions... - * \see gdcmDictSet + * \see DictSet */ -class GDCM_EXPORT gdcmDict +class GDCM_EXPORT Dict { public: - gdcmDict(std::string const & FileName); - ~gdcmDict(); + Dict(std::string const & FileName); + ~Dict(); // Print void Print(std::ostream &os = std::cout); @@ -53,14 +55,14 @@ public: void PrintByName(std::ostream &os = std::cout); // Entries - bool AddNewEntry (gdcmDictEntry *NewEntry); - bool ReplaceEntry(gdcmDictEntry *NewEntry); - bool RemoveEntry (gdcmTagKey key); + bool AddNewEntry (DictEntry *NewEntry); + bool ReplaceEntry(DictEntry *NewEntry); + bool RemoveEntry (TagKey key); bool RemoveEntry (uint16_t group, uint16_t element); // Tag - gdcmDictEntry *GetDictEntryByName(TagName name); - gdcmDictEntry *GetDictEntryByNumber(uint16_t group, uint16_t element); + DictEntry *GetDictEntryByName(TagName name); + DictEntry *GetDictEntryByNumber(uint16_t group, uint16_t element); std::list *GetDictEntryNames(); std::map > * @@ -77,11 +79,12 @@ public: private: /// ASCII file holding the Dictionnary std::string Filename; - /// Access through gdcmTagKey (see alternate access with NameHt) + /// Access through TagKey (see alternate access with NameHt) TagKeyHT KeyHt; /// Access through TagName (see alternate access with KeyHt) TagNameHT NameHt; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index c11d0680..d3bb9197 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:54 $ - Version: $Revision: 1.25 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.26 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,6 +20,8 @@ #include "gdcmDebug.h" #include "gdcmUtil.h" +namespace gdcm +{ //----------------------------------------------------------------------------- // Constructor / Destructor @@ -33,7 +35,7 @@ * @param name description of the element */ -gdcmDictEntry::gdcmDictEntry(uint16_t group, uint16_t element, +DictEntry::DictEntry(uint16_t group, uint16_t element, std::string vr, std::string fourth, std::string name) { @@ -57,9 +59,9 @@ gdcmDictEntry::gdcmDictEntry(uint16_t group, uint16_t element, * @param element the Dicom element number used to build the tag * @return the built tag */ -gdcmTagKey gdcmDictEntry::TranslateToKey(uint16_t group, uint16_t element) +TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t element) { - gdcmTagKey key = gdcmUtil::Format("%04x|%04x", group , element); + TagKey key = Util::Format("%04x|%04x", group , element); return key; } @@ -70,7 +72,7 @@ gdcmTagKey gdcmDictEntry::TranslateToKey(uint16_t group, uint16_t element) * \ is unset then overwrite it. * @param vr New V(alue) R(epresentation) to be set. */ -void gdcmDictEntry::SetVR(std::string const & vr) +void DictEntry::SetVR(std::string const & vr) { if ( IsVRUnknown() ) { @@ -78,7 +80,7 @@ void gdcmDictEntry::SetVR(std::string const & vr) } else { - dbg.Error(true, "gdcmDictEntry::SetVR", + dbg.Error(true, "DictEntry::SetVR", "Overwriting VR might compromise a dictionary"); } } @@ -90,3 +92,5 @@ void gdcmDictEntry::SetVR(std::string const & vr) // Private //----------------------------------------------------------------------------- +} // end namespace gdcm + diff --git a/src/gdcmDictEntry.h b/src/gdcmDictEntry.h index 72d60602..dce04530 100644 --- a/src/gdcmDictEntry.h +++ b/src/gdcmDictEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.h,v $ Language: C++ - Date: $Date: 2004/10/09 02:57:11 $ - Version: $Revision: 1.17 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,27 +21,30 @@ #include "gdcmCommon.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- /* - * \defgroup gdcmDictEntry + * \defgroup DictEntry * \brief - * the gdcmDictEntry in an element contained by the gdcmDict. + * the DictEntry in an element contained by the Dict. * It contains : * - the key referenced by the DICOM norm or the constructor (for private keys) * - the corresponding name in english (it's equivalent to a label) * - the owner group * - etc. */ -class GDCM_EXPORT gdcmDictEntry +class GDCM_EXPORT DictEntry { public: - gdcmDictEntry(uint16_t group, + DictEntry(uint16_t group, uint16_t element, std::string vr = "Unknown", std::string fourth = "Unknown", std::string name = "Unknown"); - static gdcmTagKey TranslateToKey(uint16_t group, uint16_t element); + static TagKey TranslateToKey(uint16_t group, uint16_t element); void SetVR(std::string const & vr); @@ -49,46 +52,46 @@ public: /// @return bool IsVRUnknown() { return VR == "??"; } - /// \brief Returns the Dicom Group Number of the current gdcmDictEntry + /// \brief Returns the Dicom Group Number of the current DictEntry /// @return the Dicom Group Number uint16_t GetGroup() { return Group; } - /// \brief Returns the Dicom Element Number of the current gdcmDictEntry + /// \brief Returns the Dicom Element Number of the current DictEntry /// @return the Dicom Element Number uint16_t GetElement() { return Element; } /// \brief Returns the Dicom Value Representation of the current - /// gdcmDictEntry + /// DictEntry /// @return the Dicom Value Representation std::string GetVR() { return VR; } - /// \brief sets the key of the current gdcmDictEntry + /// \brief sets the key of the current DictEntry /// @param k New key to be set. void SetKey(std::string const & k) { Key = k; } - /// \brief returns the Fourth field of the current gdcmDictEntry + /// \brief returns the Fourth field of the current DictEntry /// \warning NOT part of the Dicom Standard. /// May be REMOVED an any time. NEVER use it. /// @return The Fourth field std::string GetFourth() { return Fourth; } - /// \brief Returns the Dicom Name of the current gdcmDictEntry + /// \brief Returns the Dicom Name of the current DictEntry /// e.g. "Patient Name" for Dicom Tag (0x0010, 0x0010) /// @return the Dicom Name std::string GetName() { return Name; } - /// \brief Gets the key of the current gdcmDictEntry + /// \brief Gets the key of the current DictEntry /// @return the key. std::string GetKey() { return Key; } private: /// \todo FIXME /// where are the group and element used except from building up - /// a gdcmTagKey. If the answer is nowhere then there is no need + /// a TagKey. If the answer is nowhere then there is no need /// to store the group and element independently. /// /// --> EVERYWHERE ! The alternate question would be : - /// What's gdcmTagKey used for ? + /// What's TagKey used for ? /// DicomGroup number uint16_t Group; // e.g. 0x0010 @@ -98,7 +101,7 @@ private: /// \brief Value Representation i.e. some clue about the nature /// of the data represented e.g. "FD" short for - /// "Floating Point Double" (see \ref gdcmVR) + /// "Floating Point Double" (see \ref VR) std::string VR; /** @@ -164,8 +167,8 @@ private: std::string Name; /// Redundant with (group, element) but we add it for efficiency purpose. - gdcmTagKey Key; + TagKey Key; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 6e5b998c..a18a25fa 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.37 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.38 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,32 +20,34 @@ #include "gdcmDebug.h" #include #include // For getenv +namespace gdcm +{ //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief The Dictionnary Set obtained with this constructor simply * contains the Default Public dictionnary. */ -gdcmDictSet::gdcmDictSet() +DictSet::DictSet() { DictPath = BuildDictPath(); std::string pubDictFile(DictPath); pubDictFile += PUB_DICT_FILENAME; - Dicts[PUB_DICT_NAME] = new gdcmDict(pubDictFile); + Dicts[PUB_DICT_NAME] = new Dict(pubDictFile); } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Destructor */ -gdcmDictSet::~gdcmDictSet() +DictSet::~DictSet() { // Remove dictionnaries for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag) { - gdcmDict *entryToDelete = tag->second; + Dict *entryToDelete = tag->second; if ( entryToDelete ) { delete entryToDelete; @@ -55,10 +57,10 @@ gdcmDictSet::~gdcmDictSet() Dicts.clear(); // Remove virtual dictionnary entries - std::map::iterator it; + std::map::iterator it; for(it = VirtualEntry.begin(); it != VirtualEntry.end(); ++it) { - gdcmDictEntry *entry = it->second; + DictEntry *entry = it->second; if ( entry ) { delete entry; @@ -70,12 +72,12 @@ gdcmDictSet::~gdcmDictSet() //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Print, in an informal fashion, the list of all the dictionaries - * contained is this gdcmDictSet, along with their respective content. + * contained is this DictSet, along with their respective content. * @param os Output stream used for printing. */ -void gdcmDictSet::Print(std::ostream& os) +void DictSet::Print(std::ostream& os) { for (DictSetHT::iterator dict = Dicts.begin(); dict != Dicts.end(); ++dict) { @@ -87,19 +89,19 @@ void gdcmDictSet::Print(std::ostream& os) //----------------------------------------------------------------------------- // Public /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Consider all the entries of the public dicom dictionnary. * Build all list of all the tag names of all those entries. - * \sa gdcmDictSet::GetPubDictTagNamesByCategory + * \sa DictSet::GetPubDictTagNamesByCategory * @return A list of all entries of the public dicom dictionnary. */ -std::list *gdcmDictSet::GetPubDictEntryNames() +std::list *DictSet::GetPubDictEntryNames() { return GetDefaultPubDict()->GetDictEntryNames(); } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief * - Consider all the entries of the public dicom dictionnary. * - Build an hashtable whose keys are the names of the groups @@ -125,37 +127,37 @@ std::list *gdcmDictSet::GetPubDictEntryNames() * among that group. */ std::map > * - gdcmDictSet::GetPubDictEntryNamesByCategory() + DictSet::GetPubDictEntryNamesByCategory() { return GetDefaultPubDict()->GetDictEntryNamesByCategory(); } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Loads a dictionary from a specified file, and add it - * to already the existing ones contained in this gdcmDictSet. + * to already the existing ones contained in this DictSet. * @param fileName Absolute or relative filename containing the * dictionary to load. * @param name Symbolic name that be used as identifier of the newly * created dictionary. */ -gdcmDict *gdcmDictSet::LoadDictFromFile(std::string const & fileName, +Dict *DictSet::LoadDictFromFile(std::string const & fileName, DictKey const & name) { - gdcmDict *newDict = new gdcmDict(fileName); + Dict *newDict = new Dict(fileName); AppendDict(newDict, name); return newDict; } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Retrieve the specified dictionary (when existing) from this - * gdcmDictSet. + * DictSet. * @param dictName The symbolic name of the searched dictionary. * \result The retrieved dictionary. */ -gdcmDict *gdcmDictSet::GetDict(DictKey const & dictName) +Dict *DictSet::GetDict(DictKey const & dictName) { DictSetHT::iterator dict = Dicts.find(dictName); if(dict != Dicts.end()) @@ -166,20 +168,20 @@ gdcmDict *gdcmDictSet::GetDict(DictKey const & dictName) } /** - * \brief Create a gdcmDictEntry which will be reference + * \brief Create a DictEntry which will be reference * in no dictionnary * @return virtual entry */ -gdcmDictEntry *gdcmDictSet::NewVirtualDictEntry(uint16_t group, +DictEntry *DictSet::NewVirtualDictEntry(uint16_t group, uint16_t element, std::string vr, std::string fourth, std::string name) { - gdcmDictEntry* entry; - const std::string tag = gdcmDictEntry::TranslateToKey(group,element) + DictEntry* entry; + const std::string tag = DictEntry::TranslateToKey(group,element) + "#" + vr + "#" + fourth + "#" + name; - std::map::iterator it; + std::map::iterator it; it = VirtualEntry.find(tag); if(it != VirtualEntry.end()) @@ -188,7 +190,7 @@ gdcmDictEntry *gdcmDictSet::NewVirtualDictEntry(uint16_t group, } else { - entry = new gdcmDictEntry(group, element, vr, fourth, name); + entry = new DictEntry(group, element, vr, fourth, name); VirtualEntry[tag] = entry; } @@ -202,7 +204,7 @@ gdcmDictEntry *gdcmDictSet::NewVirtualDictEntry(uint16_t group, * to "../Dicts/". * @return path to directory containing the dictionnaries */ -std::string gdcmDictSet::BuildDictPath() +std::string DictSet::BuildDictPath() { std::string resultPath; const char *envPath = 0; @@ -215,7 +217,7 @@ std::string gdcmDictSet::BuildDictPath() { resultPath += '/'; } - dbg.Verbose(1, "gdcmDictSet::BuildDictPath:", + dbg.Verbose(1, "DictSet::BuildDictPath:", "Dictionary path set from environnement"); } else @@ -228,7 +230,7 @@ std::string gdcmDictSet::BuildDictPath() //----------------------------------------------------------------------------- // Protected -bool gdcmDictSet::AppendDict(gdcmDict *newDict, DictKey const & name) +bool DictSet::AppendDict(Dict *newDict, DictKey const & name) { Dicts[name] = newDict; @@ -240,4 +242,4 @@ bool gdcmDictSet::AppendDict(gdcmDict *newDict, DictKey const & name) //----------------------------------------------------------------------------- - +} // end namespace gdcm diff --git a/src/gdcmDictSet.h b/src/gdcmDictSet.h index 28cc210d..68130b4f 100644 --- a/src/gdcmDictSet.h +++ b/src/gdcmDictSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.26 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.27 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,24 +22,26 @@ #include "gdcmDict.h" #include #include +namespace gdcm +{ typedef std::string DictKey; -typedef std::map DictSetHT; +typedef std::map DictSetHT; //----------------------------------------------------------------------------- /* - * \defgroup gdcmDictSet + * \defgroup DictSet * \brief Container for managing a set of loaded dictionaries. * \note Hopefully, sharing dictionaries should avoid * \par reloading an already loaded dictionary (saving time) * \par having many in memory representations of the same dictionary * (saving memory). */ -class GDCM_EXPORT gdcmDictSet +class GDCM_EXPORT DictSet { public: - gdcmDictSet(); - ~gdcmDictSet(); + DictSet(); + ~DictSet(); void Print(std::ostream& os); @@ -47,19 +49,19 @@ public: std::map > * GetPubDictEntryNamesByCategory(); - gdcmDict* LoadDictFromFile( std::string const & fileName, + Dict* LoadDictFromFile( std::string const & fileName, DictKey const & name ); - gdcmDict* GetDict( DictKey const & DictName ); + Dict* GetDict( DictKey const & DictName ); /// \brief Retrieve the default reference DICOM V3 public dictionary. - gdcmDict* GetDefaultPubDict() { return GetDict(PUB_DICT_NAME); }; + Dict* GetDefaultPubDict() { return GetDict(PUB_DICT_NAME); }; // \brief Retrieve the virtual reference DICOM dictionary. // \warning : not end user intended - // gdcmDict* GetVirtualDict() { return &VirtualEntry; }; + // Dict* GetVirtualDict() { return &VirtualEntry; }; - gdcmDictEntry* NewVirtualDictEntry(uint16_t group, uint16_t element, + DictEntry* NewVirtualDictEntry(uint16_t group, uint16_t element, std::string vr = "Unknown", std::string fourth = "Unknown", std::string name = "Unknown"); @@ -67,16 +69,17 @@ public: static std::string BuildDictPath(); protected: - bool AppendDict(gdcmDict *NewDict, DictKey const & name); + bool AppendDict(Dict *NewDict, DictKey const & name); private: - /// Hash table of all dictionaries contained in this gdcmDictSet + /// Hash table of all dictionaries contained in this DictSet DictSetHT Dicts; /// Directory path to dictionaries std::string DictPath; - /// H table for the on the fly created gdcmDictEntries + /// H table for the on the fly created DictEntries TagKeyHT VirtualEntry; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index d3a8b464..c04df60f 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:54 $ - Version: $Revision: 1.22 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.23 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -33,26 +33,28 @@ #include #include #endif +namespace gdcm +{ // Constructor / Destructor /** - * \ingroup gdcmDirList + * \ingroup DirList * \brief Constructor * @param dirName root directory name * @param recursive whether we want to explore recursively or not */ -gdcmDirList::gdcmDirList(std::string dirName, bool recursive) +DirList::DirList(std::string dirName, bool recursive) { name = dirName; - gdcmUtil::NormalizePath(name); + Util::NormalizePath(name); Explore(name, recursive); } /** - * \ingroup gdcmDirList + * \ingroup DirList * \brief Destructor */ -gdcmDirList::~gdcmDirList() +DirList::~DirList() { } @@ -62,11 +64,11 @@ gdcmDirList::~gdcmDirList() //----------------------------------------------------------------------------- // Public /** - * \ingroup gdcmDirList + * \ingroup DirList * \brief Get the directory name * @return the directory name */ -std::string gdcmDirList::GetDirName() +std::string DirList::GetDirName() { return name; } @@ -78,17 +80,17 @@ std::string gdcmDirList::GetDirName() // Private /** - * \ingroup gdcmDirList + * \ingroup DirList * \brief Explore a directory with possibility of recursion * return number of files read * @param dirName directory to explore * @param recursive whether we want recursion or not */ -int gdcmDirList::Explore(std::string dirName, bool recursive) +int DirList::Explore(std::string dirName, bool recursive) { int numberOfFiles = 0; std::string fileName; - gdcmUtil::NormalizePath(dirName); + Util::NormalizePath(dirName); #if defined(_MSC_VER) || (__CYGWIN__) WIN32_FIND_DATA fileData; HANDLE hFile=FindFirstFile((dirName+"*").c_str(),&fileData); @@ -158,5 +160,6 @@ int gdcmDirList::Explore(std::string dirName, bool recursive) return numberOfFiles; } +} // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 6926ff02..2174b8ba 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.h,v $ Language: C++ - Date: $Date: 2004/10/07 16:55:16 $ - Version: $Revision: 1.10 $ + Date: $Date: 2004/10/12 04:35:45 $ + 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 @@ -23,17 +23,19 @@ #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- /** - * \ingroup gdcmDirList + * \ingroup DirList * \brief List containing the file headers from root directory. */ -class GDCM_EXPORT gdcmDirList: public std::list +class GDCM_EXPORT DirList: public std::list { public : - gdcmDirList(std::string dirName,bool recursive=false); - virtual ~gdcmDirList(); + DirList(std::string dirName,bool recursive=false); + virtual ~DirList(); std::string GetDirName(); @@ -49,6 +51,6 @@ private : /// name of the root directory to explore std::string name; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 2d7cfa94..61cc9634 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:54 $ - Version: $Revision: 1.26 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.27 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,6 +22,8 @@ #include "gdcmUtil.h" #include // for std::ios::left, ... +namespace gdcm +{ // CLEAN ME #define MAX_SIZE_PRINT_ELEMENT_VALUE 64 @@ -29,14 +31,14 @@ //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmDocEntry - * \brief Constructor from a given gdcmDictEntry + * \ingroup DocEntry + * \brief Constructor from a given DictEntry * @param in Pointer to existing dictionary entry */ -gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) +DocEntry::DocEntry(DictEntry* in) { ImplicitVR = false; - DictEntry = in; + DicomDict = in; SetKey( in->GetKey( ) ); Offset = 0 ; // To avoid further missprinting } @@ -44,11 +46,11 @@ gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmDocEntry - * \brief Prints the common part of gdcmValEntry, gdcmBinEntry, gdcmSeqEntry + * \ingroup DocEntry + * \brief Prints the common part of ValEntry, BinEntry, SeqEntry * @param os ostream we want to print in */ -void gdcmDocEntry::Print(std::ostream& os) +void DocEntry::Print(std::ostream& os) { PrintLevel = 2; // FIXME @@ -65,7 +67,7 @@ void gdcmDocEntry::Print(std::ostream& os) o = GetOffset(); vr = GetVR(); - s << gdcmDictEntry::TranslateToKey(GetGroup(),GetElement()); + s << DictEntry::TranslateToKey(GetGroup(),GetElement()); if (PrintLevel >= 2) { @@ -73,7 +75,7 @@ void gdcmDocEntry::Print(std::ostream& os) lgth = GetReadLength(); // ReadLength, as opposed to UsableLength if (lgth == 0xffffffff) { - st = gdcmUtil::Format("x(ffff)"); // I said : "x(ffff)" ! + st = Util::Format("x(ffff)"); // I said : "x(ffff)" ! s.setf(std::ios::left); s << std::setw(10-st.size()) << " "; s << st << " "; @@ -82,7 +84,7 @@ void gdcmDocEntry::Print(std::ostream& os) } else { - st = gdcmUtil::Format("x(%x)",lgth); + st = Util::Format("x(%x)",lgth); s.setf(std::ios::left); s << std::setw(10-st.size()) << " "; s << st << " "; @@ -90,7 +92,7 @@ void gdcmDocEntry::Print(std::ostream& os) s << std::setw(8) << lgth; } s << " Off.: "; - st = gdcmUtil::Format("x(%x)",o); + st = Util::Format("x(%x)",o); s << std::setw(10-st.size()) << " "; s << st << " "; s << std::setw(8) << o; @@ -109,16 +111,16 @@ void gdcmDocEntry::Print(std::ostream& os) } /** - * \ingroup gdcmDocEntry - * \brief Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry + * \ingroup DocEntry + * \brief Writes the common part of any ValEntry, BinEntry, SeqEntry * @param fp already open file pointer * @param filetype type of the file to be written */ -void gdcmDocEntry::Write(FILE* fp, FileType filetype) +void DocEntry::Write(FILE* fp, FileType filetype) { uint32_t ffff = 0xffffffff; uint16_t group = GetGroup(); - gdcmVRKey vr = GetVR(); + VRKey vr = GetVR(); uint16_t el = GetElement(); uint32_t lgr = GetReadLength(); @@ -136,7 +138,7 @@ void gdcmDocEntry::Write(FILE* fp, FileType filetype) fwrite ( &group,(size_t)2 ,(size_t)1 ,fp); //group fwrite ( &el, (size_t)2 ,(size_t)1 ,fp); //element - if ( filetype == gdcmExplicitVR ) + if ( filetype == ExplicitVR ) { // Special case of delimiters: if (group == 0xfffe) @@ -208,11 +210,11 @@ void gdcmDocEntry::Write(FILE* fp, FileType filetype) // Public /** - * \ingroup gdcmDocEntry + * \ingroup DocEntry * \brief Gets the full length of the elementary DocEntry (not only value * length) depending on the VR. */ -uint32_t gdcmDocEntry::GetFullLength() +uint32_t DocEntry::GetFullLength() { uint32_t l = GetReadLength(); if ( IsImplicitVR() ) @@ -234,35 +236,35 @@ uint32_t gdcmDocEntry::GetFullLength() } /** - * \ingroup gdcmDocEntry + * \ingroup DocEntry * \brief Copies all the attributes from an other DocEntry */ -void gdcmDocEntry::Copy (gdcmDocEntry* e) +void DocEntry::Copy (DocEntry* e) { - DictEntry = e->DictEntry; + DicomDict = e->DicomDict; UsableLength = e->UsableLength; ReadLength = e->ReadLength; ImplicitVR = e->ImplicitVR; Offset = e->Offset; PrintLevel = e->PrintLevel; - // TODO : remove gdcmDocEntry SQDepth + // TODO : remove DocEntry SQDepth } /** - * \ingroup gdcmDocEntry + * \ingroup DocEntry * \brief tells us if entry is the last one of a 'no length' SequenceItem * (fffe,e00d) */ -bool gdcmDocEntry::IsItemDelimitor() +bool DocEntry::IsItemDelimitor() { return (GetGroup() == 0xfffe && GetElement() == 0xe00d); } /** - * \ingroup gdcmDocEntry + * \ingroup DocEntry * \brief tells us if entry is the last one of a 'no length' Sequence * (fffe,e0dd) */ -bool gdcmDocEntry::IsSequenceDelimitor() +bool DocEntry::IsSequenceDelimitor() { return (GetGroup() == 0xfffe && GetElement() == 0xe0dd); } @@ -275,3 +277,5 @@ bool gdcmDocEntry::IsSequenceDelimitor() // Private //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index 4acd164d..e3ea3ccf 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2004/10/08 04:52:55 $ - Version: $Revision: 1.24 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.25 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,43 +22,47 @@ #include "gdcmDictEntry.h" #include -class gdcmHeader; -class gdcmValEntry; -class gdcmBinEntry; -class gdcmSeqEntry; +class Header; +class ValEntry; +class BinEntry; +class SeqEntry; + +namespace gdcm +{ + //----------------------------------------------------------------------------- /** - * \ingroup gdcmDocEntry + * \ingroup DocEntry * \brief The dicom header of a Dicom file contains a set of such entries * (when successfuly parsed against a given Dicom dictionary) */ -class GDCM_EXPORT gdcmDocEntry +class GDCM_EXPORT DocEntry { public: - gdcmDocEntry(gdcmDictEntry*); - virtual ~gdcmDocEntry() {}; + DocEntry(DictEntry*); + virtual ~DocEntry() {}; /// Returns the Dicom Group number of the current Dicom Header Entry - uint16_t GetGroup() { return DictEntry->GetGroup(); }; + uint16_t GetGroup() { return DicomDict->GetGroup(); }; /// Returns the Dicom Element number of the current Dicom Header Entry - uint16_t GetElement() { return DictEntry->GetElement();}; + uint16_t GetElement() { return DicomDict->GetElement();}; /// Returns the 'key' of the current Dicom Header Entry - void SetKey( gdcmTagKey key ) { Key = key; } + void SetKey( TagKey key ) { Key = key; } /// Returns the 'key' of the current Dicom Header Entry std::string GetKey() { return Key; } /// \brief Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom /// Dictionnary of the current Dicom Header Entry - std::string GetName() { return DictEntry->GetName(); }; + std::string GetName() { return DicomDict->GetName(); }; /// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name, /// "SL" : Signed Long), found in the Dicom Header or in the Dicom /// Dictionnary, of the current Dicom Header Entry - std::string GetVR() { return DictEntry->GetVR(); }; + std::string GetVR() { return DicomDict->GetVR(); }; /// \brief Returns offset (since the beginning of the file, including /// the File Preamble, if any) of the value of the current Dicom HeaderEntry @@ -77,7 +81,7 @@ public: uint32_t GetReadLength() { return ReadLength; }; /// Sets the 'Value Representation' of the current Dicom Header Entry - void SetVR(std::string const & v) { DictEntry->SetVR(v); }; + void SetVR(std::string const & v) { DicomDict->SetVR(v); }; /// \brief Sets both 'Read Length' and 'Usable Length' of the current /// Dicom Header Entry @@ -107,15 +111,15 @@ public: /// \brief Tells us if the VR of the current Dicom Element is Unknown /// @return true if the VR is unknown - bool IsVRUnknown() { return DictEntry->IsVRUnknown(); }; + bool IsVRUnknown() { return DicomDict->IsVRUnknown(); }; /// \brief Sets the DicEntry of the current Dicom Element /// @param newEntry pointer to the DictEntry - void SetDictEntry(gdcmDictEntry *newEntry) { DictEntry = newEntry; }; + void SetDictEntry(DictEntry *newEntry) { DicomDict = newEntry; }; /// \brief Gets the DicEntry of the current Dicom Element /// @return The DicEntry of the current Dicom Element - gdcmDictEntry * GetDictEntry() { return DictEntry; }; + DictEntry * GetDictEntry() { return DicomDict; }; /// \brief Sets the print level for the Dicom Header Elements /// \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy @@ -129,21 +133,21 @@ public: uint32_t GetFullLength(); - void Copy(gdcmDocEntry *doc); + void Copy(DocEntry *doc); bool IsItemDelimitor(); bool IsSequenceDelimitor(); private: // FIXME: In fact we should be more specific and use : - // friend gdcmDocEntry * gdcmHeader::ReadNextElement(void); - friend class gdcmHeader; + // friend DocEntry * Header::ReadNextElement(void); + friend class Header; protected: // Variables /// \brief pointer to the underlying Dicom dictionary element - gdcmDictEntry *DictEntry; + DictEntry *DicomDict; /// \brief Updated from ReadLength, by FixFoungLentgh() for fixing a bug /// in the header or helping the parser going on @@ -165,10 +169,10 @@ protected: /// How many details are to be printed (value : 0,1,2) int PrintLevel; - /// \brief Generalized key (i.e. a gdcmBaseTagKey prepending a gdcmTagKey) - /// of this gdcmDocEntry - gdcmTagKey Key; + /// \brief Generalized key (i.e. a BaseTagKey prepending a TagKey) + /// of this DocEntry + TagKey Key; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index b1b43489..9e722cf0 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.23 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.24 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -15,17 +15,20 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ +#include "gdcmDocEntrySet.h" #include "gdcmDebug.h" #include "gdcmCommon.h" #include "gdcmGlobal.h" -#include "gdcmDocEntrySet.h" #include "gdcmException.h" #include "gdcmDocEntry.h" #include "gdcmSeqEntry.h" #include "gdcmValEntry.h" #include "gdcmBinEntry.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- // Public @@ -36,21 +39,21 @@ * @param group group number of the underlying DictEntry * @param elem element number of the underlying DictEntry */ -gdcmValEntry *gdcmDocEntrySet::NewValEntryByNumber(uint16_t group, - uint16_t elem) +ValEntry *DocEntrySet::NewValEntryByNumber(uint16_t group, + uint16_t elem) { // Find out if the tag we encountered is in the dictionaries: - gdcmDictEntry *dictEntry = GetDictEntryByNumber(group, elem); + DictEntry *dictEntry = GetDictEntryByNumber(group, elem); if (!dictEntry) { dictEntry = NewVirtualDictEntry(group, elem); } - gdcmValEntry *newEntry = new gdcmValEntry(dictEntry); + ValEntry *newEntry = new ValEntry(dictEntry); if (!newEntry) { - dbg.Verbose(1, "gdcmDocument::NewValEntryByNumber", - "failed to allocate gdcmValEntry"); + dbg.Verbose(1, "Document::NewValEntryByNumber", + "failed to allocate ValEntry"); return 0; } return newEntry; @@ -64,21 +67,21 @@ gdcmValEntry *gdcmDocEntrySet::NewValEntryByNumber(uint16_t group, * @param group group number of the underlying DictEntry * @param elem element number of the underlying DictEntry */ -gdcmBinEntry *gdcmDocEntrySet::NewBinEntryByNumber(uint16_t group, - uint16_t elem) +BinEntry *DocEntrySet::NewBinEntryByNumber(uint16_t group, + uint16_t elem) { // Find out if the tag we encountered is in the dictionaries: - gdcmDictEntry *dictEntry = GetDictEntryByNumber(group, elem); + DictEntry *dictEntry = GetDictEntryByNumber(group, elem); if (!dictEntry) { dictEntry = NewVirtualDictEntry(group, elem); } - gdcmBinEntry *newEntry = new gdcmBinEntry(dictEntry); + BinEntry *newEntry = new BinEntry(dictEntry); if (!newEntry) { - dbg.Verbose(1, "gdcmDocument::NewBinEntryByNumber", - "failed to allocate gdcmBinEntry"); + dbg.Verbose(1, "Document::NewBinEntryByNumber", + "failed to allocate BinEntry"); return 0; } return newEntry; @@ -91,21 +94,21 @@ gdcmBinEntry *gdcmDocEntrySet::NewBinEntryByNumber(uint16_t group, * @param Group group number of the underlying DictEntry * @param Elem element number of the underlying DictEntry */ -gdcmSeqEntry* gdcmDocEntrySet::NewSeqEntryByNumber(uint16_t Group, +SeqEntry* DocEntrySet::NewSeqEntryByNumber(uint16_t Group, uint16_t Elem) { // Find out if the tag we encountered is in the dictionaries: - gdcmDictEntry* DictEntry = GetDictEntryByNumber( Group, Elem ); + DictEntry* DictEntry = GetDictEntryByNumber( Group, Elem ); if ( ! DictEntry ) { DictEntry = NewVirtualDictEntry(Group, Elem); } - gdcmSeqEntry *NewEntry = new gdcmSeqEntry( DictEntry ); + SeqEntry *NewEntry = new SeqEntry( DictEntry ); if ( !NewEntry ) { - dbg.Verbose(1, "gdcmDocument::NewSeqEntryByNumber", - "failed to allocate gdcmSeqEntry"); + dbg.Verbose(1, "Document::NewSeqEntryByNumber", + "failed to allocate SeqEntry"); return 0; } return NewEntry; @@ -118,10 +121,10 @@ gdcmSeqEntry* gdcmDocEntrySet::NewSeqEntryByNumber(uint16_t Group, * \brief Gets a Dicom Element inside a SQ Item Entry, by name * @return */ - gdcmDocEntry *gdcmDocEntrySet::GetDocEntryByName(std::string const & name) + DocEntry *DocEntrySet::GetDocEntryByName(std::string const & name) { - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry *dictEntry = pubDict->GetDictEntryByName(name); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); + DictEntry *dictEntry = pubDict->GetDictEntryByName(name); if( !dictEntry ) { return 0; @@ -137,10 +140,10 @@ gdcmSeqEntry* gdcmDocEntrySet::NewSeqEntryByNumber(uint16_t Group, * @return */ -std::string gdcmDocEntrySet::GetEntryByName(TagName const & name) +std::string DocEntrySet::GetEntryByName(TagName const & name) { - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry *dictEntry = pubDict->GetDictEntryByName(name); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); + DictEntry *dictEntry = pubDict->GetDictEntryByName(name); if( !dictEntry ) { @@ -159,13 +162,13 @@ std::string gdcmDocEntrySet::GetEntryByName(TagName const & name) * @param fourth owner group * @param name english name */ -gdcmDictEntry* gdcmDocEntrySet::NewVirtualDictEntry(uint16_t group, +DictEntry* DocEntrySet::NewVirtualDictEntry(uint16_t group, uint16_t element, std::string const & vr, std::string const & fourth, std::string const & name) { - return gdcmGlobal::GetDicts()->NewVirtualDictEntry(group,element,vr,fourth,name); + return Global::GetDicts()->NewVirtualDictEntry(group,element,vr,fourth,name); } /** \brief @@ -173,22 +176,22 @@ gdcmDictEntry* gdcmDocEntrySet::NewVirtualDictEntry(uint16_t group, * @param group group number of the underlying DictEntry * @param elem elem number of the underlying DictEntry */ -gdcmDocEntry* gdcmDocEntrySet::NewDocEntryByNumber(uint16_t group, +DocEntry* DocEntrySet::NewDocEntryByNumber(uint16_t group, uint16_t elem) { // Find out if the tag we encountered is in the dictionaries: - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); + DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem); if (!dictEntry) { dictEntry = NewVirtualDictEntry(group, elem); } - gdcmDocEntry *newEntry = new gdcmDocEntry(dictEntry); + DocEntry *newEntry = new DocEntry(dictEntry); if (!newEntry) { - dbg.Verbose(1, "gdcmSQItem::NewDocEntryByNumber", - "failed to allocate gdcmDocEntry"); + dbg.Verbose(1, "SQItem::NewDocEntryByNumber", + "failed to allocate DocEntry"); return 0; } return newEntry; @@ -202,45 +205,45 @@ gdcmDocEntry* gdcmDocEntrySet::NewDocEntryByNumber(uint16_t group, * @param VR V(alue) R(epresentation) of the Entry -if private Entry- */ -gdcmDocEntry* gdcmDocEntrySet::NewDocEntryByNumber(uint16_t group, +DocEntry* DocEntrySet::NewDocEntryByNumber(uint16_t group, uint16_t elem, std::string const &VR) { // Find out if the tag we encountered is in the dictionaries: - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); + DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem); if (!dictEntry) { dictEntry = NewVirtualDictEntry(group, elem, VR); } - gdcmDocEntry *newEntry = new gdcmDocEntry(dictEntry); + DocEntry *newEntry = new DocEntry(dictEntry); if (!newEntry) { - dbg.Verbose(1, "gdcmSQItem::NewDocEntryByNumber", - "failed to allocate gdcmDocEntry"); + dbg.Verbose(1, "SQItem::NewDocEntryByNumber", + "failed to allocate DocEntry"); return 0; } return newEntry; } /* \brief - * Probabely move, as is, to gdcmDocEntrySet, as a non virtual method - * an remove gdcmDocument::NewDocEntryByName + * Probabely move, as is, to DocEntrySet, as a non virtual method + * an remove Document::NewDocEntryByName */ -gdcmDocEntry *gdcmDocEntrySet::NewDocEntryByName (std::string const & name) +DocEntry *DocEntrySet::NewDocEntryByName (std::string const & name) { - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry *newTag = pubDict->GetDictEntryByName(name); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); + DictEntry *newTag = pubDict->GetDictEntryByName(name); if (!newTag) { newTag = NewVirtualDictEntry(0xffff, 0xffff, "LO", "unkn", name); } - gdcmDocEntry* newEntry = new gdcmDocEntry(newTag); + DocEntry* newEntry = new DocEntry(newTag); if (!newEntry) { - dbg.Verbose(1, "gdcmSQItem::ObtainDocEntryByName", - "failed to allocate gdcmDocEntry"); + dbg.Verbose(1, "SQItem::ObtainDocEntryByName", + "failed to allocate DocEntry"); return 0; } @@ -255,13 +258,13 @@ gdcmDocEntry *gdcmDocEntrySet::NewDocEntryByName (std::string const & name) * @param name Name of the searched DictEntry * @return Corresponding DictEntry when it exists, NULL otherwise. */ -gdcmDictEntry *gdcmDocEntrySet::GetDictEntryByName(std::string const & name) +DictEntry *DocEntrySet::GetDictEntryByName(std::string const & name) { - gdcmDictEntry *found = 0; - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); + DictEntry *found = 0; + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); if (!pubDict) { - dbg.Verbose(0, "gdcmDocument::GetDictEntry", + dbg.Verbose(0, "Document::GetDictEntry", "we SHOULD have a default dictionary"); } else @@ -280,14 +283,14 @@ gdcmDictEntry *gdcmDocEntrySet::GetDictEntryByName(std::string const & name) * @param element element number of the searched DictEntry * @return Corresponding DictEntry when it exists, NULL otherwise. */ -gdcmDictEntry *gdcmDocEntrySet::GetDictEntryByNumber(uint16_t group, +DictEntry *DocEntrySet::GetDictEntryByNumber(uint16_t group, uint16_t element) { - gdcmDictEntry *found = 0; - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); + DictEntry *found = 0; + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); if (!pubDict) { - dbg.Verbose(0, "gdcmDocument::GetDictEntry", + dbg.Verbose(0, "Document::GetDictEntry", "we SHOULD have a default dictionary"); } else @@ -301,5 +304,6 @@ gdcmDictEntry *gdcmDocEntrySet::GetDictEntryByNumber(uint16_t group, //----------------------------------------------------------------------------- // Private +} // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index 21eadf8b..088aa255 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.19 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,41 +20,47 @@ #define GDCMDOCENTRYSET_H #include "gdcmException.h" -#include "gdcmDocEntry.h" - -typedef std::string gdcmBaseTagKey; + +namespace gdcm +{ +class DocEntry; +class ValEntry; +class BinEntry; +class SeqEntry; +class DictEntry; + +typedef std::string BaseTagKey; //----------------------------------------------------------------------------- /** - * \ref gdcmDocEntrySet is an abstract base class for \ref gdcmElementSet - * and \ref gdcmSQItem which are both containers for gdcmDocEntries. - * \ref gdcmElementSet is based on the STL map<> container - * (see \ref gdcmElementSet::TagHT), as opposed to \ref gdcmSQItem - * which is based on an STL list container (see \ref gdcmSQItem::docEntries). + * \ref DocEntrySet is an abstract base class for \ref ElementSet + * and \ref SQItem which are both containers for DocEntries. + * \ref ElementSet is based on the STL map<> container + * (see \ref ElementSet::TagHT), as opposed to \ref SQItem + * which is based on an STL list container (see \ref SQItem::docEntries). * Since the syntax for adding a new element to a map<> or a list<> - * differ, \ref gdcmDocEntrySet is designed as an adapter to unify the - * interfaces of \ref gdcmDocEntrySet and \ref gdcmElementSet. + * differ, \ref DocEntrySet is designed as an adapter to unify the + * interfaces of \ref DocEntrySet and \ref ElementSet. * As an illustration of this design, please refer to the implementation * of \ref AddEntry (or any pure virtual method) in both derived classes. * This adapter unification of interfaces enables the parsing of a * DICOM header containing (optionaly heavily nested) sequences to be - * written recursively [see \ref gdcmDocument::ParseDES - * which calls \ref gdcmDocument::ParseSQ, which in turns calls - * \ref gdcmDocument::ParseDES ]. + * written recursively [see \ref Document::ParseDES + * which calls \ref Document::ParseSQ, which in turns calls + * \ref Document::ParseDES ]. * * \note Developpers should strongly resist to the temptation of adding * members to this class since this class is designed as an adapter * in the form of an abstract base class. */ -class GDCM_EXPORT gdcmDocEntrySet +class GDCM_EXPORT DocEntrySet { public: - - gdcmDocEntrySet() {} - virtual ~gdcmDocEntrySet() {} + DocEntrySet() {}; + virtual ~DocEntrySet() {}; /// \brief adds any type of entry to the entry set (pure vitual) - virtual bool AddEntry(gdcmDocEntry *Entry) = 0; // pure virtual + virtual bool AddEntry(DocEntry *Entry) = 0; // pure virtual /// \brief prints any type of entry to the entry set (pure vitual) virtual void Print (std::ostream & os = std::cout) = 0;// pure virtual @@ -62,40 +68,40 @@ public: /// \brief write any type of entry to the entry set virtual void Write (FILE *fp, FileType filetype) = 0;// pure virtual - virtual gdcmDocEntry* GetDocEntryByNumber(uint16_t group, + virtual DocEntry* GetDocEntryByNumber(uint16_t group, uint16_t element) = 0; - gdcmDocEntry *GetDocEntryByName(std::string const & name); + DocEntry *GetDocEntryByName(std::string const & name); virtual std::string GetEntryByNumber(uint16_t group,uint16_t element) = 0; std::string GetEntryByName(TagName const & name); - gdcmDictEntry *NewVirtualDictEntry(uint16_t group, - uint16_t element, - std::string const & vr = "unkn", - std::string const & fourth = "unkn", - std::string const & name = "unkn"); + DictEntry *NewVirtualDictEntry(uint16_t group, + uint16_t element, + std::string const & vr = "unkn", + std::string const & fourth = "unkn", + std::string const & name = "unkn"); protected: // DocEntry related utilities - gdcmValEntry* NewValEntryByNumber(uint16_t group, - uint16_t element); - gdcmBinEntry* NewBinEntryByNumber(uint16_t group, - uint16_t element); - gdcmDocEntry* NewDocEntryByNumber(uint16_t group, - uint16_t element); - gdcmDocEntry* NewDocEntryByNumber(uint16_t group, - uint16_t element, - std::string const & VR); - gdcmDocEntry* NewDocEntryByName (std::string const & name); - gdcmSeqEntry* NewSeqEntryByNumber(uint16_t group, - uint16_t element); + ValEntry* NewValEntryByNumber(uint16_t group, + uint16_t element); + BinEntry* NewBinEntryByNumber(uint16_t group, + uint16_t element); + DocEntry* NewDocEntryByNumber(uint16_t group, + uint16_t element); + DocEntry* NewDocEntryByNumber(uint16_t group, + uint16_t element, + std::string const & VR); + DocEntry* NewDocEntryByName (std::string const & name); + SeqEntry* NewSeqEntryByNumber(uint16_t group, + uint16_t element); // DictEntry related utilities - gdcmDictEntry *GetDictEntryByName (std::string const & name); - gdcmDictEntry *GetDictEntryByNumber(uint16_t, uint16_t); + DictEntry *GetDictEntryByName (std::string const & name); + DictEntry *GetDictEntryByNumber(uint16_t, uint16_t); }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 7b8af5e2..9f181275 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 16:43:59 $ - Version: $Revision: 1.102 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.103 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,6 +35,9 @@ #include +namespace gdcm +{ + // Implicit VR Little Endian #define UI1_2_840_10008_1_2 "1.2.840.10008.1.2" // Explicit VR Little Endian @@ -68,12 +71,12 @@ #define str2num(str, typeNum) *((typeNum *)(str)) //----------------------------------------------------------------------------- -// Refer to gdcmDocument::CheckSwap() -const unsigned int gdcmDocument::HEADER_LENGTH_TO_READ = 256; +// Refer to Document::CheckSwap() +const unsigned int Document::HEADER_LENGTH_TO_READ = 256; -// Refer to gdcmDocument::SetMaxSizeLoadEntry() -const unsigned int gdcmDocument::MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff; // 4096 -const unsigned int gdcmDocument::MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff; +// Refer to Document::SetMaxSizeLoadEntry() +const unsigned int Document::MAX_SIZE_LOAD_ELEMENT_VALUE = 0xfff; // 4096 +const unsigned int Document::MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff; //----------------------------------------------------------------------------- // Constructor / Destructor @@ -82,8 +85,8 @@ const unsigned int gdcmDocument::MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff; * \brief constructor * @param filename file to be opened for parsing */ -gdcmDocument::gdcmDocument( std::string const & filename ) - : gdcmElementSet(-1) +Document::Document( std::string const & filename ) + : ElementSet(-1) { SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE); Filename = filename; @@ -94,7 +97,7 @@ gdcmDocument::gdcmDocument( std::string const & filename ) return; } - dbg.Verbose(0, "gdcmDocument::gdcmDocument: starting parsing of file: ", + dbg.Verbose(0, "Document::Document: starting parsing of file: ", Filename.c_str()); rewind(Fp); @@ -121,16 +124,16 @@ gdcmDocument::gdcmDocument( std::string const & filename ) /// defined as having an US Value Representation in the public /// dictionnary. BUT the semantics implied by the three following /// lines state that the corresponding tag contents are in fact - /// the ones of a gdcmBinEntry. + /// the ones of a BinEntry. /// In order to fix things "Quick and Dirty" the dictionnary was /// altered on PURPOUS but now contains a WRONG value. /// In order to fix things and restore the dictionary to its /// correct value, one needs to decided of the semantics by deciding /// wether the following tags are either: - /// - multivaluated US, and hence loaded as gdcmValEntry, but afterwards - /// also used as gdcmBinEntry, which requires the proper conversion, - /// - OW, and hence loaded as gdcmBinEntry, but afterwards also used - /// as gdcmValEntry, which requires the proper conversion. + /// - multivaluated US, and hence loaded as ValEntry, but afterwards + /// also used as BinEntry, which requires the proper conversion, + /// - OW, and hence loaded as BinEntry, but afterwards also used + /// as ValEntry, which requires the proper conversion. LoadEntryBinArea(0x0028,0x1201); // R LUT LoadEntryBinArea(0x0028,0x1202); // G LUT LoadEntryBinArea(0x0028,0x1203); // B LUT @@ -163,7 +166,7 @@ gdcmDocument::gdcmDocument( std::string const & filename ) RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares // with "little-endian strings" { - Filetype = gdcmACR_LIBIDO; + Filetype = ACR_LIBIDO; std::string rows = GetEntryByNumber(0x0028, 0x0010); std::string columns = GetEntryByNumber(0x0028, 0x0011); SetEntryByNumber(columns, 0x0028, 0x0010); @@ -176,10 +179,10 @@ gdcmDocument::gdcmDocument( std::string const & filename ) /** * \brief This default constructor doesn't parse the file. You should - * then invoke \ref gdcmDocument::SetFileName and then the parsing. + * then invoke \ref Document::SetFileName and then the parsing. */ -gdcmDocument::gdcmDocument() - :gdcmElementSet(-1) +Document::Document() + :ElementSet(-1) { SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE); Initialise(); @@ -189,7 +192,7 @@ gdcmDocument::gdcmDocument() /** * \brief Canonical destructor. */ -gdcmDocument::~gdcmDocument () +Document::~Document () { RefPubDict = NULL; RefShaDict = NULL; @@ -210,7 +213,7 @@ gdcmDocument::~gdcmDocument () * \brief Prints The Dict Entries of THE public Dicom Dictionary * @return */ -void gdcmDocument::PrintPubDict(std::ostream & os) +void Document::PrintPubDict(std::ostream & os) { RefPubDict->Print(os); } @@ -219,7 +222,7 @@ void gdcmDocument::PrintPubDict(std::ostream & os) * \brief Prints The Dict Entries of THE shadow Dicom Dictionary * @return */ -void gdcmDocument::PrintShaDict(std::ostream & os) +void Document::PrintShaDict(std::ostream & os) { RefShaDict->Print(os); } @@ -229,7 +232,7 @@ void gdcmDocument::PrintShaDict(std::ostream & os) /** * \brief Get the public dictionary used */ -gdcmDict* gdcmDocument::GetPubDict() +Dict* Document::GetPubDict() { return RefPubDict; } @@ -237,7 +240,7 @@ gdcmDict* gdcmDocument::GetPubDict() /** * \brief Get the shadow dictionary used */ -gdcmDict* gdcmDocument::GetShaDict() +Dict* Document::GetShaDict() { return RefShaDict; } @@ -246,7 +249,7 @@ gdcmDict* gdcmDocument::GetShaDict() * \brief Set the shadow dictionary used * \param dict dictionary to use in shadow */ -bool gdcmDocument::SetShaDict(gdcmDict *dict) +bool Document::SetShaDict(Dict *dict) { RefShaDict = dict; return !RefShaDict; @@ -256,31 +259,31 @@ bool gdcmDocument::SetShaDict(gdcmDict *dict) * \brief Set the shadow dictionary used * \param dictName name of the dictionary to use in shadow */ -bool gdcmDocument::SetShaDict(DictKey const & dictName) +bool Document::SetShaDict(DictKey const & dictName) { - RefShaDict = gdcmGlobal::GetDicts()->GetDict(dictName); + RefShaDict = Global::GetDicts()->GetDict(dictName); return !RefShaDict; } /** * \brief This predicate, based on hopefully reasonable heuristics, - * decides whether or not the current gdcmDocument was properly parsed + * decides whether or not the current Document was properly parsed * and contains the mandatory information for being considered as * a well formed and usable Dicom/Acr File. - * @return true when gdcmDocument is the one of a reasonable Dicom/Acr file, + * @return true when Document is the one of a reasonable Dicom/Acr file, * false otherwise. */ -bool gdcmDocument::IsReadable() +bool Document::IsReadable() { - if( Filetype == gdcmUnknown) + if( Filetype == Unknown) { - dbg.Verbose(0, "gdcmDocument::IsReadable: wrong filetype"); + dbg.Verbose(0, "Document::IsReadable: wrong filetype"); return false; } if( TagHT.empty() ) { - dbg.Verbose(0, "gdcmDocument::IsReadable: no tags in internal" + dbg.Verbose(0, "Document::IsReadable: no tags in internal" " hash table."); return false; } @@ -297,9 +300,9 @@ bool gdcmDocument::IsReadable() * the current document. False either when the document contains * no Transfer Syntax, or when the Tranfer Syntaxes doesn't match. */ -bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck) +bool Document::IsGivenTransferSyntax(std::string const & syntaxToCheck) { - gdcmDocEntry *entry = GetDocEntryByNumber(0x0002, 0x0010); + DocEntry *entry = GetDocEntryByNumber(0x0002, 0x0010); if ( !entry ) { return false; @@ -308,7 +311,7 @@ bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck) // The entry might be present but not loaded (parsing and loading // happen at different stages): try loading and proceed with check... LoadDocEntrySafe(entry); - if (gdcmValEntry* valEntry = dynamic_cast< gdcmValEntry* >(entry) ) + if (ValEntry* valEntry = dynamic_cast< ValEntry* >(entry) ) { std::string transfer = valEntry->GetValue(); // The actual transfer (as read from disk) might be padded. We @@ -333,10 +336,10 @@ bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck) * \brief Determines if the Transfer Syntax of the present document * corresponds to a Implicit Value Representation of * Little Endian. - * \sa \ref gdcmDocument::IsGivenTransferSyntax. + * \sa \ref Document::IsGivenTransferSyntax. * @return True when ImplicitVRLittleEndian found. False in all other cases. */ -bool gdcmDocument::IsImplicitVRLittleEndianTransferSyntax() +bool Document::IsImplicitVRLittleEndianTransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2); } @@ -346,7 +349,7 @@ bool gdcmDocument::IsImplicitVRLittleEndianTransferSyntax() * and if it corresponds to a ExplicitVRLittleEndian one. * @return True when ExplicitVRLittleEndian found. False in all other cases. */ -bool gdcmDocument::IsExplicitVRLittleEndianTransferSyntax() +bool Document::IsExplicitVRLittleEndianTransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_1); } @@ -356,7 +359,7 @@ bool gdcmDocument::IsExplicitVRLittleEndianTransferSyntax() * and if it corresponds to a DeflatedExplicitVRLittleEndian one. * @return True when DeflatedExplicitVRLittleEndian found. False in all other cases. */ -bool gdcmDocument::IsDeflatedExplicitVRLittleEndianTransferSyntax() +bool Document::IsDeflatedExplicitVRLittleEndianTransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_1_99); } @@ -366,7 +369,7 @@ bool gdcmDocument::IsDeflatedExplicitVRLittleEndianTransferSyntax() * and if it corresponds to a Explicit VR Big Endian one. * @return True when big endian found. False in all other cases. */ -bool gdcmDocument::IsExplicitVRBigEndianTransferSyntax() +bool Document::IsExplicitVRBigEndianTransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_2); } @@ -376,7 +379,7 @@ bool gdcmDocument::IsExplicitVRBigEndianTransferSyntax() * and if it corresponds to a JPEGBaseLineProcess1 one. * @return True when JPEGBaseLineProcess1found. False in all other cases. */ -bool gdcmDocument::IsJPEGBaseLineProcess1TransferSyntax() +bool Document::IsJPEGBaseLineProcess1TransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_50); } @@ -386,7 +389,7 @@ bool gdcmDocument::IsJPEGBaseLineProcess1TransferSyntax() * and if it corresponds to a JPEGExtendedProcess2-4 one. * @return True when JPEGExtendedProcess2-4 found. False in all other cases. */ -bool gdcmDocument::IsJPEGExtendedProcess2_4TransferSyntax() +bool Document::IsJPEGExtendedProcess2_4TransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_51); } @@ -396,7 +399,7 @@ bool gdcmDocument::IsJPEGExtendedProcess2_4TransferSyntax() * and if it corresponds to a JPEGExtendeProcess3-5 one. * @return True when JPEGExtendedProcess3-5 found. False in all other cases. */ -bool gdcmDocument::IsJPEGExtendedProcess3_5TransferSyntax() +bool Document::IsJPEGExtendedProcess3_5TransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_52); } @@ -407,7 +410,7 @@ bool gdcmDocument::IsJPEGExtendedProcess3_5TransferSyntax() * @return True when JPEGSpectralSelectionProcess6-8 found. False in all * other cases. */ -bool gdcmDocument::IsJPEGSpectralSelectionProcess6_8TransferSyntax() +bool Document::IsJPEGSpectralSelectionProcess6_8TransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_53); } @@ -418,7 +421,7 @@ bool gdcmDocument::IsJPEGSpectralSelectionProcess6_8TransferSyntax() * @return True when RLE Lossless found. False in all * other cases. */ -bool gdcmDocument::IsRLELossLessTransferSyntax() +bool Document::IsRLELossLessTransferSyntax() { return IsGivenTransferSyntax(UI1_2_840_10008_1_2_5); } @@ -430,7 +433,7 @@ bool gdcmDocument::IsRLELossLessTransferSyntax() * other cases. */ -bool gdcmDocument::IsJPEGLossless() +bool Document::IsJPEGLossless() { return ( IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_55) || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_57) @@ -443,7 +446,7 @@ bool gdcmDocument::IsJPEGLossless() * @return True when JPEG2000 (Lossly or LossLess) found. False in all * other cases. */ -bool gdcmDocument::IsJPEG2000() +bool Document::IsJPEG2000() { return ( IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_90) || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_91) ); @@ -454,7 +457,7 @@ bool gdcmDocument::IsJPEG2000() * of Jpeg encoded Pixel data. * @return True when any form of JPEG found. False otherwise. */ -bool gdcmDocument::IsJPEGTransferSyntax() +bool Document::IsJPEGTransferSyntax() { return ( IsJPEGBaseLineProcess1TransferSyntax() || IsJPEGExtendedProcess2_4TransferSyntax() @@ -470,7 +473,7 @@ bool gdcmDocument::IsJPEGTransferSyntax() * of encoded Pixel Data (as opposed to native). * @return True when encapsulated. False when native. */ -bool gdcmDocument::IsEncapsulateTransferSyntax() +bool Document::IsEncapsulateTransferSyntax() { return ( IsJPEGTransferSyntax() || IsRLELossLessTransferSyntax() ); @@ -480,7 +483,7 @@ bool gdcmDocument::IsEncapsulateTransferSyntax() * \brief Predicate for dicom version 3 file. * @return True when the file is a dicom version 3. */ -bool gdcmDocument::IsDicomV3() +bool Document::IsDicomV3() { // Checking if Transfert Syntax exists is enough // Anyway, it's to late check if the 'Preamble' was found ... @@ -494,24 +497,24 @@ bool gdcmDocument::IsDicomV3() * (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown) * @return the FileType code */ -FileType gdcmDocument::GetFileType() +FileType Document::GetFileType() { return Filetype; } /** - * \brief Tries to open the file \ref gdcmDocument::Filename and + * \brief Tries to open the file \ref Document::Filename and * checks the preamble when existing. * @return The FILE pointer on success. */ -FILE* gdcmDocument::OpenFile() +FILE* Document::OpenFile() { Fp = fopen(Filename.c_str(),"rb"); if(!Fp) { dbg.Verbose( 0, - "gdcmDocument::OpenFile cannot open file: ", + "Document::OpenFile cannot open file: ", Filename.c_str()); return 0; } @@ -536,7 +539,7 @@ FILE* gdcmDocument::OpenFile() fclose(Fp); dbg.Verbose( 0, - "gdcmDocument::OpenFile not DICOM/ACR (missing preamble)", + "Document::OpenFile not DICOM/ACR (missing preamble)", Filename.c_str()); return 0; @@ -546,7 +549,7 @@ FILE* gdcmDocument::OpenFile() * \brief closes the file * @return TRUE if the close was successfull */ -bool gdcmDocument::CloseFile() +bool Document::CloseFile() { int closed = fclose(Fp); Fp = 0; @@ -561,14 +564,14 @@ bool gdcmDocument::CloseFile() * (ACR-NEMA, ExplicitVR, ImplicitVR) * \return Always true. */ -void gdcmDocument::Write(FILE* fp,FileType filetype) +void Document::Write(FILE* fp,FileType filetype) { /// \todo move the following lines (and a lot of others, to be written) /// to a future function CheckAndCorrectHeader /// (necessary if user wants to write a DICOM V3 file - /// starting from an ACR-NEMA (V2) gdcmHeader + /// starting from an ACR-NEMA (V2) Header - if (filetype == gdcmImplicitVR) + if (filetype == ImplicitVR) { std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2; ReplaceOrCreateByNumber(implicitVRTransfertSyntax,0x0002, 0x0010); @@ -581,7 +584,7 @@ void gdcmDocument::Write(FILE* fp,FileType filetype) SetEntryLengthByNumber(18, 0x0002, 0x0010); } - if (filetype == gdcmExplicitVR) + if (filetype == ExplicitVR) { std::string explicitVRTransfertSyntax = UI1_2_840_10008_1_2_1; ReplaceOrCreateByNumber(explicitVRTransfertSyntax,0x0002, 0x0010); @@ -606,7 +609,7 @@ void gdcmDocument::Write(FILE* fp,FileType filetype) * UpdateGroupLength(true,ACR); */ - gdcmElementSet::Write(fp, filetype); // This one is recursive + ElementSet::Write(fp, filetype); // This one is recursive } @@ -620,24 +623,24 @@ void gdcmDocument::Write(FILE* fp,FileType filetype) * \return pointer to the modified/created Header Entry (NULL when creation * failed). */ -gdcmValEntry* gdcmDocument::ReplaceOrCreateByNumber( +ValEntry* Document::ReplaceOrCreateByNumber( std::string const & value, uint16_t group, uint16_t elem, std::string const & VR ) { - gdcmValEntry* valEntry = 0; - gdcmDocEntry* currentEntry = GetDocEntryByNumber( group, elem); + ValEntry* valEntry = 0; + DocEntry* currentEntry = GetDocEntryByNumber( group, elem); if (!currentEntry) { // check if (group,element) DictEntry exists - // if it doesn't, create an entry in gdcmDictSet::VirtualEntry + // if it doesn't, create an entry in DictSet::VirtualEntry // and use it // Find out if the tag we received is in the dictionaries: - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry* dictEntry = pubDict->GetDictEntryByNumber(group, elem); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); + DictEntry* dictEntry = pubDict->GetDictEntryByNumber(group, elem); if (!dictEntry) { currentEntry = NewDocEntryByNumber(group, elem,VR); @@ -649,35 +652,35 @@ gdcmValEntry* gdcmDocument::ReplaceOrCreateByNumber( if (!currentEntry) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: call to" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: call to" " NewDocEntryByNumber failed."); return NULL; } - valEntry = new gdcmValEntry(currentEntry); + valEntry = new ValEntry(currentEntry); if ( !AddEntry(valEntry)) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: AddEntry" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry" " failed allthough this is a creation."); } } else { - valEntry = dynamic_cast< gdcmValEntry* >(currentEntry); + valEntry = dynamic_cast< ValEntry* >(currentEntry); if ( !valEntry ) // Euuuuh? It wasn't a ValEntry // then we change it to a ValEntry ? // Shouldn't it be considered as an error ? { - // We need to promote the gdcmDocEntry to a gdcmValEntry: - valEntry = new gdcmValEntry(currentEntry); + // We need to promote the DocEntry to a ValEntry: + valEntry = new ValEntry(currentEntry); if (!RemoveEntry(currentEntry)) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: removal" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: removal" " of previous DocEntry failed."); return NULL; } if ( !AddEntry(valEntry)) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: adding" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: adding" " promoted ValEntry failed."); return NULL; } @@ -698,25 +701,25 @@ gdcmValEntry* gdcmDocument::ReplaceOrCreateByNumber( * \return pointer to the modified/created Header Entry (NULL when creation * failed). */ -gdcmBinEntry* gdcmDocument::ReplaceOrCreateByNumber( +BinEntry* Document::ReplaceOrCreateByNumber( uint8_t* binArea, int lgth, uint16_t group, uint16_t elem, std::string const& VR ) { - gdcmBinEntry* binEntry = 0; - gdcmDocEntry* currentEntry = GetDocEntryByNumber( group, elem); + BinEntry* binEntry = 0; + DocEntry* currentEntry = GetDocEntryByNumber( group, elem); if (!currentEntry) { // check if (group,element) DictEntry exists - // if it doesn't, create an entry in gdcmDictSet::VirtualEntry + // if it doesn't, create an entry in DictSet::VirtualEntry // and use it // Find out if the tag we received is in the dictionaries: - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); + DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem); if (!dictEntry) { @@ -728,35 +731,35 @@ gdcmBinEntry* gdcmDocument::ReplaceOrCreateByNumber( } if (!currentEntry) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: call to" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: call to" " NewDocEntryByNumber failed."); return NULL; } - binEntry = new gdcmBinEntry(currentEntry); + binEntry = new BinEntry(currentEntry); if ( !AddEntry(binEntry)) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: AddEntry" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry" " failed allthough this is a creation."); } } else { - binEntry = dynamic_cast< gdcmBinEntry* >(currentEntry); + binEntry = dynamic_cast< BinEntry* >(currentEntry); if ( !binEntry ) // Euuuuh? It wasn't a BinEntry // then we change it to a BinEntry ? // Shouldn't it be considered as an error ? { - // We need to promote the gdcmDocEntry to a gdcmBinEntry: - binEntry = new gdcmBinEntry(currentEntry); + // We need to promote the DocEntry to a BinEntry: + binEntry = new BinEntry(currentEntry); if (!RemoveEntry(currentEntry)) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: removal" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: removal" " of previous DocEntry failed."); return NULL; } if ( !AddEntry(binEntry)) { - dbg.Verbose(0, "gdcmDocument::ReplaceOrCreateByNumber: adding" + dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: adding" " promoted BinEntry failed."); return NULL; } @@ -777,12 +780,12 @@ gdcmBinEntry* gdcmDocument::ReplaceOrCreateByNumber( * \return pointer to the modified/created SeqEntry (NULL when creation * failed). */ -gdcmSeqEntry* gdcmDocument::ReplaceOrCreateByNumber( +SeqEntry* Document::ReplaceOrCreateByNumber( uint16_t group, uint16_t elem) { - gdcmSeqEntry* b = 0; - gdcmDocEntry* a = GetDocEntryByNumber( group, elem); + SeqEntry* b = 0; + DocEntry* a = GetDocEntryByNumber( group, elem); if (!a) { a = NewSeqEntryByNumber(group, elem); @@ -791,7 +794,7 @@ gdcmSeqEntry* gdcmDocument::ReplaceOrCreateByNumber( return 0; } - b = new gdcmSeqEntry(a, 1); // FIXME : 1 (Depth) + b = new SeqEntry(a, 1); // FIXME : 1 (Depth) AddEntry(b); } return b; @@ -805,7 +808,7 @@ gdcmSeqEntry* gdcmDocument::ReplaceOrCreateByNumber( * @param elem element number of the Entry * \return boolean */ -bool gdcmDocument::ReplaceIfExistByNumber(std::string const & value, +bool Document::ReplaceIfExistByNumber(std::string const & value, uint16_t group, uint16_t elem ) { SetEntryByNumber(value, group, elem); @@ -822,9 +825,9 @@ bool gdcmDocument::ReplaceIfExistByNumber(std::string const & value, * @param element Element number of the searched Dicom Element * @return true is found */ -bool gdcmDocument::CheckIfEntryExistByNumber(uint16_t group, uint16_t element ) +bool Document::CheckIfEntryExistByNumber(uint16_t group, uint16_t element ) { - const std::string &key = gdcmDictEntry::TranslateToKey(group, element ); + const std::string &key = DictEntry::TranslateToKey(group, element ); return TagHT.count(key); } @@ -837,9 +840,9 @@ bool gdcmDocument::CheckIfEntryExistByNumber(uint16_t group, uint16_t element ) * @return Corresponding element value when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmDocument::GetEntryByName(TagName const& tagName) +std::string Document::GetEntryByName(TagName const& tagName) { - gdcmDictEntry* dictEntry = RefPubDict->GetDictEntryByName(tagName); + DictEntry* dictEntry = RefPubDict->GetDictEntryByName(tagName); if( !dictEntry ) { return GDCM_UNFOUND; @@ -861,15 +864,15 @@ std::string gdcmDocument::GetEntryByName(TagName const& tagName) * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmDocument::GetEntryVRByName(TagName const& tagName) +std::string Document::GetEntryVRByName(TagName const& tagName) { - gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName); + DictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName); if( dictEntry == NULL) { return GDCM_UNFOUND; } - gdcmDocEntry* elem = GetDocEntryByNumber(dictEntry->GetGroup(), + DocEntry* elem = GetDocEntryByNumber(dictEntry->GetGroup(), dictEntry->GetElement()); return elem->GetVR(); } @@ -883,16 +886,16 @@ std::string gdcmDocument::GetEntryVRByName(TagName const& tagName) * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmDocument::GetEntryByNumber(uint16_t group, uint16_t element) +std::string Document::GetEntryByNumber(uint16_t group, uint16_t element) { - gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element); + TagKey key = DictEntry::TranslateToKey(group, element); /// \todo use map methods, instead of multimap JPR if ( !TagHT.count(key)) { return GDCM_UNFOUND; } - return ((gdcmValEntry *)TagHT.find(key)->second)->GetValue(); + return ((ValEntry *)TagHT.find(key)->second)->GetValue(); } /** @@ -909,9 +912,9 @@ std::string gdcmDocument::GetEntryByNumber(uint16_t group, uint16_t element) * @return Corresponding element value representation when it exists, * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. */ -std::string gdcmDocument::GetEntryVRByNumber(uint16_t group, uint16_t element) +std::string Document::GetEntryVRByNumber(uint16_t group, uint16_t element) { - gdcmDocEntry* elem = GetDocEntryByNumber(group, element); + DocEntry* elem = GetDocEntryByNumber(group, element); if ( !elem ) { return GDCM_UNFOUND; @@ -927,9 +930,9 @@ std::string gdcmDocument::GetEntryVRByNumber(uint16_t group, uint16_t element) * @param element Element number of the searched tag. * @return Corresponding element length; -2 if not found */ -int gdcmDocument::GetEntryLengthByNumber(uint16_t group, uint16_t element) +int Document::GetEntryLengthByNumber(uint16_t group, uint16_t element) { - gdcmDocEntry* elem = GetDocEntryByNumber(group, element); + DocEntry* elem = GetDocEntryByNumber(group, element); if ( !elem ) { return -2; //magic number @@ -942,9 +945,9 @@ int gdcmDocument::GetEntryLengthByNumber(uint16_t group, uint16_t element) * @param tagName name of the searched Dicom Element. * @return true when found */ -bool gdcmDocument::SetEntryByName(std::string const & content,std::string const & tagName) +bool Document::SetEntryByName(std::string const & content,std::string const & tagName) { - gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName); + DictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName); if( !dictEntry ) { return false; @@ -955,24 +958,24 @@ bool gdcmDocument::SetEntryByName(std::string const & content,std::string const } /** - * \brief Accesses an existing gdcmDocEntry (i.e. a Dicom Element) + * \brief Accesses an existing DocEntry (i.e. a Dicom Element) * through it's (group, element) and modifies it's content with * the given value. * @param content new value (string) to substitute with * @param group group number of the Dicom Element to modify * @param element element number of the Dicom Element to modify */ -bool gdcmDocument::SetEntryByNumber(std::string const& content, +bool Document::SetEntryByNumber(std::string const& content, uint16_t group, uint16_t element) { int c; int l; - gdcmValEntry* valEntry = GetValEntryByNumber(group, element); + ValEntry* valEntry = GetValEntryByNumber(group, element); if (!valEntry ) { - dbg.Verbose(0, "gdcmDocument::SetEntryByNumber: no corresponding", + dbg.Verbose(0, "Document::SetEntryByNumber: no corresponding", " ValEntry (try promotion first)."); return false; } @@ -989,17 +992,17 @@ bool gdcmDocument::SetEntryByNumber(std::string const& content, l = finalContent.length(); if ( l != 0) // To avoid to be cheated by 'zero length' integers { - gdcmVRKey vr = valEntry->GetVR(); + VRKey vr = valEntry->GetVR(); if( vr == "US" || vr == "SS" ) { // for multivaluated items - c = gdcmUtil::CountSubstring(content, "\\") + 1; + c = Util::CountSubstring(content, "\\") + 1; l = c*2; } else if( vr == "UL" || vr == "SL" ) { // for multivaluated items - c = gdcmUtil::CountSubstring(content, "\\") + 1; + c = Util::CountSubstring(content, "\\") + 1; l = c*4;; } } @@ -1008,7 +1011,7 @@ bool gdcmDocument::SetEntryByNumber(std::string const& content, } /** - * \brief Accesses an existing gdcmDocEntry (i.e. a Dicom Element) + * \brief Accesses an existing DocEntry (i.e. a Dicom Element) * through it's (group, element) and modifies it's content with * the given value. * @param content new value (void* -> uint8_t*) to substitute with @@ -1016,13 +1019,13 @@ bool gdcmDocument::SetEntryByNumber(std::string const& content, * @param group group number of the Dicom Element to modify * @param element element number of the Dicom Element to modify */ -bool gdcmDocument::SetEntryByNumber(uint8_t*content, +bool Document::SetEntryByNumber(uint8_t*content, int lgth, uint16_t group, uint16_t element) { (void)lgth; //not used - gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element); + TagKey key = DictEntry::TranslateToKey(group, element); if ( !TagHT.count(key)) { return false; @@ -1035,7 +1038,7 @@ bool gdcmDocument::SetEntryByNumber(uint8_t*content, //content = content + '\0'; // fing a trick to enlarge a binary field? } */ - gdcmBinEntry* a = (gdcmBinEntry *)TagHT[key]; + BinEntry* a = (BinEntry *)TagHT[key]; a->SetBinArea(content); a->SetLength(lgth); a->SetValue(GDCM_BINLOADED); @@ -1044,7 +1047,7 @@ bool gdcmDocument::SetEntryByNumber(uint8_t*content, } /** - * \brief Accesses an existing gdcmDocEntry (i.e. a Dicom Element) + * \brief Accesses an existing DocEntry (i.e. a Dicom Element) * in the PubDocEntrySet of this instance * through it's (group, element) and modifies it's length with * the given value. @@ -1054,12 +1057,12 @@ bool gdcmDocument::SetEntryByNumber(uint8_t*content, * @param element element number of the Entry to modify * @return true on success, false otherwise. */ -bool gdcmDocument::SetEntryLengthByNumber(uint32_t l, +bool Document::SetEntryLengthByNumber(uint32_t l, uint16_t group, uint16_t element) { /// \todo use map methods, instead of multimap JPR - gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element); + TagKey key = DictEntry::TranslateToKey(group, element); if ( !TagHT.count(key) ) { return false; @@ -1080,12 +1083,12 @@ bool gdcmDocument::SetEntryLengthByNumber(uint32_t l, * @param elem element number of the Entry * @return File Offset of the Element Value */ -size_t gdcmDocument::GetEntryOffsetByNumber(uint16_t group, uint16_t elem) +size_t Document::GetEntryOffsetByNumber(uint16_t group, uint16_t elem) { - gdcmDocEntry* entry = GetDocEntryByNumber(group, elem); + DocEntry* entry = GetDocEntryByNumber(group, elem); if (!entry) { - dbg.Verbose(1, "gdcmDocument::GetDocEntryByNumber: no entry present."); + dbg.Verbose(1, "Document::GetDocEntryByNumber: no entry present."); return 0; } return entry->GetOffset(); @@ -1098,15 +1101,15 @@ size_t gdcmDocument::GetEntryOffsetByNumber(uint16_t group, uint16_t elem) * @param elem element number of the Entry * @return Pointer to the 'non string' area */ -void* gdcmDocument::GetEntryBinAreaByNumber(uint16_t group, uint16_t elem) +void* Document::GetEntryBinAreaByNumber(uint16_t group, uint16_t elem) { - gdcmDocEntry* entry = GetDocEntryByNumber(group, elem); + DocEntry* entry = GetDocEntryByNumber(group, elem); if (!entry) { - dbg.Verbose(1, "gdcmDocument::GetDocEntryByNumber: no entry"); + dbg.Verbose(1, "Document::GetDocEntryByNumber: no entry"); return 0; } - return ((gdcmBinEntry *)entry)->GetBinArea(); + return ((BinEntry *)entry)->GetBinArea(); } /** @@ -1115,9 +1118,9 @@ void* gdcmDocument::GetEntryBinAreaByNumber(uint16_t group, uint16_t elem) * @param group group number of the Entry * @param elem element number of the Entry */ -void* gdcmDocument::LoadEntryBinArea(uint16_t group, uint16_t elem) +void* Document::LoadEntryBinArea(uint16_t group, uint16_t elem) { - gdcmDocEntry *docElement = GetDocEntryByNumber(group, elem); + DocEntry *docElement = GetDocEntryByNumber(group, elem); if ( !docElement ) { return NULL; @@ -1128,7 +1131,7 @@ void* gdcmDocument::LoadEntryBinArea(uint16_t group, uint16_t elem) uint8_t* a = new uint8_t[l]; if(!a) { - dbg.Verbose(0, "gdcmDocument::LoadEntryBinArea cannot allocate a"); + dbg.Verbose(0, "Document::LoadEntryBinArea cannot allocate a"); return NULL; } size_t l2 = fread(a, 1, l , Fp); @@ -1140,7 +1143,7 @@ void* gdcmDocument::LoadEntryBinArea(uint16_t group, uint16_t elem) /// \todo Drop any already existing void area! JPR if( !SetEntryBinAreaByNumber( a, group, elem ) ); { - dbg.Verbose(0, "gdcmDocument::LoadEntryBinArea setting failed."); + dbg.Verbose(0, "Document::LoadEntryBinArea setting failed."); } return a; } @@ -1149,7 +1152,7 @@ void* gdcmDocument::LoadEntryBinArea(uint16_t group, uint16_t elem) * when a string is not suitable * @param element Entry whose binArea is going to be loaded */ -void* gdcmDocument::LoadEntryBinArea(gdcmBinEntry* element) +void* Document::LoadEntryBinArea(BinEntry* element) { size_t o =(size_t)element->GetOffset(); fseek(Fp, o, SEEK_SET); @@ -1157,7 +1160,7 @@ void* gdcmDocument::LoadEntryBinArea(gdcmBinEntry* element) uint8_t* a = new uint8_t[l]; if( !a ) { - dbg.Verbose(0, "gdcmDocument::LoadEntryBinArea cannot allocate a"); + dbg.Verbose(0, "Document::LoadEntryBinArea cannot allocate a"); return NULL; } element->SetBinArea((uint8_t*)a); @@ -1179,16 +1182,16 @@ void* gdcmDocument::LoadEntryBinArea(gdcmBinEntry* element) * @param element Element number of the searched Dicom Element * @return */ -bool gdcmDocument::SetEntryBinAreaByNumber(uint8_t* area, +bool Document::SetEntryBinAreaByNumber(uint8_t* area, uint16_t group, uint16_t element) { - gdcmDocEntry* currentEntry = GetDocEntryByNumber(group, element); + DocEntry* currentEntry = GetDocEntryByNumber(group, element); if ( !currentEntry ) { return false; } - if ( gdcmBinEntry* binEntry = dynamic_cast(currentEntry) ) + if ( BinEntry* binEntry = dynamic_cast(currentEntry) ) { binEntry->SetBinArea( area ); return true; @@ -1200,9 +1203,9 @@ bool gdcmDocument::SetEntryBinAreaByNumber(uint8_t* area, * \brief Update the entries with the shadow dictionary. * Only non even entries are analyzed */ -void gdcmDocument::UpdateShaEntries() +void Document::UpdateShaEntries() { - //gdcmDictEntry *entry; + //DictEntry *entry; std::string vr; /// \todo TODO : still any use to explore recursively the whole structure? @@ -1251,9 +1254,9 @@ void gdcmDocument::UpdateShaEntries() * @return Corresponding Dicom Element when it exists, and NULL * otherwise. */ -gdcmDocEntry* gdcmDocument::GetDocEntryByName(std::string const & tagName) +DocEntry* Document::GetDocEntryByName(std::string const & tagName) { - gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName); + DictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName); if( !dictEntry ) { return NULL; @@ -1272,10 +1275,10 @@ gdcmDocEntry* gdcmDocument::GetDocEntryByName(std::string const & tagName) * @param element Element number of the searched Dicom Element * @return */ -gdcmDocEntry* gdcmDocument::GetDocEntryByNumber(uint16_t group, +DocEntry* Document::GetDocEntryByNumber(uint16_t group, uint16_t element) { - gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element); + TagKey key = DictEntry::TranslateToKey(group, element); if ( !TagHT.count(key)) { return NULL; @@ -1284,24 +1287,24 @@ gdcmDocEntry* gdcmDocument::GetDocEntryByNumber(uint16_t group, } /** - * \brief Same as \ref gdcmDocument::GetDocEntryByNumber except it only + * \brief Same as \ref Document::GetDocEntryByNumber except it only * returns a result when the corresponding entry is of type * ValEntry. * @return When present, the corresponding ValEntry. */ -gdcmValEntry* gdcmDocument::GetValEntryByNumber(uint16_t group, +ValEntry* Document::GetValEntryByNumber(uint16_t group, uint16_t element) { - gdcmDocEntry* currentEntry = GetDocEntryByNumber(group, element); + DocEntry* currentEntry = GetDocEntryByNumber(group, element); if ( !currentEntry ) { return 0; } - if ( gdcmValEntry* valEntry = dynamic_cast(currentEntry) ) + if ( ValEntry* valEntry = dynamic_cast(currentEntry) ) { return valEntry; } - dbg.Verbose(0, "gdcmDocument::GetValEntryByNumber: unfound ValEntry."); + dbg.Verbose(0, "Document::GetValEntryByNumber: unfound ValEntry."); return 0; } @@ -1313,7 +1316,7 @@ gdcmValEntry* gdcmDocument::GetValEntryByNumber(uint16_t group, * @param entry Header Entry whose value shall be loaded. * @return */ -void gdcmDocument::LoadDocEntrySafe(gdcmDocEntry * entry) +void Document::LoadDocEntrySafe(DocEntry * entry) { long PositionOnEntry = ftell(Fp); LoadDocEntry(entry); @@ -1325,7 +1328,7 @@ void gdcmDocument::LoadDocEntrySafe(gdcmDocEntry * entry) * processor order. * @return The properly swaped 32 bits integer. */ -uint32_t gdcmDocument::SwapLong(uint32_t a) +uint32_t Document::SwapLong(uint32_t a) { switch (SwapCode) { @@ -1345,7 +1348,7 @@ uint32_t gdcmDocument::SwapLong(uint32_t a) break; default : //std::cout << "swapCode= " << SwapCode << std::endl; - dbg.Error(" gdcmDocument::SwapLong : unset swap code"); + dbg.Error(" Document::SwapLong : unset swap code"); a = 0; } return a; @@ -1356,7 +1359,7 @@ uint32_t gdcmDocument::SwapLong(uint32_t a) * processor order. * @return The properly unswaped 32 bits integer. */ -uint32_t gdcmDocument::UnswapLong(uint32_t a) +uint32_t Document::UnswapLong(uint32_t a) { return SwapLong(a); } @@ -1365,7 +1368,7 @@ uint32_t gdcmDocument::UnswapLong(uint32_t a) * \brief Swaps the bytes so they agree with the processor order * @return The properly swaped 16 bits integer. */ -uint16_t gdcmDocument::SwapShort(uint16_t a) +uint16_t Document::SwapShort(uint16_t a) { if ( SwapCode == 4321 || SwapCode == 2143 ) { @@ -1378,7 +1381,7 @@ uint16_t gdcmDocument::SwapShort(uint16_t a) * \brief Unswaps the bytes so they agree with the processor order * @return The properly unswaped 16 bits integer. */ -uint16_t gdcmDocument::UnswapShort(uint16_t a) +uint16_t Document::UnswapShort(uint16_t a) { return SwapShort(a); } @@ -1390,12 +1393,12 @@ uint16_t gdcmDocument::UnswapShort(uint16_t a) * \brief Parses a DocEntrySet (Zero-level DocEntries or SQ Item DocEntries) * @return length of the parsed set. */ -void gdcmDocument::ParseDES(gdcmDocEntrySet *set, +void Document::ParseDES(DocEntrySet *set, long offset, long l_max, bool delim_mode) { - gdcmDocEntry *newDocEntry = 0; + DocEntry *newDocEntry = 0; while (true) { @@ -1409,28 +1412,28 @@ void gdcmDocument::ParseDES(gdcmDocEntrySet *set, break; } - gdcmVRKey vr = newDocEntry->GetVR(); + VRKey vr = newDocEntry->GetVR(); if ( vr != "SQ" ) { - if ( gdcmGlobal::GetVR()->IsVROfGdcmStringRepresentable(vr) ) + if ( Global::GetVR()->IsVROfGdcmStringRepresentable(vr) ) { /////////////////////// ValEntry - gdcmValEntry* newValEntry = - new gdcmValEntry( newDocEntry->GetDictEntry() ); + ValEntry* newValEntry = + new ValEntry( newDocEntry->GetDictEntry() ); newValEntry->Copy( newDocEntry ); - // When "set" is a gdcmDocument, then we are at the top of the + // When "set" is a Document, then we are at the top of the // hierarchy and the Key is simply of the form ( group, elem )... - if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) ) + if (Document* dummy = dynamic_cast< Document* > ( set ) ) { (void)dummy; newValEntry->SetKey( newValEntry->GetKey() ); } - // ...but when "set" is a gdcmSQItem, we are inserting this new + // ...but when "set" is a SQItem, we are inserting this new // valEntry in a sequence item. Hence the key has the - // generalized form (refer to \ref gdcmBaseTagKey): - if (gdcmSQItem* parentSQItem = dynamic_cast< gdcmSQItem* > ( set ) ) + // generalized form (refer to \ref BaseTagKey): + if (SQItem* parentSQItem = dynamic_cast< SQItem* > ( set ) ) { newValEntry->SetKey( parentSQItem->GetBaseTagKey() + newValEntry->GetKey() ); @@ -1449,29 +1452,29 @@ void gdcmDocument::ParseDES(gdcmDocEntrySet *set, } else { - if ( ! gdcmGlobal::GetVR()->IsVROfGdcmBinaryRepresentable(vr) ) + if ( ! Global::GetVR()->IsVROfGdcmBinaryRepresentable(vr) ) { ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR - dbg.Verbose(0, "gdcmDocument::ParseDES: neither Valentry, " + dbg.Verbose(0, "Document::ParseDES: neither Valentry, " "nor BinEntry. Probably unknown VR."); } //////////////////// BinEntry or UNKOWN VR: - gdcmBinEntry* newBinEntry = - new gdcmBinEntry( newDocEntry->GetDictEntry() ); + BinEntry* newBinEntry = + new BinEntry( newDocEntry->GetDictEntry() ); newBinEntry->Copy( newDocEntry ); - // When "this" is a gdcmDocument the Key is simply of the + // When "this" is a Document the Key is simply of the // form ( group, elem )... - if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) ) + if (Document* dummy = dynamic_cast< Document* > ( set ) ) { (void)dummy; newBinEntry->SetKey( newBinEntry->GetKey() ); } // but when "this" is a SQItem, we are inserting this new // valEntry in a sequence item, and the kay has the - // generalized form (refer to \ref gdcmBaseTagKey): - if (gdcmSQItem* parentSQItem = dynamic_cast< gdcmSQItem* > ( set ) ) + // generalized form (refer to \ref BaseTagKey): + if (SQItem* parentSQItem = dynamic_cast< SQItem* > ( set ) ) { newBinEntry->SetKey( parentSQItem->GetBaseTagKey() + newBinEntry->GetKey() ); @@ -1520,25 +1523,25 @@ void gdcmDocument::ParseDES(gdcmDocEntrySet *set, } } // no other way to create it ... - gdcmSeqEntry* newSeqEntry = - new gdcmSeqEntry( newDocEntry->GetDictEntry() ); + SeqEntry* newSeqEntry = + new SeqEntry( newDocEntry->GetDictEntry() ); newSeqEntry->Copy( newDocEntry ); newSeqEntry->SetDelimitorMode( delim_mode ); - // At the top of the hierarchy, stands a gdcmDocument. When "set" - // is a gdcmDocument, then we are building the first depth level. - // Hence the gdcmSeqEntry we are building simply has a depth + // At the top of the hierarchy, stands a Document. When "set" + // is a Document, then we are building the first depth level. + // Hence the SeqEntry we are building simply has a depth // level of one: - if (gdcmDocument* dummy = dynamic_cast< gdcmDocument* > ( set ) ) + if (Document* dummy = dynamic_cast< Document* > ( set ) ) { (void)dummy; newSeqEntry->SetDepthLevel( 1 ); newSeqEntry->SetKey( newSeqEntry->GetKey() ); } // But when "set" is allready a SQItem, we are building a nested - // sequence, and hence the depth level of the new gdcmSeqEntry + // sequence, and hence the depth level of the new SeqEntry // we are building, is one level deeper: - if (gdcmSQItem* parentSQItem = dynamic_cast< gdcmSQItem* > ( set ) ) + if (SQItem* parentSQItem = dynamic_cast< SQItem* > ( set ) ) { newSeqEntry->SetDepthLevel( parentSQItem->GetDepthLevel() + 1 ); newSeqEntry->SetKey( parentSQItem->GetBaseTagKey() @@ -1565,7 +1568,7 @@ void gdcmDocument::ParseDES(gdcmDocEntrySet *set, * \brief Parses a Sequence ( SeqEntry after SeqEntry) * @return parsed length for this level */ -void gdcmDocument::ParseSQ( gdcmSeqEntry* seqEntry, +void Document::ParseSQ( SeqEntry* seqEntry, long offset, long l_max, bool delim_mode) { int SQItemNumber = 0; @@ -1573,7 +1576,7 @@ void gdcmDocument::ParseSQ( gdcmSeqEntry* seqEntry, while (true) { - gdcmDocEntry* newDocEntry = ReadNextDocEntry(); + DocEntry* newDocEntry = ReadNextDocEntry(); if ( !newDocEntry ) { // FIXME Should warn user @@ -1592,7 +1595,7 @@ void gdcmDocument::ParseSQ( gdcmSeqEntry* seqEntry, break; } - gdcmSQItem *itemSQ = new gdcmSQItem( seqEntry->GetDepthLevel() ); + SQItem *itemSQ = new SQItem( seqEntry->GetDepthLevel() ); std::ostringstream newBase; newBase << seqEntry->GetKey() << "/" @@ -1623,10 +1626,10 @@ void gdcmDocument::ParseSQ( gdcmSeqEntry* seqEntry, /** * \brief Loads the element content if its length doesn't exceed - * the value specified with gdcmDocument::SetMaxSizeLoadEntry() + * the value specified with Document::SetMaxSizeLoadEntry() * @param entry Header Entry (Dicom Element) to be dealt with */ -void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) +void Document::LoadDocEntry(DocEntry* entry) { size_t item_read; uint16_t group = entry->GetGroup(); @@ -1648,7 +1651,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) // When the length is zero things are easy: if ( length == 0 ) { - ((gdcmValEntry *)entry)->SetValue(""); + ((ValEntry *)entry)->SetValue(""); return; } @@ -1659,7 +1662,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) std::ostringstream s; if (length > MaxSizeLoadEntry) { - if (gdcmBinEntry* binEntryPtr = dynamic_cast< gdcmBinEntry* >(entry) ) + if (BinEntry* binEntryPtr = dynamic_cast< BinEntry* >(entry) ) { //s << "gdcm::NotLoaded (BinEntry)"; s << GDCM_NOTLOADED; @@ -1669,7 +1672,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) binEntryPtr->SetValue(s.str()); } // Be carefull : a BinEntry IS_A ValEntry ... - else if (gdcmValEntry* valEntryPtr = dynamic_cast< gdcmValEntry* >(entry) ) + else if (ValEntry* valEntryPtr = dynamic_cast< ValEntry* >(entry) ) { // s << "gdcm::NotLoaded. (ValEntry)"; s << GDCM_NOTLOADED; @@ -1691,7 +1694,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) } // When we find a BinEntry not very much can be done : - if (gdcmBinEntry* binEntryPtr = dynamic_cast< gdcmBinEntry* >(entry) ) + if (BinEntry* binEntryPtr = dynamic_cast< BinEntry* >(entry) ) { s << GDCM_BINLOADED; binEntryPtr->SetValue(s.str()); @@ -1744,7 +1747,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) s << std::ends; // to avoid oddities on Solaris #endif //GDCM_NO_ANSI_STRING_STREAM - ((gdcmValEntry *)entry)->SetValue(s.str()); + ((ValEntry *)entry)->SetValue(s.str()); return; } @@ -1757,11 +1760,11 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) str[length] = '\0'; std::string newValue = str; delete[] str; - if ( gdcmValEntry* valEntry = dynamic_cast(entry) ) + if ( ValEntry* valEntry = dynamic_cast(entry) ) { if ( item_read != 1 ) { - dbg.Verbose(1, "gdcmDocument::LoadDocEntry", + dbg.Verbose(1, "Document::LoadDocEntry", "unread element value"); valEntry->SetValue(GDCM_UNREAD); return; @@ -1779,7 +1782,7 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) } else { - dbg.Error(true, "gdcmDocument::LoadDocEntry" + dbg.Error(true, "Document::LoadDocEntry" "Should have a ValEntry, here !"); } } @@ -1789,14 +1792,14 @@ void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry) * \brief Find the value Length of the passed Header Entry * @param entry Header Entry whose length of the value shall be loaded. */ -void gdcmDocument::FindDocEntryLength( gdcmDocEntry *entry ) - throw ( gdcmFormatError ) +void Document::FindDocEntryLength( DocEntry *entry ) + throw ( FormatError ) { uint16_t element = entry->GetElement(); std::string vr = entry->GetVR(); uint16_t length16; - if ( Filetype == gdcmExplicitVR && !entry->IsImplicitVR() ) + if ( Filetype == ExplicitVR && !entry->IsImplicitVR() ) { if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UN" ) { @@ -1815,7 +1818,7 @@ void gdcmDocument::FindDocEntryLength( gdcmDocEntry *entry ) /// the above test is on both OB and OW... lengthOB = FindDocEntryLengthOB(); } - catch ( gdcmFormatUnexpected ) + catch ( FormatUnexpected ) { // Computing the length failed (this happens with broken // files like gdcm-JPEG-LossLess3a.dcm). We still have a @@ -1870,8 +1873,8 @@ void gdcmDocument::FindDocEntryLength( gdcmDocEntry *entry ) { if ( !IsExplicitVRBigEndianTransferSyntax() ) { - throw gdcmFormatError( "gdcmDocument::FindDocEntryLength()", - " not explicit VR." ); + throw FormatError( "Document::FindDocEntryLength()", + " not explicit VR." ); return; } length16 = 4; @@ -1880,7 +1883,7 @@ void gdcmDocument::FindDocEntryLength( gdcmDocEntry *entry ) // and the dictionary entry depending on them. uint16_t correctGroup = SwapShort( entry->GetGroup() ); uint16_t correctElem = SwapShort( entry->GetElement() ); - gdcmDictEntry* newTag = GetDictEntryByNumber( correctGroup, + DictEntry* newTag = GetDictEntryByNumber( correctGroup, correctElem ); if ( !newTag ) { @@ -1919,9 +1922,9 @@ void gdcmDocument::FindDocEntryLength( gdcmDocEntry *entry ) * \brief Find the Value Representation of the current Dicom Element. * @param entry */ -void gdcmDocument::FindDocEntryVR( gdcmDocEntry *entry ) +void Document::FindDocEntryVR( DocEntry *entry ) { - if ( Filetype != gdcmExplicitVR ) + if ( Filetype != ExplicitVR ) { return; } @@ -1965,7 +1968,7 @@ void gdcmDocument::FindDocEntryVR( gdcmDocEntry *entry ) * @return false if the VR is incorrect of if the VR isn't referenced * otherwise, it returns true */ -bool gdcmDocument::CheckDocEntryVR(gdcmDocEntry *entry, gdcmVRKey vr) +bool Document::CheckDocEntryVR(DocEntry *entry, VRKey vr) { std::string msg; bool realExplicit = true; @@ -1986,7 +1989,7 @@ bool gdcmDocument::CheckDocEntryVR(gdcmDocEntry *entry, gdcmVRKey vr) // CLEANME searching the dicom_vr at each occurence is expensive. // PostPone this test in an optional integrity check at the end // of parsing or only in debug mode. - if ( realExplicit && !gdcmGlobal::GetVR()->Count(vr) ) + if ( realExplicit && !Global::GetVR()->Count(vr) ) { realExplicit = false; } @@ -1995,14 +1998,14 @@ bool gdcmDocument::CheckDocEntryVR(gdcmDocEntry *entry, gdcmVRKey vr) { // We thought this was explicit VR, but we end up with an // implicit VR tag. Let's backtrack. - msg = gdcmUtil::Format("Falsely explicit vr file (%04x,%04x)\n", + msg = Util::Format("Falsely explicit vr file (%04x,%04x)\n", entry->GetGroup(), entry->GetElement()); - dbg.Verbose(1, "gdcmDocument::FindVR: ", msg.c_str()); + dbg.Verbose(1, "Document::FindVR: ", msg.c_str()); if( entry->GetGroup() % 2 && entry->GetElement() == 0x0000) { // Group length is UL ! - gdcmDictEntry* newEntry = NewVirtualDictEntry( + DictEntry* newEntry = NewVirtualDictEntry( entry->GetGroup(), entry->GetElement(), "UL", "FIXME", "Group Length"); entry->SetDictEntry( newEntry ); @@ -2030,7 +2033,7 @@ bool gdcmDocument::CheckDocEntryVR(gdcmDocEntry *entry, gdcmVRKey vr) // be unwise to overwrite the VR of a dictionary (since it would // compromise it's next user), we need to clone the actual DictEntry // and change the VR for the read one. - gdcmDictEntry* newEntry = NewVirtualDictEntry( + DictEntry* newEntry = NewVirtualDictEntry( entry->GetGroup(), entry->GetElement(), vr, "FIXME", entry->GetName()); entry->SetDictEntry(newEntry); @@ -2046,11 +2049,11 @@ bool gdcmDocument::CheckDocEntryVR(gdcmDocEntry *entry, gdcmVRKey vr) * @param entry entry to tranform * @return Transformed entry value */ -std::string gdcmDocument::GetDocEntryValue(gdcmDocEntry *entry) +std::string Document::GetDocEntryValue(DocEntry *entry) { if ( IsDocEntryAnInteger(entry) && entry->IsImplicitVR() ) { - std::string val = ((gdcmValEntry *)entry)->GetValue(); + std::string val = ((ValEntry *)entry)->GetValue(); std::string vr = entry->GetVR(); uint32_t length = entry->GetLength(); std::ostringstream s; @@ -2111,7 +2114,7 @@ std::string gdcmDocument::GetDocEntryValue(gdcmDocEntry *entry) return s.str(); } - return ((gdcmValEntry *)entry)->GetValue(); + return ((ValEntry *)entry)->GetValue(); } /** @@ -2122,7 +2125,7 @@ std::string gdcmDocument::GetDocEntryValue(gdcmDocEntry *entry) * @param entry Entry to reverse transform * @return Reverse transformed entry value */ -std::string gdcmDocument::GetDocEntryUnvalue(gdcmDocEntry* entry) +std::string Document::GetDocEntryUnvalue(DocEntry* entry) { if ( IsDocEntryAnInteger(entry) && entry->IsImplicitVR() ) { @@ -2135,7 +2138,7 @@ std::string gdcmDocument::GetDocEntryUnvalue(gdcmDocEntry* entry) uint16_t newInt16; tokens.erase( tokens.begin(), tokens.end()); // clean any previous value - gdcmUtil::Tokenize (((gdcmValEntry *)entry)->GetValue(), tokens, "\\"); + Util::Tokenize (((ValEntry *)entry)->GetValue(), tokens, "\\"); for (unsigned int i=0; iGetValue(), tokens, "\\"); + Util::Tokenize (((ValEntry *)entry)->GetValue(), tokens, "\\"); for (unsigned int i=0; iGetValue(); + return ((ValEntry *)entry)->GetValue(); } /** @@ -2175,7 +2178,7 @@ std::string gdcmDocument::GetDocEntryUnvalue(gdcmDocEntry* entry) * \warning NOT end user intended method ! * @param entry entry to skip */ -void gdcmDocument::SkipDocEntry(gdcmDocEntry *entry) +void Document::SkipDocEntry(DocEntry *entry) { SkipBytes(entry->GetLength()); } @@ -2185,7 +2188,7 @@ void gdcmDocument::SkipDocEntry(gdcmDocEntry *entry) * \warning NOT end user intended method ! * @param entry entry to skip */ -void gdcmDocument::SkipToNextDocEntry(gdcmDocEntry *entry) +void Document::SkipToNextDocEntry(DocEntry *entry) { fseek(Fp, (long)(entry->GetOffset()), SEEK_SET); fseek(Fp, (long)(entry->GetReadLength()), SEEK_CUR); @@ -2198,7 +2201,7 @@ void gdcmDocument::SkipToNextDocEntry(gdcmDocEntry *entry) * @param entry entry to check * @param foundLength fist assumption about length */ -void gdcmDocument::FixDocEntryFoundLength(gdcmDocEntry *entry, +void Document::FixDocEntryFoundLength(DocEntry *entry, uint32_t foundLength) { entry->SetReadLength( foundLength ); // will be updated only if a bug is found @@ -2277,7 +2280,7 @@ void gdcmDocument::FixDocEntryFoundLength(gdcmDocEntry *entry, * @param entry The element value on which to apply the predicate. * @return The result of the heuristical predicate. */ -bool gdcmDocument::IsDocEntryAnInteger(gdcmDocEntry *entry) +bool Document::IsDocEntryAnInteger(DocEntry *entry) { uint16_t element = entry->GetElement(); uint16_t group = entry->GetGroup(); @@ -2308,7 +2311,7 @@ bool gdcmDocument::IsDocEntryAnInteger(gdcmDocEntry *entry) << std::hex << group << " , " << element << ") -before- position x(" << filePosition << ")" << "lgt : " << length; - dbg.Verbose(0, "gdcmDocument::IsDocEntryAnInteger", s.str().c_str() ); + dbg.Verbose(0, "Document::IsDocEntryAnInteger", s.str().c_str() ); } } @@ -2326,8 +2329,8 @@ bool gdcmDocument::IsDocEntryAnInteger(gdcmDocEntry *entry) * @return */ -uint32_t gdcmDocument::FindDocEntryLengthOB() - throw( gdcmFormatUnexpected ) +uint32_t Document::FindDocEntryLengthOB() + throw( FormatUnexpected ) { // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data. long positionOnEntry = ftell(Fp); @@ -2343,10 +2346,10 @@ uint32_t gdcmDocument::FindDocEntryLengthOB() group = ReadInt16(); elem = ReadInt16(); } - catch ( gdcmFormatError ) + catch ( FormatError ) { - throw gdcmFormatError("gdcmDocument::FindDocEntryLengthOB()", - " group or element not present."); + throw FormatError("Document::FindDocEntryLengthOB()", + " group or element not present."); } // We have to decount the group and element we just read @@ -2354,12 +2357,12 @@ uint32_t gdcmDocument::FindDocEntryLengthOB() if ( group != 0xfffe || ( ( elem != 0xe0dd ) && ( elem != 0xe000 ) ) ) { - dbg.Verbose(1, "gdcmDocument::FindDocEntryLengthOB: neither an Item " + dbg.Verbose(1, "Document::FindDocEntryLengthOB: neither an Item " "tag nor a Sequence delimiter tag."); fseek(Fp, positionOnEntry, SEEK_SET); - throw gdcmFormatUnexpected("gdcmDocument::FindDocEntryLengthOB()", - "Neither an Item tag nor a Sequence " - "delimiter tag."); + throw FormatUnexpected("Document::FindDocEntryLengthOB()", + "Neither an Item tag nor a Sequence " + "delimiter tag."); } if ( elem == 0xe0dd ) @@ -2386,8 +2389,8 @@ uint32_t gdcmDocument::FindDocEntryLengthOB() * (swaps it depending on processor endianity) * @return read value */ -uint16_t gdcmDocument::ReadInt16() - throw( gdcmFormatError ) +uint16_t Document::ReadInt16() + throw( FormatError ) { uint16_t g; size_t item_read = fread (&g, (size_t)2,(size_t)1, Fp); @@ -2395,9 +2398,9 @@ uint16_t gdcmDocument::ReadInt16() { if( ferror(Fp) ) { - throw gdcmFormatError( "gdcmDocument::ReadInt16()", " file error." ); + throw FormatError( "Document::ReadInt16()", " file error." ); } - throw gdcmFormatError( "gdcmDocument::ReadInt16()", "EOF." ); + throw FormatError( "Document::ReadInt16()", "EOF." ); } g = SwapShort(g); return g; @@ -2408,8 +2411,8 @@ uint16_t gdcmDocument::ReadInt16() * (swaps it depending on processor endianity) * @return read value */ -uint32_t gdcmDocument::ReadInt32() - throw( gdcmFormatError ) +uint32_t Document::ReadInt32() + throw( FormatError ) { uint32_t g; size_t item_read = fread (&g, (size_t)4,(size_t)1, Fp); @@ -2417,9 +2420,9 @@ uint32_t gdcmDocument::ReadInt32() { if( ferror(Fp) ) { - throw gdcmFormatError( "gdcmDocument::ReadInt16()", " file error." ); + throw FormatError( "Document::ReadInt16()", " file error." ); } - throw gdcmFormatError( "gdcmDocument::ReadInt32()", "EOF." ); + throw FormatError( "Document::ReadInt32()", "EOF." ); } g = SwapLong(g); return g; @@ -2430,7 +2433,7 @@ uint32_t gdcmDocument::ReadInt32() * \warning NOT end user intended method ! * @return */ -void gdcmDocument::SkipBytes(uint32_t nBytes) +void Document::SkipBytes(uint32_t nBytes) { //FIXME don't dump the returned value (void)fseek(Fp, (long)nBytes, SEEK_CUR); @@ -2440,9 +2443,9 @@ void gdcmDocument::SkipBytes(uint32_t nBytes) * \brief Loads all the needed Dictionaries * \warning NOT end user intended method ! */ -void gdcmDocument::Initialise() +void Document::Initialise() { - RefPubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); + RefPubDict = Global::GetDicts()->GetDefaultPubDict(); RefShaDict = NULL; } @@ -2454,7 +2457,7 @@ void gdcmDocument::Initialise() * it's neither ACR-NEMA nor DICOM * true when we hope ours assuptions are OK */ -bool gdcmDocument::CheckSwap() +bool Document::CheckSwap() { // The only guaranted way of finding the swap code is to find a // group tag since we know it's length has to be of four bytes i.e. @@ -2487,7 +2490,7 @@ bool gdcmDocument::CheckSwap() char *entCur = deb + 128; if( memcmp(entCur, "DICM", (size_t)4) == 0 ) { - dbg.Verbose(1, "gdcmDocument::CheckSwap:", "looks like DICOM Version3"); + dbg.Verbose(1, "Document::CheckSwap:", "looks like DICOM Version3"); // Next, determine the value representation (VR). Let's skip to the // first element (0002, 0000) and check there if we find "UL" @@ -2517,30 +2520,30 @@ bool gdcmDocument::CheckSwap() memcmp(entCur, "CS", (size_t)2) == 0 ) // CS, to remove later // when Write DCM *adds* // FIXME - // Use gdcmDocument::dicom_vr to test all the possibilities + // Use Document::dicom_vr to test all the possibilities // instead of just checking for UL, OB and UI !? group 0000 { - Filetype = gdcmExplicitVR; - dbg.Verbose(1, "gdcmDocument::CheckSwap:", + Filetype = ExplicitVR; + dbg.Verbose(1, "Document::CheckSwap:", "explicit Value Representation"); } else { - Filetype = gdcmImplicitVR; - dbg.Verbose(1, "gdcmDocument::CheckSwap:", + Filetype = ImplicitVR; + dbg.Verbose(1, "Document::CheckSwap:", "not an explicit Value Representation"); } if ( net2host ) { SwapCode = 4321; - dbg.Verbose(1, "gdcmDocument::CheckSwap:", + dbg.Verbose(1, "Document::CheckSwap:", "HostByteOrder != NetworkByteOrder"); } else { SwapCode = 0; - dbg.Verbose(1, "gdcmDocument::CheckSwap:", + dbg.Verbose(1, "Document::CheckSwap:", "HostByteOrder = NetworkByteOrder"); } @@ -2554,7 +2557,7 @@ bool gdcmDocument::CheckSwap() // Alas, this is not a DicomV3 file and whatever happens there is no file // preamble. We can reset the file position indicator to where the data // is (i.e. the beginning of the file). - dbg.Verbose(1, "gdcmDocument::CheckSwap:", "not a DICOM Version3 file"); + dbg.Verbose(1, "Document::CheckSwap:", "not a DICOM Version3 file"); rewind(Fp); // Our next best chance would be to be considering a 'clean' ACR/NEMA file. @@ -2572,19 +2575,19 @@ bool gdcmDocument::CheckSwap() { case 0x00040000 : SwapCode = 3412; - Filetype = gdcmACR; + Filetype = ACR; return true; case 0x04000000 : SwapCode = 4321; - Filetype = gdcmACR; + Filetype = ACR; return true; case 0x00000400 : SwapCode = 2143; - Filetype = gdcmACR; + Filetype = ACR; return true; case 0x00000004 : SwapCode = 0; - Filetype = gdcmACR; + Filetype = ACR; return true; default : // We are out of luck. It is not a DicomV3 nor a 'clean' ACR/NEMA file. @@ -2610,18 +2613,18 @@ bool gdcmDocument::CheckSwap() case 0x0004 : case 0x0008 : SwapCode = 0; - Filetype = gdcmACR; + Filetype = ACR; return true; case 0x0200 : case 0x0400 : case 0x0800 : SwapCode = 4321; - Filetype = gdcmACR; + Filetype = ACR; return true; default : - dbg.Verbose(0, "gdcmDocument::CheckSwap:", + dbg.Verbose(0, "Document::CheckSwap:", "ACR/NEMA unfound swap info (Really hopeless !)"); - Filetype = gdcmUnknown; + Filetype = Unknown; return false; } // Then the only info we have is the net2host one. @@ -2637,9 +2640,9 @@ bool gdcmDocument::CheckSwap() * \brief Restore the unproperly loaded values i.e. the group, the element * and the dictionary entry depending on them. */ -void gdcmDocument::SwitchSwapToBigEndian() +void Document::SwitchSwapToBigEndian() { - dbg.Verbose(1, "gdcmDocument::SwitchSwapToBigEndian", + dbg.Verbose(1, "Document::SwitchSwapToBigEndian", "Switching to BigEndian mode."); if ( SwapCode == 0 ) { @@ -2663,7 +2666,7 @@ void gdcmDocument::SwitchSwapToBigEndian() * \brief during parsing, Header Elements too long are not loaded in memory * @param newSize */ -void gdcmDocument::SetMaxSizeLoadEntry(long newSize) +void Document::SetMaxSizeLoadEntry(long newSize) { if ( newSize < 0 ) { @@ -2680,10 +2683,10 @@ void gdcmDocument::SetMaxSizeLoadEntry(long newSize) /** * \brief Header Elements too long will not be printed - * \todo See comments of \ref gdcmDocument::MAX_SIZE_PRINT_ELEMENT_VALUE + * \todo See comments of \ref Document::MAX_SIZE_PRINT_ELEMENT_VALUE * @param newSize */ -void gdcmDocument::SetMaxSizePrintEntry(long newSize) +void Document::SetMaxSizePrintEntry(long newSize) { //DOH !! This is exactly SetMaxSizeLoadEntry FIXME FIXME if ( newSize < 0 ) @@ -2707,7 +2710,7 @@ void gdcmDocument::SetMaxSizePrintEntry(long newSize) * gets the VR, gets the length, gets the offset value) * @return On succes the newly created DocEntry, NULL on failure. */ -gdcmDocEntry* gdcmDocument::ReadNextDocEntry() +DocEntry* Document::ReadNextDocEntry() { uint16_t group; uint16_t elem; @@ -2717,7 +2720,7 @@ gdcmDocEntry* gdcmDocument::ReadNextDocEntry() group = ReadInt16(); elem = ReadInt16(); } - catch ( gdcmFormatError e ) + catch ( FormatError e ) { // We reached the EOF (or an error occured) therefore // header parsing has to be considered as finished. @@ -2725,14 +2728,14 @@ gdcmDocEntry* gdcmDocument::ReadNextDocEntry() return 0; } - gdcmDocEntry *newEntry = NewDocEntryByNumber(group, elem); + DocEntry *newEntry = NewDocEntryByNumber(group, elem); FindDocEntryVR(newEntry); try { FindDocEntryLength(newEntry); } - catch ( gdcmFormatError e ) + catch ( FormatError e ) { // Call it quits //std::cout << e; @@ -2747,16 +2750,16 @@ gdcmDocEntry* gdcmDocument::ReadNextDocEntry() /** - * \brief Generate a free gdcmTagKey i.e. a gdcmTagKey that is not present + * \brief Generate a free TagKey i.e. a TagKey that is not present * in the TagHt dictionary. * @param group The generated tag must belong to this group. * @return The element of tag with given group which is fee. */ -uint32_t gdcmDocument::GenerateFreeTagKeyInGroup(uint16_t group) +uint32_t Document::GenerateFreeTagKeyInGroup(uint16_t group) { for (uint32_t elem = 0; elem < UINT32_MAX; elem++) { - gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, elem); + TagKey key = DictEntry::TranslateToKey(group, elem); if (TagHT.count(key) == 0) { return elem; @@ -2766,19 +2769,19 @@ uint32_t gdcmDocument::GenerateFreeTagKeyInGroup(uint16_t group) } /** - * \brief Assuming the internal file pointer \ref gdcmDocument::Fp + * \brief Assuming the internal file pointer \ref Document::Fp * is placed at the beginning of a tag check whether this * tag is (TestGroup, TestElement). - * \warning On success the internal file pointer \ref gdcmDocument::Fp + * \warning On success the internal file pointer \ref Document::Fp * is modified to point after the tag. * On failure (i.e. when the tag wasn't the expected tag * (TestGroup, TestElement) the internal file pointer - * \ref gdcmDocument::Fp is restored to it's original position. + * \ref Document::Fp is restored to it's original position. * @param testGroup The expected group of the tag. * @param testElement The expected Element of the tag. * @return True on success, false otherwise. */ -bool gdcmDocument::ReadTag(uint16_t testGroup, uint16_t testElement) +bool Document::ReadTag(uint16_t testGroup, uint16_t testElement) { long positionOnEntry = ftell(Fp); long currentPosition = ftell(Fp); // On debugging purposes @@ -2796,7 +2799,7 @@ bool gdcmDocument::ReadTag(uint16_t testGroup, uint16_t testElement) s << std::hex << itemTagGroup << "," << itemTagElement << ")" << std::endl; s << " at address: " << (unsigned)currentPosition << std::endl; - dbg.Verbose(0, "gdcmDocument::ReadItemTagLength: wrong Item Tag found:"); + dbg.Verbose(0, "Document::ReadItemTagLength: wrong Item Tag found:"); dbg.Verbose(0, s.str().c_str()); fseek(Fp, positionOnEntry, SEEK_SET); @@ -2806,20 +2809,20 @@ bool gdcmDocument::ReadTag(uint16_t testGroup, uint16_t testElement) } /** - * \brief Assuming the internal file pointer \ref gdcmDocument::Fp + * \brief Assuming the internal file pointer \ref Document::Fp * is placed at the beginning of a tag (TestGroup, TestElement), * read the length associated to the Tag. - * \warning On success the internal file pointer \ref gdcmDocument::Fp + * \warning On success the internal file pointer \ref Document::Fp * is modified to point after the tag and it's length. * On failure (i.e. when the tag wasn't the expected tag * (TestGroup, TestElement) the internal file pointer - * \ref gdcmDocument::Fp is restored to it's original position. + * \ref Document::Fp is restored to it's original position. * @param testGroup The expected group of the tag. * @param testElement The expected Element of the tag. * @return On success returns the length associated to the tag. On failure * returns 0. */ -uint32_t gdcmDocument::ReadTagLength(uint16_t testGroup, uint16_t testElement) +uint32_t Document::ReadTagLength(uint16_t testGroup, uint16_t testElement) { long positionOnEntry = ftell(Fp); (void)positionOnEntry; @@ -2837,7 +2840,7 @@ uint32_t gdcmDocument::ReadTagLength(uint16_t testGroup, uint16_t testElement) s << "Basic Item Length is: " << itemLength << std::endl; s << " at address: " << (unsigned)currentPosition << std::endl; - dbg.Verbose(0, "gdcmDocument::ReadItemTagLength: ", s.str().c_str()); + dbg.Verbose(0, "Document::ReadItemTagLength: ", s.str().c_str()); } return itemLength; } @@ -2846,7 +2849,7 @@ uint32_t gdcmDocument::ReadTagLength(uint16_t testGroup, uint16_t testElement) * \brief When parsing the Pixel Data of an encapsulated file, read * the basic offset table (when present, and BTW dump it). */ -void gdcmDocument::ReadAndSkipEncapsulatedBasicOffsetTable() +void Document::ReadAndSkipEncapsulatedBasicOffsetTable() { //// Read the Basic Offset Table Item Tag length... uint32_t itemLength = ReadTagLength(0xfffe, 0xe000); @@ -2871,7 +2874,7 @@ void gdcmDocument::ReadAndSkipEncapsulatedBasicOffsetTable() s << " Read one length: "; s << std::hex << individualLength << std::endl; dbg.Verbose(0, - "gdcmDocument::ReadAndSkipEncapsulatedBasicOffsetTable: ", + "Document::ReadAndSkipEncapsulatedBasicOffsetTable: ", s.str().c_str()); } #endif //GDCM_DEBUG @@ -2885,7 +2888,7 @@ void gdcmDocument::ReadAndSkipEncapsulatedBasicOffsetTable() * Compute the RLE extra information and store it in \ref RLEInfo * for later pixel retrieval usage. */ -void gdcmDocument::ComputeRLEInfo() +void Document::ComputeRLEInfo() { if ( ! IsRLELossLessTransferSyntax() ) { @@ -2910,7 +2913,7 @@ void gdcmDocument::ComputeRLEInfo() // Encapsulated RLE Compressed Images (see PS 3.5-2003, Annex G) // Loop on the individual frame[s] and store the information - // on the RLE fragments in a gdcmRLEFramesInfo. + // on the RLE fragments in a RLEFramesInfo. // Note: - when only a single frame is present, this is a // classical image. // - when more than one frame are present, then we are in @@ -2934,7 +2937,7 @@ void gdcmDocument::ComputeRLEInfo() // Deduce from both the RLE Header and the frameLength the // fragment length, and again store this info in a - // gdcmRLEFramesInfo. + // RLEFramesInfo. long rleSegmentLength[15]; // skipping (not reading) RLE Segments if ( nbRleSegments > 1) @@ -2952,7 +2955,7 @@ void gdcmDocument::ComputeRLEInfo() SkipBytes(rleSegmentLength[nbRleSegments]); // Store the collected info - gdcmRLEFrame* newFrameInfo = new gdcmRLEFrame; + RLEFrame* newFrameInfo = new RLEFrame; newFrameInfo->NumberFragments = nbRleSegments; for( unsigned int uk = 1; uk <= nbRleSegments; uk++ ) { @@ -2966,7 +2969,7 @@ void gdcmDocument::ComputeRLEInfo() // Delimiter Item': if ( !ReadTag(0xfffe, 0xe0dd) ) { - dbg.Verbose(0, "gdcmDocument::ComputeRLEInfo: no sequence delimiter "); + dbg.Verbose(0, "Document::ComputeRLEInfo: no sequence delimiter "); dbg.Verbose(0, " item at end of RLE item sequence"); } } @@ -2977,7 +2980,7 @@ void gdcmDocument::ComputeRLEInfo() * length) and store it[them] in \ref JPEGInfo for later pixel * retrieval usage. */ -void gdcmDocument::ComputeJPEGFragmentInfo() +void Document::ComputeJPEGFragmentInfo() { // If you need to, look for comments of ComputeRLEInfo(). if ( ! IsJPEGTransferSyntax() ) @@ -2988,14 +2991,14 @@ void gdcmDocument::ComputeJPEGFragmentInfo() ReadAndSkipEncapsulatedBasicOffsetTable(); // Loop on the fragments[s] and store the parsed information in a - // gdcmJPEGInfo. + // JPEGInfo. long fragmentLength; while ( (fragmentLength = ReadTagLength(0xfffe, 0xe000)) ) { long fragmentOffset = ftell(Fp); // Store the collected info - gdcmJPEGFragment* newFragment = new gdcmJPEGFragment; + JPEGFragment* newFragment = new JPEGFragment; newFragment->Offset = fragmentOffset; newFragment->Length = fragmentLength; JPEGInfo.Fragments.push_back( newFragment ); @@ -3007,32 +3010,32 @@ void gdcmDocument::ComputeJPEGFragmentInfo() // Delimiter Item': if ( !ReadTag(0xfffe, 0xe0dd) ) { - dbg.Verbose(0, "gdcmDocument::ComputeRLEInfo: no sequence delimiter "); + dbg.Verbose(0, "Document::ComputeRLEInfo: no sequence delimiter "); dbg.Verbose(0, " item at end of JPEG item sequence"); } } /** - * \brief Walk recursively the given \ref gdcmDocEntrySet, and feed + * \brief Walk recursively the given \ref DocEntrySet, and feed * the given hash table (\ref TagDocEntryHT) with all the - * \ref gdcmDocEntry (Dicom entries) encountered. + * \ref DocEntry (Dicom entries) encountered. * This method does the job for \ref BuildFlatHashTable. - * @param builtHT Where to collect all the \ref gdcmDocEntry encountered + * @param builtHT Where to collect all the \ref DocEntry encountered * when recursively walking the given set. * @param set The structure to be traversed (recursively). */ -void gdcmDocument::BuildFlatHashTableRecurse( TagDocEntryHT& builtHT, - gdcmDocEntrySet* set ) +void Document::BuildFlatHashTableRecurse( TagDocEntryHT& builtHT, + DocEntrySet* set ) { - if (gdcmElementSet* elementSet = dynamic_cast< gdcmElementSet* > ( set ) ) + if (ElementSet* elementSet = dynamic_cast< ElementSet* > ( set ) ) { TagDocEntryHT* currentHT = elementSet->GetTagHT(); for( TagDocEntryHT::const_iterator i = currentHT->begin(); i != currentHT->end(); ++i) { - gdcmDocEntry* entry = i->second; - if ( gdcmSeqEntry* seqEntry = dynamic_cast(entry) ) + DocEntry* entry = i->second; + if ( SeqEntry* seqEntry = dynamic_cast(entry) ) { ListSQItem& items = seqEntry->GetSQItems(); for( ListSQItem::const_iterator item = items.begin(); @@ -3048,15 +3051,15 @@ void gdcmDocument::BuildFlatHashTableRecurse( TagDocEntryHT& builtHT, return; } - if (gdcmSQItem* SQItemSet = dynamic_cast< gdcmSQItem* > ( set ) ) + if (SQItem* SQItemSet = dynamic_cast< SQItem* > ( set ) ) { ListDocEntry& currentList = SQItemSet->GetDocEntries(); for (ListDocEntry::iterator i = currentList.begin(); i != currentList.end(); ++i) { - gdcmDocEntry* entry = *i; - if ( gdcmSeqEntry* seqEntry = dynamic_cast(entry) ) + DocEntry* entry = *i; + if ( SeqEntry* seqEntry = dynamic_cast(entry) ) { ListSQItem& items = seqEntry->GetSQItems(); for( ListSQItem::const_iterator item = items.begin(); @@ -3075,13 +3078,13 @@ void gdcmDocument::BuildFlatHashTableRecurse( TagDocEntryHT& builtHT, /** * \brief Build a \ref TagDocEntryHT (i.e. a std::map<>) from the current - * gdcmDocument. + * Document. * - * The structure used by a gdcmDocument (through \ref gdcmElementSet), + * The structure used by a Document (through \ref ElementSet), * in order to old the parsed entries of a Dicom header, is a recursive * one. This is due to the fact that the sequences (when present) * can be nested. Additionaly, the sequence items (represented in - * gdcm as \ref gdcmSQItem) add an extra complexity to the data + * gdcm as \ref SQItem) add an extra complexity to the data * structure. Hence, a gdcm user whishing to visit all the entries of * a Dicom header will need to dig in the gdcm internals (which * implies exposing all the internal data structures to the API). @@ -3090,13 +3093,13 @@ void gdcmDocument::BuildFlatHashTableRecurse( TagDocEntryHT& builtHT, * Dicom entries in a flat structure (a \ref TagDocEntryHT i.e. a * std::map<>). * \warning Of course there is NO integrity constrain between the - * returned \ref TagDocEntryHT and the \ref gdcmElementSet used - * to build it. Hence if the underlying \ref gdcmElementSet is + * returned \ref TagDocEntryHT and the \ref ElementSet used + * to build it. Hence if the underlying \ref ElementSet is * altered, then it is the caller responsability to invoke * \ref BuildFlatHashTable again... * @return The flat std::map<> we juste build. */ -TagDocEntryHT* gdcmDocument::BuildFlatHashTable() +TagDocEntryHT* Document::BuildFlatHashTable() { TagDocEntryHT* FlatHT = new TagDocEntryHT; BuildFlatHashTableRecurse( *FlatHT, this ); @@ -3106,13 +3109,13 @@ TagDocEntryHT* gdcmDocument::BuildFlatHashTable() /** - * \brief Compares two documents, according to \ref gdcmDicomDir rules + * \brief Compares two documents, according to \ref DicomDir rules * \warning Does NOT work with ACR-NEMA files * \todo Find a trick to solve the pb (use RET fields ?) * @param document * @return true if 'smaller' */ -bool gdcmDocument::operator<(gdcmDocument &document) +bool Document::operator<(Document &document) { // Patient Name std::string s1 = GetEntryByNumber(0x0010,0x0010); @@ -3170,5 +3173,6 @@ bool gdcmDocument::operator<(gdcmDocument &document) return false; } +} // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 80d3d3f6..a024bdef 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.49 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.50 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -30,27 +30,29 @@ #include "gdcmDocEntrySet.h" #include "gdcmElementSet.h" -class gdcmValEntry; -class gdcmBinEntry; -class gdcmSeqEntry; +class ValEntry; +class BinEntry; +class SeqEntry; #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- /** - * \brief Derived by both gdcmHeader and gdcmDicomDir + * \brief Derived by both Header and DicomDir */ -class GDCM_EXPORT gdcmDocument : public gdcmElementSet +class GDCM_EXPORT Document : public ElementSet { -friend class gdcmFile; +friend class File; private: /// Public dictionary used to parse this header - gdcmDict *RefPubDict; + Dict *RefPubDict; /// \brief Optional "shadow dictionary" (private elements) used to parse /// this header - gdcmDict *RefShaDict; + Dict *RefShaDict; /// \brief Size threshold above which an element value will NOT be loaded /// in memory (to avoid loading the image/volume itself). By default, @@ -88,15 +90,15 @@ protected: /// \brief Elements whose value is longer than MAX_SIZE_PRINT_ELEMENT_VALUE /// are NOT printed. /// \todo Currently not used since collides with #define in - /// \ref gdcmDocEntry.cxx. See also - /// \ref gdcmDocument::SetMaxSizePrintEntry() + /// \ref DocEntry.cxx. See also + /// \ref Document::SetMaxSizePrintEntry() static const unsigned int MAX_SIZE_PRINT_ELEMENT_VALUE; /// Store the RLE frames info obtained during parsing of pixels. - gdcmRLEFramesInfo RLEInfo; + RLEFramesInfo RLEInfo; /// Store the JPEG fragments info obtained during parsing of pixels. - gdcmJPEGFragmentsInfo JPEGInfo; + JPEGFragmentsInfo JPEGInfo; /// \brief Amount of printed details for each Header Entry (Dicom Element): /// 0 : stands for the least detail level. @@ -108,9 +110,9 @@ public: virtual void PrintShaDict (std::ostream &os = std::cout); // Dictionnaries - gdcmDict *GetPubDict(); - gdcmDict *GetShaDict(); - bool SetShaDict(gdcmDict *dict); + Dict *GetPubDict(); + Dict *GetShaDict(); + bool SetShaDict(Dict *dict); bool SetShaDict(DictKey const & dictName); // Informations contained in the parser @@ -138,36 +140,36 @@ public: void Write(FILE* fp, FileType type); - gdcmValEntry* ReplaceOrCreateByNumber(std::string const & value, + ValEntry* ReplaceOrCreateByNumber(std::string const & value, uint16_t group, uint16_t elem, std::string const & VR ="unkn"); - gdcmBinEntry* ReplaceOrCreateByNumber(uint8_t* binArea, int lgth, + BinEntry* ReplaceOrCreateByNumber(uint8_t* binArea, int lgth, uint16_t group, uint16_t elem, std::string const & VR="unkn"); - gdcmSeqEntry* ReplaceOrCreateByNumber(uint16_t group, uint16_t elem); + SeqEntry* ReplaceOrCreateByNumber(uint16_t group, uint16_t elem); bool ReplaceIfExistByNumber ( std::string const & value, uint16_t group, uint16_t elem ); virtual void* LoadEntryBinArea(uint16_t group, uint16_t elem); - virtual void* LoadEntryBinArea(gdcmBinEntry* entry); + virtual void* LoadEntryBinArea(BinEntry* entry); // System access (meaning endian related !?) - uint16_t SwapShort(uint16_t); // needed by gdcmFile - uint32_t SwapLong(uint32_t); // needed by gdcmFile - uint16_t UnswapShort(uint16_t); // needed by gdcmFile - uint32_t UnswapLong(uint32_t); // needed by gdcmFile + uint16_t SwapShort(uint16_t); // needed by File + uint32_t SwapLong(uint32_t); // needed by File + uint16_t UnswapShort(uint16_t); // needed by File + uint32_t UnswapLong(uint32_t); // needed by File protected: // Constructor and destructor are protected to forbid end user - // to instanciate from this class gdcmDocument (only gdcmHeader and - // gdcmDicomDir are meaningfull). - gdcmDocument(); - gdcmDocument( std::string const & filename ); - virtual ~gdcmDocument(); + // to instanciate from this class Document (only Header and + // DicomDir are meaningfull). + Document(); + Document( std::string const & filename ); + virtual ~Document(); void ReadAndSkipEncapsulatedBasicOffsetTable(); void ComputeRLEInfo(); @@ -198,38 +200,38 @@ public: virtual void UpdateShaEntries(); // Header entry - gdcmDocEntry* GetDocEntryByNumber(uint16_t group, uint16_t element); - gdcmDocEntry* GetDocEntryByName (std::string const & tagName); + DocEntry* GetDocEntryByNumber(uint16_t group, uint16_t element); + DocEntry* GetDocEntryByName (std::string const & tagName); - gdcmValEntry* GetValEntryByNumber(uint16_t group, uint16_t element); - //gdcmBinEntry* GetBinEntryByNumber(uint16_t group, uint16_t element); + ValEntry* GetValEntryByNumber(uint16_t group, uint16_t element); + //BinEntry* GetBinEntryByNumber(uint16_t group, uint16_t element); - void LoadDocEntrySafe(gdcmDocEntry* entry); + void LoadDocEntrySafe(DocEntry* entry); TagDocEntryHT* BuildFlatHashTable(); private: // Read - void ParseDES(gdcmDocEntrySet *set,long offset, long l_max, bool delim_mode); - void ParseSQ (gdcmSeqEntry *seq, long offset, long l_max, bool delim_mode); + void ParseDES(DocEntrySet *set,long offset, long l_max, bool delim_mode); + void ParseSQ (SeqEntry *seq, long offset, long l_max, bool delim_mode); - void LoadDocEntry (gdcmDocEntry *); - void FindDocEntryLength(gdcmDocEntry *) throw ( gdcmFormatError ); - void FindDocEntryVR (gdcmDocEntry *); - bool CheckDocEntryVR (gdcmDocEntry *, gdcmVRKey); + void LoadDocEntry (DocEntry *); + void FindDocEntryLength(DocEntry *) throw ( FormatError ); + void FindDocEntryVR (DocEntry *); + bool CheckDocEntryVR (DocEntry *, VRKey); - std::string GetDocEntryValue (gdcmDocEntry *); - std::string GetDocEntryUnvalue(gdcmDocEntry *); + std::string GetDocEntryValue (DocEntry *); + std::string GetDocEntryUnvalue(DocEntry *); - void SkipDocEntry (gdcmDocEntry *); - void SkipToNextDocEntry (gdcmDocEntry *); + void SkipDocEntry (DocEntry *); + void SkipToNextDocEntry (DocEntry *); - void FixDocEntryFoundLength(gdcmDocEntry *, uint32_t); - bool IsDocEntryAnInteger (gdcmDocEntry *); + void FixDocEntryFoundLength(DocEntry *, uint32_t); + bool IsDocEntryAnInteger (DocEntry *); - uint32_t FindDocEntryLengthOB() throw( gdcmFormatUnexpected ); + uint32_t FindDocEntryLengthOB() throw( FormatUnexpected ); - uint16_t ReadInt16() throw ( gdcmFormatError ); - uint32_t ReadInt32() throw ( gdcmFormatError ); + uint16_t ReadInt16() throw ( FormatError ); + uint32_t ReadInt32() throw ( FormatError ); void SkipBytes(uint32_t); bool ReadTag(uint16_t, uint16_t); uint32_t ReadTagLength(uint16_t, uint16_t); @@ -241,11 +243,11 @@ private: void SetMaxSizePrintEntry(long); // DocEntry related utilities - gdcmDocEntry* ReadNextDocEntry(); + DocEntry* ReadNextDocEntry(); uint32_t GenerateFreeTagKeyInGroup(uint16_t group); void BuildFlatHashTableRecurse( TagDocEntryHT& builtHT, - gdcmDocEntrySet* set ); + DocEntrySet* set ); public: @@ -265,9 +267,10 @@ public: /// File pointer FILE * GetFP() { return Fp; } - bool operator<(gdcmDocument &document); + bool operator<(Document &document); }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index d071067c..94717097 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.23 $ + Date: $Date: 2004/10/12 04:35:45 $ + Version: $Revision: 1.24 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,28 +22,31 @@ #include "gdcmBinEntry.h" #include "gdcmSeqEntry.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmElementSet - * \brief Constructor from a given gdcmElementSet + * \ingroup ElementSet + * \brief Constructor from a given ElementSet */ //BOZ depthLevel is not usefull anymore -gdcmElementSet::gdcmElementSet(int depthLevel) - : gdcmDocEntrySet() +ElementSet::ElementSet(int depthLevel) + : DocEntrySet() { (void)depthLevel; } /** - * \ingroup gdcmElementSet + * \ingroup ElementSet * \brief Canonical destructor. */ -gdcmElementSet::~gdcmElementSet() +ElementSet::~ElementSet() { for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc) { - gdcmDocEntry* entryToDelete = cc->second; + DocEntry* entryToDelete = cc->second; if ( entryToDelete ) { delete entryToDelete; @@ -64,13 +67,13 @@ gdcmElementSet::~gdcmElementSet() * from the H Table * @return */ -void gdcmElementSet::Print(std::ostream& os) +void ElementSet::Print(std::ostream& os) { for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i) { - gdcmDocEntry* entry = i->second; + DocEntry* entry = i->second; entry->Print(os); - if ( gdcmSeqEntry* seqEntry = dynamic_cast(entry) ) + if ( SeqEntry* seqEntry = dynamic_cast(entry) ) { (void)seqEntry; // Avoid the newline for a sequence: @@ -85,7 +88,7 @@ void gdcmElementSet::Print(std::ostream& os) * from the H Table * @return */ -void gdcmElementSet::Write(FILE* fp, FileType filetype) +void ElementSet::Write(FILE* fp, FileType filetype) { for (TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i) { @@ -104,13 +107,13 @@ void gdcmElementSet::Write(FILE* fp, FileType filetype) * \brief add a new Dicom Element pointer to the H Table * @param newEntry entry to add */ -bool gdcmElementSet::AddEntry( gdcmDocEntry* newEntry) +bool ElementSet::AddEntry( DocEntry* newEntry) { - gdcmTagKey key = newEntry->GetKey(); + TagKey key = newEntry->GetKey(); if( TagHT.count(key) == 1 ) { - dbg.Verbose(1, "gdcmElementSet::AddEntry key already present: ", + dbg.Verbose(1, "ElementSet::AddEntry key already present: ", key.c_str()); return(false); } @@ -125,17 +128,17 @@ bool gdcmElementSet::AddEntry( gdcmDocEntry* newEntry) * \brief Clear the hash table from given entry BUT keep the entry. * @param entryToRemove Entry to remove. */ -bool gdcmElementSet::RemoveEntryNoDestroy( gdcmDocEntry* entryToRemove) +bool ElementSet::RemoveEntryNoDestroy( DocEntry* entryToRemove) { - gdcmTagKey key = entryToRemove->GetKey(); + TagKey key = entryToRemove->GetKey(); if( TagHT.count(key) == 1 ) { TagHT.erase(key); - dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased."); + dbg.Verbose(0, "ElementSet::RemoveEntry: one element erased."); return true; } - dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: "); + dbg.Verbose(0, "ElementSet::RemoveEntry: key not present: "); return false ; } @@ -143,17 +146,18 @@ bool gdcmElementSet::RemoveEntryNoDestroy( gdcmDocEntry* entryToRemove) * \brief Clear the hash table from given entry AND delete the entry. * @param entryToRemove Entry to remove AND delete. */ -bool gdcmElementSet::RemoveEntry( gdcmDocEntry* entryToRemove) +bool ElementSet::RemoveEntry( DocEntry* entryToRemove) { - gdcmTagKey key = entryToRemove->GetKey(); + TagKey key = entryToRemove->GetKey(); if( TagHT.count(key) == 1 ) { TagHT.erase(key); - dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased."); + dbg.Verbose(0, "ElementSet::RemoveEntry: one element erased."); delete entryToRemove; return true; } - dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: "); + dbg.Verbose(0, "ElementSet::RemoveEntry: key not present: "); return false ; } +} // end namespace gdcm diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index 375576e7..4bf25ae8 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2004/10/07 18:09:11 $ - Version: $Revision: 1.18 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,23 +24,25 @@ #include #include -class gdcmValEntry; -class gdcmBinEntry; -class gdcmSeqEntry; +class ValEntry; +class BinEntry; +class SeqEntry; +namespace gdcm +{ -typedef std::map TagDocEntryHT; +typedef std::map TagDocEntryHT; //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmElementSet : public gdcmDocEntrySet +class GDCM_EXPORT ElementSet : public DocEntrySet { public: - gdcmElementSet(int); - ~gdcmElementSet(); - virtual bool AddEntry(gdcmDocEntry *Entry); - bool RemoveEntry(gdcmDocEntry *EntryToRemove); - bool RemoveEntryNoDestroy(gdcmDocEntry *EntryToRemove); + ElementSet(int); + ~ElementSet(); + virtual bool AddEntry(DocEntry *Entry); + bool RemoveEntry(DocEntry *EntryToRemove); + bool RemoveEntryNoDestroy(DocEntry *EntryToRemove); virtual void Print(std::ostream &os = std::cout); virtual void Write(FILE *fp, FileType filetype); @@ -58,12 +60,12 @@ protected: private: /// Just for following ::GetTagHT() - friend class gdcmDocument; + friend class Document; /// Accessor to \ref TagHT TagDocEntryHT* GetTagHT() { return &TagHT; }; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmException.cxx b/src/gdcmException.cxx index 3f666605..375820b4 100644 --- a/src/gdcmException.cxx +++ b/src/gdcmException.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmException.cxx,v $ Language: C++ - Date: $Date: 2004/10/08 04:52:55 $ - Version: $Revision: 1.19 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,17 +19,19 @@ #include "gdcmException.h" #include +namespace gdcm +{ //----------------------------------------------------------------------------- -// gdcmException +// Exception /** - * \ingroup gdcmException + * \ingroup Exception * \brief constructor * @param f * @param msg */ -gdcmException::gdcmException(const std::string &f, const std::string& msg) throw() +Exception::Exception(const std::string &f, const std::string& msg) throw() #ifdef __GNUC__ try #endif @@ -37,17 +39,17 @@ gdcmException::gdcmException(const std::string &f, const std::string& msg) throw } #ifdef __GNUC__ catch(...) { - fatal("gdcmException::gdcmException(const std::string&, const std::string&, const std::string&)"); + fatal("Exception::Exception(const std::string&, const std::string&, const std::string&)"); } #endif /** - * \ingroup gdcmException + * \ingroup Exception * \brief fatal * @param from */ -void gdcmException::fatal(const char *from) throw() { +void Exception::fatal(const char *from) throw() { try { std::cerr << "Fatal: exception received in " << from @@ -70,11 +72,11 @@ void gdcmException::fatal(const char *from) throw() { } /** - * \ingroup gdcmException + * \ingroup Exception * \brief getName * @return string */ -std::string gdcmException::getName() const throw() +std::string Exception::getName() const throw() { try { @@ -110,26 +112,26 @@ std::string gdcmException::getName() const throw() } /** - * \ingroup gdcmException - * \brief gdcmException + * \ingroup Exception + * \brief Exception */ - gdcmException::operator const char *() const throw() { + Exception::operator const char *() const throw() { return getName().c_str(); } //----------------------------------------------------------------------------- /** - * \ingroup gdcmException - * \brief gdcmException::operator << + * \ingroup Exception + * \brief Exception::operator << */ - std::ostream& operator<<(std::ostream &os, const gdcmException &e) { + std::ostream& operator<<(std::ostream &os, const Exception &e) { try { os << "Exception " << e.getName() << " thrown: " << e.getError() << std::endl; } catch(...) { - gdcmException::fatal("operator<<(std::ostream &, const gdcmException&)"); + Exception::fatal("operator<<(std::ostream &, const Exception&)"); } return os; } - +} // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmException.h b/src/gdcmException.h index 5924e0f7..1fb07a96 100644 --- a/src/gdcmException.h +++ b/src/gdcmException.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmException.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.16 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,12 +23,14 @@ #include #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- /* * Any exception thrown in the gdcm library */ -class GDCM_EXPORT gdcmException : public std::exception +class GDCM_EXPORT Exception : public std::exception { public: /* @@ -38,13 +40,13 @@ public: * @param from name of the thrower * @param error error description string */ - explicit gdcmException(const std::string &from, const std::string &error = "") + explicit Exception(const std::string &from, const std::string &error = "") throw(); /** * \brief virtual destructor makes this class dynamic */ - virtual ~gdcmException() throw() {}; + virtual ~Exception() throw() {}; /// exception caught within exception class: print error message and die static void fatal(const char *from) throw(); @@ -65,7 +67,7 @@ public: /// returns exception name string operator const char *() const throw(); - friend std::ostream& operator<<(std::ostream &os, const gdcmException &e); + friend std::ostream& operator<<(std::ostream &os, const Exception &e); protected: /// error message part 1 @@ -79,7 +81,7 @@ protected: /* * File error exception thrown in the gdcm library */ -class GDCM_EXPORT gdcmFileError : public gdcmException +class GDCM_EXPORT FileError : public Exception { public: /** @@ -88,9 +90,9 @@ public: * @param from name of the thrower * @param error error description string */ - explicit gdcmFileError(const std::string &from, + explicit FileError(const std::string &from, const std::string &error = "File error") - throw() : gdcmException(from, error) { } + throw() : Exception(from, error) { } }; @@ -98,32 +100,32 @@ public: /** * \brief Unexpected file format exception */ -class GDCM_EXPORT gdcmFormatUnexpected : public gdcmException +class GDCM_EXPORT FormatUnexpected : public Exception { public: /// \brief Builds a file-related exception with minimal information: /// name of the thrower method and error message /// @param from name of the thrower /// @param error error description string - explicit gdcmFormatUnexpected(const std::string &from, + explicit FormatUnexpected(const std::string &from, const std::string &error = "Unexpected file format") - throw() : gdcmException( from, error ) { } + throw() : Exception( from, error ) { } }; //----------------------------------------------------------------------------- /** * \brief Invalid file format exception */ -class GDCM_EXPORT gdcmFormatError : public gdcmFormatUnexpected +class GDCM_EXPORT FormatError : public FormatUnexpected { public: /// \brief Builds a file-related exception with minimal information: /// name of the thrower method and error message /// @param from name of the thrower /// @param error error description string - explicit gdcmFormatError(const std::string &from, + explicit FormatError(const std::string &from, const std::string &error = "Invalid file format") - throw() : gdcmFormatUnexpected( from, error ) { } + throw() : FormatUnexpected( from, error ) { } }; //----------------------------------------------------------------------------- @@ -132,7 +134,9 @@ public: * @param e exception to print * @returns output stream os */ -std::ostream& operator<<(std::ostream &os, const gdcmException &e); +std::ostream& operator<<(std::ostream &os, const Exception &e); + +} // end namespace gdcm //----------------------------------------------------------------------------- #endif // GDCM_EXCEPTION_H diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 2cd11677..3484aecf 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.138 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.139 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -20,13 +20,15 @@ #include "gdcmDebug.h" #include "gdcmPixelConvert.h" +namespace gdcm +{ typedef std::pair IterHT; //------------------------------------------------------------------------- // Constructor / Destructor /** * \brief Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 - * file (gdcmHeader only deals with the ... header) + * file (Header only deals with the ... header) * Opens (in read only and when possible) an existing file and checks * for DICOM compliance. Returns NULL on failure. * It will be up to the user to load the pixels into memory @@ -36,18 +38,18 @@ typedef std::pair IterHT; * This avoid a double parsing of public part of the header when * user sets an a posteriori shadow dictionary (efficiency can be * seen as a side effect). - * @param header already built gdcmHeader + * @param header already built Header */ -gdcmFile::gdcmFile(gdcmHeader *header) +File::File(Header *header) { - Header = header; + HeaderInternal = header; SelfHeader = false; Initialise(); } /** * \brief Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 - * file (gdcmHeader only deals with the ... header) + * file (Header only deals with the ... header) * Opens (in read only and when possible) an existing file and checks * for DICOM compliance. Returns NULL on failure. * It will be up to the user to load the pixels into memory @@ -59,9 +61,9 @@ gdcmFile::gdcmFile(gdcmHeader *header) * seen as a side effect). * @param filename file to be opened for parsing */ -gdcmFile::gdcmFile(std::string const & filename ) +File::File(std::string const & filename ) { - Header = new gdcmHeader( filename ); + HeaderInternal = new Header( filename ); SelfHeader = true; Initialise(); } @@ -69,12 +71,12 @@ gdcmFile::gdcmFile(std::string const & filename ) /** * \brief Factorization for various forms of constructors. */ -void gdcmFile::Initialise() +void File::Initialise() { - if ( Header->IsReadable() ) + if ( HeaderInternal->IsReadable() ) { ImageDataSizeRaw = ComputeDecompressedPixelDataSizeFromHeader(); - if ( Header->HasLUT() ) + if ( HeaderInternal->HasLUT() ) { ImageDataSize = 3 * ImageDataSizeRaw; } @@ -88,16 +90,16 @@ void gdcmFile::Initialise() /** * \brief canonical destructor - * \note If the gdcmHeader was created by the gdcmFile constructor, - * it is destroyed by the gdcmFile + * \note If the Header was created by the File constructor, + * it is destroyed by the File */ -gdcmFile::~gdcmFile() +File::~File() { if( SelfHeader ) { - delete Header; + delete HeaderInternal; } - Header = 0; + HeaderInternal = 0; DeleteInitialValues(); } @@ -106,7 +108,7 @@ gdcmFile::~gdcmFile() * \brief Sets some initial values for the Constructor * \warning not end user intended */ -void gdcmFile::SaveInitialValues() +void File::SaveInitialValues() { PixelRead = -1; // no ImageData read yet. @@ -126,28 +128,28 @@ void gdcmFile::SaveInitialValues() InitialGreenLUTData = 0; InitialBlueLUTData = 0; - if ( Header->IsReadable() ) + if ( HeaderInternal->IsReadable() ) { // the following values *may* be modified - // by gdcmFile::GetImageDataIntoVectorRaw + // by File::GetImageDataIntoVectorRaw // we save their initial value. - InitialSpp = Header->GetEntryByNumber(0x0028,0x0002); - InitialPhotInt = Header->GetEntryByNumber(0x0028,0x0004); - InitialPlanConfig = Header->GetEntryByNumber(0x0028,0x0006); + InitialSpp = HeaderInternal->GetEntryByNumber(0x0028,0x0002); + InitialPhotInt = HeaderInternal->GetEntryByNumber(0x0028,0x0004); + InitialPlanConfig = HeaderInternal->GetEntryByNumber(0x0028,0x0006); - InitialBitsAllocated = Header->GetEntryByNumber(0x0028,0x0100); - InitialHighBit = Header->GetEntryByNumber(0x0028,0x0102); + InitialBitsAllocated = HeaderInternal->GetEntryByNumber(0x0028,0x0100); + InitialHighBit = HeaderInternal->GetEntryByNumber(0x0028,0x0102); // the following entries *may* be removed from the H table - // (NOT deleted ...) by gdcmFile::GetImageDataIntoVectorRaw + // (NOT deleted ...) by File::GetImageDataIntoVectorRaw // we keep a pointer on them. - InitialRedLUTDescr = Header->GetDocEntryByNumber(0x0028,0x1101); - InitialGreenLUTDescr = Header->GetDocEntryByNumber(0x0028,0x1102); - InitialBlueLUTDescr = Header->GetDocEntryByNumber(0x0028,0x1103); + InitialRedLUTDescr = HeaderInternal->GetDocEntryByNumber(0x0028,0x1101); + InitialGreenLUTDescr = HeaderInternal->GetDocEntryByNumber(0x0028,0x1102); + InitialBlueLUTDescr = HeaderInternal->GetDocEntryByNumber(0x0028,0x1103); - InitialRedLUTData = Header->GetDocEntryByNumber(0x0028,0x1201); - InitialGreenLUTData = Header->GetDocEntryByNumber(0x0028,0x1202); - InitialBlueLUTData = Header->GetDocEntryByNumber(0x0028,0x1203); + InitialRedLUTData = HeaderInternal->GetDocEntryByNumber(0x0028,0x1201); + InitialGreenLUTData = HeaderInternal->GetDocEntryByNumber(0x0028,0x1202); + InitialBlueLUTData = HeaderInternal->GetDocEntryByNumber(0x0028,0x1203); } } @@ -155,42 +157,42 @@ void gdcmFile::SaveInitialValues() * \brief restores some initial values * \warning not end user intended */ -void gdcmFile::RestoreInitialValues() +void File::RestoreInitialValues() { - if ( Header->IsReadable() ) + if ( HeaderInternal->IsReadable() ) { // the following values *may* have been modified - // by gdcmFile::GetImageDataIntoVectorRaw + // by File::GetImageDataIntoVectorRaw // we restore their initial value. if ( InitialSpp != "") - Header->SetEntryByNumber(InitialSpp,0x0028,0x0002); + HeaderInternal->SetEntryByNumber(InitialSpp,0x0028,0x0002); if ( InitialPhotInt != "") - Header->SetEntryByNumber(InitialPhotInt,0x0028,0x0004); + HeaderInternal->SetEntryByNumber(InitialPhotInt,0x0028,0x0004); if ( InitialPlanConfig != "") - Header->SetEntryByNumber(InitialPlanConfig,0x0028,0x0006); + HeaderInternal->SetEntryByNumber(InitialPlanConfig,0x0028,0x0006); if ( InitialBitsAllocated != "") - Header->SetEntryByNumber(InitialBitsAllocated,0x0028,0x0100); + HeaderInternal->SetEntryByNumber(InitialBitsAllocated,0x0028,0x0100); if ( InitialHighBit != "") - Header->SetEntryByNumber(InitialHighBit,0x0028,0x0102); + HeaderInternal->SetEntryByNumber(InitialHighBit,0x0028,0x0102); // the following entries *may* be have been removed from the H table - // (NOT deleted ...) by gdcmFile::GetImageDataIntoVectorRaw + // (NOT deleted ...) by File::GetImageDataIntoVectorRaw // we restore them. if (InitialRedLUTDescr) - Header->AddEntry(InitialRedLUTDescr); + HeaderInternal->AddEntry(InitialRedLUTDescr); if (InitialGreenLUTDescr) - Header->AddEntry(InitialGreenLUTDescr); + HeaderInternal->AddEntry(InitialGreenLUTDescr); if (InitialBlueLUTDescr) - Header->AddEntry(InitialBlueLUTDescr); + HeaderInternal->AddEntry(InitialBlueLUTDescr); if (InitialRedLUTData) - Header->AddEntry(InitialBlueLUTDescr); + HeaderInternal->AddEntry(InitialBlueLUTDescr); if (InitialGreenLUTData) - Header->AddEntry(InitialGreenLUTData); + HeaderInternal->AddEntry(InitialGreenLUTData); if (InitialBlueLUTData) - Header->AddEntry(InitialBlueLUTData); + HeaderInternal->AddEntry(InitialBlueLUTData); } } @@ -198,7 +200,7 @@ void gdcmFile::RestoreInitialValues() * \brief delete initial values (il they were saved) * of InitialLutDescriptors and InitialLutData */ -void gdcmFile::DeleteInitialValues() +void File::DeleteInitialValues() { // InitialLutDescriptors and InitialLutData @@ -236,7 +238,7 @@ void gdcmFile::DeleteInitialValues() * \warning : it is NOT the group 7FE0 length * (no interest for compressed images). */ -int gdcmFile::ComputeDecompressedPixelDataSizeFromHeader() +int File::ComputeDecompressedPixelDataSizeFromHeader() { // see PS 3.3-2003 : C.7.6.3.2.1 // @@ -265,17 +267,17 @@ int gdcmFile::ComputeDecompressedPixelDataSizeFromHeader() // 0028|1203 [US] [Blue Palette Color Lookup Table Data] // Number of "Bits Allocated" - int numberBitsAllocated = Header->GetBitsAllocated(); + int numberBitsAllocated = HeaderInternal->GetBitsAllocated(); if ( ( numberBitsAllocated == 0 ) || ( numberBitsAllocated == 12 ) ) { numberBitsAllocated = 16; } - int DecompressedSize = Header->GetXSize() - * Header->GetYSize() - * Header->GetZSize() + int DecompressedSize = HeaderInternal->GetXSize() + * HeaderInternal->GetYSize() + * HeaderInternal->GetZSize() * ( numberBitsAllocated / 8 ) - * Header->GetSamplesPerPixel(); + * HeaderInternal->GetSamplesPerPixel(); return DecompressedSize; } @@ -290,7 +292,7 @@ int gdcmFile::ComputeDecompressedPixelDataSizeFromHeader() * @return Pointer to newly allocated pixel data. * NULL if alloc fails */ -uint8_t* gdcmFile::GetImageData() +uint8_t* File::GetImageData() { // FIXME (Mathieu) // I need to deallocate Pixel_Data before doing any allocation: @@ -346,11 +348,11 @@ uint8_t* gdcmFile::GetImageData() * @return On success, the number of bytes actually copied. Zero on * failure e.g. MaxSize is lower than necessary. */ -size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t maxSize) +size_t File::GetImageDataIntoVector (void* destination, size_t maxSize) { GetImageDataIntoVectorRaw (destination, maxSize); PixelRead = 0 ; // =0 : no ImageDataRaw - if ( !Header->HasLUT() ) + if ( !HeaderInternal->HasLUT() ) { return ImageDataSize; } @@ -358,7 +360,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t maxSize) // from Lut R + Lut G + Lut B uint8_t *newDest = new uint8_t[ImageDataSize]; uint8_t *a = (uint8_t *)destination; - uint8_t *lutRGBA = Header->GetLUTRGBA(); + uint8_t *lutRGBA = HeaderInternal->GetLUTRGBA(); if ( lutRGBA ) { @@ -381,11 +383,11 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t maxSize) // FIXME : Better use CreateOrReplaceIfExist ? std::string spp = "3"; // Samples Per Pixel - Header->SetEntryByNumber(spp,0x0028,0x0002); + HeaderInternal->SetEntryByNumber(spp,0x0028,0x0002); std::string rgb = "RGB "; // Photometric Interpretation - Header->SetEntryByNumber(rgb,0x0028,0x0004); + HeaderInternal->SetEntryByNumber(rgb,0x0028,0x0004); std::string planConfig = "0"; // Planar Configuration - Header->SetEntryByNumber(planConfig,0x0028,0x0006); + HeaderInternal->SetEntryByNumber(planConfig,0x0028,0x0006); } else // GetLUTRGBA() failed @@ -397,7 +399,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t maxSize) // It seems that *no Dicom Viewer* has any idea :-( std::string photomInterp = "MONOCHROME1 "; // Photometric Interpretation - Header->SetEntryByNumber(photomInterp,0x0028,0x0004); + HeaderInternal->SetEntryByNumber(photomInterp,0x0028,0x0004); } /// \todo Drop Palette Color out of the Header? @@ -413,11 +415,11 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t maxSize) * @return Pointer to newly allocated pixel data. * \ NULL if alloc fails */ -uint8_t* gdcmFile::GetImageDataRaw () +uint8_t* File::GetImageDataRaw () { size_t imgDataSize; - if ( Header->HasLUT() ) - /// \todo Let gdcmHeader user a chance to get the right value + if ( HeaderInternal->HasLUT() ) + /// \todo Let Header user a chance to get the right value imgDataSize = ImageDataSizeRaw; else imgDataSize = ImageDataSize; @@ -474,7 +476,7 @@ uint8_t* gdcmFile::GetImageDataRaw () * @return On success, the number of bytes actually copied. Zero on * failure e.g. MaxSize is lower than necessary. */ -size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) +size_t File::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) { // we save the initial values of the following // in order to be able to restore the header in a disk-consistent state @@ -489,7 +491,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) if ( ImageDataSize > maxSize ) { - dbg.Verbose(0, "gdcmFile::GetImageDataIntoVector: pixel data bigger" + dbg.Verbose(0, "File::GetImageDataIntoVector: pixel data bigger" "than caller's expected MaxSize"); return (size_t)0; } @@ -497,37 +499,37 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) ReadPixelData( destination ); // Number of Bits Allocated for storing a Pixel - int numberBitsAllocated = Header->GetBitsAllocated(); + int numberBitsAllocated = HeaderInternal->GetBitsAllocated(); if ( numberBitsAllocated == 0 ) { numberBitsAllocated = 16; } // Number of Bits actually used - int numberBitsStored = Header->GetBitsStored(); + int numberBitsStored = HeaderInternal->GetBitsStored(); if ( numberBitsStored == 0 ) { numberBitsStored = numberBitsAllocated; } // High Bit Position - int highBitPosition = Header->GetHighBitPosition(); + int highBitPosition = HeaderInternal->GetHighBitPosition(); if ( highBitPosition == 0 ) { highBitPosition = numberBitsAllocated - 1; } - bool signedPixel = Header->IsSignedPixelData(); + bool signedPixel = HeaderInternal->IsSignedPixelData(); - gdcmPixelConvert::ConvertReorderEndianity( + PixelConvert::ConvertReorderEndianity( (uint8_t*) destination, ImageDataSize, numberBitsStored, numberBitsAllocated, - Header->GetSwapCode(), + HeaderInternal->GetSwapCode(), signedPixel ); - gdcmPixelConvert::ConvertReArrangeBits( + PixelConvert::ConvertReArrangeBits( (uint8_t*) destination, ImageDataSize, numberBitsStored, @@ -548,7 +550,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) // Deal with the color // Monochrome pictures don't require color intervention - if ( Header->IsMonochrome() ) + if ( HeaderInternal->IsMonochrome() ) { return ImageDataSize; } @@ -562,13 +564,13 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) // PhotometricInterpretation=PALETTE COLOR // and heuristic has to be found :-( - int planConf = Header->GetPlanarConfiguration(); + int planConf = HeaderInternal->GetPlanarConfiguration(); // Planar configuration = 2 ==> 1 gray Plane + 3 LUT // ...and... // whatever the Planar Configuration might be, "PALETTE COLOR " // implies that we deal with the palette. - if ( ( planConf == 2 ) || Header->IsPaletteColor() ) + if ( ( planConf == 2 ) || HeaderInternal->IsPaletteColor() ) { return ImageDataSize; } @@ -579,7 +581,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) { uint8_t* newDest = new uint8_t[ImageDataSize]; // Warning : YBR_FULL_422 acts as RGB - if ( Header->IsYBRFull() ) + if ( HeaderInternal->IsYBRFull() ) { ConvertYcBcRPlanesToRGBPixels((uint8_t*)destination, newDest); } @@ -607,9 +609,9 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) std::string photInt = "RGB "; // Photometric Interpretation std::string planConfig = "0"; // Planar Configuration - Header->SetEntryByNumber(spp,0x0028,0x0002); - Header->SetEntryByNumber(photInt,0x0028,0x0004); - Header->SetEntryByNumber(planConfig,0x0028,0x0006); + HeaderInternal->SetEntryByNumber(spp,0x0028,0x0002); + HeaderInternal->SetEntryByNumber(photInt,0x0028,0x0004); + HeaderInternal->SetEntryByNumber(planConfig,0x0028,0x0006); return ImageDataSize; } @@ -618,7 +620,7 @@ size_t gdcmFile::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) * \brief Convert (Y plane, cB plane, cR plane) to RGB pixels * \warning Works on all the frames at a time */ -void gdcmFile::ConvertYcBcRPlanesToRGBPixels(uint8_t* source, +void File::ConvertYcBcRPlanesToRGBPixels(uint8_t* source, uint8_t* destination) { // to see the tricks about YBR_FULL, YBR_FULL_422, @@ -626,8 +628,8 @@ void gdcmFile::ConvertYcBcRPlanesToRGBPixels(uint8_t* source, // ftp://medical.nema.org/medical/dicom/final/sup61_ft.pdf // and be *very* affraid // - int l = Header->GetXSize() * Header->GetYSize(); - int nbFrames = Header->GetZSize(); + int l = HeaderInternal->GetXSize() * HeaderInternal->GetYSize(); + int nbFrames = HeaderInternal->GetZSize(); uint8_t* a = source; uint8_t* b = source + l; @@ -668,10 +670,10 @@ void gdcmFile::ConvertYcBcRPlanesToRGBPixels(uint8_t* source, * \brief Convert (Red plane, Green plane, Blue plane) to RGB pixels * \warning Works on all the frames at a time */ -void gdcmFile::ConvertRGBPlanesToRGBPixels(uint8_t* source, +void File::ConvertRGBPlanesToRGBPixels(uint8_t* source, uint8_t* destination) { - int l = Header->GetXSize() * Header->GetYSize() * Header->GetZSize(); + int l = HeaderInternal->GetXSize() * HeaderInternal->GetYSize() * HeaderInternal->GetZSize(); uint8_t* a = source; uint8_t* b = source + l; @@ -698,9 +700,9 @@ void gdcmFile::ConvertRGBPlanesToRGBPixels(uint8_t* source, * * @return boolean */ -bool gdcmFile::SetImageData(uint8_t* inData, size_t expectedSize) +bool File::SetImageData(uint8_t* inData, size_t expectedSize) { - Header->SetImageDataSize( expectedSize ); + HeaderInternal->SetImageDataSize( expectedSize ); // FIXME : if already allocated, memory leak ! Pixel_Data = inData; ImageDataSize = ImageDataSizeRaw = expectedSize; @@ -718,7 +720,7 @@ bool gdcmFile::SetImageData(uint8_t* inData, size_t expectedSize) * @return false if write fails */ -bool gdcmFile::WriteRawData(std::string const & fileName) +bool File::WriteRawData(std::string const & fileName) { FILE* fp1 = fopen(fileName.c_str(), "wb"); if (fp1 == NULL) @@ -741,9 +743,9 @@ bool gdcmFile::WriteRawData(std::string const & fileName) * @return false if write fails */ -bool gdcmFile::WriteDcmImplVR (std::string const & fileName) +bool File::WriteDcmImplVR (std::string const & fileName) { - return WriteBase(fileName, gdcmImplicitVR); + return WriteBase(fileName, ImplicitVR); } /** @@ -754,9 +756,9 @@ bool gdcmFile::WriteDcmImplVR (std::string const & fileName) * @return false if write fails */ -bool gdcmFile::WriteDcmExplVR (std::string const & fileName) +bool File::WriteDcmExplVR (std::string const & fileName) { - return WriteBase(fileName, gdcmExplicitVR); + return WriteBase(fileName, ExplicitVR); } /** @@ -773,9 +775,9 @@ bool gdcmFile::WriteDcmExplVR (std::string const & fileName) * @return false if write fails */ -bool gdcmFile::WriteAcr (std::string const & fileName) +bool File::WriteAcr (std::string const & fileName) { - return WriteBase(fileName, gdcmACR); + return WriteBase(fileName, ACR); } //----------------------------------------------------------------------------- @@ -788,9 +790,9 @@ bool gdcmFile::WriteAcr (std::string const & fileName) * @param type file type (ExplicitVR, ImplicitVR, ...) * @return false if write fails */ -bool gdcmFile::WriteBase (std::string const & fileName, FileType type) +bool File::WriteBase (std::string const & fileName, FileType type) { - if ( PixelRead == -1 && type != gdcmExplicitVR) + if ( PixelRead == -1 && type != ExplicitVR) { return false; } @@ -802,7 +804,7 @@ bool gdcmFile::WriteBase (std::string const & fileName, FileType type) return false; } - if ( type == gdcmImplicitVR || type == gdcmExplicitVR ) + if ( type == ImplicitVR || type == ExplicitVR ) { // writing Dicom File Preamble uint8_t* filePreamble = new uint8_t[128]; @@ -824,20 +826,20 @@ bool gdcmFile::WriteBase (std::string const & fileName, FileType type) /// but pb expected if user deals with, e.g. COMPLEX images std::string rows, columns; - if ( Header->GetFileType() == gdcmACR_LIBIDO) + if ( HeaderInternal->GetFileType() == ACR_LIBIDO) { - rows = Header->GetEntryByNumber(0x0028, 0x0010); - columns = Header->GetEntryByNumber(0x0028, 0x0011); + rows = HeaderInternal->GetEntryByNumber(0x0028, 0x0010); + columns = HeaderInternal->GetEntryByNumber(0x0028, 0x0011); - Header->SetEntryByNumber(columns, 0x0028, 0x0010); - Header->SetEntryByNumber(rows , 0x0028, 0x0011); + HeaderInternal->SetEntryByNumber(columns, 0x0028, 0x0010); + HeaderInternal->SetEntryByNumber(rows , 0x0028, 0x0011); } // ----------------- End of Special Patch ---------------- - uint16_t grPixel = Header->GetGrPixel(); - uint16_t numPixel = Header->GetNumPixel();; + uint16_t grPixel = HeaderInternal->GetGrPixel(); + uint16_t numPixel = HeaderInternal->GetNumPixel();; - gdcmDocEntry* PixelElement = + DocEntry* PixelElement = GetHeader()->GetDocEntryByNumber(grPixel, numPixel); if ( PixelRead == 1 ) @@ -851,7 +853,7 @@ bool gdcmFile::WriteBase (std::string const & fileName, FileType type) PixelElement->SetLength( ImageDataSize ); } - Header->Write(fp1, type); + HeaderInternal->Write(fp1, type); // -------------------------------------------------------------- // Special Patch to allow gdcm to re-write ACR-LibIDO formated images @@ -859,10 +861,10 @@ bool gdcmFile::WriteBase (std::string const & fileName, FileType type) // ...and we restore the Header to be Dicom Compliant again // just after writting - if ( Header->GetFileType() == gdcmACR_LIBIDO ) + if ( HeaderInternal->GetFileType() == ACR_LIBIDO ) { - Header->SetEntryByNumber(rows , 0x0028, 0x0010); - Header->SetEntryByNumber(columns, 0x0028, 0x0011); + HeaderInternal->SetEntryByNumber(rows , 0x0028, 0x0010); + HeaderInternal->SetEntryByNumber(columns, 0x0028, 0x0011); } // ----------------- End of Special Patch ---------------- @@ -880,40 +882,40 @@ bool gdcmFile::WriteBase (std::string const & fileName, FileType type) * @param destination where the pixel data should be stored. * */ -bool gdcmFile::ReadPixelData(void* destination) +bool File::ReadPixelData(void* destination) { - FILE* fp = Header->OpenFile(); + FILE* fp = HeaderInternal->OpenFile(); if ( !fp ) { return false; } - if ( fseek(fp, Header->GetPixelOffset(), SEEK_SET) == -1 ) + if ( fseek(fp, HeaderInternal->GetPixelOffset(), SEEK_SET) == -1 ) { - Header->CloseFile(); + HeaderInternal->CloseFile(); return false; } - if ( Header->GetBitsAllocated() == 12 ) + if ( HeaderInternal->GetBitsAllocated() == 12 ) { - gdcmPixelConvert::ConvertDecompress12BitsTo16Bits( + PixelConvert::ConvertDecompress12BitsTo16Bits( (uint8_t*)destination, - Header->GetXSize(), - Header->GetYSize(), + HeaderInternal->GetXSize(), + HeaderInternal->GetYSize(), fp); - Header->CloseFile(); + HeaderInternal->CloseFile(); return true; } // ---------------------- Uncompressed File - if ( !Header->IsDicomV3() || - Header->IsImplicitVRLittleEndianTransferSyntax() || - Header->IsExplicitVRLittleEndianTransferSyntax() || - Header->IsExplicitVRBigEndianTransferSyntax() || - Header->IsDeflatedExplicitVRLittleEndianTransferSyntax() ) + if ( !HeaderInternal->IsDicomV3() || + HeaderInternal->IsImplicitVRLittleEndianTransferSyntax() || + HeaderInternal->IsExplicitVRLittleEndianTransferSyntax() || + HeaderInternal->IsExplicitVRBigEndianTransferSyntax() || + HeaderInternal->IsDeflatedExplicitVRLittleEndianTransferSyntax() ) { - size_t ItemRead = fread(destination, Header->GetPixelAreaLength(), 1, fp); - Header->CloseFile(); + size_t ItemRead = fread(destination, HeaderInternal->GetPixelAreaLength(), 1, fp); + HeaderInternal->CloseFile(); if ( ItemRead != 1 ) { return false; @@ -925,40 +927,42 @@ bool gdcmFile::ReadPixelData(void* destination) } // ---------------------- Run Length Encoding - if ( Header->IsRLELossLessTransferSyntax() ) + if ( HeaderInternal->IsRLELossLessTransferSyntax() ) { - bool res = gdcmPixelConvert::ReadAndDecompressRLEFile( + bool res = PixelConvert::ReadAndDecompressRLEFile( destination, - Header->GetXSize(), - Header->GetYSize(), - Header->GetZSize(), - Header->GetBitsAllocated(), - &(Header->RLEInfo), + HeaderInternal->GetXSize(), + HeaderInternal->GetYSize(), + HeaderInternal->GetZSize(), + HeaderInternal->GetBitsAllocated(), + &(HeaderInternal->RLEInfo), fp ); - Header->CloseFile(); + HeaderInternal->CloseFile(); return res; } // --------------- SingleFrame/Multiframe JPEG Lossless/Lossy/2000 - int numberBitsAllocated = Header->GetBitsAllocated(); + int numberBitsAllocated = HeaderInternal->GetBitsAllocated(); if ( ( numberBitsAllocated == 0 ) || ( numberBitsAllocated == 12 ) ) { numberBitsAllocated = 16; } - bool res = gdcmPixelConvert::ReadAndDecompressJPEGFile( + bool res = PixelConvert::ReadAndDecompressJPEGFile( (uint8_t*)destination, - Header->GetXSize(), - Header->GetYSize(), - Header->GetBitsAllocated(), - Header->GetBitsStored(), - Header->GetSamplesPerPixel(), - Header->GetPixelSize(), - Header->IsJPEG2000(), - Header->IsJPEGLossless(), - &(Header->JPEGInfo), + HeaderInternal->GetXSize(), + HeaderInternal->GetYSize(), + HeaderInternal->GetBitsAllocated(), + HeaderInternal->GetBitsStored(), + HeaderInternal->GetSamplesPerPixel(), + HeaderInternal->GetPixelSize(), + HeaderInternal->IsJPEG2000(), + HeaderInternal->IsJPEGLossless(), + &(HeaderInternal->JPEGInfo), fp ); - Header->CloseFile(); + HeaderInternal->CloseFile(); return res; } +} // end namespace gdcm + diff --git a/src/gdcmFile.h b/src/gdcmFile.h index 7d153eff..5ef9efea 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.59 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.60 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,22 +22,25 @@ #include "gdcmCommon.h" #include "gdcmHeader.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- /* * In addition to Dicom header exploration, this class is designed * for accessing the image/volume content. One can also use it to * write Dicom/ACR-NEMA/RAW files. */ -class GDCM_EXPORT gdcmFile +class GDCM_EXPORT File { public: - gdcmFile( gdcmHeader *header ); - gdcmFile( std::string const& filename ); + File( Header *header ); + File( std::string const& filename ); - virtual ~gdcmFile(); + virtual ~File(); /// Accessor to \ref Header - gdcmHeader* GetHeader() { return Header; } + Header* GetHeader() { return HeaderInternal; } int ComputeDecompressedPixelDataSizeFromHeader(); @@ -55,7 +58,7 @@ public: uint8_t* GetImageDataRaw(); size_t GetImageDataIntoVectorRaw(void* destination, size_t maxSize); - // see also gdcmHeader::SetImageDataSize ?!? + // see also Header::SetImageDataSize ?!? bool SetImageData (uint8_t* data, size_t expectedSize); /// \todo When the caller is aware we simply point to the data: @@ -76,7 +79,7 @@ public: virtual bool SetEntryByNumber(std::string const& content, uint16_t group, uint16_t element) { - Header->SetEntryByNumber(content,group,element); + HeaderInternal->SetEntryByNumber(content,group,element); return true; } @@ -98,16 +101,16 @@ private: int image_width, int image_height, int quality); - void SaveInitialValues(); // will belong to the future gdcmPixelData class - void RestoreInitialValues(); // will belong to the future gdcmPixelData class - void DeleteInitialValues(); // will belong to the future gdcmPixelData class + void SaveInitialValues(); // will belong to the future PixelData class + void RestoreInitialValues(); // will belong to the future PixelData class + void DeleteInitialValues(); // will belong to the future PixelData class // members variables: /// \brief Header to use to load the file - gdcmHeader *Header; + Header *HeaderInternal; - /// \brief Whether the underlying \ref gdcmHeader was loaded by + /// \brief Whether the underlying \ref Header was loaded by /// the constructor or passed to the constructor. When false /// the destructor is in charge of deletion. bool SelfHeader; @@ -116,7 +119,7 @@ private: bool Parsed; // -// --------------- Will be moved to a gdcmPixelData class +// --------------- Will be moved to a PixelData class // /// \brief to hold the Pixels (when read) @@ -166,24 +169,25 @@ private: // We keep a pointer on them for a future use. /// \brief Red Palette Color Lookup Table Descriptor 0028 1101 as read - gdcmDocEntry* InitialRedLUTDescr; + DocEntry* InitialRedLUTDescr; /// \brief Green Palette Color Lookup Table Descriptor 0028 1102 as read - gdcmDocEntry* InitialGreenLUTDescr; + DocEntry* InitialGreenLUTDescr; /// \brief Blue Palette Color Lookup Table Descriptor 0028 1103 as read - gdcmDocEntry* InitialBlueLUTDescr; + DocEntry* InitialBlueLUTDescr; /// \brief Red Palette Color Lookup Table Data 0028 1201 as read - gdcmDocEntry* InitialRedLUTData; + DocEntry* InitialRedLUTData; /// \brief Green Palette Color Lookup Table Data 0028 1202 as read - gdcmDocEntry* InitialGreenLUTData; + DocEntry* InitialGreenLUTData; /// \brief Blue Palette Color Lookup Table Data 0028 1203 as read - gdcmDocEntry* InitialBlueLUTData; + DocEntry* InitialBlueLUTData; // -// --------------- end of future gdcmPixelData class +// --------------- end of future PixelData class // }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmGlobal.cxx b/src/gdcmGlobal.cxx index 0229c8ed..d875390a 100644 --- a/src/gdcmGlobal.cxx +++ b/src/gdcmGlobal.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmGlobal.cxx,v $ Language: C++ - Date: $Date: 2004/10/08 04:52:55 $ - Version: $Revision: 1.4 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,94 +19,98 @@ #include "gdcmGlobal.h" #include "gdcmDebug.h" +namespace gdcm +{ + /** * \ingroup Globals * \brief Pointer to a container, holding _all_ the Dicom Dictionaries. */ -gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0; +DictSet *Global::Dicts = (DictSet *)0; /** * \ingroup Globals * \brief Pointer to a hash table containing the 'Value Representations'. */ -gdcmVR *gdcmGlobal::VR = (gdcmVR *)0; +VR *Global::ValRes = (VR *)0; /** * \ingroup Globals * \brief Pointer to a hash table containing the Transfer Syntax codes * and their english description */ -gdcmTS *gdcmGlobal::TS = (gdcmTS *)0; +TS *Global::TranSyn = (TS *)0; /** * \ingroup Globals * \brief Pointer to the hash table containing the Dicom Elements * necessary to describe each part of a DICOMDIR */ -gdcmDicomDirElement *gdcmGlobal::ddElem = (gdcmDicomDirElement *)0; +DicomDirElement *Global::ddElem = (DicomDirElement *)0; /** * \ingroup Globals * \brief Global container */ -gdcmGlobal gdcmGlob; +Global Glob; /** - * \ingroup gdcmGlobal + * \ingroup Global * \brief constructor : populates the various H Tables */ -gdcmGlobal::gdcmGlobal() +Global::Global() { - if (VR || TS || Dicts || ddElem) + if (ValRes || TranSyn || Dicts || ddElem) { - dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated"); + dbg.Verbose(0, "Global::Global : VR or TS or Dicts already allocated"); } - Dicts = new gdcmDictSet(); - VR = new gdcmVR(); - TS = new gdcmTS(); - ddElem = new gdcmDicomDirElement(); + Dicts = new DictSet(); + ValRes = new VR(); + TranSyn = new TS(); + ddElem = new DicomDirElement(); } /** - * \ingroup gdcmGlobal + * \ingroup Global * \brief canonical destructor */ -gdcmGlobal::~gdcmGlobal() +Global::~Global() { delete Dicts; - delete VR; - delete TS; + delete ValRes; + delete TranSyn; delete ddElem; } /** - * \ingroup gdcmGlobal + * \ingroup Global * \brief returns a pointer to the 'Value Representation Table' */ -gdcmVR *gdcmGlobal::GetVR() +VR *Global::GetVR() { - return VR; + return ValRes; } /** - * \ingroup gdcmGlobal + * \ingroup Global * \brief returns a pointer to the 'Transfert Syntax Table' */ -gdcmTS *gdcmGlobal::GetTS() +TS *Global::GetTS() { - return TS; + return TranSyn; } /** - * \ingroup gdcmGlobal + * \ingroup Global * \brief returns a pointer to Dictionaries Table */ -gdcmDictSet *gdcmGlobal::GetDicts() +DictSet *Global::GetDicts() { return Dicts; } /** - * \ingroup gdcmGlobal + * \ingroup Global * \brief returns a pointer to the DicomDir related elements Table */ -gdcmDicomDirElement *gdcmGlobal::GetDicomDirElements() +DicomDirElement *Global::GetDicomDirElements() { return ddElem; } +} // end namespace gdcm diff --git a/src/gdcmGlobal.h b/src/gdcmGlobal.h index 10b87c68..7043d6d6 100644 --- a/src/gdcmGlobal.h +++ b/src/gdcmGlobal.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmGlobal.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,27 +24,32 @@ #include "gdcmDictSet.h" #include "gdcmDicomDirElement.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- /** * \brief This class contains all globals elements that might be * instanciated only once (singletons). */ -class GDCM_EXPORT gdcmGlobal { +class GDCM_EXPORT Global +{ public: - gdcmGlobal(void); - ~gdcmGlobal(); + Global(); + ~Global(); - static gdcmDictSet *GetDicts(void); - static gdcmVR *GetVR(void); - static gdcmTS *GetTS(void); - static gdcmDicomDirElement *GetDicomDirElements(void); + static DictSet *GetDicts(); + static VR *GetVR(); + static TS *GetTS(); + static DicomDirElement *GetDicomDirElements(); private: - static gdcmDictSet *Dicts; - static gdcmVR *VR; - static gdcmTS *TS; - static gdcmDicomDirElement *ddElem; + static DictSet *Dicts; + static VR *ValRes; + static TS *TranSyn; + static DicomDirElement *ddElem; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index a623626f..b6801f8b 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:54 $ - Version: $Revision: 1.192 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.193 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,14 +25,17 @@ #include +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** * \brief Constructor * @param filename name of the file whose header we want to analyze */ -gdcmHeader::gdcmHeader( std::string const & filename ): - gdcmDocument( filename ) +Header::Header( std::string const & filename ): + Document( filename ) { // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010 // We may encounter the 'RETired' (0x0028, 0x0200) tag @@ -78,15 +81,15 @@ gdcmHeader::gdcmHeader( std::string const & filename ): /** * \brief Constructor */ -gdcmHeader::gdcmHeader() - :gdcmDocument() +Header::Header() + :Document() { } /** * \brief Canonical destructor. */ -gdcmHeader::~gdcmHeader () +Header::~Header () { } @@ -99,7 +102,7 @@ gdcmHeader::~gdcmHeader () * @param filetype Type of the File to be written * (ACR-NEMA, ExplicitVR, ImplicitVR) */ -void gdcmHeader::Write(FILE* fp,FileType filetype) +void Header::Write(FILE* fp,FileType filetype) { // Bits Allocated if ( GetEntryByNumber(0x0028,0x0100) == "12") @@ -114,11 +117,11 @@ void gdcmHeader::Write(FILE* fp,FileType filetype) { // no (GrPixel, NumPixel) element std::string s_lgPix; - s_lgPix = gdcmUtil::Format("%d", i_lgPix+12); + s_lgPix = Util::Format("%d", i_lgPix+12); ReplaceOrCreateByNumber(s_lgPix,GrPixel, 0x0000); } - // FIXME : should be nice if we could move it to gdcmFile + // FIXME : should be nice if we could move it to File // (or in future gdcmPixelData class) // Drop Palette Color, if necessary @@ -129,7 +132,7 @@ void gdcmHeader::Write(FILE* fp,FileType filetype) // Drop 0028|1101, 0028|1102, 0028|1103 // Drop 0028|1201, 0028|1202, 0028|1203 - gdcmDocEntry* e = GetDocEntryByNumber(0x0028,0x01101); + DocEntry* e = GetDocEntryByNumber(0x0028,0x01101); if (e) { RemoveEntryNoDestroy(e); @@ -160,7 +163,7 @@ void gdcmHeader::Write(FILE* fp,FileType filetype) RemoveEntryNoDestroy(e); } } - gdcmDocument::Write(fp,filetype); + Document::Write(fp,filetype); } //----------------------------------------------------------------------------- @@ -172,15 +175,15 @@ void gdcmHeader::Write(FILE* fp,FileType filetype) /** * \brief This predicate, based on hopefully reasonable heuristics, - * decides whether or not the current gdcmHeader was properly parsed + * decides whether or not the current Header was properly parsed * and contains the mandatory information for being considered as * a well formed and usable Dicom/Acr File. - * @return true when gdcmHeader is the one of a reasonable Dicom/Acr file, + * @return true when Header is the one of a reasonable Dicom/Acr file, * false otherwise. */ -bool gdcmHeader::IsReadable() +bool Header::IsReadable() { - if( !gdcmDocument::IsReadable() ) + if( !Document::IsReadable() ) { return false; } @@ -215,7 +218,7 @@ bool gdcmHeader::IsReadable() * @return The encountered size when found, 0 by default. * 0 means the file is NOT USABLE. The caller will have to check */ -int gdcmHeader::GetXSize() +int Header::GetXSize() { std::string strSize; strSize = GetEntryByNumber(0x0028,0x0011); @@ -229,11 +232,11 @@ int gdcmHeader::GetXSize() /** * \brief Retrieve the number of lines of image. - * \warning The defaulted value is 1 as opposed to gdcmHeader::GetXSize() + * \warning The defaulted value is 1 as opposed to Header::GetXSize() * @return The encountered size when found, 1 by default * (The ACR-NEMA file contains a Signal, not an Image). */ -int gdcmHeader::GetYSize() +int Header::GetYSize() { std::string strSize = GetEntryByNumber(0x0028,0x0010); if ( strSize != GDCM_UNFOUND ) @@ -258,7 +261,7 @@ int gdcmHeader::GetYSize() * being the ACR-NEMA "Planes" tag content. * @return The encountered size when found, 1 by default (single image). */ -int gdcmHeader::GetZSize() +int Header::GetZSize() { // Both DicomV3 and ACR/Nema consider the "Number of Frames" // as the third dimension. @@ -283,14 +286,14 @@ int gdcmHeader::GetZSize() * else 1.0 * @return X dimension of a pixel */ -float gdcmHeader::GetXSpacing() +float Header::GetXSpacing() { float xspacing, yspacing; std::string strSpacing = GetEntryByNumber(0x0028,0x0030); if ( strSpacing == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)"); + dbg.Verbose(0, "Header::GetXSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } @@ -306,7 +309,7 @@ float gdcmHeader::GetXSpacing() } if ( xspacing == 0.) { - dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem"); + dbg.Verbose(0, "Header::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem"); // seems to be a bug in the header ... sscanf( strSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing); } @@ -319,14 +322,14 @@ float gdcmHeader::GetXSpacing() * else 1.0 * @return Y dimension of a pixel */ -float gdcmHeader::GetYSpacing() +float Header::GetYSpacing() { float yspacing = 0; std::string strSpacing = GetEntryByNumber(0x0028,0x0030); if ( strSpacing == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetYSpacing: unfound Pixel Spacing (0028,0030)"); + dbg.Verbose(0, "Header::GetYSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } @@ -342,7 +345,7 @@ float gdcmHeader::GetYSpacing() * else 1.0 * @return Z dimension of a voxel-to be */ -float gdcmHeader::GetZSpacing() +float Header::GetZSpacing() { // Spacing Between Slices : distance entre le milieu de chaque coupe // Les coupes peuvent etre : @@ -358,7 +361,7 @@ float gdcmHeader::GetZSpacing() if ( strSpacingBSlices == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetZSpacing: unfound StrSpacingBSlices"); + dbg.Verbose(0, "Header::GetZSpacing: unfound StrSpacingBSlices"); std::string strSliceThickness = GetEntryByNumber(0x0018,0x0050); if ( strSliceThickness == GDCM_UNFOUND ) { @@ -383,7 +386,7 @@ float gdcmHeader::GetZSpacing() *\brief gets the info from 0028,1052 : Rescale Intercept * @return Rescale Intercept */ -float gdcmHeader::GetRescaleIntercept() +float Header::GetRescaleIntercept() { float resInter = 0.; /// 0028 1052 DS IMG Rescale Intercept @@ -393,7 +396,7 @@ float gdcmHeader::GetRescaleIntercept() if( sscanf( strRescInter.c_str(), "%f", &resInter) != 1 ) { // bug in the element 0x0028,0x1052 - dbg.Verbose(0, "gdcmHeader::GetRescaleIntercept: Rescale Slope " + dbg.Verbose(0, "Header::GetRescaleIntercept: Rescale Slope " "is empty"); } } @@ -405,7 +408,7 @@ float gdcmHeader::GetRescaleIntercept() *\brief gets the info from 0028,1053 : Rescale Slope * @return Rescale Slope */ -float gdcmHeader::GetRescaleSlope() +float Header::GetRescaleSlope() { float resSlope = 1.; //0028 1053 DS IMG Rescale Slope @@ -415,7 +418,7 @@ float gdcmHeader::GetRescaleSlope() if( sscanf( strRescSlope.c_str(), "%f", &resSlope) != 1) { // bug in the element 0x0028,0x1053 - dbg.Verbose(0, "gdcmHeader::GetRescaleSlope: Rescale Slope is empty"); + dbg.Verbose(0, "Header::GetRescaleSlope: Rescale Slope is empty"); } } @@ -429,7 +432,7 @@ float gdcmHeader::GetRescaleSlope() * \warning to be used with GetImagePixels() * @return 1 if Gray level, 3 if Color (RGB, YBR or PALETTE COLOR) */ -int gdcmHeader::GetNumberOfScalarComponents() +int Header::GetNumberOfScalarComponents() { if ( GetSamplesPerPixel() == 3 ) { @@ -479,11 +482,11 @@ int gdcmHeader::GetNumberOfScalarComponents() * \warning to be used with GetImagePixelsRaw() * @return 1 if Gray level, 3 if Color (RGB or YBR - NOT 'PALETTE COLOR' -) */ -int gdcmHeader::GetNumberOfScalarComponentsRaw() +int Header::GetNumberOfScalarComponentsRaw() { // 0028 0100 US IMG Bits Allocated // (in order no to be messed up by old RGB images) - if ( gdcmHeader::GetEntryByNumber(0x0028,0x0100) == "24" ) + if ( Header::GetEntryByNumber(0x0028,0x0100) == "24" ) { return 3; } @@ -514,19 +517,19 @@ int gdcmHeader::GetNumberOfScalarComponentsRaw() * else 0. * @return up-left image corner X position */ -float gdcmHeader::GetXOrigin() +float Header::GetXOrigin() { float xImPos, yImPos, zImPos; std::string strImPos = GetEntryByNumber(0x0020,0x0032); if ( strImPos == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image " + dbg.Verbose(0, "Header::GetXImagePosition: unfound Image " "Position Patient (0020,0032)"); strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if ( strImPos == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetXImagePosition: unfound Image " + dbg.Verbose(0, "Header::GetXImagePosition: unfound Image " "Position (RET) (0020,0030)"); /// \todo How to tell the caller nothing was found ? return 0.; @@ -547,19 +550,19 @@ float gdcmHeader::GetXOrigin() * else 0. * @return up-left image corner Y position */ -float gdcmHeader::GetYOrigin() +float Header::GetYOrigin() { float xImPos, yImPos, zImPos; std::string strImPos = GetEntryByNumber(0x0020,0x0032); if ( strImPos == GDCM_UNFOUND) { - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image " + dbg.Verbose(0, "Header::GetYImagePosition: unfound Image " "Position Patient (0020,0032)"); strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if ( strImPos == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Image " + dbg.Verbose(0, "Header::GetYImagePosition: unfound Image " "Position (RET) (0020,0030)"); /// \todo How to tell the caller nothing was found ? return 0.; @@ -582,7 +585,7 @@ float gdcmHeader::GetYOrigin() * else 0. * @return up-left image corner Z position */ -float gdcmHeader::GetZOrigin() +float Header::GetZOrigin() { float xImPos, yImPos, zImPos; std::string strImPos = GetEntryByNumber(0x0020,0x0032); @@ -591,7 +594,7 @@ float gdcmHeader::GetZOrigin() { if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) { - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image " + dbg.Verbose(0, "Header::GetZImagePosition: wrong Image " "Position Patient (0020,0032)"); return 0.; // bug in the element 0x0020,0x0032 } @@ -607,7 +610,7 @@ float gdcmHeader::GetZOrigin() if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos ) != 3 ) { - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); + dbg.Verbose(0, "Header::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); return 0.; // bug in the element 0x0020,0x0032 } else @@ -621,7 +624,7 @@ float gdcmHeader::GetZOrigin() { if( sscanf( strSliceLocation.c_str(), "%f", &zImPos) != 1) { - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Slice Location (0020,1041)"); + dbg.Verbose(0, "Header::GetZImagePosition: wrong Slice Location (0020,1041)"); return 0.; // bug in the element 0x0020,0x1041 } else @@ -629,14 +632,14 @@ float gdcmHeader::GetZOrigin() return zImPos; } } - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: unfound Slice Location (0020,1041)"); + dbg.Verbose(0, "Header::GetZImagePosition: unfound Slice Location (0020,1041)"); std::string strLocation = GetEntryByNumber(0x0020,0x0050); if ( strLocation != GDCM_UNFOUND ) { if( sscanf( strLocation.c_str(), "%f", &zImPos) != 1) { - dbg.Verbose(0, "gdcmHeader::GetZImagePosition: wrong Location (0020,0050)"); + dbg.Verbose(0, "Header::GetZImagePosition: wrong Location (0020,0050)"); return 0.; // bug in the element 0x0020,0x0050 } else @@ -644,7 +647,7 @@ float gdcmHeader::GetZOrigin() return zImPos; } } - dbg.Verbose(0, "gdcmHeader::GetYImagePosition: unfound Location (0020,0050)"); + dbg.Verbose(0, "Header::GetYImagePosition: unfound Location (0020,0050)"); return 0.; // Hopeless } @@ -653,7 +656,7 @@ float gdcmHeader::GetZOrigin() * \brief gets the info from 0020,0013 : Image Number else 0. * @return image number */ -int gdcmHeader::GetImageNumber() +int Header::GetImageNumber() { // The function i atoi() takes the address of an area of memory as // parameter and converts the string stored at that location to an integer @@ -674,7 +677,7 @@ int gdcmHeader::GetImageNumber() * \brief gets the info from 0008,0060 : Modality * @return Modality Type */ -ModalityType gdcmHeader::GetModality() +ModalityType Header::GetModality() { // 0008 0060 CS ID Modality std::string strModality = GetEntryByNumber(0x0008,0x0060); @@ -738,12 +741,12 @@ ModalityType gdcmHeader::GetModality() * @return The encountered number of Bits Stored, 0 by default. * 0 means the file is NOT USABLE. The caller has to check it ! */ -int gdcmHeader::GetBitsStored() +int Header::GetBitsStored() { std::string strSize = GetEntryByNumber( 0x0028, 0x0101 ); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to " + dbg.Verbose(0, "Header::GetBitsStored: this is supposed to " "be mandatory"); return 0; // It's supposed to be mandatory // the caller will have to check @@ -757,12 +760,12 @@ int gdcmHeader::GetBitsStored() * The responsability of checking this value is left to the caller. * @return The high bit positin when present. 0 when absent. */ -int gdcmHeader::GetHighBitPosition() +int Header::GetHighBitPosition() { std::string strSize = GetEntryByNumber( 0x0028, 0x0102 ); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetHighBitPosition: this is supposed " + dbg.Verbose(0, "Header::GetHighBitPosition: this is supposed " "to be mandatory"); return 0; } @@ -775,12 +778,12 @@ int gdcmHeader::GetHighBitPosition() * The responsability of checking this value is left to the caller. * @return True when signed, false when UNsigned */ -bool gdcmHeader::IsSignedPixelData() +bool Header::IsSignedPixelData() { std::string strSize = GetEntryByNumber( 0x0028, 0x0103 ); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::IsSignedPixelData: this is supposed " + dbg.Verbose(0, "Header::IsSignedPixelData: this is supposed " "to be mandatory"); return false; } @@ -798,12 +801,12 @@ bool gdcmHeader::IsSignedPixelData() * @return The encountered number of Bits Allocated, 0 by default. * 0 means the file is NOT USABLE. The caller has to check it ! */ -int gdcmHeader::GetBitsAllocated() +int Header::GetBitsAllocated() { std::string strSize = GetEntryByNumber(0x0028,0x0100); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to " + dbg.Verbose(0, "Header::GetBitsStored: this is supposed to " "be mandatory"); return 0; // It's supposed to be mandatory // the caller will have to check @@ -817,12 +820,12 @@ int gdcmHeader::GetBitsAllocated() * @return The encountered number of Samples Per Pixel, 1 by default. * (Gray level Pixels) */ -int gdcmHeader::GetSamplesPerPixel() +int Header::GetSamplesPerPixel() { std::string strSize = GetEntryByNumber(0x0028,0x0002); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetBitsStored: this is supposed to " + dbg.Verbose(0, "Header::GetBitsStored: this is supposed to " "be mandatory"); return 1; // Well, it's supposed to be mandatory ... // but sometimes it's missing : *we* assume Gray pixels @@ -835,7 +838,7 @@ int gdcmHeader::GetSamplesPerPixel() * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). * @return true when "MONOCHROME1" or "MONOCHROME2". False otherwise. */ -bool gdcmHeader::IsMonochrome() +bool Header::IsMonochrome() { std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 ); if ( PhotometricInterp == "MONOCHROME1 " @@ -845,7 +848,7 @@ bool gdcmHeader::IsMonochrome() } if ( PhotometricInterp == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::IsMonochrome: absent Photometric " + dbg.Verbose(0, "Header::IsMonochrome: absent Photometric " "Interpretation"); } return false; @@ -856,7 +859,7 @@ bool gdcmHeader::IsMonochrome() * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). * @return true when "PALETTE COLOR". False otherwise. */ -bool gdcmHeader::IsPaletteColor() +bool Header::IsPaletteColor() { std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 ); if ( PhotometricInterp == "PALETTE COLOR " ) @@ -865,7 +868,7 @@ bool gdcmHeader::IsPaletteColor() } if ( PhotometricInterp == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::IsPaletteColor: absent Photometric " + dbg.Verbose(0, "Header::IsPaletteColor: absent Photometric " "Interpretation"); } return false; @@ -876,7 +879,7 @@ bool gdcmHeader::IsPaletteColor() * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). * @return true when "YBR_FULL". False otherwise. */ -bool gdcmHeader::IsYBRFull() +bool Header::IsYBRFull() { std::string PhotometricInterp = GetEntryByNumber( 0x0028, 0x0004 ); if ( PhotometricInterp == "YBR_FULL" ) @@ -885,7 +888,7 @@ bool gdcmHeader::IsYBRFull() } if ( PhotometricInterp == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::IsYBRFull: absent Photometric " + dbg.Verbose(0, "Header::IsYBRFull: absent Photometric " "Interpretation"); } return false; @@ -896,7 +899,7 @@ bool gdcmHeader::IsYBRFull() * (0 : RGB Pixels , 1 : R Plane + G Plane + B Plane) * @return The encountered Planar Configuration, 0 by default. */ -int gdcmHeader::GetPlanarConfiguration() +int Header::GetPlanarConfiguration() { std::string strSize = GetEntryByNumber(0x0028,0x0006); if ( strSize == GDCM_UNFOUND ) @@ -911,11 +914,11 @@ int gdcmHeader::GetPlanarConfiguration() * @return The size in bytes of a single pixel of data; 0 by default * 0 means the file is NOT USABLE; the caller will have to check */ -int gdcmHeader::GetPixelSize() +int Header::GetPixelSize() { // 0028 0100 US IMG Bits Allocated // (in order no to be messed up by old RGB images) - // if (gdcmHeader::GetEntryByNumber(0x0028,0x0100) == "24") + // if (Header::GetEntryByNumber(0x0028,0x0100) == "24") // return 3; std::string pixelType = GetPixelType(); @@ -935,7 +938,7 @@ int gdcmHeader::GetPixelSize() { return 8; } - dbg.Verbose(0, "gdcmHeader::GetPixelSize: Unknown pixel type"); + dbg.Verbose(0, "Header::GetPixelSize: Unknown pixel type"); return 0; } @@ -953,12 +956,12 @@ int gdcmHeader::GetPixelSize() * 24 bit images appear as 8 bit * @return 0S if nothing found. NOT USABLE file. The caller has to check */ -std::string gdcmHeader::GetPixelType() +std::string Header::GetPixelType() { std::string bitsAlloc = GetEntryByNumber(0x0028, 0x0100); // Bits Allocated if ( bitsAlloc == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Bits Allocated"); + dbg.Verbose(0, "Header::GetPixelType: unfound Bits Allocated"); bitsAlloc = "16"; } @@ -981,7 +984,7 @@ std::string gdcmHeader::GetPixelType() if (sign == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetPixelType: unfound Pixel Representation"); + dbg.Verbose(0, "Header::GetPixelType: unfound Pixel Representation"); bitsAlloc = "0"; } if ( sign == "0" ) @@ -1001,9 +1004,9 @@ std::string gdcmHeader::GetPixelType() * of *image* pixels (not *icone image* pixels, if any !) * @return Pixel Offset */ -size_t gdcmHeader::GetPixelOffset() +size_t Header::GetPixelOffset() { - gdcmDocEntry* pxlElement = GetDocEntryByNumber(GrPixel,NumPixel); + DocEntry* pxlElement = GetDocEntryByNumber(GrPixel,NumPixel); if ( pxlElement ) { return pxlElement->GetOffset(); @@ -1027,9 +1030,9 @@ size_t gdcmHeader::GetPixelOffset() * -in case of embeded compressed image-) * 0 : NOT USABLE file. The caller has to check. */ -size_t gdcmHeader::GetPixelAreaLength() +size_t Header::GetPixelAreaLength() { - gdcmDocEntry* pxlElement = GetDocEntryByNumber(GrPixel,NumPixel); + DocEntry* pxlElement = GetDocEntryByNumber(GrPixel,NumPixel); if ( pxlElement ) { return pxlElement->GetLength(); @@ -1053,7 +1056,7 @@ size_t gdcmHeader::GetPixelAreaLength() * Please warn me if you know sbdy that *does* know ... jprx * @return true if LUT Descriptors and LUT Tables were found */ -bool gdcmHeader::HasLUT() +bool Header::HasLUT() { // Check the presence of the LUT Descriptors, and LUT Tables // LutDescriptorRed @@ -1099,7 +1102,7 @@ bool gdcmHeader::HasLUT() * when (0028,0004),Photometric Interpretation = [PALETTE COLOR ] * @ return bit number of each LUT item */ -int gdcmHeader::GetLUTNbits() +int Header::GetLUTNbits() { std::vector tokens; int lutNbits; @@ -1114,7 +1117,7 @@ int gdcmHeader::GetLUTNbits() } tokens.clear(); // clean any previous value - gdcmUtil::Tokenize ( lutDescription, tokens, "\\" ); + Util::Tokenize ( lutDescription, tokens, "\\" ); //LutLength=atoi(tokens[0].c_str()); //LutDepth=atoi(tokens[1].c_str()); @@ -1139,7 +1142,7 @@ int gdcmHeader::GetLUTNbits() * no known Dicom reader deals with them :-( * @return a RGBA Lookup Table */ -uint8_t* gdcmHeader::GetLUTRGBA() +uint8_t* Header::GetLUTRGBA() { // Not so easy : see // http://www.barre.nom.fr/medical/dicom2/limitations.html#Color%20Lookup%20Tables @@ -1181,7 +1184,7 @@ uint8_t* gdcmHeader::GetLUTRGBA() &lengthR, &debR, &nbitsR ); if( nbRead != 3 ) { - dbg.Verbose(0, "gdcmHeader::GetLUTRGBA: trouble reading red LUT"); + dbg.Verbose(0, "Header::GetLUTRGBA: trouble reading red LUT"); } // lengthG: Green LUT length in Bytes @@ -1191,7 +1194,7 @@ uint8_t* gdcmHeader::GetLUTRGBA() &lengthG, &debG, &nbitsG ); if( nbRead != 3 ) { - dbg.Verbose(0, "gdcmHeader::GetLUTRGBA: trouble reading green LUT"); + dbg.Verbose(0, "Header::GetLUTRGBA: trouble reading green LUT"); } // lengthB: Blue LUT length in Bytes @@ -1201,7 +1204,7 @@ uint8_t* gdcmHeader::GetLUTRGBA() &lengthB, &debB, &nbitsB ); if( nbRead != 3 ) { - dbg.Verbose(0, "gdcmHeader::GetLUTRGBA: trouble reading blue LUT"); + dbg.Verbose(0, "Header::GetLUTRGBA: trouble reading blue LUT"); } // Load LUTs into memory, (as they were stored on disk) @@ -1211,7 +1214,7 @@ uint8_t* gdcmHeader::GetLUTRGBA() if ( !lutR || !lutG || !lutB ) { - dbg.Verbose(0, "gdcmHeader::GetLUTRGBA: trouble with one of the LUT"); + dbg.Verbose(0, "Header::GetLUTRGBA: trouble with one of the LUT"); return NULL; } // forge the 4 * 8 Bits Red/Green/Blue/Alpha LUT @@ -1288,13 +1291,13 @@ uint8_t* gdcmHeader::GetLUTRGBA() } /** - * \brief Accesses the info from 0002,0010 : Transfert Syntax and gdcmTS + * \brief Accesses the info from 0002,0010 : Transfert Syntax and TS * else 1. * @return The full Transfert Syntax Name (as opposed to Transfert Syntax UID) */ -std::string gdcmHeader::GetTransfertSyntaxName() +std::string Header::GetTransfertSyntaxName() { - // use the gdcmTS (TS : Transfert Syntax) + // use the TS (TS : Transfert Syntax) std::string transfertSyntax = GetEntryByNumber(0x0002,0x0010); if ( transfertSyntax == GDCM_NOTLOADED ) @@ -1306,7 +1309,7 @@ std::string gdcmHeader::GetTransfertSyntaxName() } if ( transfertSyntax == GDCM_UNFOUND ) { - dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:" + dbg.Verbose(0, "Header::GetTransfertSyntaxName:" " unfound Transfert Syntax (0002,0010)"); return "Uncompressed ACR-NEMA"; } @@ -1316,7 +1319,7 @@ std::string gdcmHeader::GetTransfertSyntaxName() transfertSyntax.erase(transfertSyntax.length()-1, 1); } // we do it only when we need it - gdcmTS* ts = gdcmGlobal::GetTS(); + TS* ts = Global::GetTS(); std::string tsName = ts->GetValue( transfertSyntax ); //delete ts; /// \todo Seg Fault when deleted ?! @@ -1329,16 +1332,16 @@ std::string gdcmHeader::GetTransfertSyntaxName() * @param ImageDataSize new Pixel Area Size * warning : nothing else is checked */ -void gdcmHeader::SetImageDataSize(size_t ImageDataSize) +void Header::SetImageDataSize(size_t ImageDataSize) { ///FIXME I don't understand this code wh ydo we set two times 'car' ? - std::string car = gdcmUtil::Format("%d", ImageDataSize); + std::string car = Util::Format("%d", ImageDataSize); - gdcmDocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel); + DocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel); a->SetLength(ImageDataSize); ImageDataSize += 8; - car = gdcmUtil::Format("%d", ImageDataSize); + car = Util::Format("%d", ImageDataSize); SetEntryByNumber(car, GrPixel, NumPixel); } @@ -1350,14 +1353,14 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) * \brief anonymize a Header (removes Patient's personal info) * (read the code to see which ones ...) */ -bool gdcmHeader::AnonymizeHeader() +bool Header::AnonymizeHeader() { // If exist, replace by spaces SetEntryByNumber (" ",0x0010, 0x2154); // Telephone SetEntryByNumber (" ",0x0010, 0x1040); // Adress SetEntryByNumber (" ",0x0010, 0x0020); // Patient ID - gdcmDocEntry* patientNameHE = GetDocEntryByNumber (0x0010, 0x0010); + DocEntry* patientNameHE = GetDocEntryByNumber (0x0010, 0x0010); if ( patientNameHE ) // we replace it by Study Instance UID (why not) { @@ -1432,7 +1435,7 @@ bool gdcmHeader::AnonymizeHeader() * @param iop adress of the (6)float aray to receive values * @return cosines of image orientation patient */ -void gdcmHeader::GetImageOrientationPatient( float iop[6] ) +void Header::GetImageOrientationPatient( float iop[6] ) { std::string strImOriPat; //iop is supposed to be float[6] @@ -1444,7 +1447,7 @@ void gdcmHeader::GetImageOrientationPatient( float iop[6] ) if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { - dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: " + dbg.Verbose(0, "Header::GetImageOrientationPatient: " "wrong Image Orientation Patient (0020,0037)"); } } @@ -1455,7 +1458,7 @@ void gdcmHeader::GetImageOrientationPatient( float iop[6] ) if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { - dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: " + dbg.Verbose(0, "Header::GetImageOrientationPatient: " "wrong Image Orientation Patient (0020,0035)"); } } @@ -1465,3 +1468,5 @@ void gdcmHeader::GetImageOrientationPatient( float iop[6] ) // Private //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 8940f0e3..b16dd9af 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.h,v $ Language: C++ - Date: $Date: 2004/09/29 17:33:17 $ - Version: $Revision: 1.88 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.89 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,25 +21,29 @@ #include "gdcmCommon.h" #include "gdcmDocument.h" +namespace gdcm +{ + + //----------------------------------------------------------------------------- /** * \brief - * The purpose of an instance of gdcmHeader is to act as a container of + * The purpose of an instance of Header is to act as a container of * all the DICOM elements and their corresponding values (and * additionaly the corresponding DICOM dictionary entry) of the header * of a DICOM file. * - * The typical usage of instances of class gdcmHeader is to classify a set of + * The typical usage of instances of class Header is to classify a set of * dicom files according to header information e.g. to create a file hierarchy * reflecting the Patient/Study/Serie informations, or extracting a given * SerieId. Accessing the content (image[s] or volume[s]) is beyond the * functionality of this class and belongs to gdmcFile. * \note The various entries of the explicit value representation (VR) shall - * be managed within a dictionary which is shared by all gdcmHeader + * be managed within a dictionary which is shared by all Header * instances. - * \note The gdcmHeader::Set*Tag* family members cannot be defined as + * \note The Header::Set*Tag* family members cannot be defined as * protected due to Swig limitations for as Has_a dependency between - * gdcmFile and gdcmHeader. + * File and Header. */ //----------------------------------------------------------------------------- @@ -90,27 +94,27 @@ enum ModalityType { }; //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmHeader : public gdcmDocument +class GDCM_EXPORT Header : public Document { protected: /// \brief In some cases (e.g. for some ACR-NEMA images) the Header Entry Element /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to /// make things easier the parser shall store the proper value in /// NumPixel to provide a unique access facility. See also the constructor - /// \ref gdcmHeader::gdcmHeader + /// \ref Header::Header uint16_t NumPixel; /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for /// the group of pixels is *not* found at 0x7fe0. In order to /// make things easier the parser shall store the proper value in /// GrPixel to provide a unique access facility. See also the constructor - /// \ref gdcmHeader::gdcmHeader + /// \ref Header::Header uint16_t GrPixel; public: - gdcmHeader(); - gdcmHeader( std::string const & filename ); + Header(); + Header( std::string const & filename ); - virtual ~gdcmHeader(); + virtual ~Header(); // Standard values and informations contained in the header virtual bool IsReadable(); @@ -162,13 +166,13 @@ public: std::string GetTransfertSyntaxName(); - /// Accessor to \ref gdcmHeader::GrPixel + /// Accessor to \ref Header::GrPixel uint16_t GetGrPixel() { return GrPixel; } - /// Accessor to \ref gdcmHeader::NumPixel + /// Accessor to \ref Header::NumPixel uint16_t GetNumPixel() { return NumPixel; } - /// Read (used in gdcmFile) + /// Read (used in File) void SetImageDataSize(size_t expectedSize); void Write(FILE* fp, FileType filetype); @@ -178,8 +182,9 @@ protected: void GetImageOrientationPatient( float iop[6] ); private: - friend class gdcmSerieHeader; + friend class SerieHeader; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmHeaderHelper.cxx b/src/gdcmHeaderHelper.cxx index cbb0a471..340dc812 100644 --- a/src/gdcmHeaderHelper.cxx +++ b/src/gdcmHeaderHelper.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeaderHelper.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.42 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.43 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -18,21 +18,24 @@ #include "gdcmHeaderHelper.h" #include "gdcmDirList.h" - #include "gdcmDebug.h" + #include #include #include -typedef std::vector GdcmHeaderVector; +namespace gdcm +{ + +typedef std::vector GdcmHeaderVector; //----------------------------------------------------------------------------- // Constructor / Destructor -gdcmSerieHeader::gdcmSerieHeader() +SerieHeader::SerieHeader() { CoherentGdcmFileList.clear(); } -gdcmSerieHeader::~gdcmSerieHeader() +SerieHeader::~SerieHeader() { /// \todo for ( GdcmHeaderList::const_iterator it = CoherentGdcmFileList.begin(); @@ -49,20 +52,20 @@ gdcmSerieHeader::~gdcmSerieHeader() //----------------------------------------------------------------------------- // Public /** - * \brief add a gdcmFile to the list based on file name + * \brief add a File to the list based on file name * @param filename Name of the file to deal with */ -void gdcmSerieHeader::AddFileName(std::string const & filename) +void SerieHeader::AddFileName(std::string const & filename) { - gdcmHeader *header = new gdcmHeader( filename ); + Header *header = new Header( filename ); CoherentGdcmFileList.push_back( header ); } /** - * \brief add a gdcmFile to the list - * @param file gdcmHeader to add + * \brief add a File to the list + * @param file Header to add */ -void gdcmSerieHeader::AddGdcmFile(gdcmHeader *file) +void SerieHeader::AddGdcmFile(Header *file) { CoherentGdcmFileList.push_back( file ); } @@ -71,15 +74,15 @@ void gdcmSerieHeader::AddGdcmFile(gdcmHeader *file) * \brief Sets the Directory * @param dir Name of the directory to deal with */ -void gdcmSerieHeader::SetDirectory(std::string const & dir) +void SerieHeader::SetDirectory(std::string const & dir) { - gdcmDirList filenames_list(dir); //OS specific + DirList filenames_list(dir); //OS specific - for( gdcmDirList::const_iterator it = filenames_list.begin(); + for( DirList::const_iterator it = filenames_list.begin(); it != filenames_list.end(); ++it) { //use string and not const char*: - gdcmHeader *header = new gdcmHeader( *it ); + Header *header = new Header( *it ); CoherentGdcmFileList.push_back( header ); } } @@ -90,7 +93,7 @@ void gdcmSerieHeader::SetDirectory(std::string const & dir) * But as I don't know how to do it, I leave it this way * BTW, this is also a Strategy, I don't know this is the best approach :) */ -void gdcmSerieHeader::OrderGdcmFileList() +void SerieHeader::OrderGdcmFileList() { if( ImagePositionPatientOrdering() ) { @@ -112,7 +115,7 @@ void gdcmSerieHeader::OrderGdcmFileList() //----------------------------------------------------------------------------- // Private /** - * \ingroup gdcmHeader + * \ingroup Header * \brief sorts the images, according to their Patient Position * We may order, considering : * -# Image Number @@ -120,7 +123,7 @@ void gdcmSerieHeader::OrderGdcmFileList() * -# More to come :) * @return false only if the header is bugged ! */ -bool gdcmSerieHeader::ImagePositionPatientOrdering() +bool SerieHeader::ImagePositionPatientOrdering() //based on Jolinda's algorithm { //iop is calculated based on the file file @@ -237,12 +240,12 @@ bool gdcmSerieHeader::ImagePositionPatientOrdering() } /** - * \ingroup gdcmHeader + * \ingroup Header * \brief sorts the images, according to their Image Number * @return false only if the header is bugged ! */ -bool gdcmSerieHeader::ImageNumberOrdering() +bool SerieHeader::ImageNumberOrdering() { int min, max, pos; int n = 0;//CoherentGdcmFileList.size() is a O(N) operation !! @@ -296,15 +299,16 @@ bool gdcmSerieHeader::ImageNumberOrdering() /** - * \ingroup gdcmHeader + * \ingroup Header * \brief sorts the images, according to their File Name * @return false only if the header is bugged ! */ -bool gdcmSerieHeader::FileNameOrdering() +bool SerieHeader::FileNameOrdering() { //using the sort //sort(CoherentGdcmFileList.begin(), CoherentGdcmFileList.end()); return true; } +} // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmHeaderHelper.h b/src/gdcmHeaderHelper.h index 1540a129..5dc42bfc 100644 --- a/src/gdcmHeaderHelper.h +++ b/src/gdcmHeaderHelper.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeaderHelper.h,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.21 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.22 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,31 +21,34 @@ #include "gdcmHeader.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- /* - * \defgroup gdcmSerieHeader + * \defgroup SerieHeader * \brief * * - This class should be used for a stack of 2D dicom images. - * - For a multiframe dicom image better use directly gdcmHeaderHelper + * - For a multiframe dicom image better use directly HeaderHelper */ -class GDCM_EXPORT gdcmSerieHeader +class GDCM_EXPORT SerieHeader { public: - gdcmSerieHeader(); - ~gdcmSerieHeader(); + SerieHeader(); + ~SerieHeader(); /// \todo should return bool or throw error ? void AddFileName(std::string const & filename); - void AddGdcmFile(gdcmHeader *file); + void AddGdcmFile(Header *file); void SetDirectory(std::string const & dir); void OrderGdcmFileList(); /// \warning Assumes all elements in the list have the same global infos. /// Assumes the list is not empty. - gdcmHeader* GetGdcmHeader() { return CoherentGdcmFileList.front(); } + Header* GetGdcmHeader() { return CoherentGdcmFileList.front(); } - typedef std::list GdcmHeaderList; + typedef std::list GdcmHeaderList; /// \brief Gets the *coherent* File List /// @return the *coherent* File List @@ -59,5 +62,7 @@ private: GdcmHeaderList CoherentGdcmFileList; }; +} // end namespace gdcm + //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmJPEGFragment.h b/src/gdcmJPEGFragment.h index 7c515c14..b8e8ff0b 100644 --- a/src/gdcmJPEGFragment.h +++ b/src/gdcmJPEGFragment.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragment.h,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2004/10/12 04:35:46 $ + 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 @@ -21,6 +21,8 @@ #define GDCMJPEGFRAGMENT_H #include "gdcmCommon.h" +namespace gdcm +{ /** * \brief Utility class for summerizing the informations of a JPEG @@ -30,22 +32,23 @@ * - the fragment length * * Each instance of this class (they can be as many instances for - * a given gdcmDocument as they are JPEG fragments and they are - * collected in a \ref gdcmJPEGFragmentsInfo ) + * a given Document as they are JPEG fragments and they are + * collected in a \ref JPEGFragmentsInfo ) */ -class GDCM_EXPORT gdcmJPEGFragment +class GDCM_EXPORT JPEGFragment { -friend class gdcmDocument; -friend class gdcmFile; -friend class gdcmPixelConvert; +friend class Document; +friend class File; +friend class PixelConvert; long Offset; long Length; - gdcmJPEGFragment() + JPEGFragment() { Offset = 0; Length = 0; } }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmJPEGFragmentsInfo.cxx b/src/gdcmJPEGFragmentsInfo.cxx index f981336b..41f802d3 100644 --- a/src/gdcmJPEGFragmentsInfo.cxx +++ b/src/gdcmJPEGFragmentsInfo.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2004/10/12 04:35:46 $ + 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 @@ -18,7 +18,10 @@ #include "gdcmJPEGFragmentsInfo.h" -gdcmJPEGFragmentsInfo::~gdcmJPEGFragmentsInfo() +namespace gdcm +{ + +JPEGFragmentsInfo::~JPEGFragmentsInfo() { for(JPEGFragmentsList::iterator it = Fragments.begin(); it != Fragments.end(); @@ -28,3 +31,4 @@ gdcmJPEGFragmentsInfo::~gdcmJPEGFragmentsInfo() } Fragments.clear(); } +} // end namespace gdcm diff --git a/src/gdcmJPEGFragmentsInfo.h b/src/gdcmJPEGFragmentsInfo.h index 4db039cf..53e87699 100644 --- a/src/gdcmJPEGFragmentsInfo.h +++ b/src/gdcmJPEGFragmentsInfo.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragmentsInfo.h,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2004/10/12 04:35:46 $ + 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 @@ -22,28 +22,31 @@ #include "gdcmJPEGFragment.h" #include +namespace gdcm +{ /** * \brief Utility class for gathering the informations of the collection - * of JPEG fragment[s] (see \ref gdcmJPEGFragment) when handling + * of JPEG fragment[s] (see \ref JPEGFragment) when handling * "Encapsulated JPEG Compressed Images". * The informations on each frame are obtained during the parsing - * of a gdcmDocument (refer to - * \ref gdcmDocument::ComputeJPEGFragmentInfo() ). + * of a Document (refer to + * \ref Document::ComputeJPEGFragmentInfo() ). * They shall be used when (if necessary) decoding the fragments. * - * This class is simply a stl list<> of \ref gdcmJPEGFragment. + * This class is simply a stl list<> of \ref JPEGFragment. */ -class GDCM_EXPORT gdcmJPEGFragmentsInfo +class GDCM_EXPORT JPEGFragmentsInfo { - typedef std::list< gdcmJPEGFragment* > JPEGFragmentsList; -friend class gdcmDocument; -friend class gdcmFile; -friend class gdcmPixelConvert; + typedef std::list< JPEGFragment* > JPEGFragmentsList; +friend class Document; +friend class File; +friend class PixelConvert; JPEGFragmentsList Fragments; public: - ~gdcmJPEGFragmentsInfo(); + ~JPEGFragmentsInfo(); }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmJpeg12.cxx b/src/gdcmJpeg12.cxx index cf315656..a107ac22 100644 --- a/src/gdcmJpeg12.cxx +++ b/src/gdcmJpeg12.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg12.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.20 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.21 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,6 +36,8 @@ extern "C" { #include "src/jpeg/libijg12/jpeglib.h" #include } +namespace gdcm +{ /******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ // @@ -126,7 +128,7 @@ METHODDEF(void) my_error_exit (j_common_ptr cinfo) */ /** - * \ingroup gdcmFile + * \ingroup File * \brief routine for JPEG decompression * @param fp pointer to an already open file descriptor * 12 significant bits per pixel @@ -169,7 +171,7 @@ bool gdcm_read_JPEG_file12 ( FILE* fp,void* image_buffer ) int row_stride;/* physical row width in output buffer */ #ifdef GDCM_JPG_DEBUG - printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n"); + printf("entree dans File::gdcm_read_JPEG_file12, depuis gdcmJpeg\n"); #endif //GDCM_JPG_DEBUG /* In this example we want to open the input file before doing anything else, @@ -369,3 +371,6 @@ bool gdcm_read_JPEG_file12 ( FILE* fp,void* image_buffer ) */ //----------------------------------------------------------------------------- + +} // end namespace gdcm + diff --git a/src/gdcmJpeg2000.cxx b/src/gdcmJpeg2000.cxx index 65198a9a..a6f3a42a 100644 --- a/src/gdcmJpeg2000.cxx +++ b/src/gdcmJpeg2000.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg2000.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/10/12 04:35:46 $ + 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 @@ -18,6 +18,9 @@ //----------------------------------------------------------------------------- #include "gdcmFile.h" +namespace gdcm +{ + //----------------------------------------------------------------------------- /** * \brief routine for JPEG decompression @@ -34,6 +37,7 @@ bool gdcm_read_JPEG2000_file (FILE* fp,void* image_buffer) { std::cout << "Sorry JPEG 2000 File not yet taken into account" << std::endl; return false; } +} // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmJpeg8.cxx b/src/gdcmJpeg8.cxx index d8d62229..fab29603 100644 --- a/src/gdcmJpeg8.cxx +++ b/src/gdcmJpeg8.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg8.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.5 $ + Date: $Date: 2004/10/12 04:35:46 $ + Version: $Revision: 1.6 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -91,6 +91,8 @@ extern "C" { #include } +namespace gdcm +{ /******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ @@ -129,7 +131,7 @@ extern "C" { */ /** - * \ingroup gdcmFile + * \ingroup File * \brief routine for JPEG decompression * @param fp pointer to an already open file descriptor * 8 significant bits per pixel @@ -402,7 +404,7 @@ bool gdcm_read_JPEG_file ( FILE* fp, void* image_buffer ) int row_stride;/* physical row width in output buffer */ #ifdef GDCM_JPG_DEBUG - printf("entree dans gdcmFile::gdcm_read_JPEG_file (i.e. 8), depuis gdcmJpeg\n"); + printf("entree dans File::gdcm_read_JPEG_file (i.e. 8), depuis gdcmJpeg\n"); #endif //GDCM_JPG_DEBUG /* In this example we want to open the input file before doing anything else, @@ -613,3 +615,5 @@ bool gdcm_read_JPEG_file ( FILE* fp, void* image_buffer ) */ //---------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmParsePixels.cxx b/src/gdcmParsePixels.cxx index 080904d6..477ec99f 100644 --- a/src/gdcmParsePixels.cxx +++ b/src/gdcmParsePixels.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmParsePixels.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/10/12 04:35:46 $ + 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 @@ -19,11 +19,14 @@ #include "gdcmCommon.h" #include "gdcmFile.h" +namespace gdcm +{ + #define str2num(str, typeNum) *((typeNum *)(str)) //----------------------------------------------------------------------------- /** - * \ingroup gdcmFile + * \ingroup File * \brief Parse pixel data from disk and *prints* the result * \ For multi-fragment Jpeg/Rle files checking purpose *only* * \ Allows to 'see' if the file *does* conform @@ -31,31 +34,31 @@ * \ with Dicom Part 3, Annex A (PS 3.5-2003, page 58, page 85) * */ -bool gdcmFile::ParsePixelData(void) { +bool File::ParsePixelData(void) { // DO NOT remove the printf s. // The ONLY purpose of this method is to PRINT the content FILE* fp; - if ( !(fp=Header->OpenFile())) + if ( !(fp=GetHeader()->OpenFile())) return false; - if ( fseek(fp, Header->GetPixelOffset(), SEEK_SET) == -1 ) { - Header->CloseFile(); + if ( fseek(fp, GetHeader()->GetPixelOffset(), SEEK_SET) == -1 ) { + GetHeader()->CloseFile(); return false; } - if ( !Header->IsDicomV3() || - Header->IsImplicitVRLittleEndianTransferSyntax() || - Header->IsExplicitVRLittleEndianTransferSyntax() || - Header->IsExplicitVRBigEndianTransferSyntax() || - Header->IsDeflatedExplicitVRLittleEndianTransferSyntax() ) { + if ( !GetHeader()->IsDicomV3() || + GetHeader()->IsImplicitVRLittleEndianTransferSyntax() || + GetHeader()->IsExplicitVRLittleEndianTransferSyntax() || + GetHeader()->IsExplicitVRBigEndianTransferSyntax() || + GetHeader()->IsDeflatedExplicitVRLittleEndianTransferSyntax() ) { - printf ("gdcmFile::ParsePixelData : non JPEG/RLE File\n"); + printf ("File::ParsePixelData : non JPEG/RLE File\n"); return false; } int nb; - std::string str_nb=Header->GetEntryByNumber(0x0028,0x0100); + std::string str_nb=GetHeader()->GetEntryByNumber(0x0028,0x0100); if (str_nb == GDCM_UNFOUND ) { nb = 16; } else { @@ -64,7 +67,7 @@ bool gdcmFile::ParsePixelData(void) { } //int nBytes= nb/8; //FIXME - //int taille = Header->GetXSize() * Header->GetYSize() * Header->GetSamplesPerPixel(); + //int taille = GetHeader()->GetXSize() * GetHeader()->GetYSize() * GetHeader()->GetSamplesPerPixel(); printf ("Checking the Dicom-encapsulated Jpeg/RLE Pixels\n"); @@ -75,22 +78,22 @@ bool gdcmFile::ParsePixelData(void) { // -------------------- for Parsing : Position on begining of Jpeg/RLE Pixels - if( !Header->IsRLELossLessTransferSyntax()) { + if( !GetHeader()->IsRLELossLessTransferSyntax()) { // JPEG Image ftellRes=ftell(fp); fread(&ItemTagGr,2,1,fp); //Reading (fffe):Basic Offset Table Item Tag Gr fread(&ItemTagEl,2,1,fp); //Reading (e000):Basic Offset Table Item Tag El - if(Header->GetSwapCode()) { - ItemTagGr=Header->SwapShort(ItemTagGr); - ItemTagEl=Header->SwapShort(ItemTagEl); + if(GetHeader()->GetSwapCode()) { + ItemTagGr=GetHeader()->SwapShort(ItemTagGr); + ItemTagEl=GetHeader()->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000): %04x,%04x\n", (unsigned)ftellRes,ItemTagGr,ItemTagEl ); ftellRes=ftell(fp); fread(&ln,4,1,fp); - if(Header->GetSwapCode()) - ln=Header->SwapLong(ln); // Basic Offset Table Item Length + if(GetHeader()->GetSwapCode()) + ln=GetHeader()->SwapLong(ln); // Basic Offset Table Item Length printf("at %x : Basic Offset Table Item Length (\?\?) %d x(%08x)\n", (unsigned)ftellRes,ln,ln); if (ln != 0) { @@ -107,9 +110,9 @@ bool gdcmFile::ParsePixelData(void) { ftellRes=ftell(fp); fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El - if(Header->GetSwapCode()) { - ItemTagGr=Header->SwapShort(ItemTagGr); - ItemTagEl=Header->SwapShort(ItemTagEl); + if(GetHeader()->GetSwapCode()) { + ItemTagGr=GetHeader()->SwapShort(ItemTagGr); + ItemTagEl=GetHeader()->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", (unsigned)ftellRes,ItemTagGr,ItemTagEl ); @@ -118,8 +121,8 @@ bool gdcmFile::ParsePixelData(void) { ftellRes=ftell(fp); fread(&ln,4,1,fp); - if(Header->GetSwapCode()) - ln=Header->SwapLong(ln); // length + if(GetHeader()->GetSwapCode()) + ln=GetHeader()->SwapLong(ln); // length printf(" at %x : fragment length %d x(%08x)\n", (unsigned)ftellRes, ln,ln); @@ -134,9 +137,9 @@ bool gdcmFile::ParsePixelData(void) { ftellRes=ftell(fp); fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El - if(Header->GetSwapCode()) { - ItemTagGr=Header->SwapShort(ItemTagGr); - ItemTagEl=Header->SwapShort(ItemTagEl); + if(GetHeader()->GetSwapCode()) { + ItemTagGr=GetHeader()->SwapShort(ItemTagGr); + ItemTagEl=GetHeader()->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", (unsigned)ftellRes,ItemTagGr,ItemTagEl ); @@ -153,17 +156,17 @@ bool gdcmFile::ParsePixelData(void) { // Item Tag fread(&ItemTagGr,2,1,fp); //Reading (fffe):Basic Offset Table Item Tag Gr fread(&ItemTagEl,2,1,fp); //Reading (e000):Basic Offset Table Item Tag El - if(Header->GetSwapCode()) { - ItemTagGr=Header->SwapShort(ItemTagGr); - ItemTagEl=Header->SwapShort(ItemTagEl); + if(GetHeader()->GetSwapCode()) { + ItemTagGr=GetHeader()->SwapShort(ItemTagGr); + ItemTagEl=GetHeader()->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000): %04x,%04x\n", (unsigned)ftellRes,ItemTagGr,ItemTagEl ); // Item Length ftellRes=ftell(fp); fread(&ln,4,1,fp); - if(Header->GetSwapCode()) - ln=Header->SwapLong(ln); // Basic Offset Table Item Length + if(GetHeader()->GetSwapCode()) + ln=GetHeader()->SwapLong(ln); // Basic Offset Table Item Length printf("at %x : Basic Offset Table Item Length (\?\?) %d x(%08x)\n", (unsigned)ftellRes,ln,ln); if (ln != 0) { @@ -180,9 +183,9 @@ bool gdcmFile::ParsePixelData(void) { ftellRes=ftell(fp); fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El - if(Header->GetSwapCode()) { - ItemTagGr=Header->SwapShort(ItemTagGr); - ItemTagEl=Header->SwapShort(ItemTagEl); + if(GetHeader()->GetSwapCode()) { + ItemTagGr=GetHeader()->SwapShort(ItemTagGr); + ItemTagEl=GetHeader()->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", (unsigned)ftellRes,ItemTagGr,ItemTagEl ); @@ -192,23 +195,23 @@ bool gdcmFile::ParsePixelData(void) { // Parse fragments of the current Fragment (Frame) ftellRes=ftell(fp); fread(&fragmentLength,4,1,fp); - if(Header->GetSwapCode()) - fragmentLength=Header->SwapLong(fragmentLength); // length + if(GetHeader()->GetSwapCode()) + fragmentLength=GetHeader()->SwapLong(fragmentLength); // length printf(" at %x : 'fragment' length %d x(%08x)\n", (unsigned)ftellRes, (unsigned)fragmentLength,(unsigned)fragmentLength); //------------------ scanning (not reading) fragment pixels fread(&nbRleSegments,4,1,fp); // Reading : Number of RLE Segments - if(Header->GetSwapCode()) - nbRleSegments=Header->SwapLong(nbRleSegments); + if(GetHeader()->GetSwapCode()) + nbRleSegments=GetHeader()->SwapLong(nbRleSegments); printf(" Nb of RLE Segments : %d\n",nbRleSegments); for(int k=1; k<=15; k++) { // Reading RLE Segments Offset Table ftellRes=ftell(fp); fread(&RleSegmentOffsetTable[k],4,1,fp); - if(Header->GetSwapCode()) - RleSegmentOffsetTable[k]=Header->SwapLong(RleSegmentOffsetTable[k]); + if(GetHeader()->GetSwapCode()) + RleSegmentOffsetTable[k]=GetHeader()->SwapLong(RleSegmentOffsetTable[k]); printf(" at : %x Offset Segment %d : %d (%x)\n", (unsigned)ftellRes,k,RleSegmentOffsetTable[k], RleSegmentOffsetTable[k]); @@ -238,9 +241,9 @@ bool gdcmFile::ParsePixelData(void) { ftellRes=ftell(fp); fread(&ItemTagGr,2,1,fp); // Reading (fffe) : Item Tag Gr fread(&ItemTagEl,2,1,fp); // Reading (e000) : Item Tag El - if(Header->GetSwapCode()) { - ItemTagGr=Header->SwapShort(ItemTagGr); - ItemTagEl=Header->SwapShort(ItemTagEl); + if(GetHeader()->GetSwapCode()) { + ItemTagGr=GetHeader()->SwapShort(ItemTagGr); + ItemTagEl=GetHeader()->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", (unsigned)ftellRes,ItemTagGr,ItemTagEl ); @@ -250,3 +253,5 @@ bool gdcmFile::ParsePixelData(void) { } //----------------------------------------------------------------------------- +} // end namespace gdcm + diff --git a/src/gdcmPixelConvert.cxx b/src/gdcmPixelConvert.cxx index 1e2901d2..74f305ac 100644 --- a/src/gdcmPixelConvert.cxx +++ b/src/gdcmPixelConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelConvert.cxx,v $ Language: C++ - Date: $Date: 2004/10/11 03:47:50 $ - Version: $Revision: 1.7 $ + Date: $Date: 2004/10/12 04:35:47 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,10 +21,6 @@ // Removing the prefix fixMem and dealing with allocations should do the trick // // grep PIXELCONVERT everywhere and clean up ! - - -#define str2num(str, typeNum) *((typeNum *)(str)) - #include "gdcmDebug.h" #include "gdcmPixelConvert.h" @@ -33,6 +29,12 @@ // for JPEGLosslessDecodeImage #include "jpeg/ljpg/jpegless.h" + +namespace gdcm +{ + +#define str2num(str, typeNum) *((typeNum *)(str)) + // For JPEG 2000, body in file gdcmJpeg2000.cxx bool gdcm_read_JPEG2000_file (FILE* fp, void* image_buffer); @@ -46,7 +48,7 @@ bool gdcm_read_JPEG_file12 (FILE* fp, void* image_buffer); //----------------------------------------------------------------------------- // Constructor / Destructor -gdcmPixelConvert::gdcmPixelConvert() +PixelConvert::PixelConvert() { RGB = 0; RGBSize = 0; @@ -54,7 +56,7 @@ gdcmPixelConvert::gdcmPixelConvert() UncompressedSize = 0; } -void gdcmPixelConvert::Squeeze() +void PixelConvert::Squeeze() { if ( RGB ) { delete [] RGB; @@ -64,12 +66,12 @@ void gdcmPixelConvert::Squeeze() } } -gdcmPixelConvert::~gdcmPixelConvert() +PixelConvert::~PixelConvert() { Squeeze(); } -void gdcmPixelConvert::AllocateRGB() +void PixelConvert::AllocateRGB() { if ( RGB ) { delete [] RGB; @@ -77,7 +79,7 @@ void gdcmPixelConvert::AllocateRGB() RGB = new uint8_t[RGBSize]; } -void gdcmPixelConvert::AllocateUncompressed() +void PixelConvert::AllocateUncompressed() { if ( Uncompressed ) { delete [] Uncompressed; @@ -89,12 +91,12 @@ void gdcmPixelConvert::AllocateUncompressed() * \brief Read from file a 12 bits per pixel image and uncompress it * into a 16 bits per pixel image. */ -void gdcmPixelConvert::ConvertDecompress12BitsTo16Bits( +void PixelConvert::ConvertDecompress12BitsTo16Bits( uint8_t* pixelZone, int sizeX, int sizeY, FILE* filePtr) - throw ( gdcmFormatError ) + throw ( FormatError ) { int nbPixels = sizeX * sizeY; uint16_t* destination = (uint16_t*)pixelZone; @@ -107,22 +109,22 @@ void gdcmPixelConvert::ConvertDecompress12BitsTo16Bits( ItemRead = fread( &b0, 1, 1, filePtr); if ( ItemRead != 1 ) { - throw gdcmFormatError( "gdcmFile::ConvertDecompress12BitsTo16Bits()", - "Unfound first block" ); + throw FormatError( "File::ConvertDecompress12BitsTo16Bits()", + "Unfound first block" ); } ItemRead = fread( &b1, 1, 1, filePtr); if ( ItemRead != 1 ) { - throw gdcmFormatError( "gdcmFile::ConvertDecompress12BitsTo16Bits()", - "Unfound second block" ); + throw FormatError( "File::ConvertDecompress12BitsTo16Bits()", + "Unfound second block" ); } ItemRead = fread( &b2, 1, 1, filePtr); if ( ItemRead != 1 ) { - throw gdcmFormatError( "gdcmFile::ConvertDecompress12BitsTo16Bits()", - "Unfound second block" ); + throw FormatError( "File::ConvertDecompress12BitsTo16Bits()", + "Unfound second block" ); } // Two steps are necessary to please VC++ @@ -146,7 +148,7 @@ void gdcmPixelConvert::ConvertDecompress12BitsTo16Bits( * High Byte 'Planes'...(for what it may mean) * @return Boolean */ -bool gdcmPixelConvert::UncompressRLE16BitsFromRLE8Bits( +bool PixelConvert::UncompressRLE16BitsFromRLE8Bits( int XSize, int YSize, int NumberOfFrames, @@ -186,7 +188,7 @@ bool gdcmPixelConvert::UncompressRLE16BitsFromRLE8Bits( * \brief Implementation of the RLE decoding algorithm for uncompressing * a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86] */ -bool gdcmPixelConvert::ReadAndUncompressRLEFragment( uint8_t* decodedZone, +bool PixelConvert::ReadAndUncompressRLEFragment( uint8_t* decodedZone, long fragmentSize, long uncompressedSegmentSize, FILE* fp ) @@ -229,7 +231,7 @@ bool gdcmPixelConvert::ReadAndUncompressRLEFragment( uint8_t* decodedZone, if ( numberOfReadBytes > fragmentSize ) { - dbg.Verbose(0, "gdcmFile::gdcm_read_RLE_fragment: we read more " + dbg.Verbose(0, "File::gdcm_read_RLE_fragment: we read more " "bytes than the segment size."); return false; } @@ -245,12 +247,12 @@ bool gdcmPixelConvert::ReadAndUncompressRLEFragment( uint8_t* decodedZone, * at which the pixel data should be copied * @return Boolean */ -bool gdcmPixelConvert::ReadAndDecompressRLEFile( void* image_buffer, +bool PixelConvert::ReadAndDecompressRLEFile( void* image_buffer, int XSize, int YSize, int ZSize, int BitsAllocated, - gdcmRLEFramesInfo* RLEInfo, + RLEFramesInfo* RLEInfo, FILE* fp ) { uint8_t* im = (uint8_t*)image_buffer; @@ -258,7 +260,7 @@ bool gdcmPixelConvert::ReadAndDecompressRLEFile( void* image_buffer, // Loop on the frame[s] - for( gdcmRLEFramesInfo::RLEFrameList::iterator + for( RLEFramesInfo::RLEFrameList::iterator it = RLEInfo->Frames.begin(); it != RLEInfo->Frames.end(); ++it ) @@ -267,7 +269,7 @@ bool gdcmPixelConvert::ReadAndDecompressRLEFile( void* image_buffer, for( unsigned int k = 1; k <= (*it)->NumberFragments; k++ ) { fseek( fp, (*it)->Offset[k] ,SEEK_SET ); - (void)gdcmPixelConvert::ReadAndUncompressRLEFragment( + (void)PixelConvert::ReadAndUncompressRLEFragment( (uint8_t*) im, (*it)->Length[k], uncompressedSegmentSize, fp ); im += uncompressedSegmentSize; @@ -277,7 +279,7 @@ bool gdcmPixelConvert::ReadAndDecompressRLEFile( void* image_buffer, if ( BitsAllocated == 16 ) { // Try to deal with RLE 16 Bits - (void)gdcmPixelConvert::UncompressRLE16BitsFromRLE8Bits( + (void)PixelConvert::UncompressRLE16BitsFromRLE8Bits( XSize, YSize, ZSize, @@ -295,7 +297,7 @@ bool gdcmPixelConvert::ReadAndDecompressRLEFile( void* image_buffer, * @param lgr Area Length * @param nb Pixels Bit number */ -void gdcmPixelConvert::SwapZone(void* im, int swap, int lgr, int nb) +void PixelConvert::SwapZone(void* im, int swap, int lgr, int nb) { int i; @@ -375,7 +377,7 @@ void gdcmPixelConvert::SwapZone(void* im, int swap, int lgr, int nb) /** * \brief Deal with endianity i.e. re-arange bytes inside the integer */ -void gdcmPixelConvert::ConvertReorderEndianity( uint8_t* pixelZone, +void PixelConvert::ConvertReorderEndianity( uint8_t* pixelZone, size_t imageDataSize, int numberBitsStored, int numberBitsAllocated, @@ -412,7 +414,7 @@ void gdcmPixelConvert::ConvertReorderEndianity( uint8_t* pixelZone, * @param destination Where decompressed fragments should end up * @return Boolean */ -bool gdcmPixelConvert::ReadAndDecompressJPEGFile( uint8_t* destination, +bool PixelConvert::ReadAndDecompressJPEGFile( uint8_t* destination, int XSize, int YSize, int BitsAllocated, @@ -421,11 +423,11 @@ bool gdcmPixelConvert::ReadAndDecompressJPEGFile( uint8_t* destination, int PixelSize, bool isJPEG2000, bool isJPEGLossless, - gdcmJPEGFragmentsInfo* JPEGInfo, + JPEGFragmentsInfo* JPEGInfo, FILE* fp ) { // Loop on the fragment[s] - for( gdcmJPEGFragmentsInfo::JPEGFragmentsList::iterator + for( JPEGFragmentsInfo::JPEGFragmentsList::iterator it = JPEGInfo->Fragments.begin(); it != JPEGInfo->Fragments.end(); ++it ) @@ -466,7 +468,7 @@ bool gdcmPixelConvert::ReadAndDecompressJPEGFile( uint8_t* destination, else { // other JPEG lossy not supported - dbg.Error(" gdcmFile::ReadPixelData : unknown jpeg lossy " + dbg.Error(" File::ReadPixelData : unknown jpeg lossy " " compression "); return false; } @@ -488,13 +490,13 @@ bool gdcmPixelConvert::ReadAndDecompressJPEGFile( uint8_t* destination, * @param destination Where decompressed fragments should end up * @return Boolean */ -bool gdcmPixelConvert::ConvertReArrangeBits( +bool PixelConvert::ConvertReArrangeBits( uint8_t* pixelZone, size_t imageDataSize, int numberBitsStored, int numberBitsAllocated, int highBitPosition ) - throw ( gdcmFormatError ) + throw ( FormatError ) { if ( numberBitsStored != numberBitsAllocated ) { @@ -523,11 +525,11 @@ bool gdcmPixelConvert::ConvertReArrangeBits( } else { - dbg.Verbose(0, "gdcmPixelConvert::ConvertReArrangeBits: weird image"); - throw gdcmFormatError( "gdcmFile::ConvertReArrangeBits()", + dbg.Verbose(0, "PixelConvert::ConvertReArrangeBits: weird image"); + throw FormatError( "File::ConvertReArrangeBits()", "weird image !?" ); } } return true; //??? } - +} // end namespace gdcm diff --git a/src/gdcmPixelConvert.h b/src/gdcmPixelConvert.h index 8121f0b6..0ac94ca4 100644 --- a/src/gdcmPixelConvert.h +++ b/src/gdcmPixelConvert.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelConvert.h,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.5 $ + Date: $Date: 2004/10/12 04:35:47 $ + Version: $Revision: 1.6 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,12 +25,15 @@ #include "gdcmJPEGFragmentsInfo.h" #include "gdcmException.h" +namespace gdcm +{ + /* * \brief Utility container for gathering the various forms the pixel data * migth take during the user demanded processes. */ -class GDCM_EXPORT gdcmPixelConvert { -friend class gdcmFile; +class GDCM_EXPORT PixelConvert { +friend class File; /// Pixel data represented as RGB after color interpretation uint8_t* RGB; size_t RGBSize; //aka ImageDataSize @@ -38,8 +41,8 @@ friend class gdcmFile; uint8_t* Uncompressed; size_t UncompressedSize; public: - gdcmPixelConvert(); - ~gdcmPixelConvert(); + PixelConvert(); + ~PixelConvert(); uint8_t* GetRGB() { return RGB; } void SetRGBSize( size_t size ) { RGBSize = size; } @@ -70,13 +73,13 @@ public: int YSize, int ZSize, int BitsAllocated, - gdcmRLEFramesInfo* RLEInfo, + RLEFramesInfo* RLEInfo, FILE* fp ); static void ConvertDecompress12BitsTo16Bits( uint8_t* pixelZone, int sizeX, int sizeY, - FILE* filePtr) throw ( gdcmFormatError ); + FILE* filePtr) throw ( FormatError ); static void SwapZone(void* im, int swap, int lgr, int nb); static void ConvertReorderEndianity( uint8_t* pixelZone, @@ -95,17 +98,17 @@ public: int PixelSize, bool isJPEG2000, bool isJPEGLossless, - gdcmJPEGFragmentsInfo* JPEGInfo, + JPEGFragmentsInfo* JPEGInfo, FILE* fp ); - static bool gdcmPixelConvert::ConvertReArrangeBits( + static bool PixelConvert::ConvertReArrangeBits( uint8_t* pixelZone, size_t imageDataSize, int numberBitsStored, int numberBitsAllocated, - int highBitPosition ) throw ( gdcmFormatError ); + int highBitPosition ) throw ( FormatError ); }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmRLEFrame.h b/src/gdcmRLEFrame.h index 3f288ecf..f1e27c6e 100644 --- a/src/gdcmRLEFrame.h +++ b/src/gdcmRLEFrame.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFrame.h,v $ Language: C++ - Date: $Date: 2004/10/08 16:27:20 $ - Version: $Revision: 1.4 $ + Date: $Date: 2004/10/12 04:35:47 $ + Version: $Revision: 1.5 $ 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,8 @@ #define GDCMRLEFRAME_H #include "gdcmCommon.h" - +namespace gdcm +{ /** * \brief Utility class for summerizing the informations of a SINGLE RLE * frame of an "Encapsulated RLE Compressed Image" (refer to @@ -32,23 +33,23 @@ * both the above RLE Header and the itemlength of the frame). * * Each instance of this class (they can be as many instances for - * a given gdcmDocument as they are frames and they are collected in - * a \ref gdcmRLEFramesInfo ) describes : + * a given Document as they are frames and they are collected in + * a \ref RLEFramesInfo ) describes : * - the total number of segments (up to 15), * - the offsets of each segment of the frame, * - the (corresponding) lengths of each segment of the frame. */ -class GDCM_EXPORT gdcmRLEFrame +class GDCM_EXPORT RLEFrame { -friend class gdcmDocument; -friend class gdcmFile; -friend class gdcmPixelConvert; +friend class Document; +friend class File; +friend class PixelConvert; int NumberFragments; long Offset[15]; long Length[15]; - gdcmRLEFrame() { NumberFragments = 0; } + RLEFrame() { NumberFragments = 0; } }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmRLEFramesInfo.cxx b/src/gdcmRLEFramesInfo.cxx index 0c3d1ba3..cf24f379 100644 --- a/src/gdcmRLEFramesInfo.cxx +++ b/src/gdcmRLEFramesInfo.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFramesInfo.cxx,v $ Language: C++ - Date: $Date: 2004/10/06 09:58:08 $ - Version: $Revision: 1.1 $ + Date: $Date: 2004/10/12 04:35:47 $ + 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 @@ -18,7 +18,10 @@ #include "gdcmRLEFramesInfo.h" -gdcmRLEFramesInfo::~gdcmRLEFramesInfo() +namespace gdcm +{ + +RLEFramesInfo::~RLEFramesInfo() { for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it) { @@ -26,3 +29,4 @@ gdcmRLEFramesInfo::~gdcmRLEFramesInfo() } Frames.clear(); } +} // end namespace gdcm diff --git a/src/gdcmRLEFramesInfo.h b/src/gdcmRLEFramesInfo.h index 8994ed8e..d5ff6e10 100644 --- a/src/gdcmRLEFramesInfo.h +++ b/src/gdcmRLEFramesInfo.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFramesInfo.h,v $ Language: C++ - Date: $Date: 2004/10/10 16:44:00 $ - Version: $Revision: 1.4 $ + Date: $Date: 2004/10/12 04:35:47 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,31 +22,34 @@ #include "gdcmRLEFrame.h" #include +namespace gdcm +{ /** * \brief Utility class for gathering the informations of the collection - * of RLE frame[s] (see \ref gdcmRLEFrame) when handling + * of RLE frame[s] (see \ref RLEFrame) when handling * "Encapsulated RLE Compressed Images" (see PS 3.5-2003 annex G). * Note: a classical image can be considered as the degenerated case * of a multiframe image. In this case the collection is limited * to a single individual frame. * The informations on each frame are obtained during the parsing - * of a gdcmDocument (refer to - * \ref gdcmDocument::ComputeRLEInfo() ). + * of a Document (refer to + * \ref Document::ComputeRLEInfo() ). * They shall be used when (if necessary) decoding the frames. * - * This class is simply a stl list<> of \ref gdcmRLEFrame. + * This class is simply a stl list<> of \ref RLEFrame. */ -class GDCM_EXPORT gdcmRLEFramesInfo +class GDCM_EXPORT RLEFramesInfo { - typedef std::list< gdcmRLEFrame* > RLEFrameList; -friend class gdcmDocument; -friend class gdcmFile; -friend class gdcmPixelConvert; + typedef std::list< RLEFrame* > RLEFrameList; +friend class Document; +friend class File; +friend class PixelConvert; RLEFrameList Frames; public: - ~gdcmRLEFramesInfo(); + ~RLEFramesInfo(); }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 597d833c..ac3442dd 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.28 $ + Date: $Date: 2004/10/12 04:35:47 $ + Version: $Revision: 1.29 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,18 +22,19 @@ #include "gdcmBinEntry.h" #include "gdcmGlobal.h" #include "gdcmUtil.h" - #include "gdcmDebug.h" +namespace gdcm +{ //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmSQItem - * \brief Constructor from a given gdcmSQItem + * \ingroup SQItem + * \brief Constructor from a given SQItem */ -gdcmSQItem::gdcmSQItem(int depthLevel ) - : gdcmDocEntrySet( ) +SQItem::SQItem(int depthLevel ) + : DocEntrySet( ) { SQDepthLevel = depthLevel; } @@ -41,7 +42,7 @@ gdcmSQItem::gdcmSQItem(int depthLevel ) /** * \brief Canonical destructor. */ -gdcmSQItem::~gdcmSQItem() +SQItem::~SQItem() { for(ListDocEntry::iterator cc = docEntries.begin(); cc != docEntries.end(); @@ -57,7 +58,7 @@ gdcmSQItem::~gdcmSQItem() /* * \brief canonical Printer */ - void gdcmSQItem::Print(std::ostream& os) + void SQItem::Print(std::ostream& os) { std::ostringstream s; @@ -73,15 +74,15 @@ gdcmSQItem::~gdcmSQItem() i != docEntries.end(); ++i) { - gdcmDocEntry* Entry = *i; + DocEntry* Entry = *i; bool PrintEndLine = true; os << s.str(); Entry->SetPrintLevel(2); Entry->Print(os); - if ( gdcmSeqEntry* SeqEntry = dynamic_cast(Entry) ) + if ( SeqEntry* seqEntry = dynamic_cast(Entry) ) { - (void)SeqEntry; //not used + (void)seqEntry; //not used PrintEndLine = false; } if (PrintEndLine) @@ -92,10 +93,10 @@ gdcmSQItem::~gdcmSQItem() } /* - * \ingroup gdcmSQItem + * \ingroup SQItem * \brief canonical Writer */ -void gdcmSQItem::Write(FILE* fp,FileType filetype) +void SQItem::Write(FILE* fp,FileType filetype) { uint16_t item[4] = { 0xfffe, 0xe000, 0xffff, 0xffff }; uint16_t itemt[4]= { 0xfffe, 0xe00d, 0xffff, 0xffff }; @@ -137,7 +138,7 @@ void gdcmSQItem::Write(FILE* fp,FileType filetype) /** * \brief adds any Entry (Dicom Element) to the Sequence Item */ -bool gdcmSQItem::AddEntry(gdcmDocEntry* entry) +bool SQItem::AddEntry(DocEntry* entry) { docEntries.push_back(entry); //TODO : check if it worked @@ -157,7 +158,7 @@ bool gdcmSQItem::AddEntry(gdcmDocEntry* entry) * @return true if element was found or created successfully */ -bool gdcmSQItem::SetEntryByNumber(std::string val, uint16_t group, +bool SQItem::SetEntryByNumber(std::string val, uint16_t group, uint16_t element) { for(ListDocEntry::iterator i = docEntries.begin(); i != docEntries.end(); ++i) @@ -171,39 +172,39 @@ bool gdcmSQItem::SetEntryByNumber(std::string val, uint16_t group, ||( group == (*i)->GetGroup() && element < (*i)->GetElement()) ) { // instead of ReplaceOrCreateByNumber - // that is a method of gdcmDocument :-( - gdcmValEntry* entry = 0; - gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element); + // that is a method of Document :-( + ValEntry* entry = 0; + TagKey key = DictEntry::TranslateToKey(group, element); if ( ! PtagHT->count(key)) { // we assume a Public Dictionnary *is* loaded - gdcmDict *pubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); + Dict *pubDict = Global::GetDicts()->GetDefaultPubDict(); // if the invoked (group,elem) doesn't exist inside the Dictionary // we create a VirtualDictEntry - gdcmDictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, + DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, element); if (dictEntry == NULL) { dictEntry = - gdcmGlobal::GetDicts()->NewVirtualDictEntry(group, element, + Global::GetDicts()->NewVirtualDictEntry(group, element, "UN", "??", "??"); } // we assume the constructor didn't fail - entry = new gdcmValEntry(dictEntry); + entry = new ValEntry(dictEntry); /// \todo /// ---- /// better we don't assume too much ! - /// gdcmSQItem is now used to describe any DICOMDIR related object + /// SQItem is now used to describe any DICOMDIR related object } else { - gdcmDocEntry* foundEntry = PtagHT->find(key)->second; - entry = dynamic_cast(foundEntry); + DocEntry* foundEntry = PtagHT->find(key)->second; + entry = dynamic_cast(foundEntry); if (!entry) { - dbg.Verbose(0, "gdcmSQItem::SetEntryByNumber: docEntries" - " contains non gdcmValEntry occurences"); + dbg.Verbose(0, "SQItem::SetEntryByNumber: docEntries" + " contains non ValEntry occurences"); } } if (entry) @@ -217,7 +218,7 @@ bool gdcmSQItem::SetEntryByNumber(std::string val, uint16_t group, } if (group == (*i)->GetGroup() && element == (*i)->GetElement() ) { - if ( gdcmValEntry* entry = dynamic_cast(*i) ) + if ( ValEntry* entry = dynamic_cast(*i) ) { entry->SetValue(val); } @@ -235,7 +236,7 @@ bool gdcmSQItem::SetEntryByNumber(std::string val, uint16_t group, * \brief Gets a Dicom Element inside a SQ Item Entry, by number * @return */ -gdcmDocEntry* gdcmSQItem::GetDocEntryByNumber(uint16_t group, uint16_t element) +DocEntry* SQItem::GetDocEntryByNumber(uint16_t group, uint16_t element) { for(ListDocEntry::iterator i = docEntries.begin(); i != docEntries.end(); ++i) @@ -253,14 +254,14 @@ gdcmDocEntry* gdcmSQItem::GetDocEntryByNumber(uint16_t group, uint16_t element) * @return */ -std::string gdcmSQItem::GetEntryByNumber(uint16_t group, uint16_t element) +std::string SQItem::GetEntryByNumber(uint16_t group, uint16_t element) { for(ListDocEntry::iterator i = docEntries.begin(); i != docEntries.end(); ++i) { if ( (*i)->GetGroup() == group && (*i)->GetElement() == element) { - return ((gdcmValEntry *)(*i))->GetValue(); //FIXME + return ((ValEntry *)(*i))->GetValue(); //FIXME } } return GDCM_UNFOUND; @@ -270,3 +271,5 @@ std::string gdcmSQItem::GetEntryByNumber(uint16_t group, uint16_t element) //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmSQItem.h b/src/gdcmSQItem.h index ecfffb68..8d2b585b 100644 --- a/src/gdcmSQItem.h +++ b/src/gdcmSQItem.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.h,v $ Language: C++ - Date: $Date: 2004/10/07 21:01:10 $ - Version: $Revision: 1.18 $ + Date: $Date: 2004/10/12 04:35:47 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -18,21 +18,29 @@ #ifndef GDCMSQITEM_H #define GDCMSQITEM_H -#include "gdcmDocEntry.h" #include "gdcmDocEntrySet.h" -#include "gdcmDocument.h" +#include "gdcmElementSet.h" + +//#include "gdcmDocEntry.h" +//#include "gdcmDocument.h" +//#include "gdcmBinEntry.h" + #include -class gdcmBinEntry; +namespace gdcm +{ +class DocEntry; //----------------------------------------------------------------------------- -typedef std::list ListDocEntry; +typedef std::list ListDocEntry; //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmSQItem : public gdcmDocEntrySet +class GDCM_EXPORT SQItem + : + public DocEntrySet { public: - gdcmSQItem(int); - ~gdcmSQItem(); + SQItem(int); + ~SQItem(); virtual void Print(std::ostream &os = std::cout); virtual void Write(FILE *fp, FileType filetype); @@ -42,13 +50,13 @@ public: /// \brief adds the passed DocEntry to the DocEntry chained List for /// this SQ Item. - void AddDocEntry(gdcmDocEntry *e) { docEntries.push_back(e); }; + void AddDocEntry(DocEntry *e) { docEntries.push_back(e); }; - virtual bool AddEntry(gdcmDocEntry *Entry); // add to the List + virtual bool AddEntry(DocEntry *Entry); // add to the List - gdcmDocEntry *GetDocEntryByNumber(uint16_t group, uint16_t element); + DocEntry *GetDocEntryByNumber(uint16_t group, uint16_t element); // FIXME method to write - //gdcmDocEntry *GetDocEntryByName (std::string Name); + //DocEntry *GetDocEntryByName (std::string Name); bool SetEntryByNumber(std::string val, uint16_t group, uint16_t element); @@ -67,10 +75,10 @@ public: void SetDepthLevel(int depth) { SQDepthLevel = depth; } /// Accessor on \ref BaseTagKey. - void SetBaseTagKey( gdcmBaseTagKey key ) { BaseTagKey = key; } + void SetBaseTagKey( BaseTagKey key ) { BaseTagKeyNested = key; } /// Accessor on \ref BaseTagKey. - gdcmBaseTagKey GetBaseTagKey( ) { return BaseTagKey; } + BaseTagKey GetBaseTagKey( ) { return BaseTagKeyNested; } protected: @@ -83,8 +91,8 @@ protected: /// \brief SQ Item ordinal number int SQItemNumber; - ///\brief pointer to the HTable of the gdcmDocument, - /// (because we don't know it within any gdcmDicomDirObject nor any gdcmSQItem) + ///\brief pointer to the HTable of the Document, + /// (because we don't know it within any DicomDirObject nor any SQItem) TagDocEntryHT *PtagHT; @@ -92,16 +100,16 @@ private: /// \brief Sequences can be nested. This \ref SQDepthLevel represents /// the level of the nesting of instances of this class. - /// \ref SQDepthLevel and its \ref gdcmSeqEntry::SQDepthLevel + /// \ref SQDepthLevel and its \ref SeqEntry::SQDepthLevel /// counterpart are only defined on printing purposes /// (see \ref Print). int SQDepthLevel; - /// \brief A TagKey of a gdcmDocEntry nested in a sequence is prepended + /// \brief A TagKey of a DocEntry nested in a sequence is prepended /// with this BaseTagKey. - gdcmBaseTagKey BaseTagKey; + BaseTagKey BaseTagKeyNested; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index 0fd0b47d..41b2b30a 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:07 $ - Version: $Revision: 1.30 $ + Date: $Date: 2004/10/12 04:35:48 $ + Version: $Revision: 1.31 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,14 +24,18 @@ #include #include + +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmSeqEntry - * \brief Constructor from a given gdcmSeqEntry + * \ingroup SeqEntry + * \brief Constructor from a given SeqEntry */ -gdcmSeqEntry::gdcmSeqEntry( gdcmDictEntry* e ) - : gdcmDocEntry(e) +SeqEntry::SeqEntry( DictEntry* e ) + : DocEntry(e) { UsableLength = 0; ReadLength = 0xffffffff; @@ -42,12 +46,12 @@ gdcmSeqEntry::gdcmSeqEntry( gdcmDictEntry* e ) } /** - * \brief Constructor from a given gdcmSeqEntry + * \brief Constructor from a given SeqEntry * @param e Pointer to existing Doc entry * @param depth depth level of the current Seq entry */ -gdcmSeqEntry::gdcmSeqEntry( gdcmDocEntry* e, int depth ) - : gdcmDocEntry( e->GetDictEntry() ) +SeqEntry::SeqEntry( DocEntry* e, int depth ) + : DocEntry( e->GetDictEntry() ) { this->UsableLength = 0; this->ReadLength = 0xffffffff; @@ -60,7 +64,7 @@ gdcmSeqEntry::gdcmSeqEntry( gdcmDocEntry* e, int depth ) /** * \brief Canonical destructor. */ -gdcmSeqEntry::~gdcmSeqEntry() { +SeqEntry::~SeqEntry() { for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc) { delete *cc; @@ -72,11 +76,11 @@ gdcmSeqEntry::~gdcmSeqEntry() { /** * \brief canonical Printer */ -void gdcmSeqEntry::Print( std::ostream &os ) +void SeqEntry::Print( std::ostream &os ) { // First, Print the Dicom Element itself. SetPrintLevel(2); - gdcmDocEntry::Print(os); + DocEntry::Print(os); os << std::endl; if (GetReadLength() == 0) @@ -110,7 +114,7 @@ void gdcmSeqEntry::Print( std::ostream &os ) /* * \brief canonical Writer */ -void gdcmSeqEntry::Write(FILE* fp, FileType filetype) +void SeqEntry::Write(FILE* fp, FileType filetype) { uint16_t seq_term_gr = 0xfffe; uint16_t seq_term_el = 0xe0dd; @@ -119,7 +123,7 @@ void gdcmSeqEntry::Write(FILE* fp, FileType filetype) //uint16_t item_term_gr = 0xfffe; //uint16_t item_term_el = 0xe00d; - gdcmDocEntry::Write(fp, filetype); + DocEntry::Write(fp, filetype); for(ListSQItem::iterator cc = GetSQItems().begin(); cc != GetSQItems().end(); ++cc) @@ -138,7 +142,7 @@ void gdcmSeqEntry::Write(FILE* fp, FileType filetype) // Public /// \brief adds the passed ITEM to the ITEM chained List for this SeQuence. -void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem, int itemNumber) +void SeqEntry::AddEntry(SQItem *sqItem, int itemNumber) { sqItem->SetSQItemNumber(itemNumber); items.push_back(sqItem); @@ -150,7 +154,7 @@ void gdcmSeqEntry::AddEntry(gdcmSQItem *sqItem, int itemNumber) * Returns the last item when argument is bigget than the total * item number. */ -gdcmSQItem* gdcmSeqEntry::GetSQItemByOrdinalNumber(int nb) +SQItem* SeqEntry::GetSQItemByOrdinalNumber(int nb) { if (nb<0) return (*(items.begin())); @@ -171,3 +175,5 @@ gdcmSQItem* gdcmSeqEntry::GetSQItemByOrdinalNumber(int nb) // Private //----------------------------------------------------------------------------- +} // end namespace gdcm + diff --git a/src/gdcmSeqEntry.h b/src/gdcmSeqEntry.h index 22c67cf0..0358bf0d 100644 --- a/src/gdcmSeqEntry.h +++ b/src/gdcmSeqEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.h,v $ Language: C++ - Date: $Date: 2004/10/07 21:05:40 $ - Version: $Revision: 1.19 $ + Date: $Date: 2004/10/12 04:35:48 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,17 +22,19 @@ #include "gdcmSQItem.h" #include "gdcmDocEntry.h" #include +namespace gdcm +{ //----------------------------------------------------------------------------- -typedef std::list ListSQItem; +typedef std::list ListSQItem; //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmSeqEntry : public gdcmDocEntry +class GDCM_EXPORT SeqEntry : public DocEntry { public: - gdcmSeqEntry( gdcmDictEntry* ); - gdcmSeqEntry(gdcmDocEntry* d, int depth); - virtual ~gdcmSeqEntry(); + SeqEntry( DictEntry* ); + SeqEntry(DocEntry* d, int depth); + virtual ~SeqEntry(); virtual void Print(std::ostream &os = std::cout); virtual void Write(FILE *fp, FileType); @@ -44,10 +46,10 @@ public: void SetDelimitorMode(bool dm) { delimitor_mode = dm;} /// Sets the Sequence Delimitation Item - void SetSequenceDelimitationItem(gdcmDocEntry * e) { seq_term = e;} + void SetSequenceDelimitationItem(DocEntry * e) { seq_term = e;} - void AddEntry(gdcmSQItem *it, int itemNumber); - gdcmSQItem *GetSQItemByOrdinalNumber(int itemNumber); + void AddEntry(SQItem *it, int itemNumber); + SQItem *GetSQItemByOrdinalNumber(int itemNumber); /// Gets the depth level int GetDepthLevel() { return SQDepthLevel; } @@ -66,15 +68,15 @@ private: ListSQItem items; /// sequence terminator item - gdcmDocEntry *seq_term; + DocEntry *seq_term; - /// \brief Defines the depth level of this \ref gdcmSeqEntry inside + /// \brief Defines the depth level of this \ref SeqEntry inside /// the (optionaly) nested sequences. \ref SQDepthLevel - /// and its \ref gdcmSQItem::SQDepthLevel counterpart + /// and its \ref SQItem::SQDepthLevel counterpart /// are only defined on printing purposes (see \ref Print). int SQDepthLevel; }; - +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmTS.cxx b/src/gdcmTS.cxx index 82a25780..4f87ab6c 100644 --- a/src/gdcmTS.cxx +++ b/src/gdcmTS.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmTS.cxx,v $ Language: C++ - Date: $Date: 2004/10/08 04:43:38 $ - Version: $Revision: 1.25 $ + Date: $Date: 2004/10/12 04:35:48 $ + Version: $Revision: 1.26 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,13 +25,16 @@ #include #include +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor -gdcmTS::gdcmTS() +TS::TS() { - std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_TS); + std::string filename=DictSet::BuildDictPath() + std::string(DICT_TS); std::ifstream from(filename.c_str()); - dbg.Error(!from, "gdcmTS::gdcmTS: can't open dictionary",filename.c_str()); + dbg.Error(!from, "TS::TS: can't open dictionary",filename.c_str()); std::string key; std::string name; @@ -52,7 +55,7 @@ gdcmTS::gdcmTS() } //----------------------------------------------------------------------------- -gdcmTS::~gdcmTS() +TS::~TS() { ts.clear(); } @@ -60,11 +63,11 @@ gdcmTS::~gdcmTS() //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmVR + * \ingroup VR * \brief Print all * @param os The output stream to be written to. */ -void gdcmTS::Print(std::ostream &os) +void TS::Print(std::ostream &os) { std::ostringstream s; @@ -77,12 +80,12 @@ void gdcmTS::Print(std::ostream &os) //----------------------------------------------------------------------------- // Public -int gdcmTS::Count(TSKey key) +int TS::Count(TSKey key) { return ts.count(key); } -std::string gdcmTS::GetValue(TSKey key) +std::string TS::GetValue(TSKey key) { if (ts.count(key) == 0) { @@ -98,3 +101,5 @@ std::string gdcmTS::GetValue(TSKey key) // Private //----------------------------------------------------------------------------- + +} // end namespace gdcm diff --git a/src/gdcmTS.h b/src/gdcmTS.h index 35c61a7e..cbf78f1d 100644 --- a/src/gdcmTS.h +++ b/src/gdcmTS.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmTS.h,v $ Language: C++ - Date: $Date: 2004/10/07 21:05:40 $ - Version: $Revision: 1.9 $ + Date: $Date: 2004/10/12 04:35:48 $ + 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 @@ -23,6 +23,8 @@ #include #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- typedef std::string TSKey; @@ -34,11 +36,11 @@ typedef std::map TSHT; // Transfert Syntax Hash Table * Container for dicom Transfert Syntax Hash Table * \note This is a singleton */ -class GDCM_EXPORT gdcmTS +class GDCM_EXPORT TS { public: - gdcmTS(); - ~gdcmTS(); + TS(); + ~TS(); void Print(std::ostream &os = std::cout); @@ -48,6 +50,7 @@ public: private: TSHT ts; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index b4907d91..6e6f9f3d 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:55 $ - Version: $Revision: 1.53 $ + Date: $Date: 2004/10/12 04:35:48 $ + Version: $Revision: 1.54 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,6 +19,11 @@ #include "gdcmUtil.h" #include "gdcmDebug.h" +#include //only included in implementation file +#include //only included in implementation file + +namespace gdcm +{ /** * \ingroup Globals @@ -33,10 +38,8 @@ * << std::hex << element; * buf.str(); */ -#include //only included in implementation file -#include //only included in implementation file -std::string gdcmUtil::Format(const char* format, ...) +std::string Util::Format(const char* format, ...) { char buffer[2048]; va_list args; @@ -50,7 +53,7 @@ std::string gdcmUtil::Format(const char* format, ...) * \ingroup Globals * \brief Because not available in C++ (?) */ -void gdcmUtil::Tokenize (const std::string& str, +void Util::Tokenize (const std::string& str, std::vector& tokens, const std::string& delimiters) { @@ -70,7 +73,7 @@ void gdcmUtil::Tokenize (const std::string& str, * Counts the number of occurences of a substring within a string */ -int gdcmUtil::CountSubstring (const std::string& str, +int Util::CountSubstring (const std::string& str, const std::string& subStr) { int count = 0; // counts how many times it appears @@ -96,7 +99,7 @@ int gdcmUtil::CountSubstring (const std::string& str, * to avoid corrupting the terminal of invocation when printing) * @param s string to remove non printable characters from */ -std::string gdcmUtil::CreateCleanString(std::string s) +std::string Util::CreateCleanString(std::string s) { std::string str = s; @@ -127,7 +130,7 @@ std::string gdcmUtil::CreateCleanString(std::string s) * \brief Add a SEPARATOR to the end of the name is necessary * @param name file/directory name to normalize */ -void gdcmUtil::NormalizePath(std::string &name) +void Util::NormalizePath(std::string &name) { const char SEPARATOR_X = '/'; const char SEPARATOR_WIN = '\\'; @@ -145,7 +148,7 @@ void gdcmUtil::NormalizePath(std::string &name) * \brief Get the (directory) path from a full path file name * @param fullName file/directory name to extract Path from */ -std::string gdcmUtil::GetPath(std::string &fullName) +std::string Util::GetPath(std::string &fullName) { int pos1 = fullName.rfind("/"); int pos2 = fullName.rfind("\\"); @@ -166,7 +169,7 @@ std::string gdcmUtil::GetPath(std::string &fullName) * \brief Get the (last) name of a full path file name * @param fullName file/directory name to extract end name from */ -std::string gdcmUtil::GetName(std::string &fullName) +std::string Util::GetName(std::string &fullName) { int fin = fullName.length()-1; char a =fullName.c_str()[fin]; @@ -192,3 +195,6 @@ std::string gdcmUtil::GetName(std::string &fullName) return lastName; } + +} // end namespace gdcm + diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 3371cb3e..3ec7b666 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.h,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:55 $ - Version: $Revision: 1.35 $ + Date: $Date: 2004/10/12 04:35:48 $ + 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 @@ -23,7 +23,8 @@ #include #include - +namespace gdcm +{ /** * \defgroup Globals Utility functions * \brief Here are some utility functions, belonging to NO class, @@ -33,7 +34,7 @@ //----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmUtil +class GDCM_EXPORT Util { public: static std::string Format(const char* format, ...); @@ -48,5 +49,6 @@ public: static std::string GetPath(std::string &fullName); static std::string GetName(std::string &fullName); }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmVR.cxx b/src/gdcmVR.cxx index 4cc07ea9..b45fbbb6 100644 --- a/src/gdcmVR.cxx +++ b/src/gdcmVR.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmVR.cxx,v $ Language: C++ - Date: $Date: 2004/10/08 04:43:38 $ - Version: $Revision: 1.18 $ + Date: $Date: 2004/10/12 04:35:48 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,15 +24,18 @@ #include #include +namespace gdcm +{ + //----------------------------------------------------------------------------- /** * \brief Constructor */ -gdcmVR::gdcmVR() +VR::VR() { - std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR); + std::string filename=DictSet::BuildDictPath() + std::string(DICT_VR); std::ifstream from(filename.c_str()); - dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str()); + dbg.Error(!from, "VR::VR: can't open dictionary",filename.c_str()); char buff[1024]; std::string key; @@ -62,7 +65,7 @@ gdcmVR::gdcmVR() /** * \brief Destructor */ -gdcmVR::~gdcmVR() +VR::~VR() { vr.clear(); } @@ -73,11 +76,11 @@ gdcmVR::~gdcmVR() * \brief Print all * @param os The output stream to be written to. */ -void gdcmVR::Print(std::ostream &os) +void VR::Print(std::ostream &os) { std::ostringstream s; - for (gdcmVRHT::iterator it = vr.begin(); it != vr.end(); ++it) + for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it) { s << "VR : "<first<<" = "<second< #include #include +namespace gdcm +{ //----------------------------------------------------------------------------- -typedef std::string gdcmVRKey; -typedef std::string gdcmVRAtr; +typedef std::string VRKey; +typedef std::string VRAtr; /// Value Representation Hash Table -typedef std::map gdcmVRHT; +typedef std::map VRHT; //----------------------------------------------------------------------------- /* * Container for dicom Value Representation Hash Table * \note This is a singleton */ -class GDCM_EXPORT gdcmVR +class GDCM_EXPORT VR { public: - gdcmVR(void); - ~gdcmVR(); + VR(void); + ~VR(); void Print(std::ostream &os = std::cout); - int Count(gdcmVRKey key); - bool IsVROfGdcmBinaryRepresentable(gdcmVRKey); - bool IsVROfGdcmStringRepresentable(gdcmVRKey); + int Count(VRKey key); + bool IsVROfGdcmBinaryRepresentable(VRKey); + bool IsVROfGdcmStringRepresentable(VRKey); private: - gdcmVRHT vr; + VRHT vr; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx index 9160b21a..aaf16de4 100644 --- a/src/gdcmValEntry.cxx +++ b/src/gdcmValEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmValEntry.cxx,v $ Language: C++ - Date: $Date: 2004/10/10 00:42:55 $ - Version: $Revision: 1.29 $ + Date: $Date: 2004/10/12 04:35:48 $ + Version: $Revision: 1.30 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,25 +21,28 @@ #include "gdcmGlobal.h" #include "gdcmUtil.h" +namespace gdcm +{ + // CLEAN ME #define MAX_SIZE_PRINT_ELEMENT_VALUE 128 //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \brief Constructor from a given gdcmDictEntry + * \brief Constructor from a given DictEntry * @param e Pointer to existing dictionary entry */ -gdcmValEntry::gdcmValEntry(gdcmDictEntry* e) : gdcmDocEntry(e) +ValEntry::ValEntry(DictEntry* e) : DocEntry(e) { } /** - * \brief Constructor from a given gdcmDocEntry + * \brief Constructor from a given DocEntry * @param e Pointer to existing Doc entry */ -gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) - : gdcmDocEntry(e->GetDictEntry()) +ValEntry::ValEntry(DocEntry* e) + : DocEntry(e->GetDictEntry()) { UsableLength = e->GetLength(); ReadLength = e->GetReadLength(); @@ -52,7 +55,7 @@ gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) /** * \brief Canonical destructor. */ -gdcmValEntry::~gdcmValEntry () +ValEntry::~ValEntry () { } @@ -61,7 +64,7 @@ gdcmValEntry::~gdcmValEntry () /** * \brief canonical Printer */ -void gdcmValEntry::Print(std::ostream & os) +void ValEntry::Print(std::ostream & os) { uint16_t g = GetGroup(); uint16_t e = GetElement(); @@ -71,7 +74,7 @@ void gdcmValEntry::Print(std::ostream & os) TSKey v; std::string d2; - gdcmDocEntry::Print(os); + DocEntry::Print(os); if (g == 0xfffe) { @@ -79,10 +82,10 @@ void gdcmValEntry::Print(std::ostream & os) return; } - gdcmTS * ts = gdcmGlobal::GetTS(); + TS * ts = Global::GetTS(); v = GetValue(); // not applicable for SQ ... - d2 = gdcmUtil::CreateCleanString(v); // replace non printable characters by '.' + d2 = Util::CreateCleanString(v); // replace non printable characters by '.' if( (GetLength()<=MAX_SIZE_PRINT_ELEMENT_VALUE) || //(PrintLevel>=3) || (d2.find("gdcm::NotLoaded.") < d2.length()) ) (PrintLevel>=3) || (d2.find(GDCM_NOTLOADED) < d2.length()) ) @@ -150,17 +153,17 @@ void gdcmValEntry::Print(std::ostream & os) { if (v == "4294967295") // to avoid troubles in convertion { - st = gdcmUtil::Format(" x(ffffffff)"); + st = Util::Format(" x(ffffffff)"); } else { if ( GetLength() !=0 ) { - st = gdcmUtil::Format(" x(%x)", atoi(v.c_str()));//FIXME + st = Util::Format(" x(%x)", atoi(v.c_str()));//FIXME } else { - st = gdcmUtil::Format(" "); + st = Util::Format(" "); } } s << st; @@ -171,9 +174,9 @@ void gdcmValEntry::Print(std::ostream & os) /* * \brief canonical Writer */ -void gdcmValEntry::Write(FILE* fp, FileType filetype) +void ValEntry::Write(FILE* fp, FileType filetype) { - gdcmDocEntry::Write(fp, filetype); + DocEntry::Write(fp, filetype); //std::cout << "=====================================" << GetVR() << std::endl; @@ -191,7 +194,7 @@ void gdcmValEntry::Write(FILE* fp, FileType filetype) // we split the string and write each value as a short int std::vector tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value - gdcmUtil::Tokenize (GetValue(), tokens, "\\"); + Util::Tokenize (GetValue(), tokens, "\\"); for (unsigned int i=0; i tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value - gdcmUtil::Tokenize (GetValue(), tokens, "\\"); + Util::Tokenize (GetValue(), tokens, "\\"); for (unsigned int i=0; i +namespace gdcm +{ //----------------------------------------------------------------------------- /** - * \ingroup gdcmValEntry + * \ingroup ValEntry * \brief The dicom header of a Dicom file contains a set of such entries * (when successfuly parsed against a given Dicom dictionary) */ -class GDCM_EXPORT gdcmValEntry : public gdcmDocEntry +class GDCM_EXPORT ValEntry : public DocEntry { public: - gdcmValEntry(gdcmDictEntry* e); - gdcmValEntry(gdcmDocEntry* d); - virtual ~gdcmValEntry(); + ValEntry(DictEntry* e); + ValEntry(DocEntry* d); + virtual ~ValEntry(); /// \brief Returns the 'Value' (e.g. "Dupond Marcel") converted into a /// 'string', if it's stored as an integer in the header of the @@ -52,10 +54,11 @@ private: // Members : /// \brief Document Entry value, internaly represented as a std::string - /// The Value Representation (\ref gdcmVR) is independently used + /// The Value Representation (\ref VR) is independently used /// in order to interpret (decode) this field. std::string Value; }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index fdbb9c85..dc866270 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -58,7 +58,7 @@ #include #include -vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.50 $"); +vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.51 $"); vtkStandardNewMacro(vtkGdcmReader); //----------------------------------------------------------------------------- @@ -444,7 +444,7 @@ int vtkGdcmReader::CheckFileCoherence() fclose(fp); // Stage 1.2: check for Gdcm parsability - gdcmHeader GdcmHeader(filename->c_str() ); + gdcm::Header GdcmHeader(filename->c_str() ); if (!GdcmHeader.IsReadable()) { vtkErrorMacro("Gdcm cannot parse file " << filename->c_str()); @@ -612,7 +612,7 @@ size_t vtkGdcmReader::LoadImageInMemory( unsigned long & updateProgressCount) { vtkDebugMacro("Copying to memory image [" << fileName.c_str() << "]"); - gdcmFile file( fileName.c_str() ); + gdcm::File file( fileName.c_str() ); size_t size; // If the data structure of vtk for image/volume representation -- 2.45.1