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