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