]> Creatis software - gdcm.git/blob - Example/PrintFile.cxx
Normalization
[gdcm.git] / Example / PrintFile.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintFile.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/02/02 10:06:31 $
7   Version:   $Revision: 1.29 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18 #include "gdcmFile.h"
19 #include "gdcmDebug.h"
20 #include "gdcmFileHelper.h"
21
22 #include <iostream>
23
24 int main(int argc, char *argv[])
25 {
26    gdcm::File *e1;
27    gdcm::FileHelper   *f1;
28    std::string fileName;   
29    if (argc != 2) 
30    {
31       std::cout << " usage : PrintDocument fileName printLevel debug" 
32                 << std::endl;
33    }
34
35    if (argc > 1) 
36    {
37       fileName=argv[1];
38    } 
39    else 
40    {
41       fileName += GDCM_DATA_ROOT;
42       fileName += "/test.acr";
43    }
44
45
46    if (argc > 3)
47       gdcm::Debug::DebugOn();
48    
49    e1 = new gdcm::File( fileName.c_str() );
50    f1 = new gdcm::FileHelper(e1);
51
52    if (argc > 2) 
53    {
54       int level = atoi(argv[2]);   
55       f1->SetPrintLevel(level);
56    }
57
58    f1->Print();   
59
60    std::cout << "\n\n" << std::endl; 
61
62    std::cout <<std::endl;
63    std::cout <<" dataSize " << f1->GetImageDataSize() << std::endl;
64    std::cout <<" dataSizeRaw " << f1->GetImageDataRawSize() << std::endl;
65
66    int nX,nY,nZ,sPP,planarConfig;
67    std::string pixelType;
68    nX=e1->GetXSize();
69    nY=e1->GetYSize();
70    nZ=e1->GetZSize();
71    std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
72
73    pixelType    = e1->GetPixelType();
74    sPP          = e1->GetSamplesPerPixel();
75    planarConfig = e1->GetPlanarConfiguration();
76    
77    std::cout << " pixelType= ["           << pixelType 
78              << "] SamplesPerPixel= ["     << sPP
79              << "] PlanarConfiguration= [" << planarConfig 
80              << "] "<< std::endl 
81              << " PhotometricInterpretation= [" 
82                                 << e1->GetEntryValue(0x0028,0x0004)
83              << "] "<< std::endl;
84
85    int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
86    std::cout << " NumberOfScalarComponents = " << numberOfScalarComponents <<std::endl
87              << " LUT = " << (e1->HasLUT() ? "TRUE" : "FALSE")
88              << std::endl;
89
90   
91    if ( e1->GetEntryValue(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) 
92    {
93       std::cout << "Transfer Syntax not loaded. " << std::endl
94                 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
95                 << std::endl;
96       return 0;
97    }
98   
99    std::string transferSyntaxName = e1->GetTransferSyntaxName();
100    std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
101    std::cout << " SwapCode= " << e1->GetSwapCode() << std::endl;
102    
103    if(e1->IsReadable())
104       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
105    else
106       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
107    std::cout<<std::flush;
108    delete e1;
109
110    return 0;
111    
112 }