From 6b51b22366f878e1050c75a6ebb755bd2ff365c7 Mon Sep 17 00:00:00 2001 From: regrain Date: Tue, 25 Oct 2005 14:52:26 +0000 Subject: [PATCH] * Some classes inherit now from gdcm::RefCounter -- BeNours --- Example/Anonymize.cxx | 18 +- Example/AnonymizeDicomDir.cxx | 13 +- Example/AnonymizeNoLoad.cxx | 21 +- Example/FindTags.cxx | 11 +- Example/MakeDicomDir.cxx | 18 +- Example/PatchHeader.cxx | 38 ++- Example/PrintDicomDir.cxx | 285 ++++++++++---------- Example/PrintFile.cxx | 26 +- Example/ReWrite.cxx | 132 +++++---- Example/TestChangeHeader.cxx | 82 +++--- Example/TestCopyDicom.cxx | 36 +-- Example/Volume2Dicom.cxx | 180 ++++++------- Example/WriteDicomSimple.cxx | 23 +- Example/WriteRead.cxx | 93 ++++--- Example/exColorToRGB.cxx | 26 +- Example/exCurveData.cxx | 14 +- Example/exExtractDicomTags.cxx | 11 +- Example/exExtractTag.cxx | 16 +- Example/exGC.cxx | 33 +-- Example/exGrey2RGB.cxx | 8 +- Example/exImageLighten.cxx | 18 +- Example/exOverlaysACR.cxx | 37 +-- Example/exReadPapyrus.cxx | 20 +- Example/exReadWriteFile.cxx | 16 +- Testing/TestAllReadCompareDicom.cxx | 34 +-- Testing/TestAllVM.cxx | 20 +- Testing/TestBug.cxx | 8 +- Testing/TestBuildUpDicomDir.cxx | 18 +- Testing/TestDicomDir.cxx | 41 +-- Testing/TestDicomDirElement.cxx | 12 +- Testing/TestDict.cxx | 8 +- Testing/TestDictGroupName.cxx | 14 +- Testing/TestFileAccessors.cxx | 16 +- Testing/TestImageSet.cxx | 34 +-- Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx | 10 +- Testing/TestMakeDicomDir.cxx | 18 +- Testing/TestMakeIcon.cxx | 72 ++--- Testing/TestPrintAllDocument.cxx | 10 +- Testing/TestReadWriteReadCompare.cxx | 52 ++-- Testing/TestTS.cxx | 60 +++-- Testing/TestVR.cxx | 8 +- Testing/TestWriteSimple.cxx | 54 ++-- src/gdcmDicomDir.cxx | 104 +++---- src/gdcmDicomDir.h | 15 +- src/gdcmDicomDirElement.h | 19 +- src/gdcmDicomDirImage.h | 13 +- src/gdcmDicomDirMeta.h | 13 +- src/gdcmDicomDirObject.h | 6 +- src/gdcmDicomDirPatient.cxx | 12 +- src/gdcmDicomDirPatient.h | 14 +- src/gdcmDicomDirSerie.cxx | 12 +- src/gdcmDicomDirSerie.h | 14 +- src/gdcmDicomDirStudy.cxx | 21 +- src/gdcmDicomDirStudy.h | 15 +- src/gdcmDicomDirVisit.h | 12 +- src/gdcmDict.h | 20 +- src/gdcmDictGroupName.h | 18 +- src/gdcmDictSet.cxx | 28 +- src/gdcmDictSet.h | 16 +- src/gdcmDocEntrySet.h | 20 +- src/gdcmDocument.cxx | 7 +- src/gdcmDocument.h | 9 +- src/gdcmElementSet.h | 11 +- src/gdcmFile.cxx | 19 +- src/gdcmFile.h | 14 +- src/gdcmFileHelper.cxx | 52 +--- src/gdcmFileHelper.h | 23 +- src/gdcmGlobal.cxx | 24 +- src/gdcmSQItem.h | 12 +- src/gdcmSeqEntry.cxx | 7 +- src/gdcmSerieHelper.cxx | 12 +- src/gdcmTS.h | 59 ++-- src/gdcmVR.h | 17 +- vtk/vtkGdcmReader.cxx | 20 +- vtk/vtkGdcmWriter.cxx | 10 +- 75 files changed, 1158 insertions(+), 1174 deletions(-) diff --git a/Example/Anonymize.cxx b/Example/Anonymize.cxx index 16983535..7e33bfa6 100644 --- a/Example/Anonymize.cxx +++ b/Example/Anonymize.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: Anonymize.cxx,v $ Language: C++ - Date: $Date: 2005/08/30 15:13:05 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/10/25 14:52:26 $ + 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 @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) gdcm::File *f; - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode( gdcm::LD_ALL ); f->SetFileName( fileName ); int res = f->Load(); @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) { std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 0; } std::cout << " ... is readable " << std::endl; @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) // ============================================================ // We need a gdcm::FileHelper, since we want to load the pixels - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); // (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one) @@ -106,8 +106,8 @@ int main(int argc, char *argv[]) std::cerr << "Sorry, Pixels of" << fileName <<" are not " << " gdcm-readable." << std::endl << "Use exAnonymizeNoLoad" << std::endl; - delete f; - delete fh; + f->Delete(); + fh->Delete(); return 0; } @@ -143,8 +143,8 @@ int main(int argc, char *argv[]) // ============================================================ f->ClearAnonymizeList(); - delete f; - delete fh; + f->Delete(); + fh->Delete(); return 0; } diff --git a/Example/AnonymizeDicomDir.cxx b/Example/AnonymizeDicomDir.cxx index 02190c34..747714b5 100644 --- a/Example/AnonymizeDicomDir.cxx +++ b/Example/AnonymizeDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: AnonymizeDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/10/25 14:52:26 $ + 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 @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) // Read the input DICOMDIR gdcm::File *f; - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode(0); f->SetFileName( fileName ); bool res = f->Load(); @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) if ( !e ) { std::cout << "No Directory Record Sequence (0004,1220) found" <Delete(); return 0; } @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) if ( !s ) { std::cout << "Element (0004,1220) is not a Sequence ?!?" <Delete(); return 0; } @@ -188,7 +188,8 @@ int main(int argc, char *argv[]) fp->close(); - delete f; + delete fp; + f->Delete(); return 0; } diff --git a/Example/AnonymizeNoLoad.cxx b/Example/AnonymizeNoLoad.cxx index 3fa85005..0eb1da3f 100644 --- a/Example/AnonymizeNoLoad.cxx +++ b/Example/AnonymizeNoLoad.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: AnonymizeNoLoad.cxx,v $ Language: C++ - Date: $Date: 2005/08/30 15:13:05 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/10/25 14:52:26 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) // // Parse the input file. // - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode(loadMode); f->SetFileName( fileName ); @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR Document" << std::endl; - delete f; + f->Delete(); return 1; } std::cout << fileName << " is readable " << std::endl; @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) // f->ClearAnonymizeList(); - delete f; + f->Delete(); return 0; } @@ -192,13 +192,13 @@ int main(int argc, char *argv[]) it != fileList.end(); ++it ) { - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode(loadMode); f->SetFileName( it->c_str() ); if ( !f->Load() ) { - delete f; + f->Delete(); continue; } // @@ -243,10 +243,9 @@ int main(int argc, char *argv[]) f->ClearAnonymizeList(); - delete f; - } - - } + f->Delete(); + } + } return 0; } diff --git a/Example/FindTags.cxx b/Example/FindTags.cxx index a1b9e4f7..a56ddb4a 100644 --- a/Example/FindTags.cxx +++ b/Example/FindTags.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: FindTags.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.15 $ + Date: $Date: 2005/10/25 14:52:26 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) std::string fileName; gdcm::FileHelper *h; - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); if(argc > 1 ) @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) f->Load(); // Should test if it worked ! - h = new gdcm::FileHelper(f); + h = gdcm::FileHelper::New(f); std::string ManufacturerName="SIEMENS "; std::string RecCode="ACR-NEMA 2.0"; @@ -113,6 +113,9 @@ int main(int argc, char *argv[]) std::cout << "----------------apres Write---------------------" << std::endl; + h->Delete(); + f->Delete(); + return 0; } diff --git a/Example/MakeDicomDir.cxx b/Example/MakeDicomDir.cxx index e8ebe983..bb97ae6b 100644 --- a/Example/MakeDicomDir.cxx +++ b/Example/MakeDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: MakeDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/08/31 09:29:10 $ - Version: $Revision: 1.15 $ + Date: $Date: 2005/10/25 14:52:26 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) // we ask for Directory parsing - dcmdir = new gdcm::DicomDir( ); + dcmdir = gdcm::DicomDir::New( ); dcmdir->SetStartMethod(StartMethod); dcmdir->SetEndMethod(EndMethod); @@ -119,17 +119,17 @@ int main(int argc, char *argv[]) { std::cout << "makeDicomDir: no patient found. Exiting." << std::endl; - delete dcmdir; + dcmdir->Delete(); return 1; } // ----- Create the corresponding DicomDir dcmdir->Write("NewDICOMDIR"); - delete dcmdir; + dcmdir->Delete(); // Read from disc the just written DicomDir - gdcm::DicomDir *newDicomDir = new gdcm::DicomDir(); + gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New(); newDicomDir->SetFileName( "NewDICOMDIR" ); newDicomDir->Load(); if( !newDicomDir->IsReadable() ) @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) <<" is not readable"<Delete(); return 1; } @@ -148,12 +148,12 @@ int main(int argc, char *argv[]) <<" has no patient"<Delete(); return(1); } std::cout<Delete(); return 0; } diff --git a/Example/PatchHeader.cxx b/Example/PatchHeader.cxx index 27654339..e88de916 100644 --- a/Example/PatchHeader.cxx +++ b/Example/PatchHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: PatchHeader.cxx,v $ Language: C++ - Date: $Date: 2005/08/30 15:13:05 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -269,7 +269,7 @@ int main(int argc, char *argv[]) loadMode |= gdcm::LD_NOSHADOWSEQ; else { - if ( am->ArgMgrDefined("noshadow") ) + if ( am->ArgMgrDefined("noshadow") ) loadMode |= gdcm::LD_NOSHADOW; if ( am->ArgMgrDefined("noseq") ) loadMode |= gdcm::LD_NOSEQ; @@ -288,12 +288,10 @@ int main(int argc, char *argv[]) if ( fileName != 0 ) // ====== Deal with a single file ====== { - - // - // Parse the input file. - // - - f = new gdcm::File( ); + // + // Parse the input file. + // + f = gdcm::File::New( ); f->SetLoadMode(loadMode); f->SetFileName( fileName ); bool res = f->Load(); @@ -303,12 +301,12 @@ int main(int argc, char *argv[]) // not only gdcm::File (as opposed to gdcm::DicomDir) if ( !res ) { - std::cout <Delete(); + return 1; } std::cout << fileName << " is readable " << std::endl; @@ -325,7 +323,7 @@ int main(int argc, char *argv[]) fp->close(); delete fp; - delete f; + f->Delete(); return 0; } @@ -338,14 +336,14 @@ int main(int argc, char *argv[]) it != fileList.end(); ++it ) { - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode(loadMode); f->SetFileName( it->c_str() ); bool res = f->Load(); if ( !res ) { - delete f; + f->Delete(); continue; } @@ -357,8 +355,8 @@ int main(int argc, char *argv[]) fp->close(); delete fp; - delete f; - } + f->Delete(); + } } return 0; } diff --git a/Example/PrintDicomDir.cxx b/Example/PrintDicomDir.cxx index 2d40b7df..29dfdc80 100644 --- a/Example/PrintDicomDir.cxx +++ b/Example/PrintDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: PrintDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.29 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -81,7 +81,7 @@ int main(int argc, char* argv[]) // new gdcm2 style - f = new gdcm::DicomDir(); + f = gdcm::DicomDir::New(); f->SetFileName ( fileName ); f->Load( ); @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) <<"' is not readable"<Delete(); return 1; } @@ -106,152 +106,161 @@ int main(int argc, char* argv[]) <<" has no patient"<Delete(); return 1; } // Structure use Examples switch (detailLevel) - { - case 1: - std::cout << std::endl << std::endl - << " = PATIENT List ==========================================" - << std::endl<< std::endl; - - pa = f->GetFirstPatient(); - while (pa) - { - std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name - std::cout << " Pat.ID:["; - std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID - pa = f->GetNextPatient(); - } - break; - - case 2: - std::cout << std::endl << std::endl - << " = PATIENT/STUDY List =======================================" - << std::endl<< std::endl; - - pa = f->GetFirstPatient(); - while ( pa ) // on degouline les PATIENT de ce DICOMDIR - { - std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name - std::cout << " Pat.ID:["; - std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID - st = pa->GetFirstStudy(); - while ( st ) { // on degouline les STUDY de ce patient - std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description - std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID - std::cout << std::endl; - st = pa->GetNextStudy(); + { + case 1: + std::cout << std::endl << std::endl + << " = PATIENT List ==========================================" + << std::endl<< std::endl; + + pa = f->GetFirstPatient(); + while (pa) + { + std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name + std::cout << " Pat.ID:["; + std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID + pa = f->GetNextPatient(); } - pa = f->GetNextPatient(); - } - break; + break; + + case 2: + std::cout << std::endl << std::endl + << " = PATIENT/STUDY List =======================================" + << std::endl<< std::endl; + + pa = f->GetFirstPatient(); + while ( pa ) // on degouline les PATIENT de ce DICOMDIR + { + std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name + std::cout << " Pat.ID:["; + std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID + st = pa->GetFirstStudy(); + while ( st ) + { // on degouline les STUDY de ce patient + std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description + std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID + std::cout << std::endl; + st = pa->GetNextStudy(); + } + pa = f->GetNextPatient(); + } + break; + + case 3: + std::cout << std::endl << std::endl + << " = PATIENT/STUDY/SERIE List ==================================" + << std::endl<< std::endl; + + pa = f->GetFirstPatient(); + while ( pa ) // on degouline les PATIENT de ce DICOMDIR + { + // Patient's Name, Patient ID + std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name + std::cout << " Pat.ID:["; + std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID + + st = pa->GetFirstStudy(); + while ( st ) + { // on degouline les STUDY de ce patient + std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description + std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID + std::cout << std::endl; + + se = st->GetFirstSerie(); + while ( se ) + { // on degouline les SERIES de cette study + std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]"; // Series Description + std::cout << " Ser.nb:[" << se->GetEntryString(0x0020, 0x0011); // Series number + std::cout << "] Mod.:[" << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality + std::cout << std::endl; + se = st->GetNextSerie(); + } - case 3: - std::cout << std::endl << std::endl - << " = PATIENT/STUDY/SERIE List ==================================" - << std::endl<< std::endl; + vs = st->GetFirstVisit(); + while ( vs ) + { // on degouline les VISIT de cette study + std::cout << "--- --- VISIT: "; + std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID + std::cout << " Inst.Name:[" << vs->GetEntryString(0x0008,0x0080) << "]"; // Institution Name + std::cout << " Adm.ID:[" << vs->GetEntryString(0x0038, 0x0010) << "]"; // Admission ID + std::cout << " Adm. date:[" << vs->GetEntryString(0x0038, 0x0020) << "]"; // Admitting Date + std::cout << std::endl; + vs = st->GetNextVisit(); + } - pa = f->GetFirstPatient(); - while ( pa ) // on degouline les PATIENT de ce DICOMDIR - { - // Patient's Name, Patient ID - std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name - std::cout << " Pat.ID:["; - std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID - - st = pa->GetFirstStudy(); - while ( st ) { // on degouline les STUDY de ce patient - std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description - std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID - std::cout << std::endl; - - se = st->GetFirstSerie(); - while ( se ) { // on degouline les SERIES de cette study - std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]"; // Series Description - std::cout << " Ser.nb:[" << se->GetEntryString(0x0020, 0x0011); // Series number - std::cout << "] Mod.:[" << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality - std::cout << std::endl; - se = st->GetNextSerie(); - } - - vs = st->GetFirstVisit(); - while ( vs ) { // on degouline les VISIT de cette study - std::cout << "--- --- VISIT: "; - std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID - std::cout << " Inst.Name:[" << vs->GetEntryString(0x0008,0x0080) << "]"; // Institution Name - std::cout << " Adm.ID:[" << vs->GetEntryString(0x0038, 0x0010) << "]"; // Admission ID - std::cout << " Adm. date:[" << vs->GetEntryString(0x0038, 0x0020) << "]"; // Admitting Date - std::cout << std::endl; - vs = st->GetNextVisit(); + st = pa->GetNextStudy(); } + pa = f->GetNextPatient(); + } + break; + + case 4: + std::cout << std::endl << std::endl + << " = PATIENT/STUDY/SERIE/IMAGE List ============================" + << std::endl<< std::endl; + + pa = f->GetFirstPatient(); + while ( pa ) + { // les PATIENT de ce DICOMDIR + // Patient's Name, Patient ID + std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name + std::cout << " Pat.ID:["; + std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID + + st = pa->GetFirstStudy(); + while ( st ) + { // on degouline les STUDY de ce patient + std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description + std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID + std::cout << std::endl; + + vs = st->GetFirstVisit(); + while ( vs ) + { // on degouline les VISIT de cette study + std::cout << "--- --- VISIT: "; + std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID + std::cout << " Inst.Name:[" << vs->GetEntryString(0x0008,0x0080) << "]"; // Institution Name + std::cout << " Adm.ID:[" << vs->GetEntryString(0x0038, 0x0010) << "]"; // Admission ID + std::cout << " Adm. date:[" << vs->GetEntryString(0x0038, 0x0020) << "]"; // Admitting Date + std::cout << std::endl; + vs = st->GetNextVisit(); + } - st = pa->GetNextStudy(); + se = st->GetFirstSerie(); + while ( se ) + { // on degouline les SERIES de cette study + std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]"; // Series Description + std::cout << " Ser.nb:[" << se->GetEntryString(0x0020, 0x0011); // Series number + std::cout << "] Mod.:[" << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality + std::cout << std::endl; + + im = se->GetFirstImage(); + while ( im ) + { // on degouline les Images de cette serie + std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryString(0x0004, 0x1500) + << "]" << std::endl; // File name (Referenced File ID) + im = se->GetNextImage(); + } + se = st->GetNextSerie(); + } + st = pa->GetNextStudy(); + } + pa = f->GetNextPatient(); } - pa = f->GetNextPatient(); - } - break; - - case 4: - std::cout << std::endl << std::endl - << " = PATIENT/STUDY/SERIE/IMAGE List ============================" - << std::endl<< std::endl; - - pa = f->GetFirstPatient(); - while ( pa ) { // les PATIENT de ce DICOMDIR - // Patient's Name, Patient ID - std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name - std::cout << " Pat.ID:["; - std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID - - st = pa->GetFirstStudy(); - while ( st ) { // on degouline les STUDY de ce patient - std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description - std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID - std::cout << std::endl; - - vs = st->GetFirstVisit(); - while ( vs ) { // on degouline les VISIT de cette study - std::cout << "--- --- VISIT: "; - std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID - std::cout << " Inst.Name:[" << vs->GetEntryString(0x0008,0x0080) << "]"; // Institution Name - std::cout << " Adm.ID:[" << vs->GetEntryString(0x0038, 0x0010) << "]"; // Admission ID - std::cout << " Adm. date:[" << vs->GetEntryString(0x0038, 0x0020) << "]"; // Admitting Date - std::cout << std::endl; - vs = st->GetNextVisit(); - } + break; - se = st->GetFirstSerie(); - while ( se ) { // on degouline les SERIES de cette study - std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]"; // Series Description - std::cout << " Ser.nb:[" << se->GetEntryString(0x0020, 0x0011); // Series number - std::cout << "] Mod.:[" << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality - std::cout << std::endl; - - im = se->GetFirstImage(); - while ( im ) { // on degouline les Images de cette serie - std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryString(0x0004, 0x1500) - << "]" << std::endl; // File name (Referenced File ID) - im = se->GetNextImage(); - } - se = st->GetNextSerie(); - } - st = pa->GetNextStudy(); - } - pa = f->GetNextPatient(); - } - break; - - case 5: - std::cout << std::endl << std::endl - << " = DICOMDIR full content ==========================================" - << std::endl<< std::endl; - f->Print(); - break; + case 5: + std::cout << std::endl << std::endl + << " = DICOMDIR full content ==========================================" + << std::endl<< std::endl; + f->Print(); + break; } // end switch @@ -296,7 +305,7 @@ int main(int argc, char* argv[]) else std::cout <Delete(); return(0); } diff --git a/Example/PrintFile.cxx b/Example/PrintFile.cxx index 6a01b904..d2291f7a 100644 --- a/Example/PrintFile.cxx +++ b/Example/PrintFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: PrintFile.cxx,v $ Language: C++ - Date: $Date: 2005/10/20 08:53:21 $ - Version: $Revision: 1.65 $ + Date: $Date: 2005/10/25 14:52:27 $ + Version: $Revision: 1.66 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -219,7 +219,7 @@ int main(int argc, char *argv[]) // any kind of gdcm-Parsable *document* // not only gdcm::File (as opposed to gdcm::DicomDir) - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode(loadMode); f->SetFileName( fileName ); @@ -239,11 +239,11 @@ int main(int argc, char *argv[]) << std::endl; std::cout << "use 'PrintFile filein=... debug' to try to guess the pb" << std::endl; - delete f; + f->Delete(); return 0; } - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); fh->SetPrintLevel( level ); fh->Print(); @@ -286,6 +286,7 @@ int main(int argc, char *argv[]) std::cout << "Transfer Syntax not loaded. " << std::endl << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" << std::endl; + f->Delete(); return 0; } @@ -378,7 +379,7 @@ int main(int argc, char *argv[]) gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem(); if ( !sqi ) { - std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002); + std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002); int length; // LUT length in Bytes int deb; // Subscript of the first Lut Value int nbits; // Lut item size (in Bits) @@ -463,7 +464,7 @@ int main(int argc, char *argv[]) } std::cout<Delete(); delete fh; } else // ====== Deal with a Directory ====== @@ -473,13 +474,14 @@ int main(int argc, char *argv[]) gdcm::DirListType fileList = dirList.GetFilenames(); gdcm::File *f; bool res; + for( gdcm::DirListType::iterator it = fileList.begin(); it != fileList.end(); ++it ) { std::cout << std::endl<<" Start processing :[" << it->c_str() << "]" << std::endl; - f = new gdcm::File(); + f = gdcm::File::New(); f->SetLoadMode(loadMode); f->SetFileName( it->c_str() ); @@ -503,11 +505,11 @@ int main(int argc, char *argv[]) std::cout << "use 'PrintFile filein=... debug' " << "to try to guess the pb" << std::endl; - delete f; + f->Delete(); continue; } - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); fh->SetPrintLevel( level ); fh->Print(); @@ -580,8 +582,8 @@ int main(int argc, char *argv[]) else std::cout <c_str()<<" is NOT Readable"<Delete(); + fh->Delete(); } std::cout<SetLoadMode( loadMode ); f->SetFileName( fileName ); bool res = f->Load(); if ( !res ) { - delete f; + f->Delete(); return 0; } if (!f->IsReadable()) { std::cerr << "Sorry, not a Readable DICOM / ACR File" <Delete(); return 0; } - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); void *imageData; int dataSize; @@ -162,74 +162,68 @@ int main(int argc, char *argv[]) switch (mode[0]) { - case 'A' : - case 'a' : - // Writting an ACR file - // from a full gdcm readable File - - std::cout << "WriteACR" << std::endl; - fh->WriteAcr(outputFileName); - break; - - case 'D' : // Not documented in the 'usage', because the method - case 'd' : // is known to be bugged. - // Writting a DICOM Implicit VR file - // from a full gdcm readable File - - std::cout << "WriteDCM Implicit VR" << std::endl; - fh->WriteDcmImplVR(outputFileName); - break; - - case 'X' : - case 'x' : - // writting a DICOM Explicit VR - // from a full gdcm readable File - - std::cout << "WriteDCM Explicit VR" << std::endl; - // fh->WriteDcmExplVR(outputFileName); - // Try this one : - fh->SetWriteTypeToDcmExplVR(); - fh->Write(outputFileName); - break; - - case 'R' : - case 'r' : - // Writting a Raw File, - - std::cout << "WriteRaw" << std::endl; - fh->WriteRawData(outputFileName); - break; + case 'A' : + case 'a' : + // Writting an ACR file + // from a full gdcm readable File + std::cout << "WriteACR" << std::endl; + fh->WriteAcr(outputFileName); + break; + + case 'D' : // Not documented in the 'usage', because the method + case 'd' : // is known to be bugged. + // Writting a DICOM Implicit VR file + // from a full gdcm readable File + std::cout << "WriteDCM Implicit VR" << std::endl; + fh->WriteDcmImplVR(outputFileName); + break; + + case 'X' : + case 'x' : + // writting a DICOM Explicit VR + // from a full gdcm readable File + std::cout << "WriteDCM Explicit VR" << std::endl; + // fh->WriteDcmExplVR(outputFileName); + // Try this one : + fh->SetWriteTypeToDcmExplVR(); + fh->Write(outputFileName); + break; + + case 'R' : + case 'r' : + // Writting a Raw File, + std::cout << "WriteRaw" << std::endl; + fh->WriteRawData(outputFileName); + break; // Just for fun : // Write a 'Video inverse' version of the file. // *Not* described, on purpose, in the USAGE - - case 'V' : - case 'v' : - - if ( fh->GetFile()->GetBitsAllocated() == 8) - { - std::cout << "videoinv for 8 bits" << std::endl; - for (int i=0; iWriteDcmExplVR(outputFileName); - break; - + case 'V' : + case 'v' : + if ( fh->GetFile()->GetBitsAllocated() == 8) + { + std::cout << "videoinv for 8 bits" << std::endl; + for (int i=0; iWriteDcmExplVR(outputFileName); + break; } - delete f; - delete fh; + + f->Delete(); + fh->Delete(); return 0; } diff --git a/Example/TestChangeHeader.cxx b/Example/TestChangeHeader.cxx index eac9c726..c6c19cd3 100644 --- a/Example/TestChangeHeader.cxx +++ b/Example/TestChangeHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestChangeHeader.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 08:37:44 $ - Version: $Revision: 1.17 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -23,48 +23,48 @@ int main(int argc, char *argv[]) { - if (argc < 3) - { - std::cerr << "usage :" << std::endl << - argv[0] << " fileNameForHeader fileNameForData" << - std::endl; - return 1; - } + if (argc < 3) + { + std::cerr << "usage :" << std::endl << + argv[0] << " fileNameForHeader fileNameForData" << + std::endl; + return 1; + } - gdcm::File *h1 = new gdcm::File( ); - h1->SetFileName ( argv[1] ); - h1->Load( ); - gdcm::FileHelper *f1 = new gdcm::FileHelper( h1 ); - - gdcm::File *h2 = new gdcm::File( ); - h2->SetFileName ( argv[2] ); - h2->Load( ); - gdcm::FileHelper *f2 = new gdcm::FileHelper( h2 ); - + gdcm::File *h1 = gdcm::File::New( ); + h1->SetFileName ( argv[1] ); + h1->Load( ); + gdcm::FileHelper *f1 = gdcm::FileHelper::New( h1 ); + + gdcm::File *h2 = gdcm::File::New( ); + h2->SetFileName ( argv[2] ); + h2->Load( ); + gdcm::FileHelper *f2 = gdcm::FileHelper::New( h2 ); + - // 0018 1310 US ACQ Acquisition Matrix - gdcm::DictEntry *dictEntry = - f2->GetFile()->GetPubDict()->GetEntry( 0x0018, 1310 ); - std::cerr << std::hex << dictEntry->GetGroup() << "," - << dictEntry->GetElement() << std::endl; + // 0018 1310 US ACQ Acquisition Matrix + gdcm::DictEntry *dictEntry = + f2->GetFile()->GetPubDict()->GetEntry( 0x0018, 1310 ); + std::cerr << std::hex << dictEntry->GetGroup() << "," + << dictEntry->GetElement() << std::endl; - std::string matrix = f2->GetFile()->GetEntryString(0x0018, 0x1310); - if(matrix != "gdcm::Unfound") - { - std::cerr << "Aquisition Matrix:" << matrix << std::endl; - f1->GetFile()->InsertEntryString( matrix, 0x0018, 0x1310); - } + std::string matrix = f2->GetFile()->GetEntryString(0x0018, 0x1310); + if(matrix != "gdcm::Unfound") + { + std::cerr << "Aquisition Matrix:" << matrix << std::endl; + f1->GetFile()->InsertEntryString( matrix, 0x0018, 0x1310); + } - f1->GetImageData(); - - h1->Print(); - - f1->WriteDcmExplVR("output-matrix.dcm"); - - delete f1; - delete f2; - delete h1; - delete h2; + f1->GetImageData(); + + h1->Print(); + + f1->WriteDcmExplVR("output-matrix.dcm"); + + f1->Delete(); + f2->Delete(); + h1->Delete(); + h2->Delete(); - return 0; + return 0; } diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index 081c58c1..77be5b59 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestCopyDicom.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/10/25 14:52:27 $ + Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -66,7 +66,6 @@ int main(int argc, char *argv[]) } // don't modify identation in order to let this source xdiffable with ../Test - std::string filename = argv[1]; std::string output = argv[2]; @@ -81,26 +80,21 @@ int main(int argc, char *argv[]) return 1; } } - gdcm::File *fileOr = new gdcm::File(); + gdcm::File *fileOr = gdcm::File::New(); fileOr->SetFileName( filename ); fileOr->Load(); - gdcm::FileHelper *original = new gdcm::FileHelper( fileOr ); + gdcm::FileHelper *original = gdcm::FileHelper::New( fileOr ); std::cout << "--- Original ----------------------" << std::endl; - //original->GetFile()->Print(); - gdcm::FileHelper *copy = new gdcm::FileHelper( ); + gdcm::FileHelper *copy = gdcm::FileHelper::New( ); copy->SetFileName( output ); copy->Load(); - //size_t dataSize; uint8_t *imageData; - //dataSize = original->GetImageDataSize();// just an accesor :useless here imageData = original->GetImageData(); // VERY important : // brings pixels into memory ! - //(void)imageData; // not enough to avoid warning with icc compiler - //(void)dataSize; // not enough to avoid warning on 'Golgot' std::cout << imageData << std::endl; // to avoid warning ? @@ -117,19 +111,16 @@ int main(int argc, char *argv[]) } else { - // We skip pb of SQ recursive exploration - std::cout << "Skipped Sequence " - << "------------- " << d->GetVR() << " "<< std::hex - << d->GetGroup() << "," << d->GetElement() - << std::endl; + // We skip pb of SQ recursive exploration + std::cout << "Skipped Sequence " + << "------------- " << d->GetVR() << " "<< std::hex + << d->GetGroup() << "," << d->GetElement() + << std::endl; } d=original->GetFile()->GetNextEntry(); } - //copy->GetImageData(); - //copy->SetImageData(imageData, dataSize); - std::cout << "--- Copy ----------------------" << std::endl; std::cout <WriteDcmExplVR( output ); - - delete fileOr; // File - delete original; // FileHelper - delete copy; // FileHelper + fileOr->Delete(); // File + original->Delete(); // FileHelper + copy->Delete(); // FileHelper return 0; } diff --git a/Example/Volume2Dicom.cxx b/Example/Volume2Dicom.cxx index 8d18a440..e8b97936 100644 --- a/Example/Volume2Dicom.cxx +++ b/Example/Volume2Dicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: Volume2Dicom.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -53,107 +53,89 @@ int main( int argc, char *argv[] ) //const char *inputfile = argv[1]; std::string directory = argv[1]; -// itksys::SystemTools::ConvertToUnixSlashes( directory ); + // itksys::SystemTools::ConvertToUnixSlashes( directory ); if (directory[directory.size()-1] != '/') - directory += '/'; + directory += '/'; std::cout << "Converting image into dicom in " << directory << std::endl; - //////////////////////////////////////////////////////////// - // Reading input image and getting some information // - //////////////////////////////////////////////////////////// - //std::cout << "Loading image " << inputfile << std::endl; - //PixelType* imageData = input->GetPixelContainer()->GetImportPointer(); - uint8_t *imageData = new uint8_t[256*256*10]; - memset( imageData, 0, 256*256*10); - std::cout << "Image Loaded." << std::endl; - - int sizex = 256; - int sizey = 256; - int sizez = 10; - //float spacing[3] = { 1.0, 1.0, 1.5 }; - //float orig[3] = { 0.0, 0.0, 0.0 }; - int sliceSize = sizex*sizey*sizeof(uint8_t); - - //////////////////////////////////////////////////////////// - // compute window center and window width // - //////////////////////////////////////////////////////////// - uint8_t min, max; min = max = imageData[0]; - for (int i=1; i max) - max = val; - if (val < min) - min = val; - } - //float wcenter = (max+min) / 2.; - //float wwidth = (max-min)>0 ? (max-min) : 1.; - - //////////////////////////////////////////////////////////// - // Get file date and time // - //////////////////////////////////////////////////////////// - std::string filedate, filetime; - //GetFileDateAndTime(inputfile, filedate, filetime); - - //////////////////////////////////////////////////////////// - // Create a new dicom header and fill in some info // - //////////////////////////////////////////////////////////// - gdcm::File *f = new gdcm::File(); - - //f->SetDateAndTime(filedate, filetime); - //f->SetModality("CT"); - //f->SetPatientName( "TestPatient"); - //f->SetPatientID( "TestID"); - //f->SetStudyID( "1"); - //f->SetSeriesNumber( "1"); - //f->SetSliceThickness(spacing[2]); - //f->SetSpaceBetweenSlices(spacing[2]); - //f->SetXYSpacing( spacing[0], spacing[1]); - //f->SetXSize(sizex); - //f->SetYSize(sizey); - //f->SetNbBitsAllocated(16); - //f->SetNbBitsStored(12); - //f->SetNbBitsStored(12); - //f->SetPixelSigned(true); - //f->SetCenter( wcenter); - //f->SetWindow( wwidth); - - //////////////////////////////////////////////////////////// - // Create a new dicom file object from the header // - //////////////////////////////////////////////////////////// - gdcm::FileHelper *fh = new gdcm::FileHelper(f); - uint8_t *myData = fh->GetImageData(); // Get an Image pointer - fh->SetImageData( myData, sliceSize); // This callback ensures that the internal - // Pixel_Data of fh is set correctly - - - //////////////////////////////////////////////////////////// - // Iterate through the slices and save them to file // - //////////////////////////////////////////////////////////// - for (int z=0; zSetImageUIDFromSliceNumber(z); - //f->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]); - - // copy image slice content - memcpy(myData,imageData+z*sizex*sizey,sliceSize); - - // write the image - std::string filename = directory + gdcm::Util::Format("%Image_%05d.dcm", z); - std::cout << "Writing file " << filename; - fh->WriteDcmExplVR(filename); - std::cout << " OK" << std::endl; - } - - //////////////////////////////////////////////////////////// - // Free the allocated objects // - //////////////////////////////////////////////////////////// - // delete fh; // FIXME: these calls sometimes crashes under .NET ???? - // delete f; - - return 0; + //////////////////////////////////////////////////////////// + // Reading input image and getting some information // + //////////////////////////////////////////////////////////// + //std::cout << "Loading image " << inputfile << std::endl; + //PixelType* imageData = input->GetPixelContainer()->GetImportPointer(); + uint8_t *imageData = new uint8_t[256*256*10]; + memset( imageData, 0, 256*256*10); + std::cout << "Image Loaded." << std::endl; + + int sizex = 256; + int sizey = 256; + int sizez = 10; + //float spacing[3] = { 1.0, 1.0, 1.5 }; + //float orig[3] = { 0.0, 0.0, 0.0 }; + int sliceSize = sizex*sizey*sizeof(uint8_t); + + //////////////////////////////////////////////////////////// + // compute window center and window width // + //////////////////////////////////////////////////////////// + uint8_t min, max; min = max = imageData[0]; + for (int i=1; i max) + max = val; + if (val < min) + min = val; + } + //float wcenter = (max+min) / 2.; + //float wwidth = (max-min)>0 ? (max-min) : 1.; + + //////////////////////////////////////////////////////////// + // Get file date and time // + //////////////////////////////////////////////////////////// + std::string filedate, filetime; + //GetFileDateAndTime(inputfile, filedate, filetime); + + //////////////////////////////////////////////////////////// + // Create a new dicom header and fill in some info // + //////////////////////////////////////////////////////////// + gdcm::File *f = gdcm::File::New(); + + //////////////////////////////////////////////////////////// + // Create a new dicom file object from the header // + //////////////////////////////////////////////////////////// + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); + uint8_t *myData = fh->GetImageData(); // Get an Image pointer + fh->SetImageData( myData, sliceSize); // This callback ensures that the internal + // Pixel_Data of fh is set correctly + + + //////////////////////////////////////////////////////////// + // Iterate through the slices and save them to file // + //////////////////////////////////////////////////////////// + for (int z=0; zSetImageUIDFromSliceNumber(z); + //f->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]); + + // copy image slice content + memcpy(myData,imageData+z*sizex*sizey,sliceSize); + + // write the image + std::string filename = directory + gdcm::Util::Format("%Image_%05d.dcm", z); + std::cout << "Writing file " << filename; + fh->WriteDcmExplVR(filename); + std::cout << " OK" << std::endl; + } + + //////////////////////////////////////////////////////////// + // Free the allocated objects // + //////////////////////////////////////////////////////////// + fh->Delete(); + f->Delete(); + + return 0; } diff --git a/Example/WriteDicomSimple.cxx b/Example/WriteDicomSimple.cxx index 455b9063..ab83ac19 100644 --- a/Example/WriteDicomSimple.cxx +++ b/Example/WriteDicomSimple.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicomSimple.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.14 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) // Step 1 : Create the header of the image - gdcm::File *header = new gdcm::File(); + gdcm::File *header = gdcm::File::New(); std::ostringstream str; // Set the image size @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) std::cerr << "-------------------------------\n" << "Error while creating the file\n" << "This file is considered to be not readable\n"; - + header->Delete(); return 1; } @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) } // Step 3 : Create the file of the image - gdcm::FileHelper *file = new gdcm::FileHelper(header); + gdcm::FileHelper *file = gdcm::FileHelper::New(header); file->SetImageData(imageData,size); // Step 4 : Set the writting mode and write the image @@ -162,18 +162,17 @@ int main(int argc, char *argv[]) << "File :" << fileName << std::endl; delete[] imageData; - delete file; - delete header; + file->Delete(); + header->Delete(); return 0; default : std::cout << "-------------------------------\n" << "Write mode undefined...\n" << "No file written\n"; - delete[] imageData; - delete file; - delete header; + file->Delete(); + header->Delete(); return 1; } @@ -185,8 +184,8 @@ int main(int argc, char *argv[]) } delete[] imageData; - delete file; - delete header; + file->Delete(); + header->Delete(); return 0; } diff --git a/Example/WriteRead.cxx b/Example/WriteRead.cxx index 2f247d92..46634fde 100644 --- a/Example/WriteRead.cxx +++ b/Example/WriteRead.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteRead.cxx,v $ Language: C++ - Date: $Date: 2005/07/08 12:02:02 $ - Version: $Revision: 1.14 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -32,67 +32,86 @@ int main(int argc, char *argv[]) int dataSize, dataSize2; if( argc < 2 ) - { - std::cerr << "Usage " << argv[0] << " image.dcm" << std::endl; - return 1; - } + { + std::cerr << "Usage " << argv[0] << " image.dcm" << std::endl; + return 1; + } std::string fileName = argv[1]; // --------------------- we read the input image std::cout << argv[1] << std::endl; - e1 = new gdcm::File( ); + e1 = gdcm::File::New( ); e1->SetFileName( fileName ); e1->Load(); - if (!e1->IsReadable()) { - std::cerr << "Sorry, " << fileName <<" not a Readable DICOM / ACR File" - <IsReadable()) + { + std::cerr << "Sorry, " << fileName <<" not a Readable DICOM / ACR File" + <Delete(); + return 1; } - f1 = new gdcm::FileHelper(e1); + f1 = gdcm::FileHelper::New(e1); imageData= f1->GetImageData(); dataSize = f1->GetImageDataSize(); // --------------------- we write it as an Explicit VR DICOM file - fileNameToWrite = "temp.XDCM"; - std::cout << "WriteDCM Explicit VR" << std::endl; - f1->WriteDcmExplVR(fileNameToWrite); + fileNameToWrite = "temp.XDCM"; + std::cout << "WriteDCM Explicit VR" << std::endl; + f1->WriteDcmExplVR(fileNameToWrite); // --------------------- we read the written image - e2 = new gdcm::File( ); + e2 = gdcm::File::New( ); e2->SetFileName( fileNameToWrite ); e2->Load(); - if (!e2->IsReadable()) { - std::cerr << "Sorry, " << fileNameToWrite << " not a Readable DICOM / ACR File" - <IsReadable()) + { + std::cerr << "Sorry, " << fileNameToWrite << " not a Readable DICOM / ACR File" + <Delete(); + e2->Delete(); + f1->Delete(); + return 1; } - f2 = new gdcm::FileHelper(e2); + f2 = gdcm::FileHelper::New(e2); imageData2= f2->GetImageData(); dataSize2 = f2->GetImageDataSize(); // --------------------- we compare the pixel areas - if (dataSize != dataSize2) { - std::cout << " ----------------------------------------- " - << "Bad shot! Lengthes are different : " - << dataSize << " # " << dataSize2 - << " for file : " << fileName << std::endl; + if (dataSize != dataSize2) + { + std::cout << " ----------------------------------------- " + << "Bad shot! Lengthes are different : " + << dataSize << " # " << dataSize2 + << " for file : " << fileName << std::endl; - return 0; - } - if (int res=memcmp(imageData,imageData2,dataSize) !=0) { - std::cout << " ----------------------------------------- " - << "Bad shot! Pixels are different : " - << " for file : " << fileName << std::endl; - std::cout << "memcmp(imageData,imageData2,dataSize) = " << res << std::endl; - return 1; - } + e1->Delete(); + e2->Delete(); + f1->Delete(); + f2->Delete(); + return 1; + } + if (int res=memcmp(imageData,imageData2,dataSize) !=0) + { + std::cout << " ----------------------------------------- " + << "Bad shot! Pixels are different : " + << " for file : " << fileName << std::endl; + std::cout << "memcmp(imageData,imageData2,dataSize) = " << res << std::endl; + e1->Delete(); + e2->Delete(); + f1->Delete(); + f2->Delete(); + return 1; + } - //If we reach here everything is fine, return 0 then: - return 0; + e1->Delete(); + e2->Delete(); + f1->Delete(); + f2->Delete(); + return 0; } diff --git a/Example/exColorToRGB.cxx b/Example/exColorToRGB.cxx index 12964570..6d547945 100644 --- a/Example/exColorToRGB.cxx +++ b/Example/exColorToRGB.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exColorToRGB.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -51,24 +51,28 @@ int main(int argc, char *argv[]) std::cout << argv[1] << std::endl; - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode( gdcm::LD_ALL); f->SetFileName( fileName ); bool res = f->Load(); - if (!res) { + if (!res) + { std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 0; } std::cout << " ... is readable " << std::endl; /* - if (!f->IsMonochrome()) { + if (!f->IsMonochrome()) + { std::cerr << "Sorry, " << fileName <<" not a 'color' File " << " " <Delete(); return 0; } */ @@ -78,7 +82,7 @@ int main(int argc, char *argv[]) // ============================================================ // We need a gdcm::FileHelper, since we want to load the pixels - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); // uint8_t DOESN'T mean it's mandatory for the image to be a 8 bits one ! // It's just for prototyping. @@ -90,6 +94,7 @@ int main(int argc, char *argv[]) { std::cerr << "Sorry, Pixels of" << fileName <<" are not " << " gdcm-readable." << std::endl; + f->Delete(); return 0; } @@ -98,7 +103,7 @@ int main(int argc, char *argv[]) // ------ without Sequences ------------- - gdcm::FileHelper *copy = new gdcm::FileHelper( ); + gdcm::FileHelper *copy = gdcm::FileHelper::New( ); copy->SetFileName( output ); copy->Load(); @@ -132,10 +137,9 @@ int main(int argc, char *argv[]) copy->WriteDcmExplVR( output ); - - delete f; - delete fh; - delete copy; + f->Delete(); + fh->Delete(); + copy->Delete(); exit (0); } diff --git a/Example/exCurveData.cxx b/Example/exCurveData.cxx index 47ec1b3c..ce1c5293 100644 --- a/Example/exCurveData.cxx +++ b/Example/exCurveData.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exCurveData.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:43 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) // Read the input image. // ============================================================ - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW); f->SetFileName( fileName ); @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) std::cout << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 1; } std::cout << " ... is readable " << std::endl; @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) if (curve_data_str == gdcm::GDCM_UNFOUND) { std::cout << " Image doesn't contain any Curve Data" << std::endl; - delete f; + f->Delete(); return 1; } std::cout << " File is read! " << std::endl; @@ -194,7 +194,7 @@ int main(int argc, char *argv[]) break; default: std::cerr << "Error don't know the type: " << data_rep_str << std::endl; - delete f; + f->Delete(); return 1; } // Just to make sure that values read are consistant and we won't read out of bound data: @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) //o.write((char*)curve_data, num_points*sz); //o.close(); - delete f; + f->Delete(); return 0; } diff --git a/Example/exExtractDicomTags.cxx b/Example/exExtractDicomTags.cxx index c799f927..85f24ea3 100644 --- a/Example/exExtractDicomTags.cxx +++ b/Example/exExtractDicomTags.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exExtractDicomTags.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:44 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/10/25 14:52:27 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -83,14 +83,14 @@ int main(int argc, char *argv[]) int loadMode = 0x0; // load everything - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode( loadMode ); f->SetFileName( fileName ); bool res = f->Load(); if ( !res ) { - delete f; + f->Delete(); return 0; } @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) if (!f->IsReadable()) { std::cout << "NOT a Dicom File : " << fileName <Delete(); return 1; } @@ -247,5 +247,6 @@ int main(int argc, char *argv[]) std::cout << "GetYSpacing = [" << sy << "]" << std::endl; std::cout << "GetZSpacing = [" << sz << "]" << std::endl; + f->Delete(); return 0; } diff --git a/Example/exExtractTag.cxx b/Example/exExtractTag.cxx index b1097a8e..07843925 100644 --- a/Example/exExtractTag.cxx +++ b/Example/exExtractTag.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exExtractTag.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:44 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/10/25 14:52:27 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) // Read the input image. // ============================================================ - f = new gdcm::File( ); + f = gdcm::File::New( ); //f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW); f->SetFileName( fileName ); @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) std::cerr << "Sorry, " << fileName << " not a gdcm-readable " << "DICOM / ACR File" << std::endl; - delete f; + f->Delete(); return 1; } std::cout << " ... is readable " << std::endl; @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) { gdcm::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem); std::cerr << "Image doesn't contain any tag: " << dictEntry->GetName() << std::endl; - delete f; + f->Delete(); return 1; } @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if( !dicom_tag ) { std::cerr << "Sorry DataEntry only please" << std::endl; - delete f; + f->Delete(); return 1; } @@ -95,13 +95,13 @@ int main(int argc, char *argv[]) if( !o ) { std::cerr << "Problem opening file: " << argv[4] << std::endl; - delete f; + f->Delete(); return 1; } o.write((char*)dicom_tag->GetBinArea(), dicom_tag->GetLength()); o.close(); - delete f; + f->Delete(); return 0; } diff --git a/Example/exGC.cxx b/Example/exGC.cxx index 68f8adff..8a55ded2 100644 --- a/Example/exGC.cxx +++ b/Example/exGC.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exGC.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:44 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/25 14:52:27 $ + 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 @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) std::cout << argv[1] << std::endl; - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode( gdcm::LD_ALL); f->SetFileName( fileName ); bool res = f->Load(); @@ -83,6 +83,7 @@ int main(int argc, char *argv[]) std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 0; } std::cout << " ... is readable " << std::endl; @@ -101,7 +102,7 @@ int main(int argc, char *argv[]) // ============================================================ // We need a gdcm::FileHelper, since we want to load the pixels - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); // (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one) @@ -111,6 +112,8 @@ int main(int argc, char *argv[]) { std::cerr << "Sorry, Pixels of" << fileName <<" are not " << " gdcm-readable." << std::endl; + f->Delete(); + fh->Delete(); return 0; } @@ -118,7 +121,7 @@ int main(int argc, char *argv[]) // ------ without Sequences ------------- - gdcm::FileHelper *copy = new gdcm::FileHelper( ); + gdcm::FileHelper *copy = gdcm::FileHelper::New( ); copy->SetFileName( output ); copy->Load(); @@ -162,17 +165,17 @@ int main(int argc, char *argv[]) } } - std::cout << n << " points put to black (within " - << imageSize/3 << ")" << std::endl; + std::cout << n << " points put to black (within " + << imageSize/3 << ")" << std::endl; n = 0; for (i = 0; iWriteDcmExplVR( output ); - delete f; - delete fh; - delete copy; + f->Delete(); + fh->Delete(); + copy->Delete(); exit (0); } diff --git a/Example/exGrey2RGB.cxx b/Example/exGrey2RGB.cxx index 768228bb..2fba62d4 100644 --- a/Example/exGrey2RGB.cxx +++ b/Example/exGrey2RGB.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exGrey2RGB.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:44 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/10/25 14:52:28 $ + 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 @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) } } - gdcm::FileHelper *fh = new gdcm::FileHelper( ); + gdcm::FileHelper *fh = gdcm::FileHelper::New( ); fh->SetFileName( filename ); fh->Load(); @@ -119,6 +119,8 @@ int main(int argc, char *argv[]) fh->SetImageData(imageDataRGB, dataSize*3); fh->WriteDcmExplVR( output ); + fh->Delete(); + return 0; } diff --git a/Example/exImageLighten.cxx b/Example/exImageLighten.cxx index fe3ff421..7ee9e264 100644 --- a/Example/exImageLighten.cxx +++ b/Example/exImageLighten.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exImageLighten.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:44 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/10/25 14:52:28 $ + 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 @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) std::cout << argv[1] << std::endl; - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode( gdcm::LD_ALL); f->SetFileName( fileName ); bool res = f->Load(); @@ -64,6 +64,7 @@ int main(int argc, char *argv[]) std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 0; } std::cout << " ... is readable " << std::endl; @@ -77,7 +78,7 @@ int main(int argc, char *argv[]) // to load the Palettes Color (if any) // First, create a gdcm::FileHelper - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); // Load the pixels, DO NOT transform LUT (if any) into RGB Pixels uint8_t *imageDataRaw = fh->GetImageDataRaw(); @@ -88,7 +89,7 @@ int main(int argc, char *argv[]) // Create a new gdcm::Filehelper, to hold new image. // ============================================================ - gdcm::FileHelper *copy = new gdcm::FileHelper( ); + gdcm::FileHelper *copy = gdcm::FileHelper::New( ); copy->SetFileName( output ); copy->Load(); @@ -128,9 +129,10 @@ int main(int argc, char *argv[]) std::cout << std::endl << "------------------------------------------------------------" << std::endl; - delete f; - delete fh; - delete copy; + + f->Delete(); + fh->Delete(); + copy->Delete(); exit (0); } diff --git a/Example/exOverlaysACR.cxx b/Example/exOverlaysACR.cxx index f5eb508e..61590cf9 100644 --- a/Example/exOverlaysACR.cxx +++ b/Example/exOverlaysACR.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exOverlaysACR.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:44 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/10/25 14:52:28 $ + 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 @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) //std::cout << argv[1] << std::endl; - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW); f->SetFileName( fileName ); @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) std::cout << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 0; } std::cout << " ... is readable " << std::endl; @@ -115,14 +115,14 @@ int main(int argc, char *argv[]) if ( bitsAllocated <= 8 ) { std::cout << " 8 bits pixel image cannot contain Overlays " << std::endl; - delete f; + f->Delete(); return 0; } std::string s1 = f->GetEntryString(0x6000, 0x0102); if (s1 == gdcm::GDCM_UNFOUND) { std::cout << " Image doesn't contain any Overlay " << std::endl; - delete f; + f->Delete(); return 0; } std::cout << " File is read! " << std::endl; @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) if (fp == 0) { std::cout << "Unable to open File" << std::endl; - delete f; + f->Delete(); return 0; } else @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) << "readable. expected length :" << nx*ny << " " << "read length : " << lgt << std::endl; - delete f; + f->Delete(); delete pixels; return 0; } @@ -199,9 +199,9 @@ int main(int argc, char *argv[]) gdcm::FileHelper *fh = 0; -while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) - != gdcm::GDCM_UNFOUND ) -{ + while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) + != gdcm::GDCM_UNFOUND ) + { strOverlayLocation = f->GetEntryString(currentOvlGroup, 0x0200); if ( strOverlayLocation != gdcm::GDCM_UNFOUND ) @@ -234,7 +234,7 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) if( gdcm::Debug::GetDebugFlag() ) std::cout << "About to built empty file" << std::endl; - fileToBuild = new gdcm::File(); + fileToBuild = gdcm::File::New(); if( gdcm::Debug::GetDebugFlag() ) std::cout << "Finish to built empty file" << std::endl; @@ -259,7 +259,7 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) if( gdcm::Debug::GetDebugFlag() ) std::cout << "-------------About to built FileHelper" << std::endl; - fh = new gdcm::FileHelper(fileToBuild); + fh = gdcm::FileHelper::New(fileToBuild); if( gdcm::Debug::GetDebugFlag() ) std::cout << "-------------Finish to built FileHelper" << std::endl; @@ -275,9 +275,9 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) { std::cout << "Failed\n" << "File in unwrittable\n"; - delete fh; + fh->Delete(); if (fileToBuild) - delete fileToBuild; + fileToBuild->Delete(); delete pixels; delete tabPixels; return 0; @@ -290,13 +290,14 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) i++; } - delete f; if (f) - delete fh; + fh->Delete(); if (fileToBuild) - delete fileToBuild; + fileToBuild->Delete(); + f->Delete(); delete pixels; delete tabPixels; + return 0; } diff --git a/Example/exReadPapyrus.cxx b/Example/exReadPapyrus.cxx index 185c84ae..eed4ddb3 100644 --- a/Example/exReadPapyrus.cxx +++ b/Example/exReadPapyrus.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exReadPapyrus.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:44 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/10/25 14:52:28 $ + 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 @@ -133,14 +133,14 @@ int main(int argc, char *argv[]) } int loadMode = 0x0; // load everything - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode( loadMode ); f->SetFileName( fileName ); bool res = f->Load(); if ( !res ) { - delete f; + f->Delete(); return 0; } @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) if (!seqPapyrus) { std::cout << "NOT a Papyrus File : " << fileName <Delete(); return 1; } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) { std::cout << "NO SQItem found within private Papyrus Sequence" << std::endl; - delete f; + f->Delete(); return 1; } @@ -271,7 +271,7 @@ int main(int argc, char *argv[]) std::string NumberOfFrames = gdcm::Util::Format("%d", nbImages); - gdcm::File *n = new gdcm::File(); + gdcm::File *n = gdcm::File::New(); n->InsertEntryString(MediaStSOPinstUID, 0x0002,0x0002); // Whe keep default gdcm Transfer Syntax (Explicit VR Little Endian) @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) n->InsertEntryString(PixelRepresentation,0x0028,0x0103); // create the file - gdcm::FileHelper *file = new gdcm::FileHelper(n); + gdcm::FileHelper *file = gdcm::FileHelper::New(n); file->SetImageData(PixelArea,lgrImage*nbImages); file->SetWriteTypeToDcmExplVR(); @@ -305,7 +305,11 @@ int main(int argc, char *argv[]) if (!file) { std::cout <<"Fail to open (write) file:[" << outputFileName << "]" << std::endl;; + n->Delete(); + file->Delete(); return 1; } + n->Delete(); + file->Delete(); return 0; } diff --git a/Example/exReadWriteFile.cxx b/Example/exReadWriteFile.cxx index 37f5b6e2..7599959c 100644 --- a/Example/exReadWriteFile.cxx +++ b/Example/exReadWriteFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exReadWriteFile.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:24 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/10/25 14:52:28 $ + 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 @@ -59,7 +59,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <SetFileName( filename ); f1->Load(); @@ -218,7 +218,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <GetImageData(); @@ -253,7 +253,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <SetFileName( output ); copy->Load(); @@ -323,9 +323,9 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <Delete(); + fh1->Delete(); + copy->Delete(); exit (0); } diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index bb428fd0..53afc933 100644 --- a/Testing/TestAllReadCompareDicom.cxx +++ b/Testing/TestAllReadCompareDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllReadCompareDicom.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:46 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/10/25 14:52:30 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -398,7 +398,7 @@ int InternalTest(std::string const &filename, std::cout << "1..."; // new style - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode ( gdcm::LD_ALL ); // Load everything f->SetFileName( filename ); f->Load(); @@ -408,10 +408,10 @@ int InternalTest(std::string const &filename, std::cout << " Failed" << std::endl << " Image not gdcm compatible:" << filename << std::endl; - delete f; + f->Delete(); return 1; } - gdcm::FileHelper *tested = new gdcm::FileHelper( f ); + gdcm::FileHelper *tested = gdcm::FileHelper::New( f ); ////// Step 2: ////// Check for existence of reference baseline dicom file: @@ -443,8 +443,8 @@ int InternalTest(std::string const &filename, << " Image not Testing compatible:" << filename << std::endl; delete reference; - delete tested; - delete f; + tested->Delete(); + f->Delete(); return 1; } @@ -471,8 +471,8 @@ int InternalTest(std::string const &filename, << "Z: " << tested->GetFile()->GetZSize() << " # " << reference->GetZSize() << std::endl; delete reference; - delete tested; - delete f; + tested->Delete(); + f->Delete(); return 1; } @@ -488,8 +488,8 @@ int InternalTest(std::string const &filename, << reference->GetNumberOfComponents() << std::endl << " Pixel type: " << tested->GetFile()->GetPixelType() << std::endl; delete reference; - delete tested; - delete f; + tested->Delete(); + f->Delete(); return 1; } @@ -507,9 +507,9 @@ int InternalTest(std::string const &filename, << tested->GetFile()->GetYSize() << "," << tested->GetFile()->GetZSize() << ")" << std::endl; - delete tested; + tested->Delete(); delete reference; - delete f; + f->Delete(); return 1; } @@ -546,16 +546,16 @@ int InternalTest(std::string const &filename, } std::cout << std::endl; - delete tested; + tested->Delete(); delete reference; - delete f; + f->Delete(); return 1; } //////////////// Clean up: - delete tested; + tested->Delete(); delete reference; - delete f; + f->Delete(); std::cout << "OK." << std::endl; diff --git a/Testing/TestAllVM.cxx b/Testing/TestAllVM.cxx index 1dce8206..3dc460c3 100644 --- a/Testing/TestAllVM.cxx +++ b/Testing/TestAllVM.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllVM.cxx,v $ Language: C++ - Date: $Date: 2005/10/23 14:53:51 $ - Version: $Revision: 1.7 $ + Date: $Date: 2005/10/25 14:52:30 $ + 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 @@ -24,17 +24,17 @@ int DoTheVMTest(std::string const &filename) { - gdcm::File file; + gdcm::File *file = gdcm::File::New(); // - Do not test unknow VM in shadow groups (if element 0x0000 is present) // - Skip Sequences (if they are 'True Length'); loading will be quicker // (anyway, Sequences are skipped at processing time ...) - file.SetLoadMode( gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ ); + file->SetLoadMode( gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ ); - file.SetFileName( filename ); - if( !file.Load() ) //would be really bad... + file->SetFileName( filename ); + if( !file->Load() ) //would be really bad... return 1; - gdcm::DocEntry *d = file.GetFirstEntry(); + gdcm::DocEntry *d = file->GetFirstEntry(); std::cerr << "Testing file : " << filename << std::endl; while(d) { @@ -56,9 +56,11 @@ int DoTheVMTest(std::string const &filename) { // We skip pb of SQ recursive exploration } - d = file.GetNextEntry(); + d = file->GetNextEntry(); } - return 0; + file->Delete(); + + return 0; } int TestAllVM(int argc, char *argv[]) diff --git a/Testing/TestBug.cxx b/Testing/TestBug.cxx index 2ff730c6..97675608 100644 --- a/Testing/TestBug.cxx +++ b/Testing/TestBug.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestBug.cxx,v $ Language: C++ - Date: $Date: 2005/07/08 13:39:57 $ - Version: $Revision: 1.20 $ + Date: $Date: 2005/10/25 14:52:30 $ + 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 @@ -24,7 +24,7 @@ int TestBug(int argc, char *argv[]) { gdcm::File *f; - f = new gdcm::File(); + f = gdcm::File::New(); if (argc > 1) f->SetFileName( argv[1] ); @@ -36,7 +36,7 @@ int TestBug(int argc, char *argv[]) f->Load( ); f->GetPubDict()->Print(); - delete f; + f->Delete(); return 0; } diff --git a/Testing/TestBuildUpDicomDir.cxx b/Testing/TestBuildUpDicomDir.cxx index 0c4813c3..64efd4b0 100644 --- a/Testing/TestBuildUpDicomDir.cxx +++ b/Testing/TestBuildUpDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestBuildUpDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 09:22:13 $ - Version: $Revision: 1.7 $ + Date: $Date: 2005/10/25 14:52:30 $ + 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 @@ -44,7 +44,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) gdcm::DicomDir *dcmdir; std::string dirName; - dcmdir = new gdcm::DicomDir(); + dcmdir = gdcm::DicomDir::New(); gdcm::DicomDirPatient *p1; // --- Forget these 4 lines : @@ -171,7 +171,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) <<" is not readable"<Delete(); return 1; } @@ -184,10 +184,10 @@ int TestBuildUpDicomDir(int argc, char *argv[]) // Write it on disc dcmdir->Write("NewDICOMDIR"); - delete dcmdir; + dcmdir->Delete(); // Read the newly written DicomDir - gdcm::DicomDir *newDicomDir = new gdcm::DicomDir(); + gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New(); newDicomDir->SetFileName("NewDICOMDIR"); newDicomDir->Load( ); if( !newDicomDir->IsReadable() ) @@ -196,7 +196,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) <<" is not readable"<Delete(); return 1; } // Check some value we are sure @@ -208,7 +208,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) { std::cout << "A patient is missing in written DicomDir" << std::endl; - delete newDicomDir; + newDicomDir->Delete(); return 1; } @@ -363,7 +363,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) } std::cout<Delete(); return errorFound; } diff --git a/Testing/TestDicomDir.cxx b/Testing/TestDicomDir.cxx index 886120b3..384fa293 100644 --- a/Testing/TestDicomDir.cxx +++ b/Testing/TestDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:46 $ - Version: $Revision: 1.41 $ + Date: $Date: 2005/10/25 14:52:30 $ + Version: $Revision: 1.42 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -100,9 +100,9 @@ int TestDicomDir(int argc, char *argv[]) file += "/DICOMDIR"; } - dicomdir = new gdcm::DicomDir( ); + dicomdir = gdcm::DicomDir::New(); dicomdir->SetFileName(file); - dicomdir->Load( ); + dicomdir->Load(); if (argc > 2) { int level = atoi(argv[2]); @@ -116,7 +116,7 @@ int TestDicomDir(int argc, char *argv[]) <<"' is not readable"<Delete(); return 1; } else @@ -132,7 +132,7 @@ int TestDicomDir(int argc, char *argv[]) <<" has no patient"<Delete(); return 1; } @@ -187,10 +187,10 @@ int TestDicomDir(int argc, char *argv[]) << "NewDICOMDIR written on disc =================================" << std::endl<< std::endl; // Read what we wrote - gdcm::DicomDir *d2 = new gdcm::DicomDir( ); + gdcm::DicomDir *d2 = gdcm::DicomDir::New(); d2->SetFileName("NewDICOMDIR"); - d2->Load( ); - if (!d2->IsReadable( )) + d2->Load(); + if (!d2->IsReadable()) { std::cout << std::endl << std::endl << "Read NewDicomDir from disc failed ========================" @@ -212,8 +212,8 @@ int TestDicomDir(int argc, char *argv[]) if (!d2) { std::cout << "NewDICOMDIR contains no Patient ?!?" << std::endl; - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } @@ -222,8 +222,8 @@ int TestDicomDir(int argc, char *argv[]) if ( CompareSQItem(pa2,pa1) == 1 ) { - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } @@ -238,8 +238,8 @@ int TestDicomDir(int argc, char *argv[]) { if ( CompareSQItem(st2,st1) == 1 ) { - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } @@ -256,7 +256,8 @@ int TestDicomDir(int argc, char *argv[]) while ( se1 && se2 ) { // we process all the SERIE of this study if ( CompareSQItem(se2,se1) == 1 ) - return 1; + return 1; + std::cout << "--- --- " << se2->GetEntryString(0x0008, 0x103e); // Serie Description std::cout << " Ser.nb:["<< se2->GetEntryString(0x0020, 0x0011); // Series number std::cout << "] Mod.:[" << se2->GetEntryString(0x0008, 0x0060) << "]" << std::endl; // Modality @@ -267,8 +268,8 @@ int TestDicomDir(int argc, char *argv[]) { if ( CompareSQItem(im2,im1) == 1 ) { - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 1; } @@ -286,8 +287,8 @@ int TestDicomDir(int argc, char *argv[]) } std::cout << std::flush; - delete dicomdir; - delete d2; + dicomdir->Delete(); + d2->Delete(); return 0; } diff --git a/Testing/TestDicomDirElement.cxx b/Testing/TestDicomDirElement.cxx index 41171ded..7eb6a17f 100644 --- a/Testing/TestDicomDirElement.cxx +++ b/Testing/TestDicomDirElement.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDicomDirElement.cxx,v $ Language: C++ - Date: $Date: 2005/07/08 13:39:57 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/10/25 14:52:30 $ + 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 @@ -23,11 +23,11 @@ int TestDicomDirElement(int , char *[]) { - gdcm::DicomDirElement *ddElt = new gdcm::DicomDirElement(); + gdcm::DicomDirElement *ddElt = gdcm::DicomDirElement::New(); if (ddElt == 0) { - std::cout << "new DicomDirElement failed" << std::endl; - return 1; + std::cout << "new DicomDirElement failed" << std::endl; + return 1; } ddElt->Print( std::cout ); @@ -48,6 +48,6 @@ int TestDicomDirElement(int , char *[]) std::cout << " -------- DicomDirElement After modif --------" <Print( std::cout ); - delete ddElt; + ddElt->Delete(); return 0; } diff --git a/Testing/TestDict.cxx b/Testing/TestDict.cxx index 232bbb01..4dd71b14 100644 --- a/Testing/TestDict.cxx +++ b/Testing/TestDict.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDict.cxx,v $ Language: C++ - Date: $Date: 2005/10/20 15:24:05 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/25 14:52:30 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -28,13 +28,13 @@ int TestDict(int , char *[]) std::cout << "----- Test Default Dicom Dictionary : ----------" << std::endl; // Just to improve test coverage: - gdcm::Dict *tempDict = new gdcm::Dict("dummyFileNameThatDoesntExist"); + gdcm::Dict *tempDict = gdcm::Dict::New("dummyFileNameThatDoesntExist"); // Default dict is supposed to be used. tempDict->Print(); std::cout << "---- end Test Default Dicom Dictionary : -------" << std::endl; // Lets delete it. - delete tempDict; + tempDict->Delete(); // Print the DictSet diff --git a/Testing/TestDictGroupName.cxx b/Testing/TestDictGroupName.cxx index cc74a79f..47add5e4 100644 --- a/Testing/TestDictGroupName.cxx +++ b/Testing/TestDictGroupName.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDictGroupName.cxx,v $ Language: C++ - Date: $Date: 2005/07/08 13:39:57 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/10/25 14:52:30 $ + 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 @@ -21,10 +21,10 @@ #include -int CompareDictGroupName(gdcm::DictGroupName &groupName, +int CompareDictGroupName(gdcm::DictGroupName *groupName, uint16_t group,std::string ref) { - std::string val = groupName.GetName(group); + std::string val = groupName->GetName(group); std::cout << "Group : 0x" << std::hex << std::setw(4) << group << std::dec << " : " << val << " - " << (bool)(val==ref) << std::endl; @@ -34,8 +34,8 @@ int CompareDictGroupName(gdcm::DictGroupName &groupName, int TestDictGroupName(int , char *[]) { - gdcm::DictGroupName groupName; - groupName.Print( std::cout ); + gdcm::DictGroupName *groupName = gdcm::DictGroupName::New(); + groupName->Print( std::cout ); int ret = 0; @@ -44,5 +44,7 @@ int TestDictGroupName(int , char *[]) ret += CompareDictGroupName(groupName,0x7fe0,"Pixels"); ret += CompareDictGroupName(groupName,0x0007,gdcm::GDCM_UNFOUND); + groupName->Delete(); + return ret; } diff --git a/Testing/TestFileAccessors.cxx b/Testing/TestFileAccessors.cxx index ff1ea02b..3ace1920 100644 --- a/Testing/TestFileAccessors.cxx +++ b/Testing/TestFileAccessors.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestFileAccessors.cxx,v $ Language: C++ - Date: $Date: 2005/10/20 08:58:15 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -45,7 +45,7 @@ catch(...) \ { \ std::cout << " --> Can't access to the '" << #name << "' method !" << std::endl; \ - delete f; \ + f->Delete(); \ return 1; \ } @@ -63,7 +63,7 @@ int TestFileAccessors(int, char *[]) filename += gdcmDataImages[i]; std::cout << "Begin with " << filename << std::endl; - gdcm::File *f= new gdcm::File( ); + gdcm::File *f= gdcm::File::New( ); f->SetFileName( filename ); f->Load( ); @@ -119,7 +119,7 @@ int TestFileAccessors(int, char *[]) { std::cout << " " << filename << " is Readable" << std::endl; - gdcm::FileHelper *fh= new gdcm::FileHelper( f ); + gdcm::FileHelper *fh= gdcm::FileHelper::New( f ); TestMethodMacro(std::dec,fh,GetImageDataSize) TestMethodMacro(std::dec,fh,GetImageDataRawSize) @@ -128,17 +128,17 @@ int TestFileAccessors(int, char *[]) TestMethodMacro(std::dec,fh,GetUserDataSize) TestMethodMacro(std::dec,fh,GetWriteType) - delete fh; + fh->Delete(); } else { std::cout << filename << " is NOT Readable" << std::endl << std::endl; - delete f; + f->Delete(); return 1; } - delete f; + f->Delete(); std::cout << "End with " << filename << std::endl; i++; } diff --git a/Testing/TestImageSet.cxx b/Testing/TestImageSet.cxx index 05e6c66f..4caf0ade 100644 --- a/Testing/TestImageSet.cxx +++ b/Testing/TestImageSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestImageSet.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:46 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -141,7 +141,7 @@ void ClearList(FileList &list) FileList::iterator it; for(it=list.begin();it!=list.end();++it) { - delete (*it); + (*it)->Delete(); } list.clear(); } @@ -182,7 +182,7 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName) memset(imageData,0,size); // Write the image - gdcm::FileHelper *hlp = new gdcm::FileHelper(file); + gdcm::FileHelper *hlp = gdcm::FileHelper::New(file); hlp->SetImageData(imageData,size); hlp->SetWriteTypeToDcmExplVR(); if( !hlp->Write(fileName) ) @@ -190,22 +190,22 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName) std::cout << "Failed\n" << " File in unwrittable\n"; - delete hlp; + hlp->Delete(); delete[] imageData; return NULL; } delete[] imageData; - delete hlp; + hlp->Delete(); // Read the written image - gdcm::File *reread = new gdcm::File( ); + gdcm::File *reread = gdcm::File::New( ); reread->SetFileName( fileName ); reread->Load(); if( !reread->IsReadable() ) { std::cerr << "Failed" << std::endl << " Could not reread written image :" << fileName << std::endl; - delete reread; + reread->Delete(); return NULL; } @@ -248,7 +248,7 @@ int TestImageSet(int argc, char *argv[]) { std::ostringstream fileName; fileName << "FileSeq" << i << ".dcm"; - file = new gdcm::File(); + file = gdcm::File::New(); // It's up to the user to initialize Serie UID and Study UID // Study Instance UID studyUID = gdcm::Util::CreateUniqueUID(); @@ -260,13 +260,13 @@ int TestImageSet(int argc, char *argv[]) newFile = WriteImage(file, fileName.str()); if( !newFile ) { - delete file; + file->Delete(); return 1; } else fileList.push_back(newFile); - delete file; + file->Delete(); } if( CompareImages(fileList, false, false) ) @@ -286,20 +286,20 @@ int TestImageSet(int argc, char *argv[]) { std::ostringstream fileName; fileName << "FileSeq" << i << ".dcm"; - file = new gdcm::File(); + file = gdcm::File::New(); file->InsertEntryString(studyUID, 0x0020, 0x000d); file->InsertEntryString(serieUID, 0x0020, 0x000e); newFile = WriteImage(file, fileName.str()); if( !newFile ) { - delete file; + file->Delete(); return(1); } else fileList.push_back(newFile); - delete file; + file->Delete(); } if( CompareImages(fileList, true, true) ) @@ -318,20 +318,20 @@ int TestImageSet(int argc, char *argv[]) { std::ostringstream fileName; fileName << "FileSeq" << i << ".dcm"; - file = new gdcm::File(); + file = gdcm::File::New(); file->InsertEntryString(studyUID, 0x0020, 0x000d); serieUID = gdcm::Util::CreateUniqueUID(); file->InsertEntryString(serieUID, 0x0020, 0x000e); newFile = WriteImage(file, fileName.str()); if( !newFile ) { - delete file; + file->Delete(); return(1); } else fileList.push_back(newFile); - delete file; + file->Delete(); } if( CompareImages(fileList, false, true) ) diff --git a/Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx b/Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx index 42a337ae..b6491ca0 100644 --- a/Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx +++ b/Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestLoadAllDocumentsNoPrivNoSeq.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:46 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -54,7 +54,7 @@ int TestLoadAllDocumentsNoPrivNoSeq(int, char *[]) filename += "/"; //doh! filename += gdcmDataImages[i]; - gdcm::File *f= new gdcm::File( ); + gdcm::File *f= gdcm::File::New( ); f->SetFileName( filename ); // just to improve coverage f->SetLoadMode (gdcm::LD_NOSEQ|gdcm::LD_NOSHADOW); @@ -120,11 +120,11 @@ int TestLoadAllDocumentsNoPrivNoSeq(int, char *[]) { std::cout << filename << " is NOT Readable" << std::endl << std::endl; - delete f; + f->Delete(); return 1; } */ - delete f; + f->Delete(); i++; } return 0; diff --git a/Testing/TestMakeDicomDir.cxx b/Testing/TestMakeDicomDir.cxx index c560f1b0..0aa1ecc9 100644 --- a/Testing/TestMakeDicomDir.cxx +++ b/Testing/TestMakeDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestMakeDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/08/31 09:29:11 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -62,7 +62,7 @@ int TestMakeDicomDir(int argc, char *argv[]) gdcm::DicomDir *dcmdir; // new style (user is allowed no to load Sequences an/or Shadow Groups) - dcmdir = new gdcm::DicomDir( ); + dcmdir = gdcm::DicomDir::New( ); // dcmdir->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW); // some images have a wrong length for element 0x0000 of private groups @@ -78,16 +78,16 @@ int TestMakeDicomDir(int argc, char *argv[]) std::cout << "makeDicomDir: no patient found. Exiting." << std::endl; - delete dcmdir; + dcmdir->Delete(); return 1; } // Create the corresponding DicomDir dcmdir->Write("NewDICOMDIR"); - delete dcmdir; + dcmdir->Delete(); // Read from disc the just written DicomDir - gdcm::DicomDir *newDicomDir = new gdcm::DicomDir(); + gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New(); newDicomDir->SetFileName("NewDICOMDIR"); newDicomDir->Load(); @@ -97,7 +97,7 @@ int TestMakeDicomDir(int argc, char *argv[]) <<" is not readable"<Delete(); return 1; } @@ -107,11 +107,11 @@ int TestMakeDicomDir(int argc, char *argv[]) <<" has no patient"<Delete(); return(1); } std::cout<Delete(); return 0; } diff --git a/Testing/TestMakeIcon.cxx b/Testing/TestMakeIcon.cxx index 1ff478a8..678f8930 100644 --- a/Testing/TestMakeIcon.cxx +++ b/Testing/TestMakeIcon.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestMakeIcon.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:46 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -48,23 +48,24 @@ int TestMakeIcon (int argc, char *argv[]) << " input filename.dcm output Filename.dcm" << std::endl; } - gdcm::File *f = new gdcm::File( ); + gdcm::File *f = gdcm::File::New( ); f->SetFileName( input ); f->Load( ); if ( ! f->IsReadable() ) { std::cout << " Failed to Open/Parse file" << input << std::endl; - delete f; + f->Delete(); return 1; } - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); uint8_t *pixels = fh->GetImageData(); uint32_t lgth = fh->GetImageDataSize(); gdcm::SeqEntry *icon = f->InsertSeqEntry(0x0088, 0x0200); - gdcm::SQItem *sqi = new gdcm::SQItem(1); + gdcm::SQItem *sqi = gdcm::SQItem::New(1); icon->AddSQItem(sqi, 1); + sqi->Delete(); // icone is just define like the image // The purpose is NOT to imagine an icon, @@ -85,9 +86,10 @@ int TestMakeIcon (int argc, char *argv[]) fh->WriteDcmExplVR(output); - delete f; + f->Delete(); + fh->Delete(); - f = new gdcm::File(); + f = gdcm::File::New(); f->SetFileName(output); f->Load(); f->Print(); @@ -98,8 +100,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "Sequence 0088|0200 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "Sequence 0088|0200 found" << std::endl; @@ -110,8 +111,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "Sequence 0088|0200 has no SQItem" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -122,8 +122,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "GetDataEntry 0028|0010 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "First Item ->DataEntry 0028|0010 found" << std::endl; @@ -133,8 +132,7 @@ int TestMakeIcon (int argc, char *argv[]) << "Read : " << sqi->GetDataEntry(0x0028,0x0010)->GetString() << " - Expected : 128" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -143,8 +141,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "GetDataEntry 0028|0011 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "First Item ->DataEntry 0028|0011 found" << std::endl; @@ -154,8 +151,7 @@ int TestMakeIcon (int argc, char *argv[]) << "Read : " << sqi->GetDataEntry(0x0028,0x0011)->GetString() << " - Expected : 128" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -164,8 +160,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "GetDataEntry 0028|0100 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "First Item ->DataEntry 0028|0100 found" << std::endl; @@ -175,8 +170,7 @@ int TestMakeIcon (int argc, char *argv[]) << "Read : " << sqi->GetDataEntry(0x0028,0x0100)->GetString() << " - Expected : 8" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -185,8 +179,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "GetDataEntry 0028|0101 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "First Item ->DataEntry 0028|0101 found" << std::endl; @@ -196,8 +189,7 @@ int TestMakeIcon (int argc, char *argv[]) << "Read : " << sqi->GetDataEntry(0x0028,0x0101)->GetString() << " - Expected : 8" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -206,8 +198,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "DataEntry 0028|0102 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "First Item ->DataEntry 0028|0102 found" << std::endl; @@ -217,8 +208,7 @@ int TestMakeIcon (int argc, char *argv[]) << "Read : " << sqi->GetDataEntry(0x0028,0x0102)->GetString() << " - Expected : 7" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -227,8 +217,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "GetDataEntry 0028|0010 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "First Item ->DataEntry 0028|0103 found" << std::endl; @@ -238,8 +227,7 @@ int TestMakeIcon (int argc, char *argv[]) << "Read : " << sqi->GetDataEntry(0x0028,0x0103)->GetString() << " - Expected : 0" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -248,8 +236,7 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "GetDataEntry 0005|0010 not found" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "First Item ->GetDataEntry 0005|0010 found" << std::endl; @@ -259,8 +246,7 @@ int TestMakeIcon (int argc, char *argv[]) << "Read : " << sqi->GetDataEntry(0x0005,0x0010)->GetLength() << " - Expected : 6" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } @@ -270,14 +256,12 @@ int TestMakeIcon (int argc, char *argv[]) { std::cout << "Value 0005|0010 don't match (DataEntry)" << std::endl << " ... Failed" << std::endl; - delete fh; - delete f; + f->Delete(); return 1; } std::cout << "Value DataEntry 0005|0010 OK" << std::endl; - delete fh; - delete f; + f->Delete(); std::cout << " ... OK" << std::endl; return 0; diff --git a/Testing/TestPrintAllDocument.cxx b/Testing/TestPrintAllDocument.cxx index 76215a24..d083bf07 100644 --- a/Testing/TestPrintAllDocument.cxx +++ b/Testing/TestPrintAllDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestPrintAllDocument.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:46 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -53,7 +53,7 @@ int TestPrintAllDocument(int, char *[]) filename += "/"; //doh! filename += gdcmDataImages[i]; - gdcm::File *f= new gdcm::File( ); + gdcm::File *f= gdcm::File::New( ); f->SetFileName( filename ); f->Load(); @@ -116,10 +116,10 @@ int TestPrintAllDocument(int, char *[]) { std::cout << filename << " is NOT Readable" << std::endl << std::endl; - delete f; + f->Delete(); return 1; } - delete f; + f->Delete(); i++; } return 0; diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index 2fe46dee..7f62c0b7 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestReadWriteReadCompare.cxx,v $ Language: C++ - Date: $Date: 2005/10/19 13:15:37 $ - Version: $Revision: 1.26 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -28,7 +28,7 @@ int CompareInternal(std::string const &filename, std::string const &output) //////////////// Step 1 (see above description): - gdcm::File *file = new gdcm::File( ); + gdcm::File *file = gdcm::File::New( ); file->SetFileName( filename ); file->Load (); if( !file->IsReadable() ) @@ -36,13 +36,13 @@ int CompareInternal(std::string const &filename, std::string const &output) std::cout << "Failed" << std::endl << "Test::TestReadWriteReadCompare: Image not gdcm compatible:" << filename << std::endl; - delete file; + file->Delete(); return 1; } std::cout << " step 1..."; //////////////// Step 2: - gdcm::FileHelper *filehelper = new gdcm::FileHelper( file ); + gdcm::FileHelper *filehelper = gdcm::FileHelper::New( file ); int dataSize = filehelper->GetImageDataSize(); uint8_t *imageData = filehelper->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to @@ -56,7 +56,7 @@ int CompareInternal(std::string const &filename, std::string const &output) std::cout << "2..."; //////////////// Step 3: - gdcm::File *fileout = new gdcm::File(); + gdcm::File *fileout = gdcm::File::New(); fileout->SetFileName( output ); fileout->Load(); // gdcm::FileHelper *reread = new gdcm::FileHelper( output ); // deprecated @@ -66,13 +66,13 @@ int CompareInternal(std::string const &filename, std::string const &output) std::cout << "Failed" << std::endl << "Test::TestReadWriteReadCompare: Could not parse the newly " << "written image:" << filename << std::endl; - delete file; - delete filehelper; - delete fileout; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); return 1; } - gdcm::FileHelper *reread = new gdcm::FileHelper( fileout ); + gdcm::FileHelper *reread = gdcm::FileHelper::New( fileout ); std::cout << "3..."; // For the next step: @@ -93,10 +93,10 @@ int CompareInternal(std::string const &filename, std::string const &output) << reread->GetFile()->GetYSize() << " | " << "Z: " << file->GetZSize() << " # " << reread->GetFile()->GetZSize() << std::endl; - delete file; - delete filehelper; - delete fileout; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 1; } @@ -106,10 +106,10 @@ int CompareInternal(std::string const &filename, std::string const &output) std::cout << "Failed" << std::endl << " Pixel areas lengths differ: " << dataSize << " # " << dataSizeWritten << std::endl; - delete file; - delete filehelper; - delete fileout; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 1; } @@ -118,19 +118,19 @@ int CompareInternal(std::string const &filename, std::string const &output) { std::cout << "Failed" << std::endl << " Pixel differ (as expanded in memory)." << std::endl; - delete file; - delete filehelper; - delete fileout; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 1; } std::cout << "4...OK." << std::endl ; //////////////// Clean up: - delete file; - delete filehelper; - delete fileout; - delete reread; + file->Delete(); + filehelper->Delete(); + fileout->Delete(); + reread->Delete(); return 0; } diff --git a/Testing/TestTS.cxx b/Testing/TestTS.cxx index 7b3c457c..b757561e 100644 --- a/Testing/TestTS.cxx +++ b/Testing/TestTS.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestTS.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:05:26 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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,58 +20,62 @@ int TestTS(int , char *[]) { - gdcm::TS ts; + gdcm::TS *ts = gdcm::TS::New(); // There should be ~150 entries - ts.Print( std::cout ); + ts->Print( std::cout ); // Implicit VR Little Endian - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2" ) << std::endl; // Implicit VR Big Endian DLX (G.E Private) - std::cout << ts.IsTransferSyntax( "1.2.840.113619.5.2" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.113619.5.2" ) << std::endl; // Explicit VR Little Endian - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.1" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.1" ) << std::endl; // Deflated Explicit VR Little Endian - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.1.99" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.1.99" ) << std::endl; // Explicit VR Big Endian - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.2" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.2" ) << std::endl; // JPEG Baseline (Process 1) - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.50" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.50" ) << std::endl; // JPEG Extended (Process 2 & 4) - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.51" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.51" ) << std::endl; // JPEG Extended (Process 3 & 5) - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.52" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.52" ) << std::endl; // JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8) - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.53" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.53" ) << std::endl; // JPEG Full Progression, Non-Hierarchical (Process 10 & 12) - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.55" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.55" ) << std::endl; // JPEG Lossless, Non-Hierarchical (Process 14) - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.57" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.57" ) << std::endl; // JPEG Lossless, Hierarchical, First-Order Prediction (Process 14, // [Selection Value 1]) - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.70" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.70" ) << std::endl; // JPEG 2000 Lossless - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.90" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.90" ) << std::endl; // JPEG 2000 - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.91" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.91" ) << std::endl; // RLE Lossless - std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.5" ) << std::endl; + std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.5" ) << std::endl; // Unknown - std::cout << ts.IsTransferSyntax( "Unknown Transfer Syntax" ) << std::endl; + std::cout << ts->IsTransferSyntax( "Unknown Transfer Syntax" ) << std::endl; // Test JPEG test: std::cout << "Test TS:" << std::endl; - std::cout << ts.IsJPEGLossless( "1.2.840.10008.1.2.4.55") << std::endl; + std::cout << ts->IsJPEGLossless( "1.2.840.10008.1.2.4.55") << std::endl; //if ( key == "1.2.840.10008.1.2.4.55" // || key == "1.2.840.10008.1.2.4.57" // || key == "1.2.840.10008.1.2.4.70" ) - std::cout << ts.IsRLELossless( "1.2.840.10008.1.2.5") << std::endl; - std::cout << ts.IsJPEGLossless( "1.2.840.10008.1.2.5") << std::endl; - std::cout << ts.IsJPEG2000( "1.2.840.10008.1.2.5") << std::endl; - std::cout << ts.IsJPEG( "1.2.840.10008.1.2.5") << std::endl; - std::cout << ts.GetSpecialTransferSyntax( - ts.GetSpecialTransferSyntax( "1.2.840.10008.1.2.5")) << std::endl; + std::cout << ts->IsRLELossless( "1.2.840.10008.1.2.5") << std::endl; + std::cout << ts->IsJPEGLossless( "1.2.840.10008.1.2.5") << std::endl; + std::cout << ts->IsJPEG2000( "1.2.840.10008.1.2.5") << std::endl; + std::cout << ts->IsJPEG( "1.2.840.10008.1.2.5") << std::endl; + std::cout << ts->GetSpecialTransferSyntax( + ts->GetSpecialTransferSyntax( "1.2.840.10008.1.2.5")) << std::endl; std::cout << gdcm::Global::GetTS()->IsRLELossless( "1.2.840.10008.1.2.5" ) << std::endl; - return ts.GetValue( "" ) != gdcm::GDCM_UNFOUND; + bool ret = ts->GetValue( "" ) != gdcm::GDCM_UNFOUND; + + ts->Delete(); + + return ret; } diff --git a/Testing/TestVR.cxx b/Testing/TestVR.cxx index 303ec22d..26e8144f 100644 --- a/Testing/TestVR.cxx +++ b/Testing/TestVR.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestVR.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 08:28:02 $ - Version: $Revision: 1.10 $ + Date: $Date: 2005/10/25 14:52:31 $ + 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 @@ -21,7 +21,7 @@ int TestVR(int , char *[]) { int error = 0; - gdcm::VR *vr = new gdcm::VR(); + gdcm::VR *vr = gdcm::VR::New(); gdcm::Debug::DebugOn(); @@ -96,6 +96,6 @@ int TestVR(int , char *[]) error++; } - delete vr; + vr->Delete(); return error; } diff --git a/Testing/TestWriteSimple.cxx b/Testing/TestWriteSimple.cxx index 62ce6927..c5f4c393 100644 --- a/Testing/TestWriteSimple.cxx +++ b/Testing/TestWriteSimple.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestWriteSimple.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 08:34:26 $ - Version: $Revision: 1.41 $ + Date: $Date: 2005/10/25 14:52:31 $ + Version: $Revision: 1.42 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -110,7 +110,7 @@ int WriteSimple(Image &img) // Step 1 : Create the header of the image std::cout << " 1..."; - gdcm::File *fileToBuild = new gdcm::File(); + gdcm::File *fileToBuild = gdcm::File::New(); std::ostringstream str; // Set the image size @@ -204,7 +204,7 @@ int WriteSimple(Image &img) // Step 3 : Create the file of the image std::cout << "3..."; - gdcm::FileHelper *fileH = new gdcm::FileHelper(fileToBuild); + gdcm::FileHelper *fileH = gdcm::FileHelper::New(fileToBuild); fileH->SetImageData(imageData,size); // Step 4 : Set the writting mode and write the image @@ -229,8 +229,8 @@ int WriteSimple(Image &img) std::cout << "Failed for [" << fileName.str() << "]\n" << " Write mode '"<Delete(); + fileToBuild->Delete(); delete[] imageData; return 1; } @@ -240,8 +240,8 @@ int WriteSimple(Image &img) std::cout << "Failed for [" << fileName.str() << "]\n" << " File is unwrittable\n"; - delete fileH; - delete fileToBuild; + fileH->Delete(); + fileToBuild->Delete(); delete[] imageData; return 1; } @@ -251,7 +251,7 @@ int WriteSimple(Image &img) // old form. //gdcm::FileHelper *reread = new gdcm::FileHelper( fileName.str() ); // Better use : - gdcm::FileHelper *reread = new gdcm::FileHelper( ); + gdcm::FileHelper *reread = gdcm::FileHelper::New( ); reread->SetFileName( fileName.str() ); reread->SetLoadMode(gdcm::LD_ALL); // Load everything // Possible values are @@ -266,9 +266,9 @@ int WriteSimple(Image &img) { std::cerr << "Failed" << std::endl << "Could not read written image : " << fileName.str() << std::endl; - delete fileToBuild; - delete fileH; - delete reread; + fileToBuild->Delete(); + fileH->Delete(); + reread->Delete(); delete[] imageData; return 1; } @@ -285,9 +285,9 @@ int WriteSimple(Image &img) << " File type differ: " << fileH->GetWriteType() << " # " << reread->GetFile()->GetFileType() << std::endl; - delete fileToBuild; - delete fileH; - delete reread; + fileToBuild->Delete(); + fileH->Delete(); + reread->Delete(); delete[] imageData; return 1; @@ -306,9 +306,9 @@ int WriteSimple(Image &img) << reread->GetFile()->GetYSize() << " | " << "Z: " << fileToBuild->GetZSize() << " # " << reread->GetFile()->GetZSize() << std::endl; - delete fileToBuild; - delete fileH; - delete reread; + fileToBuild->Delete(); + fileH->Delete(); + reread->Delete(); delete[] imageData; return 1; @@ -320,9 +320,9 @@ int WriteSimple(Image &img) std::cout << "Failed" << std::endl << " Pixel areas lengths differ: " << size << " # " << dataSizeWritten << std::endl; - delete fileToBuild; - delete fileH; - delete reread; + fileToBuild->Delete(); + fileH->Delete(); + reread->Delete(); delete[] imageData; return 1; @@ -350,9 +350,9 @@ int WriteSimple(Image &img) } } std::cout << std::endl; - delete fileToBuild; - delete fileH; - delete reread; + fileToBuild->Delete(); + fileH->Delete(); + reread->Delete(); delete[] imageData; return 1; @@ -360,9 +360,9 @@ int WriteSimple(Image &img) std::cout << "OK" << std::endl; - delete fileToBuild; - delete fileH; - delete reread; + fileToBuild->Delete(); + fileH->Delete(); + reread->Delete(); delete[] imageData; return 0; diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 17da13ee..2f19e243 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 09:22:15 $ - Version: $Revision: 1.166 $ + Date: $Date: 2005/10/25 14:52:33 $ + Version: $Revision: 1.167 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -124,36 +124,6 @@ DicomDir::DicomDir() NewMeta(); } -#ifndef GDCM_LEGACY_REMOVE -/* * - * \ brief Constructor Parses recursively the directory and creates the DicomDir - * or uses an already built DICOMDIR, depending on 'parseDir' value. - * @ param fileName name - * - of the root directory (parseDir = true) - * - of the DICOMDIR (parseDir = false) - * @ param parseDir boolean - * - true if user passed an entry point - * and wants to explore recursively the directories - * - false if user passed an already built DICOMDIR file - * and wants to use it - * @ deprecated use : new DicomDir() + [ SetLoadMode(lm) + ] SetDirectoryName(name) - * or : new DicomDir() + SetFileName(name) - */ -DicomDir::DicomDir(std::string const &fileName, bool parseDir ): - Document( ) -{ - // At this step, Document constructor is already executed, - // whatever user passed (either a root directory or a DICOMDIR) - // and whatever the value of parseDir was. - // (nothing is cheked in Document constructor, to avoid overhead) - - ParseDir = parseDir; - SetLoadMode (LD_ALL); // concerns only dicom files - SetFileName( fileName ); - Load( ); -} -#endif - /** * \brief Canonical destructor */ @@ -166,7 +136,7 @@ DicomDir::~DicomDir() ClearPatient(); if ( MetaElems ) { - delete MetaElems; + MetaElems->Delete(); } } @@ -306,12 +276,12 @@ bool DicomDir::IsReadable() DicomDirMeta *DicomDir::NewMeta() { if ( MetaElems ) - delete MetaElems; + MetaElems->Delete(); DocEntry *entry = GetFirstEntry(); if ( entry ) { - MetaElems = new DicomDirMeta(true); // true = empty + MetaElems = DicomDirMeta::New(true); // true = empty entry = GetFirstEntry(); while( entry ) @@ -327,7 +297,7 @@ DicomDirMeta *DicomDir::NewMeta() } else // after root directory parsing { - MetaElems = new DicomDirMeta(false); // false = not empty + MetaElems = DicomDirMeta::New(false); // false = not empty } MetaElems->SetSQItemNumber(0); // To avoid further missprinting return MetaElems; @@ -339,9 +309,9 @@ DicomDirMeta *DicomDir::NewMeta() */ DicomDirPatient *DicomDir::NewPatient() { - DicomDirPatient *p = new DicomDirPatient(); - AddPatientToEnd( p ); - return p; + DicomDirPatient *dd = DicomDirPatient::New(); + AddPatientToEnd( dd ); + return dd; } /** @@ -353,7 +323,7 @@ void DicomDir::ClearPatient() cc!= Patients.end(); ++cc) { - delete *cc; + (*cc)->Unregister(); } Patients.clear(); } @@ -626,18 +596,12 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path) break; } - f = new File( ); + f = File::New( ); f->SetLoadMode(LoadMode); // we allow user not to load Sequences, or Shadow // groups, or ...... f->SetFileName( it->c_str() ); - /*int res = */f->Load( ); + f->Load( ); -// if ( !f ) -// { -// gdcmWarningMacro( "Failure in new gdcm::File " << it->c_str() ); -// continue; -// } - if ( f->IsReadable() ) { // Add the file to the chained list: @@ -646,7 +610,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path) } else { - delete f; + f->Delete(); } count++; } @@ -662,7 +626,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path) itDoc!=list.end(); ++itDoc) { - delete dynamic_cast(*itDoc); + dynamic_cast(*itDoc)->Delete(); } } @@ -780,50 +744,50 @@ void DicomDir::CreateDicomDir() if ( v == "IMAGE " ) { - si = new DicomDirImage(true); + si = DicomDirImage::New(true); if ( !AddImageToEnd( static_cast(si)) ) { - delete si; + si->Delete(); si = NULL; gdcmErrorMacro( "Add AddImageToEnd failed"); } } else if ( v == "SERIES" ) { - si = new DicomDirSerie(true); + si = DicomDirSerie::New(true); if ( !AddSerieToEnd( static_cast(si)) ) { - delete si; + si->Delete(); si = NULL; gdcmErrorMacro( "Add AddSerieToEnd failed"); } } else if ( v == "VISIT " ) { - si = new DicomDirVisit(true); + si = DicomDirVisit::New(true); if ( !AddVisitToEnd( static_cast(si)) ) { - delete si; + si->Delete(); si = NULL; gdcmErrorMacro( "Add AddVisitToEnd failed"); } } else if ( v == "STUDY " ) { - si = new DicomDirStudy(true); + si = DicomDirStudy::New(true); if ( !AddStudyToEnd( static_cast(si)) ) { - delete si; + si->Delete(); si = NULL; gdcmErrorMacro( "Add AddStudyToEnd failed"); } } else if ( v == "PATIENT " ) { - si = new DicomDirPatient(true); + si = DicomDirPatient::New(true); if ( !AddPatientToEnd( static_cast(si)) ) { - delete si; + si->Delete(); si = NULL; gdcmErrorMacro( "Add PatientToEnd failed"); } @@ -1029,48 +993,48 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, { case GDCM_DICOMDIR_IMAGE: elemList = Global::GetDicomDirElements()->GetDicomDirImageElements(); - si = new DicomDirImage(true); + si = DicomDirImage::New(true); if ( !AddImageToEnd(static_cast(si)) ) { - delete si; + si->Delete(); gdcmErrorMacro( "Add ImageToEnd failed"); } break; case GDCM_DICOMDIR_SERIE: elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements(); - si = new DicomDirSerie(true); + si = DicomDirSerie::New(true); if ( !AddSerieToEnd(static_cast(si)) ) { - delete si; + si->Delete(); gdcmErrorMacro( "Add SerieToEnd failed"); } break; case GDCM_DICOMDIR_STUDY: elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements(); - si = new DicomDirStudy(true); + si = DicomDirStudy::New(true); if ( !AddStudyToEnd(static_cast(si)) ) { - delete si; + si->Delete(); gdcmErrorMacro( "Add StudyToEnd failed"); } break; case GDCM_DICOMDIR_PATIENT: elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements(); - si = new DicomDirPatient(true); + si = DicomDirPatient::New(true); if ( !AddPatientToEnd(static_cast(si)) ) { - delete si; + si->Delete(); gdcmErrorMacro( "Add PatientToEnd failed"); } break; case GDCM_DICOMDIR_META: if ( MetaElems ) { - delete MetaElems; + MetaElems->Delete(); gdcmErrorMacro( "MetaElements already exist, they will be destroyed"); } elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements(); - MetaElems = new DicomDirMeta(true); + MetaElems = DicomDirMeta::New(true); si = MetaElems; break; default: diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 2a524f3e..7a698763 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.h,v $ Language: C++ - Date: $Date: 2005/08/31 09:29:12 $ - Version: $Revision: 1.68 $ + Date: $Date: 2005/10/25 14:52:33 $ + Version: $Revision: 1.69 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -50,12 +50,12 @@ typedef std::vector VectDocument; */ class GDCM_EXPORT DicomDir: public Document { + gdcmTypeMacro(DicomDir); + public: - typedef void Method(void*); + static DicomDir *New() {return new DicomDir();} - DicomDir(); - GDCM_LEGACY( DicomDir(std::string const &filename, bool parseDir = false) ); - ~DicomDir(); + typedef void Method(void*); GDCM_LEGACY( bool Load(std::string const &filename) ); bool Load( ); @@ -140,6 +140,9 @@ public: } DicomDirType; protected: + DicomDir(); + ~DicomDir(); + void CreateDicomDirChainedList(std::string const &path); void CallStartMethod(); void CallProgressMethod(); diff --git a/src/gdcmDicomDirElement.h b/src/gdcmDicomDirElement.h index 74b18e03..37c605ec 100644 --- a/src/gdcmDicomDirElement.h +++ b/src/gdcmDicomDirElement.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirElement.h,v $ Language: C++ - Date: $Date: 2005/10/19 12:01:50 $ - Version: $Revision: 1.32 $ + Date: $Date: 2005/10/25 14:52:33 $ + 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,7 +19,7 @@ #ifndef GDCMDICOMDIRELEMENT_H #define GDCMDICOMDIRELEMENT_H -#include "gdcmCommon.h" +#include "gdcmRefCounter.h" #include @@ -65,13 +65,14 @@ typedef std::list ListDicomDirFiducialElem; * \brief Represents elements contained in a DicomDir class * for the chained lists from the file 'Dicts/DicomDir.dic' */ -class GDCM_EXPORT DicomDirElement +class GDCM_EXPORT DicomDirElement : public RefCounter { + gdcmTypeMacro(DicomDirElement); + public: - DicomDirElement(); - ~DicomDirElement(); + static DicomDirElement *New() {return new DicomDirElement();} - /** + /** * \brief canonical Printer */ void Print(std::ostream &os); @@ -124,6 +125,10 @@ public: void AddDicomDirElement(DicomDirType type, uint16_t group, uint16_t elem); +protected: + DicomDirElement(); + ~DicomDirElement(); + private: /// Elements chained list, related to the MetaElements of DICOMDIR ListDicomDirMetaElem DicomDirMetaList; diff --git a/src/gdcmDicomDirImage.h b/src/gdcmDicomDirImage.h index 2fc5738c..573cc64f 100644 --- a/src/gdcmDicomDirImage.h +++ b/src/gdcmDicomDirImage.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirImage.h,v $ Language: C++ - Date: $Date: 2005/02/01 13:11:49 $ - Version: $Revision: 1.16 $ + Date: $Date: 2005/10/25 14:52:33 $ + 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 @@ -30,11 +30,16 @@ namespace gdcm */ class GDCM_EXPORT DicomDirImage : public DicomDirObject { + gdcmTypeMacro(DicomDirImage); + public: - DicomDirImage(bool empty=false); - ~DicomDirImage(); + static DicomDirImage *New(bool empty=false) {return new DicomDirImage(empty);} void Print(std::ostream &os = std::cout, std::string const &indent = "" ); + +protected: + DicomDirImage(bool empty=false); + ~DicomDirImage(); }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDirMeta.h b/src/gdcmDicomDirMeta.h index ddeca253..96403f23 100644 --- a/src/gdcmDicomDirMeta.h +++ b/src/gdcmDicomDirMeta.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirMeta.h,v $ Language: C++ - Date: $Date: 2005/02/01 13:11:49 $ - Version: $Revision: 1.18 $ + Date: $Date: 2005/10/25 14:52:33 $ + 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 @@ -30,12 +30,17 @@ namespace gdcm */ class GDCM_EXPORT DicomDirMeta : public DicomDirObject { + gdcmTypeMacro(DicomDirMeta); + public: - DicomDirMeta(bool empty=false); - ~DicomDirMeta(); + static DicomDirMeta *New(bool empty=false) {return new DicomDirMeta(empty);} virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); virtual void WriteContent(std::ofstream *fp, FileType t); + +protected: + DicomDirMeta(bool empty=false); + ~DicomDirMeta(); }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDirObject.h b/src/gdcmDicomDirObject.h index 5e6dc853..39e4e996 100644 --- a/src/gdcmDicomDirObject.h +++ b/src/gdcmDicomDirObject.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.h,v $ Language: C++ - Date: $Date: 2005/07/12 17:08:12 $ - Version: $Revision: 1.17 $ + Date: $Date: 2005/10/25 14:52:33 $ + 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 @@ -39,6 +39,8 @@ typedef std::list ListContent; */ class GDCM_EXPORT DicomDirObject : public SQItem { + gdcmTypeMacro(DicomDirObject); + public: protected: diff --git a/src/gdcmDicomDirPatient.cxx b/src/gdcmDicomDirPatient.cxx index 7c2b598d..73680f80 100644 --- a/src/gdcmDicomDirPatient.cxx +++ b/src/gdcmDicomDirPatient.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.cxx,v $ Language: C++ - Date: $Date: 2005/06/24 10:55:58 $ - Version: $Revision: 1.38 $ + Date: $Date: 2005/10/25 14:52:33 $ + Version: $Revision: 1.39 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -75,9 +75,9 @@ void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t) */ DicomDirStudy* DicomDirPatient::NewStudy() { - DicomDirStudy *st = new DicomDirStudy(); - Studies.push_back(st); - return st; + DicomDirStudy *dd = DicomDirStudy::New(); + Studies.push_back(dd); + return dd; } /** @@ -89,7 +89,7 @@ void DicomDirPatient::ClearStudy() cc != Studies.end(); ++cc ) { - delete *cc; + (*cc)->Delete(); } Studies.clear(); } diff --git a/src/gdcmDicomDirPatient.h b/src/gdcmDicomDirPatient.h index 737acd7c..4f989ca4 100644 --- a/src/gdcmDicomDirPatient.h +++ b/src/gdcmDicomDirPatient.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.h,v $ Language: C++ - Date: $Date: 2005/09/02 07:10:03 $ - Version: $Revision: 1.27 $ + Date: $Date: 2005/10/25 14:52:33 $ + Version: $Revision: 1.28 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,9 +35,10 @@ typedef std::list ListDicomDirStudy; class GDCM_EXPORT DicomDirPatient : public DicomDirObject { + gdcmTypeMacro(DicomDirPatient); + public: - DicomDirPatient(bool empty=false); - ~DicomDirPatient(); + static DicomDirPatient *New(bool empty=false) {return new DicomDirPatient(empty);} void Print(std::ostream &os = std::cout, std::string const &indent = "" ); void WriteContent(std::ofstream *fp, FileType t); @@ -52,8 +53,11 @@ public: DicomDirStudy *GetNextStudy(); DicomDirStudy *GetLastStudy(); -private: +protected: + DicomDirPatient(bool empty=false); + ~DicomDirPatient(); +private: /// chained list of DicomDirStudy (to be exploited hierarchicaly) ListDicomDirStudy Studies; /// iterator on the DicomDirStudies of the current DicomDirPatient diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index db93cc01..090dac64 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.cxx,v $ Language: C++ - Date: $Date: 2005/06/24 10:55:58 $ - Version: $Revision: 1.38 $ + Date: $Date: 2005/10/25 14:52:33 $ + Version: $Revision: 1.39 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -74,9 +74,9 @@ void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t) */ DicomDirImage *DicomDirSerie::NewImage() { - DicomDirImage *st = new DicomDirImage(); - Images.push_back(st); - return st; + DicomDirImage *dd = DicomDirImage::New(); + Images.push_back(dd); + return dd; } /** @@ -88,7 +88,7 @@ void DicomDirSerie::ClearImage() cc != Images.end(); ++cc) { - delete *cc; + (*cc)->Delete(); } Images.clear(); } diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h index 27c5adc9..dfcf8968 100644 --- a/src/gdcmDicomDirSerie.h +++ b/src/gdcmDicomDirSerie.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.h,v $ Language: C++ - Date: $Date: 2005/09/02 07:10:03 $ - Version: $Revision: 1.29 $ + Date: $Date: 2005/10/25 14:52:33 $ + 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 @@ -34,9 +34,10 @@ typedef std::list ListDicomDirImage; */ class GDCM_EXPORT DicomDirSerie : public DicomDirObject { + gdcmTypeMacro(DicomDirSerie); + public: - DicomDirSerie(bool empty=false); - ~DicomDirSerie(); + static DicomDirSerie *New(bool empty=false) {return new DicomDirSerie(empty);} void Print( std::ostream &os = std::cout, std::string const &indent = "" ); void WriteContent( std::ofstream *fp, FileType t ); @@ -50,8 +51,11 @@ public: DicomDirImage *GetFirstImage(); DicomDirImage *GetNextImage(); -private: +protected: + DicomDirSerie(bool empty=false); + ~DicomDirSerie(); +private: ///chained list of DicomDirImages (to be exploited recursively) ListDicomDirImage Images; /// iterator on the DicomDirImages of the current DicomDirSerie diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index 9a5dd265..b907e698 100644 --- a/src/gdcmDicomDirStudy.cxx +++ b/src/gdcmDicomDirStudy.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirStudy.cxx,v $ Language: C++ - Date: $Date: 2005/07/11 08:20:25 $ - Version: $Revision: 1.40 $ + Date: $Date: 2005/10/25 14:52:33 $ + Version: $Revision: 1.41 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -83,9 +83,9 @@ void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t) */ DicomDirSerie *DicomDirStudy::NewSerie() { - DicomDirSerie *st = new DicomDirSerie(); - Series.push_back(st); - return st; + DicomDirSerie *dd = DicomDirSerie::New(); + Series.push_back(dd); + return dd; } /** @@ -97,7 +97,7 @@ void DicomDirStudy::ClearSerie() cc != Series.end(); ++cc ) { - delete *cc; + (*cc)->Delete(); } Series.clear(); } @@ -151,9 +151,10 @@ DicomDirSerie *DicomDirStudy::GetLastSerie() */ DicomDirVisit *DicomDirStudy::NewVisit() { - DicomDirVisit *st = new DicomDirVisit(); - Visits.push_back(st); - return st; + DicomDirVisit *dd = DicomDirVisit::New(); + Visits.push_back(dd); + dd->Delete(); + return dd; } /** @@ -165,7 +166,7 @@ void DicomDirStudy::ClearVisit() cc != Visits.end(); ++cc ) { - delete *cc; + (*cc)->Delete(); } Visits.clear(); } diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h index bc8245ab..ba277d51 100644 --- a/src/gdcmDicomDirStudy.h +++ b/src/gdcmDicomDirStudy.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirStudy.h,v $ Language: C++ - Date: $Date: 2005/09/02 07:10:03 $ - Version: $Revision: 1.29 $ + Date: $Date: 2005/10/25 14:52:33 $ + 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 @@ -42,9 +42,10 @@ typedef std::list ListDicomDirStudyComponent; */ class GDCM_EXPORT DicomDirStudy : public DicomDirObject { + gdcmTypeMacro(DicomDirStudy); + public: - DicomDirStudy(bool empty=false); - ~DicomDirStudy(); + static DicomDirStudy *New(bool empty=false) {return new DicomDirStudy(empty);} void Print(std::ostream &os = std::cout, std::string const &indent = "" ); void WriteContent(std::ofstream *fp, FileType t); @@ -77,8 +78,12 @@ public: DicomDirStudyComponent *GetNextStudyComponent(); DicomDirStudyComponent *GetLastStudyComponent(); */ -private: +protected: + DicomDirStudy(bool empty=false); + ~DicomDirStudy(); + +private: /// chained list of DicomDirSeries (to be exploited hierarchicaly) ListDicomDirSerie Series; /// iterator on the DicomDirSeries of the current DicomDirStudy diff --git a/src/gdcmDicomDirVisit.h b/src/gdcmDicomDirVisit.h index 18337fba..27f03b6d 100644 --- a/src/gdcmDicomDirVisit.h +++ b/src/gdcmDicomDirVisit.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirVisit.h,v $ Language: C++ - Date: $Date: 2005/07/08 19:07:12 $ - Version: $Revision: 1.1 $ + Date: $Date: 2005/10/25 14:52:34 $ + 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 @@ -30,13 +30,17 @@ namespace gdcm */ class GDCM_EXPORT DicomDirVisit : public DicomDirObject { + gdcmTypeMacro(DicomDirVisit); + public: - DicomDirVisit(bool empty=false); - ~DicomDirVisit(); + static DicomDirVisit *New(bool empty=false) {return new DicomDirVisit(empty);} void Print( std::ostream &os = std::cout, std::string const &indent = "" ); // void WriteContent( std::ofstream *fp, FileType t ); +protected: + DicomDirVisit(bool empty=false); + ~DicomDirVisit(); }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmDict.h b/src/gdcmDict.h index d48b9694..168f794e 100644 --- a/src/gdcmDict.h +++ b/src/gdcmDict.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.h,v $ Language: C++ - Date: $Date: 2005/10/23 15:32:30 $ - Version: $Revision: 1.44 $ + Date: $Date: 2005/10/25 14:52:34 $ + 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 @@ -19,7 +19,7 @@ #ifndef GDCMDICT_H #define GDCMDICT_H -#include "gdcmBase.h" +#include "gdcmRefCounter.h" #include "gdcmDictEntry.h" #include @@ -44,12 +44,13 @@ typedef std::map TagKeyHT; * combined with all software versions... * \see DictSet */ -class GDCM_EXPORT Dict : public Base +class GDCM_EXPORT Dict : public RefCounter { + gdcmTypeMacro(Dict); + public: - Dict(); - Dict(std::string const &filename); - ~Dict(); + static Dict *New() {return new Dict();} + static Dict *New(std::string const &filename) {return new Dict(filename);} bool AddDict(std::string const &filename); bool RemoveDict(std::string const &filename); @@ -70,6 +71,11 @@ public: DictEntry *GetFirstEntry(); DictEntry *GetNextEntry(); +protected: + Dict(); + Dict(std::string const &filename); + ~Dict(); + private: void DoTheLoadingJob(std::ifstream &ifs); diff --git a/src/gdcmDictGroupName.h b/src/gdcmDictGroupName.h index b03c5c61..c31266d6 100644 --- a/src/gdcmDictGroupName.h +++ b/src/gdcmDictGroupName.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictGroupName.h,v $ Language: C++ - Date: $Date: 2005/10/23 15:32:31 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/10/25 14:52:34 $ + 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 @@ -19,7 +19,8 @@ #ifndef GDCMDICTGROUPNAME_H #define GDCMDICTGROUPNAME_H -#include "gdcmCommon.h" +#include "gdcmRefCounter.h" + #include #include #include @@ -36,16 +37,21 @@ typedef std::map DictGroupNameHT; * \brief Container for dicom 'Value Representation' Hash Table. * \note This is a singleton. */ -class GDCM_EXPORT DictGroupName +class GDCM_EXPORT DictGroupName : public RefCounter { + gdcmTypeMacro(DictGroupName); + public: - DictGroupName(void); - ~DictGroupName(); + static DictGroupName *New() {return new DictGroupName();} void Print(std::ostream &os = std::cout); const TagName &GetName(uint16_t group); +protected: + DictGroupName(); + ~DictGroupName(); + private: DictGroupNameHT groupName; }; diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 32a5023a..524f0f98 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2005/10/20 15:24:08 $ - Version: $Revision: 1.71 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.72 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,7 +36,7 @@ DictSet::DictSet() DictPath = BuildDictPath(); std::string pubDictFile(DictPath); pubDictFile += PUB_DICT_FILENAME; - Dicts[PUB_DICT_NAME] = new Dict(pubDictFile); + Dicts[PUB_DICT_NAME] = Dict::New(pubDictFile); } /** @@ -47,12 +47,8 @@ DictSet::~DictSet() // Remove dictionaries for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag) { - Dict *entryToDelete = tag->second; - if ( entryToDelete ) - { - delete entryToDelete; - } - tag->second = NULL; + if ( tag->second ) + tag->second->Delete(); } Dicts.clear(); } @@ -70,8 +66,8 @@ DictSet::~DictSet() Dict *DictSet::LoadDictFromFile(std::string const &filename, DictKey const &name) { - Dict *newDict = new Dict(filename); - AppendDict(newDict, name); + Dict *newDict = Dict::New(filename); + Dicts[name] = newDict; return newDict; } @@ -151,16 +147,6 @@ std::string DictSet::BuildDictPath() //----------------------------------------------------------------------------- // Protected -/** - * \brief Adds a Dictionary to a DictSet - * \return always true - */ -bool DictSet::AppendDict(Dict *newDict, DictKey const &name) -{ - Dicts[name] = newDict; - - return true; -} //----------------------------------------------------------------------------- // Private diff --git a/src/gdcmDictSet.h b/src/gdcmDictSet.h index 4ae5d721..e49e859e 100644 --- a/src/gdcmDictSet.h +++ b/src/gdcmDictSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.h,v $ Language: C++ - Date: $Date: 2005/10/23 15:32:31 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,7 +19,7 @@ #ifndef GDCMDICTSET_H #define GDCMDICTSET_H -#include "gdcmBase.h" +#include "gdcmRefCounter.h" #include "gdcmDict.h" #include @@ -38,11 +38,12 @@ typedef std::map DictSetHT; * \par having many in memory representations of the same dictionary * (saving memory). */ -class GDCM_EXPORT DictSet : public Base +class GDCM_EXPORT DictSet : public RefCounter { + gdcmTypeMacro(DictSet); + public: - DictSet(); - ~DictSet(); + static DictSet *New() {return new DictSet();} void Print(std::ostream &os = std::cout, std::string const &indent = "" ); @@ -68,7 +69,8 @@ public: static std::string BuildDictPath(); protected: - bool AppendDict(Dict *NewDict, DictKey const &name); + DictSet(); + ~DictSet(); private: /// Hash table of all dictionaries contained in this DictSet diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index 3448c892..92f1c492 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2005/10/24 16:00:47 $ - Version: $Revision: 1.61 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.62 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,7 +19,7 @@ #ifndef GDCMDOCENTRYSET_H #define GDCMDOCENTRYSET_H -#include "gdcmBase.h" +#include "gdcmRefCounter.h" #include "gdcmVRKey.h" #include "gdcmTagKey.h" @@ -56,14 +56,11 @@ class DictEntry; * members to this class since this class is designed as an adapter * in the form of an abstract base class. */ -class GDCM_EXPORT DocEntrySet : public Base +class GDCM_EXPORT DocEntrySet : public RefCounter { -public: - /// Canonical Constructor - DocEntrySet(); - /// Canonical Destructor - virtual ~DocEntrySet() {} + gdcmTypeMacro(DocEntrySet); +public: /// \brief write any type of entry to the entry set virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0; @@ -114,6 +111,11 @@ public: SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem); protected: + /// Canonical Constructor + DocEntrySet(); + /// Canonical Destructor + virtual ~DocEntrySet() {} + // DictEntry related utilities DictEntry *GetDictEntry(uint16_t group, uint16_t elem); DictEntry *GetDictEntry(uint16_t group, uint16_t elem, diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 3cdda736..0af2d956 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 12:42:37 $ - Version: $Revision: 1.306 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.307 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1204,7 +1204,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, break; } // create the current SQItem - SQItem *itemSQ = new SQItem( seqEntry->GetDepthLevel() ); + SQItem *itemSQ = SQItem::New( seqEntry->GetDepthLevel() ); unsigned int l = newDocEntry->GetReadLength(); if ( l == 0xffffffff ) @@ -1227,6 +1227,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, // end try ----------------- seqEntry->AddSQItem( itemSQ, SQItemNumber ); + itemSQ->Delete(); newDocEntry->Delete(); SQItemNumber++; if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max ) diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 1d8ce95c..ea455441 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2005/10/19 12:01:51 $ - Version: $Revision: 1.126 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.127 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -39,9 +39,10 @@ class Dict; */ class GDCM_EXPORT Document : public ElementSet { -public: + gdcmTypeMacro(Document); -typedef std::list ListElements; +public: + typedef std::list ListElements; // Loading //Deprecated : use SetFileName() + Load() diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index d924c6e8..26ae0a20 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2005/10/24 16:00:47 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,10 +41,9 @@ typedef std::map TagDocEntryHT; */ class GDCM_EXPORT ElementSet : public DocEntrySet { -public: - ElementSet(); - ~ElementSet(); + gdcmTypeMacro(ElementSet); +public: virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); @@ -61,6 +60,8 @@ public: bool IsEmpty() { return TagHT.empty(); } protected: + ElementSet(); + ~ElementSet(); private: // Variables diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 2d76f3f0..88b7d144 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 14:36:30 $ - Version: $Revision: 1.294 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.295 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1790,21 +1790,6 @@ void File::ReadEncapsulatedBasicOffsetTable() // These are the deprecated method that one day should be removed (after the next release) #ifndef GDCM_LEGACY_REMOVE -/* - * brief Constructor (DEPRECATED : temporaryly kept not to break the API) - * param filename name of the file whose header we want to analyze - * deprecated do not use any longer - */ -File::File( std::string const &filename ) - :Document( ) -{ - RLEInfo = new RLEFramesInfo; - JPEGInfo = new JPEGFragmentsInfo; - - SetFileName( filename ); - Load( ); // gdcm::Document is first Loaded, then the 'File part' -} - /* * \ brief Loader. (DEPRECATED : temporaryly kept not to break the API) * @ param fileName file to be open for parsing diff --git a/src/gdcmFile.h b/src/gdcmFile.h index 8e6e51ad..73590e86 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2005/10/06 18:54:50 $ - Version: $Revision: 1.117 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.118 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -98,10 +98,10 @@ enum ModalityType { */ class GDCM_EXPORT File : public Document { + gdcmTypeMacro(File); + public: - File(); - GDCM_LEGACY(File( std::string const &filename )); - ~File(); + static File *New() {return new File();} // Loading GDCM_LEGACY(bool Load( std::string const &filename )); @@ -175,7 +175,9 @@ public: bool Write(std::string fileName, FileType filetype); protected: - + File(); + ~File(); + /// Store the RLE frames info obtained during parsing of pixels. RLEFramesInfo *RLEInfo; /// Store the JPEG fragments info obtained during parsing of pixels. diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 0d5cd331..257bace4 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -4,8 +4,8 @@ Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 12:42:01 $ - Version: $Revision: 1.73 $ + Date: $Date: 2005/10/25 14:52:34 $ + Version: $Revision: 1.74 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -130,8 +130,7 @@ namespace gdcm */ FileHelper::FileHelper( ) { - FileInternal = new File( ); - SelfHeader = true; + FileInternal = File::New( ); Initialize(); } @@ -152,7 +151,7 @@ FileHelper::FileHelper( ) FileHelper::FileHelper(File *header) { FileInternal = header; - SelfHeader = false; + header->Register(); Initialize(); if ( FileInternal->IsReadable() ) { @@ -160,36 +159,6 @@ FileHelper::FileHelper(File *header) } } -#ifndef GDCM_LEGACY_REMOVE -/* - * brief DEPRECATED : use SetFilename() + SetLoadMode() + Load() methods - * Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 - * file (gdcm::File 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 - * note the in-memory representation of all available tags found in - * the DICOM header is post-poned to first header information access. - * This avoid a double parsing of public part of the header when - * one sets an a posteriori shadow dictionary (efficiency can be - * seen as a side effect). - * param filename file to be opened for parsing - * deprecated use SetFilename() + Load() methods - */ -FileHelper::FileHelper(std::string const &filename ) -{ - FileInternal = new File( ); - FileInternal->SetFileName( filename ); - FileInternal->Load(); - SelfHeader = true; - Initialize(); - if ( FileInternal->IsReadable() ) - { - PixelReadConverter->GrabInformationsFromFile( FileInternal ); - } -} -#endif - /** * \brief canonical destructor * \note If the header (gdcm::File) was created by the FileHelper constructor, @@ -210,10 +179,7 @@ FileHelper::~FileHelper() delete Archive; } - if ( SelfHeader ) - { - delete FileInternal; - } + FileInternal->Unregister(); FileInternal = 0; } @@ -1392,13 +1358,14 @@ void FileHelper::CheckMandatoryElements() // Create 'Source Image Sequence' SeqEntry SeqEntry *sis = SeqEntry::New ( Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x2112) ); - SQItem *sqi = new SQItem(1); + SQItem *sqi = SQItem::New(1); // (we assume 'SOP Instance UID' exists too) // create 'Referenced SOP Class UID' DataEntry *e_0008_1150 = DataEntry::New( Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) ); e_0008_1150->SetString( e_0008_0016->GetString()); sqi->AddEntry(e_0008_1150); + e_0008_1150->Delete(); // create 'Referenced SOP Instance UID' DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018); @@ -1406,8 +1373,11 @@ void FileHelper::CheckMandatoryElements() Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) ); e_0008_1155->SetString( e_0008_0018->GetString()); sqi->AddEntry(e_0008_1155); + e_0008_1155->Delete(); + + sis->AddSQItem(sqi,1); + sqi->Delete(); - sis->AddSQItem(sqi,1); // temporarily replaces any previous 'Source Image Sequence' Archive->Push(sis); sis->Delete(); diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index 7f7476d4..899cb436 100644 --- a/src/gdcmFileHelper.h +++ b/src/gdcmFileHelper.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFileHelper.h,v $ Language: C++ - Date: $Date: 2005/10/25 12:43:25 $ - Version: $Revision: 1.28 $ + Date: $Date: 2005/10/25 14:52:34 $ + 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 @@ -20,7 +20,7 @@ #define GDCMFILEHELPER_H #include "gdcmDebug.h" -#include "gdcmBase.h" +#include "gdcmRefCounter.h" namespace gdcm @@ -40,8 +40,10 @@ typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, File *); * for accessing the image/volume content. One can also use it to * write Dicom/ACR-NEMA/RAW files. */ -class GDCM_EXPORT FileHelper : public Base +class GDCM_EXPORT FileHelper : public RefCounter { + gdcmTypeMacro(FileHelper); + public: enum FileMode { @@ -50,9 +52,8 @@ public: }; public: - FileHelper( ); - FileHelper( File *header ); - GDCM_LEGACY(FileHelper( std::string const &filename )); + static FileHelper *New() {return new FileHelper();} + static FileHelper *New(File *header) {return new FileHelper(header);} virtual ~FileHelper(); @@ -149,6 +150,9 @@ public: bool Write (std::string const &fileName); protected: + FileHelper( ); + FileHelper( File *header ); + bool CheckWriteIntegrity(); void SetWriteToRaw(); @@ -182,11 +186,6 @@ private: /// gdcm::File to use to load the file File *FileInternal; - /// \brief Whether the underlying \ref gdcm::File was loaded by - /// the constructor or passed to the constructor. - /// When false the destructor is in charge of deletion. - bool SelfHeader; - /// Whether already parsed or not bool Parsed; diff --git a/src/gdcmGlobal.cxx b/src/gdcmGlobal.cxx index b2864d5d..4a21aca3 100644 --- a/src/gdcmGlobal.cxx +++ b/src/gdcmGlobal.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmGlobal.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 12:58:28 $ - Version: $Revision: 1.27 $ + Date: $Date: 2005/10/25 14:52:35 $ + Version: $Revision: 1.28 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -70,11 +70,11 @@ Global::Global() gdcmWarningMacro( "VR or TS or Dicts already allocated"); return; } - Dicts = new DictSet(); - ValRes = new VR(); - TranSyn = new TS(); - GroupName = new DictGroupName(); - ddElem = new DicomDirElement(); + Dicts = DictSet::New(); + ValRes = VR::New(); + TranSyn = TS::New(); + GroupName = DictGroupName::New(); + ddElem = DicomDirElement::New(); } /** @@ -82,11 +82,11 @@ Global::Global() */ Global::~Global() { - delete Dicts; - delete ValRes; - delete TranSyn; - delete GroupName; - delete ddElem; + Dicts->Delete(); + ValRes->Delete(); + TranSyn->Delete(); + GroupName->Delete(); + ddElem->Delete(); } //----------------------------------------------------------------------------- diff --git a/src/gdcmSQItem.h b/src/gdcmSQItem.h index 42567308..0d885225 100644 --- a/src/gdcmSQItem.h +++ b/src/gdcmSQItem.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.h,v $ Language: C++ - Date: $Date: 2005/10/24 16:00:48 $ - Version: $Revision: 1.46 $ + Date: $Date: 2005/10/25 14:52:35 $ + Version: $Revision: 1.47 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,9 +40,10 @@ typedef std::list ListDocEntry; */ class GDCM_EXPORT SQItem : public DocEntrySet { + gdcmTypeMacro(SQItem); + public: - SQItem(int depthLevel); - ~SQItem(); + static SQItem *New(int depthLevel) {return new SQItem(depthLevel);} virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); void WriteContent(std::ofstream *fp, FileType filetype); @@ -71,6 +72,9 @@ public: void SetDepthLevel(int depth) { SQDepthLevel = depth; } protected: + SQItem(int depthLevel); + ~SQItem(); + // Variables that need to be accessed in subclasses /// \brief Chained list of Doc Entries ListDocEntry DocEntries; diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index c0647f9d..615863ef 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 16:00:48 $ - Version: $Revision: 1.59 $ + Date: $Date: 2005/10/25 14:52:35 $ + 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 @@ -116,6 +116,7 @@ void SeqEntry::AddSQItem(SQItem *sqItem, int itemNumber) // Or we can add (or remove) anywhere, and SQItemNumber will be broken sqItem->SetSQItemNumber(itemNumber); Items.push_back(sqItem); + sqItem->Register(); } /** @@ -125,7 +126,7 @@ void SeqEntry::ClearSQItem() { for(ListSQItem::iterator cc = Items.begin(); cc != Items.end(); ++cc) { - delete *cc; + (*cc)->Unregister(); } if (SeqTerm) { diff --git a/src/gdcmSerieHelper.cxx b/src/gdcmSerieHelper.cxx index f025fd03..c205856f 100644 --- a/src/gdcmSerieHelper.cxx +++ b/src/gdcmSerieHelper.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSerieHelper.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 12:40:03 $ - Version: $Revision: 1.29 $ + Date: $Date: 2005/10/25 14:52:35 $ + 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 @@ -68,7 +68,7 @@ void SerieHelper::ClearAll() it != l->end(); ++it) { - delete *it; // remove each entry + (*it)->Delete(); // remove each entry } l->clear(); delete l; // remove the container @@ -88,7 +88,7 @@ void SerieHelper::ClearAll() void SerieHelper::AddFileName(std::string const &filename) { // Create a DICOM file - File *header = new File (); + File *header = File::New(); header->SetLoadMode(LoadMode); header->SetFileName( filename ); header->Load(); @@ -139,13 +139,13 @@ void SerieHelper::AddFileName(std::string const &filename) else { // at least one rule was unmatched we need to deallocate the file: - delete header; + header->Delete(); } } else { gdcmWarningMacro("Could not read file: " << filename ); - delete header; + header->Delete(); } } diff --git a/src/gdcmTS.h b/src/gdcmTS.h index d89e4d5e..8a5e3408 100644 --- a/src/gdcmTS.h +++ b/src/gdcmTS.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmTS.h,v $ Language: C++ - Date: $Date: 2005/10/18 10:43:32 $ - Version: $Revision: 1.21 $ + Date: $Date: 2005/10/25 14:52:35 $ + 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 @@ -19,7 +19,7 @@ #ifndef GDCMTS_H #define GDCMTS_H -#include "gdcmCommon.h" +#include "gdcmRefCounter.h" #include #include @@ -38,34 +38,35 @@ typedef std::map TSHT; // Transfer Syntax Hash Table * \brief Container for dicom 'Transfer Syntax' Hash Table * \note This is a singleton */ -class GDCM_EXPORT TS +class GDCM_EXPORT TS : public RefCounter { + gdcmTypeMacro(TS); + public: -enum SpecialType { - ImplicitVRLittleEndian = 0, - ImplicitVRBigEndianPrivateGE, - ExplicitVRLittleEndian, - DeflatedExplicitVRLittleEndian, - ExplicitVRBigEndian, - JPEGBaselineProcess1, - JPEGExtendedProcess2_4, - JPEGExtendedProcess3_5, - JPEGSpectralSelectionProcess6_8, - JPEGFullProgressionProcess10_12, - JPEGLosslessProcess14, - JPEGLosslessProcess14_1, - JPEGLSLossless, - JPEGLSNearLossless, - JPEG2000Lossless, - JPEG2000, - RLELossless, - MPEG2MainProfile, - UnknownTS -}; + enum SpecialType { + ImplicitVRLittleEndian = 0, + ImplicitVRBigEndianPrivateGE, + ExplicitVRLittleEndian, + DeflatedExplicitVRLittleEndian, + ExplicitVRBigEndian, + JPEGBaselineProcess1, + JPEGExtendedProcess2_4, + JPEGExtendedProcess3_5, + JPEGSpectralSelectionProcess6_8, + JPEGFullProgressionProcess10_12, + JPEGLosslessProcess14, + JPEGLosslessProcess14_1, + JPEGLSLossless, + JPEGLSNearLossless, + JPEG2000Lossless, + JPEG2000, + RLELossless, + MPEG2MainProfile, + UnknownTS + }; public: - TS(); - ~TS(); + static TS *New() {return new TS();} void Print(std::ostream &os = std::cout); @@ -84,6 +85,10 @@ public: SpecialType GetSpecialTransferSyntax(TSKey const &key); const char* GetSpecialTransferSyntax(SpecialType t); +protected: + TS(); + ~TS(); + private: TSHT TsMap; }; diff --git a/src/gdcmVR.h b/src/gdcmVR.h index 399884c2..7a2af7b5 100644 --- a/src/gdcmVR.h +++ b/src/gdcmVR.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmVR.h,v $ Language: C++ - Date: $Date: 2005/10/23 14:56:27 $ - Version: $Revision: 1.24 $ + Date: $Date: 2005/10/25 14:52:35 $ + 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 @@ -19,7 +19,7 @@ #ifndef GDCMVR_H #define GDCMVR_H -#include "gdcmCommon.h" +#include "gdcmRefCounter.h" #include "gdcmVRKey.h" #include @@ -39,11 +39,12 @@ typedef std::map VRHT; * \brief Container for dicom Value Representation Hash Table * \note This is a singleton */ -class GDCM_EXPORT VR +class GDCM_EXPORT VR : public RefCounter { + gdcmTypeMacro(VR); + public: - VR(void); - ~VR(); + static VR *New() {return new VR();} void Print(std::ostream &os = std::cout); @@ -67,6 +68,10 @@ public: unsigned short GetAtomicElementLength(VRKey const &tested); +protected: + VR(); + ~VR(); + private: VRHT vr; }; diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index a503fcb1..24e3f929 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmReader.cxx,v $ Language: C++ - Date: $Date: 2005/09/20 08:50:57 $ - Version: $Revision: 1.84 $ + Date: $Date: 2005/10/25 14:52:37 $ + Version: $Revision: 1.85 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -69,7 +69,7 @@ #include #include -vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.84 $") +vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.85 $") vtkStandardNewMacro(vtkGdcmReader) //----------------------------------------------------------------------------- @@ -452,7 +452,7 @@ void vtkGdcmReader::LoadFileInformation() fclose(fp); // Read the file - file=new gdcm::File(); + file=gdcm::File::New(); file->SetLoadMode( LoadMode ); file->SetFileName(filename->c_str() ); file->Load(); @@ -463,7 +463,7 @@ void vtkGdcmReader::LoadFileInformation() vtkErrorMacro(<< "Gdcm cannot parse file " << filename->c_str()); vtkErrorMacro(<< "Removing this file from read files: " << filename->c_str()); - delete file; + file->Delete(); file=NULL; InternalFileList.push_back(file); continue; @@ -479,7 +479,7 @@ void vtkGdcmReader::LoadFileInformation() << " File type found : " << type.c_str() << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n" << " Removing this file from read files"); - delete file; + file->Delete(); file=NULL; InternalFileList.push_back(file); continue; @@ -499,7 +499,7 @@ void vtkGdcmReader::LoadFileInformation() } else if(!TestFileInformation(file)) { - delete file; + file->Delete(); file=NULL; } @@ -681,7 +681,7 @@ void vtkGdcmReader::RemoveAllInternalFile(void) it!=InternalFileList.end(); ++it) { - delete (*it); + (*it)->Delete(); } } this->InternalFileList.clear(); @@ -741,7 +741,7 @@ void vtkGdcmReader::LoadImageInMemory( if(!f) return; - gdcm::FileHelper *fileH = new gdcm::FileHelper( f ); + gdcm::FileHelper *fileH = gdcm::FileHelper::New( f ); fileH->SetUserFunction( UserFunction ); int numColumns = f->GetXSize(); @@ -821,7 +821,7 @@ void vtkGdcmReader::LoadImageInMemory( dst += 2 * planeSize; } - delete fileH; + fileH->Delete(); } //----------------------------------------------------------------------------- diff --git a/vtk/vtkGdcmWriter.cxx b/vtk/vtkGdcmWriter.cxx index e5b3b519..333be8f2 100644 --- a/vtk/vtkGdcmWriter.cxx +++ b/vtk/vtkGdcmWriter.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmWriter.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:55 $ - Version: $Revision: 1.25 $ + Date: $Date: 2005/10/25 14:52:37 $ + 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 @@ -31,7 +31,7 @@ #define vtkFloatingPointType float #endif -vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.25 $") +vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.26 $") vtkStandardNewMacro(vtkGdcmWriter) //----------------------------------------------------------------------------- @@ -332,7 +332,7 @@ void vtkGdcmWriter::RecursiveWrite(int axis, vtkImageData *cache, void vtkGdcmWriter::WriteDcmFile(char *fileName, vtkImageData *image) { // From here, the write of the file begins - gdcm::FileHelper *dcmFile = new gdcm::FileHelper(); + gdcm::FileHelper *dcmFile = gdcm::FileHelper::New(); // Set the image informations SetImageInformation(dcmFile, image); @@ -367,7 +367,7 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName, vtkImageData *image) { delete[] dcmFile->GetUserData(); } - delete dcmFile; + dcmFile->Delete(); } //----------------------------------------------------------------------------- -- 2.45.1