X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=Example%2FWriteDicom.cxx;h=684d6213db70848c63c086223bb3a05b4e9fde54;hb=d00078b5e19310b379c8339fa8fe38362e8ca392;hp=c8747dc3a3251abc7a6526d173aa4ba82427bae6;hpb=978f699b97794e209f9d20e2a33a72404bda54ef;p=gdcm.git diff --git a/Example/WriteDicom.cxx b/Example/WriteDicom.cxx index c8747dc3..684d6213 100644 --- a/Example/WriteDicom.cxx +++ b/Example/WriteDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicom.cxx,v $ Language: C++ - Date: $Date: 2004/11/16 04:26:18 $ - Version: $Revision: 1.7 $ + Date: $Date: 2005/01/20 16:16:58 $ + 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 @@ -15,7 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include "gdcm.h" +#include "gdcmHeader.h" +#include "gdcmFileHelper.h" // Writting of a DICOM file based on a correct dicom header // and data pixel of another image @@ -23,57 +24,56 @@ int main(int argc, char* argv[]) { - if (argc < 3) - { - std::cerr << "Usage :" << std::endl << argv[0] << - " HeaderFileName DataFileName" << std::endl; - return 0; - } - - const char *first = argv[1]; - gdcm::File *f1 = new gdcm::File( first ); - - const char *second = argv[2]; - gdcm::File *f2 = new gdcm::File( second ); - - // We assume that DICOM fields of second file actually exists : - - std::string nbFrames = f2->GetHeader()->GetEntryByNumber(0x0028, 0x0008); - if(nbFrames != "gdcm::Unfound") { - f1->GetHeader()->ReplaceOrCreateByNumber( nbFrames, 0x0028, 0x0008); - } - - f1->GetHeader()->ReplaceOrCreateByNumber( - f2->GetHeader()->GetEntryByNumber(0x0028, 0x0010), 0x0028, 0x0010); // nbLig - f1->GetHeader()->ReplaceOrCreateByNumber( - f2->GetHeader()->GetEntryByNumber(0x0028, 0x0011), 0x0028, 0x0011); // nbCol - - // Some other tags should be updated: - - // TODO : add a default value - // TODO : a function which take as input a list of tuple (gr, el) - // and that does the job - - int dataSize = f2->GetImageDataSize(); - uint8_t* imageData = f2->GetImageData(); - - std::cout << "dataSize :" << dataSize << std::endl; - - // TODO : Shouldn't we merge those two functions ? - f1->SetImageData( imageData, dataSize); - f1->GetHeader()->SetImageDataSize( dataSize ); - - f1->GetHeader()->Print(); - - std::string s0 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0000); - std::string s10 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0010); - - std::cout << "lgr 7fe0, 0000 " << s0 << std::endl; - std::cout << "lgr 7fe0, 0010 " << s10 << std::endl; - - std::cout << "WriteDCM" << std::endl; - - f1->WriteDcmExplVR("WriteDicom.dcm"); - - return 0; + if (argc < 3) + { + std::cerr << "Usage :" << std::endl << argv[0] << + " HeaderFileName DataFileName" << std::endl; + return 0; + } + + const char *first = argv[1]; + gdcm::FileHelper *f1 = new gdcm::FileHelper( first ); + + const char *second = argv[2]; + gdcm::FileHelper *f2 = new gdcm::FileHelper( second ); + + // We assume that DICOM fields of second file actually exists : + + std::string nbFrames = f2->GetHeader()->GetEntry(0x0028, 0x0008); + if(nbFrames != "gdcm::Unfound") { + f1->GetHeader()->ReplaceOrCreate( nbFrames, 0x0028, 0x0008); + } + + f1->GetHeader()->ReplaceOrCreate( + f2->GetHeader()->GetEntry(0x0028, 0x0010), 0x0028, 0x0010); // nbLig + f1->GetHeader()->ReplaceOrCreate( + f2->GetHeader()->GetEntry(0x0028, 0x0011), 0x0028, 0x0011); // nbCol + + // Some other tags should be updated: + + // TODO : add a default value + // TODO : a function which take as input a list of tuple (gr, el) + // and that does the job + + int dataSize = f2->GetImageDataSize(); + uint8_t* imageData = f2->GetImageData(); + + std::cout << "dataSize :" << dataSize << std::endl; + + // TODO : Shouldn't we merge those two functions ? + f1->SetImageData( imageData, dataSize); + + f1->GetHeader()->Print(); + + std::string s0 = f2->GetHeader()->GetEntry(0x7fe0, 0x0000); + std::string s10 = f2->GetHeader()->GetEntry(0x7fe0, 0x0010); + + std::cout << "lgr 7fe0, 0000 " << s0 << std::endl; + std::cout << "lgr 7fe0, 0010 " << s10 << std::endl; + + std::cout << "WriteDCM" << std::endl; + + f1->WriteDcmExplVR("WriteDicom.dcm"); + + return 0; }