+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: TestCopyDicom.cxx,v $
+ Language: C++
+ Date: $Date: 2004/11/17 10:20:06 $
+ 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
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
#include "gdcmHeader.h"
#include "gdcmFile.h"
#include "gdcmDocument.h"
#ifndef _WIN32
#include <unistd.h> //for access, unlink
+#else
+#include <io.h> //for _access on Win32
#endif
// return true if the file exists
// Here we load a gdcmFile and then try to create from scratch a copy of it,
// copying field by field the dicom image
-int TestCopyDicom(int argc, char* argv[])
+int TestCopyDicom(int , char* [])
{
int i =0;
int retVal = 0; //by default this is an error
}
}
- gdcmFile *original = new gdcmFile( filename );
- gdcmFile *copy = new gdcmFile( output );
+ gdcm::File *original = new gdcm::File( filename );
+ gdcm::File *copy = new gdcm::File( output );
- TagDocEntryHT & Ht = original->GetHeader()->GetEntry();
+ const gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetTagHT();
+
+ size_t dataSize = original->GetImageDataSize();
+ uint8_t* imageData = original->GetImageData();
//First of all copy the header field by field
// (the user does NOT have to know the way we implemented the Header !)
// Waiting for a 'clean' solution, I keep the method ...JPRx
- gdcmDocEntry* d;
+ gdcm::DocEntry* d;
- for (TagDocEntryHT::iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
+ for (gdcm::TagDocEntryHT::const_iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
{
d = tag->second;
- if ( gdcmBinEntry* b = dynamic_cast<gdcmBinEntry*>(d) )
- {
+ if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
+ {
copy->GetHeader()->ReplaceOrCreateByNumber(
- b->GetVoidArea(),
+ b->GetBinArea(),
b->GetLength(),
b->GetGroup(),
b->GetElement(),
b->GetVR() );
- }
- else if ( gdcmValEntry* v = dynamic_cast<gdcmValEntry*>(d) )
- {
- copy->GetHeader()->ReplaceOrCreateByNumber(
+ }
+ else if ( gdcm::ValEntry* v = dynamic_cast<gdcm::ValEntry*>(d) )
+ {
+ copy->GetHeader()->ReplaceOrCreateByNumber(
v->GetValue(),
v->GetGroup(),
v->GetElement(),
v->GetVR() );
- }
- else
- {
+ }
+ else
+ {
// We skip pb of SQ recursive exploration
//std::cout << "Skipped Sequence "
// << "------------- " << d->GetVR() << " "<< std::hex
// << d->GetGroup() << " " << d->GetElement()
// << std::endl;
- }
+ }
}
- size_t dataSize = original->GetImageDataSize();
- void *imageData = original->GetImageData();
-
- copy->SetImageData(imageData, dataSize);
+ // Useless to set the image datas, because it's already made when
+ // copying the corresponding BinEntry that contains the pixel datas
+ //copy->SetImageData(imageData, dataSize);
original->GetHeader()->SetImageDataSize(dataSize);
copy->WriteDcmExplVR( output );
delete original;
delete copy;
- copy = new gdcmFile( output );
+ copy = new gdcm::File( output );
//Is the file written still gdcm parsable ?
if ( !copy->GetHeader()->IsReadable() )