]> Creatis software - gdcm.git/blob - Example/PrintFile.cxx
cafceb7067522b6b57a7f297608a1bea9f43c8e7
[gdcm.git] / Example / PrintFile.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintFile.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/19 15:26:42 $
7   Version:   $Revision: 1.22 $
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 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    if (argc > 3)
46       gdcm::Debug::SetDebugOn();
47    
48    e1= new gdcm::Header( fileName.c_str() );
49    f1 = new gdcm::File(e1);
50
51    if (argc > 2) 
52    {
53       int level = atoi(argv[2]);   
54       e1->SetPrintLevel(level);
55    }
56
57    e1->Print();   
58
59    std::cout << "\n\n" << std::endl; 
60
61    std::cout <<std::endl;
62    std::cout <<" dataSize " << f1->GetImageDataSize() << std::endl;
63    std::cout <<" dataSizeRaw " << f1->GetImageDataRawSize() << std::endl;
64
65    int nX,nY,nZ,sPP,planarConfig;
66    std::string pixelType;
67    nX=e1->GetXSize();
68    nY=e1->GetYSize();
69    nZ=e1->GetZSize();
70    std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
71
72    pixelType    = e1->GetPixelType();
73    sPP          = e1->GetSamplesPerPixel();
74    planarConfig = e1->GetPlanarConfiguration();
75    
76    std::cout << " pixelType= ["           << pixelType 
77              << "] SamplesPerPixel= ["     << sPP
78              << "] PlanarConfiguration= [" << planarConfig 
79              << "] "<< std::endl 
80              << " PhotometricInterpretation= [" 
81                                 << e1->GetEntry(0x0028,0x0004)
82              << "] "<< std::endl;
83
84    int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
85    std::cout << " NumberOfScalarComponents = " << numberOfScalarComponents <<std::endl
86              << " LUT = " << (e1->HasLUT() ? "TRUE" : "FALSE")
87              << std::endl;
88
89   
90    if ( e1->GetEntry(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) 
91    {
92       std::cout << "Transfer Syntax not loaded. " << std::endl
93                 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
94                 << std::endl;
95       return 0;
96    }
97   
98    std::string transferSyntaxName = e1->GetTransferSyntaxName();
99    std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
100    std::cout << " SwapCode= " << e1->GetSwapCode() << std::endl;
101    
102    if(e1->IsReadable())
103       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
104    else
105       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
106    std::cout<<std::flush;
107    delete e1;
108
109    return 0;
110    
111 }