X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FexReadWriteFile.cxx;h=3d53160b1a63617565ff17c7c6b751b9f1723c39;hb=2e0fae6ec87d9ecb1b76b32d8242a4fba9afefd3;hp=c6d0bb2f52027bfe3b63a7cf100de761a7bec583;hpb=8c10737e97f1eff61304cfac871c54c3168f0cbc;p=gdcm.git diff --git a/Example/exReadWriteFile.cxx b/Example/exReadWriteFile.cxx index c6d0bb2f..3d53160b 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/02/09 14:00:41 $ - Version: $Revision: 1.2 $ + Date: $Date: 2007/05/23 14:18:05 $ + 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 @@ -19,10 +19,10 @@ #include "gdcmFile.h" #include "gdcmFileHelper.h" #include "gdcmDocument.h" -#include "gdcmValEntry.h" -#include "gdcmBinEntry.h" +#include "gdcmDataEntry.h" #include "gdcmSeqEntry.h" +#include // for exit int main(int argc, char *argv[]) { @@ -56,10 +56,12 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <SetFileName( filename ); + f1->Load(); // Ask content to be printed @@ -77,53 +79,44 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <GetFirstEntry(); + GDCM_NAME_SPACE::DocEntry *d = f1->GetFirstEntry(); while( d ) { // We skip SeqEntries, since user cannot do much with them - if ( !(dynamic_cast(d)) + if ( !(dynamic_cast(d)) // We skip Shadow Groups, since nobody knows what they mean - && !( d->GetGroup()%2 ) - // we skip BinEntries, since their content is not human-readable - && !dynamic_cast(d) ) + && !( d->GetGroup()%2 ) ) { // If user just 'wants to see' //d->Print(); //std::cout << std::endl; // If user wants to get info about the entry - // (he is sure, here that DocEntry is a ValEntry) - valEntry = dynamic_cast(d); + // (he is sure, here that DocEntry is a DataEntry) + dataEntry = dynamic_cast(d); // Let's be carefull -maybe he commented out some previous line- - if (!valEntry) + if (!dataEntry) continue; - value = valEntry->GetValue(); - group = valEntry->GetGroup(); - elem = valEntry->GetElement(); - vr = valEntry->GetVR(); + value = dataEntry->GetString(); + vr = dataEntry->GetVR(); // user wants really to know everything about entry! - vm = valEntry->GetVM(); - name = valEntry->GetName(); - offset = valEntry->GetOffset(); + vm = dataEntry->GetVM(); + name = dataEntry->GetName(); std::cout //<< std::hex << group << "," << elem - << valEntry->GetKey() - << " VR :[" << vr << "] VM : [" << vm + << dataEntry->GetKey() + << " VR :[" << vr << "] VM : [" << vm << "] name : [" << name << "]" << " value : [" << value << "]" - - << std::endl; + << std::endl; } d = f1->GetNextEntry(); } @@ -200,29 +193,32 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <GetEntryValue(0x0008,0x0070) + std::cout << "Manufacturer :[" << f1->GetEntryString(0x0008,0x0070) << "]" << std::endl; - std::cout << "Institution :[" << f1->GetEntryValue(0x0008,0x0080) + std::cout << "Institution :[" << f1->GetEntryString(0x0008,0x0080) << "]" << std::endl; - std::cout << "Patient's name :[" << f1->GetEntryValue(0x0010,0x0010) + std::cout << "Patient's name :[" << f1->GetEntryString(0x0010,0x0010) << "]" << std::endl; - std::cout << "Physician's name :[" << f1->GetEntryValue(0x0008,0x0090) + std::cout << "Physician's name :[" << f1->GetEntryString(0x0008,0x0090) << "]" << std::endl; - std::cout << "Study Date :[" << f1->GetEntryValue(0x0008,0x0020) + std::cout << "Study Date :[" << f1->GetEntryString(0x0008,0x0020) << "]" << std::endl; - std::cout << "Study inst UID :[" << f1->GetEntryValue(0x0020,0x000d) + std::cout << "Study inst UID :[" << f1->GetEntryString(0x0020,0x000d) << "]" << std::endl; - std::cout << "Serie inst UID :[" << f1->GetEntryValue(0x0020,0x000e) + std::cout << "Serie inst UID :[" << f1->GetEntryString(0x0020,0x000e) << "]" << std::endl; - std::cout << "Frame ref UID :[" << f1->GetEntryValue(0x0020,0x0052) + std::cout << "Frame ref UID :[" << f1->GetEntryString(0x0020,0x0052) << "]" << std::endl; + + // User wants to get info about the 'real world' vs image + // ------ User wants to load the pixels--------------------------------- // Hope now he knows enought about the image ;-) - // First, create a gdcm::FileHelper - gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1); + // First, create a GDCM_NAME_SPACE::FileHelper + GDCM_NAME_SPACE::FileHelper *fh1 = GDCM_NAME_SPACE::FileHelper::New(f1); // Load the pixels, transforms LUT (if any) into RGB Pixels uint8_t *imageData = fh1->GetImageData(); @@ -257,32 +253,28 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <SetFileName( output ); + copy->Load(); d = f1->GetFirstEntry(); while(d) { // We skip SeqEntries, since user cannot do much with them - if ( !(dynamic_cast(d)) + if ( !(dynamic_cast(d)) // We skip Shadow Groups, since nobody knows what they mean && !( d->GetGroup()%2 ) ) { - if ( gdcm::BinEntry *b = dynamic_cast(d) ) + if ( GDCM_NAME_SPACE::DataEntry *de = dynamic_cast(d) ) { - copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(), - b->GetGroup(),b->GetElement(), - b->GetVR() ); - } - else if ( gdcm::ValEntry *v = dynamic_cast(d) ) - { - copy->GetFile()->InsertValEntry( v->GetValue(), - v->GetGroup(),v->GetElement(), - v->GetVR() ); + copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(), + de->GetGroup(),de->GetElement(), + de->GetVR() ); } else { - // We skip gdcm::SeqEntries + // We skip GDCM_NAME_SPACE::SeqEntries } } d = f1->GetNextEntry(); @@ -331,9 +323,9 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <Delete(); + fh1->Delete(); + copy->Delete(); exit (0); }