5 int main(int argc, char* argv[])
14 //gdcmDocument * d; //not used
19 std::cerr << "usage: " << std::endl
20 << argv[0] << " fileName writtingMode "
22 << "(a : ACR, d : DICOM Implicit VR,"
23 << " x : DICOM Explicit VR r : RAW)"
28 if (0) { // Just to keep the code for further use
29 std::cout <<std::endl << "-------- Test gdcmHeader ------" <<std::endl;
30 e1 = new gdcmHeaderHelper(argv[1]);
31 if (!f1->GetHeader()->IsReadable()) {
32 std::cout << "Sorry, not a DICOM / ACR File" <<std::endl;
35 std::cout << std::endl << "----------------------> after new gdcmHeader"
38 std::cout <<std::endl <<"---------------------------------------"
43 std::cout << std::endl
44 << "--------------------- file :" << argv[1]
49 e1 = new gdcmHeader( toto.c_str() );
50 if (!e1->IsReadable())
52 std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
57 f1 = new gdcmFile(e1);
60 dataSize = f1->GetImageDataSize();
61 std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
62 int nX,nY,nZ,sPP,planarConfig;
63 std::string pixelType, transferSyntaxName;
67 std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
69 pixelType = e1->GetPixelType();
70 sPP = e1->GetSamplesPerPixel();
71 planarConfig = e1->GetPlanarConfiguration();
73 std::cout << " pixelType=" << pixelType
74 << " SampleserPixel=" << sPP
75 << " PlanarConfiguration=" << planarConfig
76 << " PhotometricInterpretation="
77 << e1->GetEntryByNumber(0x0028,0x0004)
80 int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
81 std::cout << "NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
82 transferSyntaxName = e1->GetTransfertSyntaxName();
83 std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
85 if ( transferSyntaxName != "Implicit VR - Little Endian"
86 && transferSyntaxName != "Explicit VR - Little Endian"
87 && transferSyntaxName != "Deflated Explicit VR - Little Endian"
88 && transferSyntaxName != "Explicit VR - Big Endian"
89 && transferSyntaxName != "Uncompressed ACR-NEMA" ) {
90 std::cout << std::endl << "==========================================="
93 std::cout << std::endl << "==========================================="
96 imageData= f1->GetImageData();
100 // ecriture d'un fichier ACR
101 // à partir d'un dcmHeader correct.
103 sprintf(zozo, "%s.ACR", toto.c_str());
104 printf ("WriteACR\n");
109 // ecriture d'un fichier DICOM Implicit VR
110 // à partir d'un dcmHeader correct.
112 sprintf(zozo, "%s.DCM", toto.c_str());
113 printf ("WriteDCM Implicit VR\n");
114 f1->WriteDcmImplVR(zozo);
118 // ecriture d'un fichier DICOM Explicit VR
119 // à partir d'un dcmHeader correct.
121 sprintf(zozo, "%s.XDCM", toto.c_str());
122 std::cout << "WriteDCM Explicit VR" << std::endl;
123 f1->WriteDcmExplVR(zozo);
127 // Ecriture d'un Raw File, a afficher avec
128 // affim filein= dimx= dimy= nbit= signe=
130 sprintf(zozo, "%s.RAW", toto.c_str());
131 std::cout << "WriteRaw" << std::endl;
132 f1->WriteRawData(zozo);