X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestBuildUpDicomDir.cxx;h=64efd4b0e89217b6f6856c06d88911ab061cd81e;hb=7fd1222c03038e650429f10a908d8dfac8b9c462;hp=f191a9c8d08bb84f46532a26ddfac286aab005ba;hpb=b19adc9e0168b80e420811c89a93dc114493033c;p=gdcm.git diff --git a/Testing/TestBuildUpDicomDir.cxx b/Testing/TestBuildUpDicomDir.cxx index f191a9c8..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/02/02 10:41:10 $ - Version: $Revision: 1.1 $ + 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 @@ -37,13 +37,14 @@ int TestBuildUpDicomDir(int argc, char *argv[]) { if (argc) { - std::cerr << "Usage: " << argv[0] << " dummy "; + std::cerr << "Usage: " << argv[0] << " dummy " << std::endl; } + bool errorFound = false; gdcm::DicomDir *dcmdir; std::string dirName; - dcmdir = new gdcm::DicomDir(); + dcmdir = gdcm::DicomDir::New(); gdcm::DicomDirPatient *p1; // --- Forget these 4 lines : @@ -57,7 +58,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) // Create patient ONE // ------------------ p1 = dcmdir->NewPatient(); - p1->SetValEntry("patientONE",0x0010, 0x0010); + p1->SetEntryString("patientONE",0x0010, 0x0010); // fill here other patient characteristics gdcm::DicomDirStudy *s11; @@ -71,19 +72,19 @@ int TestBuildUpDicomDir(int argc, char *argv[]) // Let's create and add a Study for this Patient s11 = p1->NewStudy(); - s11->SetValEntry("StudyDescrOne.One_",0x0008, 0x1030); + s11->SetEntryString("StudyDescrOne.One_",0x0008, 0x1030); // we know entry (0008,1060) is not yet created - s11->InsertValEntry("Dr Mabuse", 0x0008, 0x1060); + s11->InsertEntryString("Dr Mabuse", 0x0008, 0x1060); // fill here other Study characteristics gdcm::DicomDirStudy *s12 = p1->NewStudy(); - s12->SetValEntry("StudyDescrOne.Two",0x0008, 0x1030); - s12->InsertValEntry("Dr Zorglub", 0x0008, 0x1060); + s12->SetEntryString("StudyDescrOne.Two",0x0008, 0x1030); + s12->InsertEntryString("Dr Zorglub", 0x0008, 0x1060); // fill here other Study characteristics gdcm::DicomDirStudy *s13 = p1->NewStudy(); - s13->SetValEntry("StudyDescrOne.Tree",0x0008, 0x1030); - s13->InsertValEntry("Dr Follamour", 0x0008, 0x1060); + s13->SetEntryString("StudyDescrOne.Tree",0x0008, 0x1030); + s13->InsertEntryString("Dr Follamour", 0x0008, 0x1060); // fill here other Study characteristics gdcm::DicomDirSerie *s111; @@ -97,7 +98,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) // Let's create and add a Serie for this Study s111 = s11->NewSerie(); - s111->SetValEntry("01-01-111", 0x0008, 0x0021); + s111->SetEntryString("01-01-111", 0x0008, 0x0021); // fill here other Serie characteristics gdcm::DicomDirImage *s1111; @@ -112,47 +113,47 @@ int TestBuildUpDicomDir(int argc, char *argv[]) // Let's create and add a Image for this Serie s1111 = s111->NewImage(); - s1111->SetValEntry("imageFileName1111",0x0004,0x1500); + s1111->SetEntryString("imageFileName1111",0x0004,0x1500); gdcm::DicomDirImage *s1112 = s111->NewImage(); - s1112->SetValEntry("imageFileName1112",0x0004,0x1500); + s1112->SetEntryString("imageFileName1112",0x0004,0x1500); // Create patient TWO // ------------------ gdcm::DicomDirPatient *p2 = dcmdir->NewPatient(); - p2->SetValEntry("patientTWO",0x0010, 0x0010); + p2->SetEntryString("patientTWO",0x0010, 0x0010); // fill here other patient characteristics gdcm::DicomDirStudy *s21 = p2->NewStudy(); - s21->SetValEntry("StudyDescrTwo.One",0x0008, 0x1030); + s21->SetEntryString("StudyDescrTwo.One",0x0008, 0x1030); // fill here other Study characteristics gdcm::DicomDirSerie *s211 = s21->NewSerie(); - s111->SetValEntry("01-01-211", 0x0008, 0x0021); + s111->SetEntryString("01-01-211", 0x0008, 0x0021); // fill here other Serie characteristics gdcm::DicomDirImage *s2111 = s211->NewImage(); - s2111->SetValEntry("imageFileName2111",0x0004,0x1500); + s2111->SetEntryString("imageFileName2111",0x0004,0x1500); // fill here other Image characteristics gdcm::DicomDirImage *s2112 = s211->NewImage(); - s2112->SetValEntry("imageFileName1122",0x0004,0x1500); + s2112->SetEntryString("imageFileName1122",0x0004,0x1500); // fill here other Image characteristics // Create patient TREE // ------------------- gdcm::DicomDirPatient *p3 = dcmdir->NewPatient(); - p3->SetValEntry("patientTHREE",0x0010, 0x0010); + p3->SetEntryString("patientTHREE",0x0010, 0x0010); // fill here other Patient characteristics // Add a new Serie/Image for a Patient's Study created a long time ago // ------------------------------------------------------------------- gdcm::DicomDirSerie *s131 = s13->NewSerie(); - s111->SetValEntry("01-01-131", 0x0008, 0x0021); + s111->SetEntryString("01-01-131", 0x0008, 0x0021); // fill here other Serie characteristics gdcm::DicomDirImage *s1311 = s131->NewImage(); - s1311->SetValEntry("imageFileName1311",0x0004,0x1500); + s1311->SetEntryString("imageFileName1311",0x0004,0x1500); // fill here other Image characteristics // Print @@ -170,7 +171,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) <<" is not readable"<Delete(); return 1; } @@ -181,18 +182,21 @@ int TestBuildUpDicomDir(int argc, char *argv[]) dcmdir->Print(); // Write it on disc - dcmdir->WriteDicomDir("NewDICOMDIR"); - delete dcmdir; + dcmdir->Write("NewDICOMDIR"); + + dcmdir->Delete(); // Read the newly written DicomDir - gdcm::DicomDir *newDicomDir = new gdcm::DicomDir("NewDICOMDIR"); + gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New(); + newDicomDir->SetFileName("NewDICOMDIR"); + newDicomDir->Load( ); if( !newDicomDir->IsReadable() ) { std::cout<<" Written DicomDir 'NewDICOMDIR'" <<" is not readable"<Delete(); return 1; } // Check some value we are sure @@ -204,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; } @@ -212,20 +216,19 @@ int TestBuildUpDicomDir(int argc, char *argv[]) << "----------Final Check ---------------------" <GetEntryValue(0x0010, 0x0010) != "patientONE" ) + if ( p1->GetEntryString(0x0010, 0x0010) != "patientONE" ) { std::cout << "0x0010,0x0010 [" - << p1->GetEntryValue(0x0010, 0x0010) + << p1->GetEntryString(0x0010, 0x0010) << "]" << std::endl; errorFound = true; break; } std::cout << "Patient : [" - << p1->GetEntryValue(0x0010, 0x0010) + << p1->GetEntryString(0x0010, 0x0010) << "]" << std::endl; if ( !(s11 = p1->GetFirstStudy()) ) @@ -234,7 +237,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) errorFound = true; break; } - valueStuff = s11->GetEntryValue(0x0008, 0x1030); + valueStuff = s11->GetEntryString(0x0008, 0x1030); if ( valueStuff.find("StudyDescrOne.One_") >= valueStuff.length() ) { std::cout << "1 : 0x0008,0x1030 [" @@ -247,11 +250,11 @@ int TestBuildUpDicomDir(int argc, char *argv[]) << valueStuff << "]" << std::endl; - valueStuff = s11->GetEntryValue(0x0008, 0x1060); + valueStuff = s11->GetEntryString(0x0008, 0x1060); if (!gdcm::Util::DicomStringEqual(valueStuff, "Dr Mabuse") ) { std::cout << "2 : 0x0008,0x1060 [" - << s11->GetEntryValue(0x0008,0x1060) + << s11->GetEntryString(0x0008,0x1060) << "]" << std::endl; errorFound = true; break; @@ -259,43 +262,43 @@ int TestBuildUpDicomDir(int argc, char *argv[]) std::cout << "Pysician : [" << valueStuff << "]" << std::endl; - if ( !(s12 = p1->GetNextStudy()) ) + if ( (s12 = p1->GetNextStudy()) == 0 ) { errorFound = true; break; } - if ( gdcm::Util::DicomStringEqual(s12->GetEntryValue(0x0008, + if ( gdcm::Util::DicomStringEqual(s12->GetEntryString(0x0008, 0x1030),"StudyDescrOne.Two " )) { std::cout << "3 0x0008,0x1030 [" - << s12->GetEntryValue(0x0008,0x1030) + << s12->GetEntryString(0x0008,0x1030) << "]" << std::endl; errorFound = true; break; } std::cout << "Study Descr : [" - << s12->GetEntryValue(0x0008,0x1030) + << s12->GetEntryString(0x0008,0x1030) << "]" << std::endl; - if ( gdcm::Util::DicomStringEqual(s12->GetEntryValue(0x0008, + if ( gdcm::Util::DicomStringEqual(s12->GetEntryString(0x0008, 0x1060),"Dr Zorglub " )) { std::cout << "4 0x0008,0x1060 [" - << s12->GetEntryValue(0x0008,0x1060) + << s12->GetEntryString(0x0008,0x1060) << "]" << std::endl; errorFound = true; break; } std::cout << "Pysician : [" - << s12->GetEntryValue(0x0008,0x1060) + << s12->GetEntryString(0x0008,0x1060) << "]" << std::endl; - if ( !(s13 = p1->GetNextStudy()) ) + if ( (s13 = p1->GetNextStudy()) == 0 ) { std::cout << "Study StudyDescrOne.Tree missing" << std::endl; break; } - if ( s13->GetEntryValue(0x0008, 0x1030) != "StudyDescrOne.Tree" ) + if ( s13->GetEntryString(0x0008, 0x1030) != "StudyDescrOne.Tree" ) { errorFound = true; break; @@ -304,7 +307,7 @@ int TestBuildUpDicomDir(int argc, char *argv[]) << valueStuff << "]" << std::endl; - valueStuff = s13->GetEntryValue(0x0008, 0x1060); + valueStuff = s13->GetEntryString(0x0008, 0x1060); if (!gdcm::Util::DicomStringEqual(valueStuff, "Dr Follamour") ) { std::cout << "5 0x0008,0x1060 [" @@ -317,14 +320,14 @@ int TestBuildUpDicomDir(int argc, char *argv[]) << valueStuff << "]" << std::endl; - if (!(s111 = s11->GetFirstSerie()) ) + if ((s111 = s11->GetFirstSerie()) == 0 ) { std::cout << "Serie 01-01-111 missing" << std::endl; errorFound = true; break; } - valueStuff = s111->GetEntryValue(0x0008, 0x0021); + valueStuff = s111->GetEntryString(0x0008, 0x0021); if (!gdcm::Util::DicomStringEqual(valueStuff, "01-01-131") ) { std::cout << "6 0x0008,0x0021 [" @@ -337,43 +340,30 @@ int TestBuildUpDicomDir(int argc, char *argv[]) << valueStuff << "]" << std::endl; - if ( !(s1111 = s111->GetFirstImage()) ) + if ( (s1111 = s111->GetFirstImage()) == 0 ) { std::cout << "missing image S1111" << std::endl; errorFound = true; break; } -/* - if ( s1111->GetEntryValue(0x0004,0x1500) != "imageFileName1111 " ) - { - errorFound = true; - break; - } -*/ - if ( !(s1112 = s111->GetNextImage()) ) + + if ( (s1112 = s111->GetNextImage()) == 0 ) { std::cout << "missing image S1112" << std::endl; errorFound = true; break; } -/* - if ( s1112->GetEntryValue(0x0004,0x1500) != "imageFileName1112 " ) - { - errorFound = true; - break; - } - */ - break; // No error found. Stop looping + + break; // No error found. Stop looping } - delete newDicomDir; if ( errorFound ) { std::cout << "MissWritting / MissReading " << std::endl; - std::cout<Delete(); + + return errorFound; }