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