Program: gdcm
Module: $RCSfile: TestDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:46 $
- Version: $Revision: 1.41 $
+ Date: $Date: 2007/04/12 13:06:02 $
+ Version: $Revision: 1.45 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <iostream>
#include <fstream>
+#include <stdlib.h>
+
// check *all* the dicom elements (gdcm::DocEntry)
// of this gdcm::DicomDirObject
int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 )
((gdcm::DataEntry *)e2)->GetString() )
{
+ /// \todo : check the value *written on disc*, not the value converted as a std::string
+ /// (this comparison doesn't make the difference between Ox(ff) and "255" ...)
+
// serious trouble : values differ in source and destination file
std::cout << "for gdcm DicomDir element (" << std::hex
<< e2->GetGroup() << "," <<e2->GetElement()
file += "/DICOMDIR";
}
- dicomdir = new gdcm::DicomDir( );
+ std::cout << "DicomDir we're going to deal with : ["<< file << "]"
+ << std::endl;
+
+ dicomdir = gdcm::DicomDir::New();
dicomdir->SetFileName(file);
- dicomdir->Load( );
+ dicomdir->Load();
if (argc > 2)
{
int level = atoi(argv[2]);
dicomdir->SetPrintLevel(level);
}
- // Test if the DicomDir is readable
+ // Test if the DICOMDIR file is readable
if( !dicomdir->IsReadable() )
{
std::cout<<" DicomDir '"<<file
<<"' is not readable"<<std::endl
<<" ...Failed"<<std::endl;
- delete dicomdir;
+ dicomdir->Delete();
return 1;
}
else
<<"' is readable"<<std::endl;
}
- // Test if the DicomDir contains any patient
+ // Test if the gdcm::DicomDir contains any patient
if( !dicomdir->GetFirstPatient() )
{
std::cout<<" DicomDir '"<<file
<<" has no patient"<<std::endl
<<" ...Failed"<<std::endl;
- delete dicomdir;
+ dicomdir->Delete();
return 1;
}
pa1 = dicomdir->GetFirstPatient();
while ( pa1 )
- { // we process all the PATIENT of this DICOMDIR
+ { // we process all the PATIENT of this gdcm::DicomDir
std::cout << pa1->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name
st1 = pa1->GetFirstStudy();
pa1 = dicomdir->GetNextPatient();
}
+/*
+// this one is *really* too much verbose!
+
std::cout << std::endl << std::endl
<< " = DICOMDIR full content ===================================="
<< std::endl<< std::endl;
- // dicomdir->Print();
-
+ dicomdir->Print();
+ std::cout << std::endl << std::endl
+ << " = end of DICOMDIR full content ===================================="
+ << std::endl<< std::endl;
+*/
// ------------------------- second stage ---------------------------
+
+
+ gdcm::Debug::DebugOn();
+
// Write on disc what we read
dicomdir->Write("NewDICOMDIR");
<< "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 ========================"
if (!d2)
{
std::cout << "NewDICOMDIR contains no Patient ?!?" << std::endl;
- delete dicomdir;
- delete d2;
+ dicomdir->Delete();
+ d2->Delete();
return 1;
}
if ( CompareSQItem(pa2,pa1) == 1 )
{
- delete dicomdir;
- delete d2;
+ dicomdir->Delete();
+ d2->Delete();
return 1;
}
{
if ( CompareSQItem(st2,st1) == 1 )
{
- delete dicomdir;
- delete d2;
+ dicomdir->Delete();
+ d2->Delete();
return 1;
}
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
{
if ( CompareSQItem(im2,im1) == 1 )
{
- delete dicomdir;
- delete d2;
+ dicomdir->Delete();
+ d2->Delete();
return 1;
}
}
std::cout << std::flush;
- delete dicomdir;
- delete d2;
+ dicomdir->Delete();
+ d2->Delete();
return 0;
}