X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FPrintFile.cxx;h=7fb53f008fb111d0c1794af753f7e66b0301c2b3;hb=1fe34ecf6db1977790024ac1a0a4ce5be010b9d8;hp=edc2957f83b8cdfba0665b2c501da0a9c0b51bcf;hpb=a12b9768f8dad74ef6b76c5c77b312ebab679625;p=gdcm.git diff --git a/Example/PrintFile.cxx b/Example/PrintFile.cxx index edc2957f..7fb53f00 100644 --- a/Example/PrintFile.cxx +++ b/Example/PrintFile.cxx @@ -1,36 +1,76 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: PrintFile.cxx,v $ + Language: C++ + Date: $Date: 2005/05/02 17:28:15 $ + Version: $Revision: 1.34 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "gdcmFile.h" +#include "gdcmDebug.h" +#include "gdcmFileHelper.h" + #include -#include "gdcm.h" -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - - gdcmHeader *e1; - gdcmFile *f1; - std::string fileName; - if (argc != 2) { - std::cout << " usage : PrintDocument fileName" << std::endl; + gdcm::File *e1; + gdcm::FileHelper *f1; + std::string fileName; + + if (argc == 1) + { + std::cout << " usage : PrintFile fileName printLevel debug " + << "short (=NOSEQ + NOSHADOW)" + << std::endl; + return 0; } - if (argc > 1) { + e1 = new gdcm::File(); + + if (argc > 1) + { fileName=argv[1]; - } else { - fileName += GDCM_DATA_ROOT; - fileName += "/test.acr"; + } + + if (argc > 3) + gdcm::Debug::DebugOn(); + + if (argc > 4) + e1->SetLoadMode(NO_SEQ | NO_SHADOW); + e1->Load( fileName.c_str() ); + + if ( !e1->IsReadable() ) + { + delete e1; + return 0; } - - e1= new gdcmHeader - (fileName.c_str(),false, true); - f1 = new gdcmFile(e1); + f1 = new gdcm::FileHelper(e1); + + if (argc > 2) // keep it here (f1 needs to be constructed !) + { + int level = atoi(argv[2]); + f1->SetPrintLevel(level); + } + + f1->Print(); - e1->SetPrintLevel(2); - - e1->Print(); - std::cout << "\n\n" << std::endl; - int dataSize = f1->GetImageDataSize(); - std::cout <GetImageDataSize() << std::endl; + std::cout <<" dataSizeRaw " << f1->GetImageDataRawSize() << std::endl; + int nX,nY,nZ,sPP,planarConfig; std::string pixelType; nX=e1->GetXSize(); @@ -42,32 +82,31 @@ int main(int argc, char* argv[]) sPP = e1->GetSamplesPerPixel(); planarConfig = e1->GetPlanarConfiguration(); - std::cout << " pixelType=" << pixelType - << " SampleserPixel=" << sPP - << " PlanarConfiguration=" << planarConfig - << std::endl - << " PhotometricInterpretation=" - << e1->GetEntryByNumber(0x0028,0x0004) - << std::endl; + std::cout << " pixelType= [" << pixelType + << "] SamplesPerPixel= [" << sPP + << "] PlanarConfiguration= [" << planarConfig + << "] "<< std::endl + << " PhotometricInterpretation= [" + << e1->GetEntryValue(0x0028,0x0004) + << "] "<< std::endl; int numberOfScalarComponents=e1->GetNumberOfScalarComponents(); - std::cout << " NumberOfScalarComponents " << numberOfScalarComponents <GetTransfertSyntaxName(); + + if ( e1->GetEntryValue(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) + { + std::cout << "Transfer Syntax not loaded. " << std::endl + << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE" + << std::endl; + return 0; + } + + std::string transferSyntaxName = e1->GetTransferSyntaxName(); std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl; - - if ( transferSyntaxName != "Implicit VR - Little Endian" - && transferSyntaxName != "Explicit VR - Little Endian" - && transferSyntaxName != "Deflated Explicit VR - Little Endian" - && transferSyntaxName != "Explicit VR - Big Endian" - && transferSyntaxName != "Uncompressed ACR-NEMA" ) - { - std::cout << std::endl << "===========================================" - << std::endl; - f1->ParsePixelData(); - std::cout << std::endl << "===========================================" - << std::endl; - } + std::cout << " SwapCode= " << e1->GetSwapCode() << std::endl; if(e1->IsReadable()) std::cout <