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