]> Creatis software - gdcm.git/blob - Example/FindTags.cxx
ENH: gdcm now compiles on borland
[gdcm.git] / Example / FindTags.cxx
1 #include <iostream>
2 #include "gdcm.h"
3 #include "math.h"
4 #include <stdio.h>
5
6 int main(int argc, char* argv[]) {  
7
8    std::string toto, titi;
9
10    gdcm::File  * f1;
11
12    if(argc > 1 )
13       f1 = new gdcm::File(argv[1]);
14    else  {
15       toto = GDCM_DATA_ROOT;
16       toto += "/test.acr";
17       f1 = new gdcm::File(toto);
18    }
19
20    std::string ManufacturerName="SIEMENS ";
21    std::string RecCode="ACR-NEMA 2.0";
22    std::string ImagePositionPatient, Location, ImageLocation;
23    char zozo[100], zizi[50];
24    char c;
25
26    float x, y, z, l;
27
28    int dataSize = f1->GetImageDataSize();
29    printf ("---> pourFindTaggs : dataSize %d\n",dataSize);
30
31    f1->SetEntryByNumber(RecCode ,0x0008,0x0010);
32    f1->SetEntryByNumber(ManufacturerName ,0x0008,0x0070);
33
34 // ImagePositionPatient
35    ImagePositionPatient = f1->GetHeader()->GetEntryByNumber(0x0020,0x0032);
36
37 // Image Position (RET)
38    f1->SetEntryByNumber(ImagePositionPatient, 0x0020,0x0030);
39
40    sscanf(ImagePositionPatient.c_str(), "%f%c%f%c%f", &x,&c,&y,&c,&z);
41
42 // ceci est probablement une mauvaise idée !
43 // (peut casser l'ordre des images si la pile d'images 
44 // traverse l'axe des X, ou des Y, ou des Z)
45 //l=sqrt(x*x + y*y + z*z);
46
47 // ceci ne marchera pas si on se déplace à Z constant :-(
48    l=z;
49 // existerait-il qq chose qui marche à tout coup?
50
51 // Location
52    sprintf(zizi,"%f\n",l);
53    Location = zizi;
54    f1->SetEntryByNumber(Location, 0x0020,0x0050);
55
56 // sinon, la longueur du champ est erronée (?!?) 
57 // Probable sac de noeud entre strlen(xxx.c_str()) et xxx.length()
58 // a eclaircir !
59
60 // SetEntryLengthByNumber is private now.
61 //TO DO : see is the pb goes on...
62
63 //f1->GetHeader()->SetEntryLengthByNumber(strlen(Location.c_str())-1, 0x0020,0x0050);
64
65 // Image Location 
66
67    sprintf(zizi,"%d\n",0x7FE0);
68    ImageLocation = zizi;
69 //f1->SetEntryByNumber(Location, 0x0028,0x0200);
70 //f1->GetHeader()->SetEntryLengthByNumber(strlen(ImageLocation.c_str())-1, 0x0020,0x0050); // prudence !
71
72 // void* imageData= f1->GetImageData();
73
74 // ecriture d'un fichier ACR à partir d'un dcmHeader correct.
75
76    printf ("----------------avant PrintEntry---------------------\n");
77    f1->GetHeader()->Print();
78    printf ("----------------avant WriteDcm---------------------\n");
79
80
81 // ecriture d'un fichier ACR à partir d'un dcmHeader correct.
82
83    sprintf(zozo, "%s.acr", toto.c_str());
84    printf ("WriteACR\n");
85    f1->WriteAcr(zozo);
86
87    printf ("----------------apres Write---------------------\n");
88
89   return 0;
90 }
91
92
93