1 /*=========================================================================
4 Module: $RCSfile: FindTags.cxx,v $
6 Date: $Date: 2004/12/03 20:43:36 $
7 Version: $Revision: 1.7 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmHeader.h"
23 #include <stdio.h> // for sscanf
25 int main(int argc, char* argv[])
27 std::string toto, titi;
32 f1 = new gdcm::File(argv[1]);
34 toto = GDCM_DATA_ROOT;
36 f1 = new gdcm::File(toto);
39 std::string ManufacturerName="SIEMENS ";
40 std::string RecCode="ACR-NEMA 2.0";
41 std::string ImagePositionPatient, Location, ImageLocation;
47 int dataSize = f1->GetImageDataSize();
48 std::cout << "---> pourFindTaggs : dataSize " << dataSize << std::endl;
50 f1->SetEntryByNumber(RecCode ,0x0008,0x0010);
51 f1->SetEntryByNumber(ManufacturerName ,0x0008,0x0070);
53 // ImagePositionPatient
54 ImagePositionPatient = f1->GetHeader()->GetEntryByNumber(0x0020,0x0032);
56 // Image Position (RET)
57 f1->SetEntryByNumber(ImagePositionPatient, 0x0020,0x0030);
59 sscanf(ImagePositionPatient.c_str(), "%f%c%f%c%f", &x,&c,&y,&c,&z);
61 // ceci est probablement une mauvaise idée !
62 // (peut casser l'ordre des images si la pile d'images
63 // traverse l'axe des X, ou des Y, ou des Z)
64 //l=sqrt(x*x + y*y + z*z);
66 // ceci ne marchera pas si on se déplace à Z constant :-(
68 // existerait-il qq chose qui marche à tout coup?
71 std::string zizi = gdcm::Util::Format("%f",l);
72 Location = gdcm::Util::DicomString(zizi.c_str());
73 f1->SetEntryByNumber(Location, 0x0020,0x0050);
75 // sinon, la longueur du champ est erronée (?!?)
76 // Probable sac de noeud entre strlen(xxx.c_str()) et xxx.length()
79 // SetEntryLengthByNumber is private now.
80 //TO DO : see is the pb goes on...
82 //f1->GetHeader()->SetEntryLengthByNumber(strlen(Location.c_str())-1, 0x0020,0x0050);
86 zizi = gdcm::Util::Format("%d",0x7FE0);
87 ImageLocation = gdcm::Util::DicomString(zizi.c_str());
88 //f1->SetEntryByNumber(Location, 0x0028,0x0200);
89 //f1->GetHeader()->SetEntryLengthByNumber(strlen(ImageLocation.c_str())-1, 0x0020,0x0050); // prudence !
91 // void* imageData= f1->GetImageData();
93 // ecriture d'un fichier ACR à partir d'un dcmHeader correct.
95 std::cout << "----------------avant PrintEntry---------------------" << std::endl;
96 f1->GetHeader()->Print();
97 std::cout << "----------------avant WriteDcm---------------------" << std::endl;
100 // ecriture d'un fichier ACR à partir d'un dcmHeader correct.
102 zozo = toto + ".acr";
103 std::cout << "WriteACR" << std::endl;
106 std::cout << "----------------apres Write---------------------" << std::endl;