X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=Testing%2FTestMakeIcon.cxx;h=34eee75ed0549cfa758f8b6d0f01c6cf0973c94a;hb=e30768c5d2c9057ca9be9bdb2d12ff1eb1384539;hp=0e31543f10d3a8dc57d66810d48b329423c03349;hpb=ab0656f216518d796419d84eb7c7cec7fa2c1d69;p=gdcm.git diff --git a/Testing/TestMakeIcon.cxx b/Testing/TestMakeIcon.cxx index 0e31543f..34eee75e 100644 --- a/Testing/TestMakeIcon.cxx +++ b/Testing/TestMakeIcon.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestMakeIcon.cxx,v $ Language: C++ - Date: $Date: 2005/02/11 13:12:05 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/04/26 16:23:58 $ + Version: $Revision: 1.6 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -30,8 +30,13 @@ int TestMakeIcon (int argc, char *argv[]) { // hard coded small image name - std::string input = "LIBIDO-8-ACR_NEMA-Lena_128_128.acr"; - std::string output = "test.dcm"; + std::string input = GDCM_DATA_ROOT; + input += "/"; + input += "LIBIDO-8-ACR_NEMA-Lena_128_128.acr"; + + std::string output = "testIcon.dcm"; + + gdcm::Debug::DebugOn(); if ( argc == 3 ) { @@ -44,16 +49,18 @@ int TestMakeIcon (int argc, char *argv[]) << " input filename.dcm output Filename.dcm" << std::endl; } - gdcm::File *f1 = new gdcm::File(input); + gdcm::File *f1 = new gdcm::File( ); + f1->Load(input); - if (f1 == 0) + if ( ! f1->IsReadable() ) { - std::cout << " failed to open file" << std::endl; + std::cout << " Failed to Open/Parse file" << input << std::endl; + delete f1; return 1; } gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1); uint8_t *pixels = fh1->GetImageData(); - uint32_t lgth = fh1->GetImageDataSize(); + uint32_t lgth = fh1->GetImageDataSize(); gdcm::SeqEntry *icon = f1->InsertSeqEntry(0x0088, 0x0200); gdcm::SQItem *sqi = new gdcm::SQItem(1); @@ -62,6 +69,7 @@ int TestMakeIcon (int argc, char *argv[]) // icone is just define like the image // The purpose is NOT to imagine an icon, // just check the stuff works + uint16_t binVal[3]={0x52f7,0xf358,0xad9b}; sqi->InsertValEntry( "MONOCHROME2", 0x0028,0x0004); @@ -81,19 +89,32 @@ int TestMakeIcon (int argc, char *argv[]) f1 = new gdcm::File(output); f1->Print(); + std::cout << "End of Print" << std::endl; icon = f1->GetSeqEntry(0x0088, 0x0200); + if (!icon) + { + std::cout << "Sequence 0088|0200 not found" << std::endl + << " ... Failed" << std::endl; + delete fh1; + delete f1; + return 1; + } + std::cout << "Sequence 0088|0200 found" << std::endl; + sqi = icon->GetFirstSQItem(); if ( !sqi ) { - std::cout << "Sequence 0088|0200 not found" << std::endl + std::cout << "Sequence 0088|0200 has no SQItem" << std::endl << " ... Failed" << std::endl; delete fh1; delete f1; return 1; } + std::cout << "First Item found" << std::endl; + // Test for entry 0028|0010 if ( !sqi->GetValEntry(0x0028,0x0010) ) { @@ -103,6 +124,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "First Item ->ValEntry 0028|0010 found" << std::endl; if ( sqi->GetValEntry(0x0028,0x0010)->GetValue() != "128" ) { std::cout << "Value 0028|0010 don't match" << std::endl @@ -123,6 +145,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "First Item ->ValEntry 0028|0011 found" << std::endl; if ( sqi->GetValEntry(0x0028,0x0011)->GetValue() != "128" ) { std::cout << "Value 0028|0011 don't match" << std::endl @@ -143,6 +166,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "First Item ->ValEntry 0028|0100 found" << std::endl; if ( sqi->GetValEntry(0x0028,0x0100)->GetValue() != "8" ) { std::cout << "Value 0028|0100 don't match" << std::endl @@ -163,6 +187,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "First Item ->ValEntry 0028|0101 found" << std::endl; if ( sqi->GetValEntry(0x0028,0x0101)->GetValue() != "8" ) { std::cout << "Value 0028|0101 don't match" << std::endl @@ -183,6 +208,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "First Item ->ValEntry 0028|0102 found" << std::endl; if ( sqi->GetValEntry(0x0028,0x0102)->GetValue() != "7" ) { std::cout << "Value 0028|0102 don't match" << std::endl @@ -203,6 +229,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "First Item ->ValEntry 0028|0103 found" << std::endl; if ( sqi->GetValEntry(0x0028,0x0103)->GetValue() != "0" ) { std::cout << "Value 0028|0103 don't match" << std::endl @@ -215,7 +242,7 @@ int TestMakeIcon (int argc, char *argv[]) } // Test for entry 0005|0010 - if ( !sqi->GetValEntry(0x0028,0x0010) ) + if ( !sqi->GetBinEntry(0x0005,0x0010) ) { std::cout << "BinEntry 0005|0010 not found" << std::endl << " ... Failed" << std::endl; @@ -223,6 +250,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "First Item ->BinEntry 0005|0010 found" << std::endl; if( sqi->GetBinEntry(0x0005,0x0010)->GetLength() != 6 ) { std::cout << "BinEntry size 0005|0010 don't match" << std::endl @@ -234,6 +262,8 @@ int TestMakeIcon (int argc, char *argv[]) return 1; } + std::cout << "Length BinEntry 0005|0010 OK" << std::endl; + if( memcmp(sqi->GetBinEntry(0x0005,0x0010)->GetBinArea(),binVal,6)!=0 ) { std::cout << "Value 0005|0010 don't match (BinEntry)" << std::endl @@ -242,6 +272,7 @@ int TestMakeIcon (int argc, char *argv[]) delete f1; return 1; } + std::cout << "Value BinEntry 0005|0010 OK" << std::endl; delete fh1; delete f1;