Mercurial > hg > orthanc
comparison UnitTestsSources/FromDcmtkTests.cpp @ 2006:6301bbcbcaed
more generic support of value representations
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 09 Jun 2016 14:48:40 +0200 |
parents | b5d4f9c156ad |
children | 655489d9165d |
comparison
equal
deleted
inserted
replaced
2005:9e021b2b348b | 2006:6301bbcbcaed |
---|---|
32 | 32 |
33 #include "PrecompiledHeadersUnitTests.h" | 33 #include "PrecompiledHeadersUnitTests.h" |
34 #include "gtest/gtest.h" | 34 #include "gtest/gtest.h" |
35 | 35 |
36 #include "../OrthancServer/FromDcmtkBridge.h" | 36 #include "../OrthancServer/FromDcmtkBridge.h" |
37 #include "../OrthancServer/ToDcmtkBridge.h" | |
37 #include "../OrthancServer/OrthancInitialization.h" | 38 #include "../OrthancServer/OrthancInitialization.h" |
38 #include "../OrthancServer/DicomModification.h" | 39 #include "../OrthancServer/DicomModification.h" |
39 #include "../OrthancServer/ServerToolbox.h" | 40 #include "../OrthancServer/ServerToolbox.h" |
40 #include "../Core/OrthancException.h" | 41 #include "../Core/OrthancException.h" |
41 #include "../Core/Images/ImageBuffer.h" | 42 #include "../Core/Images/ImageBuffer.h" |
46 #include "../Core/Uuid.h" | 47 #include "../Core/Uuid.h" |
47 #include "../Core/Endianness.h" | 48 #include "../Core/Endianness.h" |
48 #include "../Resources/EncodingTests.h" | 49 #include "../Resources/EncodingTests.h" |
49 #include "../OrthancServer/DicomProtocol/DicomFindAnswers.h" | 50 #include "../OrthancServer/DicomProtocol/DicomFindAnswers.h" |
50 #include "../OrthancServer/Internals/DicomImageDecoder.h" | 51 #include "../OrthancServer/Internals/DicomImageDecoder.h" |
52 #include "../Plugins/Engine/PluginsEnumerations.h" | |
51 | 53 |
52 #include <dcmtk/dcmdata/dcelem.h> | 54 #include <dcmtk/dcmdata/dcelem.h> |
53 | 55 |
54 using namespace Orthanc; | 56 using namespace Orthanc; |
55 | 57 |
298 | 300 |
299 | 301 |
300 TEST(FromDcmtkBridge, ValueRepresentation) | 302 TEST(FromDcmtkBridge, ValueRepresentation) |
301 { | 303 { |
302 ASSERT_EQ(ValueRepresentation_PatientName, | 304 ASSERT_EQ(ValueRepresentation_PatientName, |
303 FromDcmtkBridge::GetValueRepresentation(DICOM_TAG_PATIENT_NAME)); | 305 FromDcmtkBridge::LookupValueRepresentation(DICOM_TAG_PATIENT_NAME)); |
304 ASSERT_EQ(ValueRepresentation_Date, | 306 ASSERT_EQ(ValueRepresentation_Date, |
305 FromDcmtkBridge::GetValueRepresentation(DicomTag(0x0008, 0x0020) /* StudyDate */)); | 307 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0020) /* StudyDate */)); |
306 ASSERT_EQ(ValueRepresentation_Time, | 308 ASSERT_EQ(ValueRepresentation_Time, |
307 FromDcmtkBridge::GetValueRepresentation(DicomTag(0x0008, 0x0030) /* StudyTime */)); | 309 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x0030) /* StudyTime */)); |
308 ASSERT_EQ(ValueRepresentation_DateTime, | 310 ASSERT_EQ(ValueRepresentation_DateTime, |
309 FromDcmtkBridge::GetValueRepresentation(DicomTag(0x0008, 0x002a) /* AcquisitionDateTime */)); | 311 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0008, 0x002a) /* AcquisitionDateTime */)); |
310 ASSERT_EQ(ValueRepresentation_Other, | 312 ASSERT_EQ(ValueRepresentation_NotSupported, |
311 FromDcmtkBridge::GetValueRepresentation(DICOM_TAG_PATIENT_ID)); | 313 FromDcmtkBridge::LookupValueRepresentation(DicomTag(0x0001, 0x0001) /* some private tag */)); |
314 } | |
315 | |
316 | |
317 TEST(FromDcmtkBridge, ValueRepresentationConversions) | |
318 { | |
319 ASSERT_EQ(1, ValueRepresentation_ApplicationEntity); | |
320 ASSERT_EQ(1, OrthancPluginValueRepresentation_AE); | |
321 | |
322 for (int i = ValueRepresentation_ApplicationEntity; | |
323 i <= ValueRepresentation_NotSupported; i++) | |
324 { | |
325 ValueRepresentation vr = static_cast<ValueRepresentation>(i); | |
326 | |
327 if (vr == ValueRepresentation_NotSupported) | |
328 { | |
329 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException); | |
330 ASSERT_THROW(Plugins::Convert(vr), OrthancException); | |
331 } | |
332 else if (vr == ValueRepresentation_OtherDouble || | |
333 vr == ValueRepresentation_OtherLong || | |
334 vr == ValueRepresentation_UniversalResource || | |
335 vr == ValueRepresentation_UnlimitedCharacters) | |
336 { | |
337 // These VR are not supported as of DCMTK 3.6.0 | |
338 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException); | |
339 ASSERT_EQ(OrthancPluginValueRepresentation_UN, Plugins::Convert(vr)); | |
340 } | |
341 else | |
342 { | |
343 ASSERT_EQ(vr, FromDcmtkBridge::Convert(ToDcmtkBridge::Convert(vr))); | |
344 | |
345 OrthancPluginValueRepresentation plugins = Plugins::Convert(vr); | |
346 ASSERT_EQ(vr, Plugins::Convert(plugins)); | |
347 } | |
348 } | |
349 | |
350 for (int i = OrthancPluginValueRepresentation_AE; | |
351 i <= OrthancPluginValueRepresentation_UT; i++) | |
352 { | |
353 OrthancPluginValueRepresentation plugins = static_cast<OrthancPluginValueRepresentation>(i); | |
354 ValueRepresentation orthanc = Plugins::Convert(plugins); | |
355 ASSERT_EQ(plugins, Plugins::Convert(orthanc)); | |
356 } | |
312 } | 357 } |
313 | 358 |
314 | 359 |
315 | 360 |
316 static const DicomTag REFERENCED_STUDY_SEQUENCE(0x0008, 0x1110); | 361 static const DicomTag REFERENCED_STUDY_SEQUENCE(0x0008, 0x1110); |
529 } | 574 } |
530 | 575 |
531 | 576 |
532 TEST(ParsedDicomFile, ToJsonFlags1) | 577 TEST(ParsedDicomFile, ToJsonFlags1) |
533 { | 578 { |
534 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7053, 0x1000), EVR_PN, "MyPrivateTag", 1, 1); | 579 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7053, 0x1000), ValueRepresentation_PatientName, "MyPrivateTag", 1, 1); |
535 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1000), EVR_PN, "Declared public tag", 1, 1); | 580 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1000), ValueRepresentation_PatientName, "Declared public tag", 1, 1); |
536 | 581 |
537 ParsedDicomFile f(true); | 582 ParsedDicomFile f(true); |
538 f.Insert(DicomTag(0x7050, 0x1000), "Some public tag", false); // Even group => public tag | 583 f.Insert(DicomTag(0x7050, 0x1000), "Some public tag", false); // Even group => public tag |
539 f.Insert(DicomTag(0x7052, 0x1000), "Some unknown tag", false); // Even group => public, unknown tag | 584 f.Insert(DicomTag(0x7052, 0x1000), "Some unknown tag", false); // Even group => public, unknown tag |
540 f.Insert(DicomTag(0x7053, 0x1000), "Some private tag", false); // Odd group => private tag | 585 f.Insert(DicomTag(0x7053, 0x1000), "Some private tag", false); // Odd group => private tag |
670 } | 715 } |
671 | 716 |
672 | 717 |
673 TEST(ParsedDicomFile, FromJson) | 718 TEST(ParsedDicomFile, FromJson) |
674 { | 719 { |
675 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7057, 0x1000), EVR_OB, "MyPrivateTag", 1, 1); | 720 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7057, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag", 1, 1); |
676 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7059, 0x1000), EVR_OB, "MyPrivateTag", 1, 1); | 721 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7059, 0x1000), ValueRepresentation_OtherByte, "MyPrivateTag", 1, 1); |
677 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1000), EVR_PN, "Declared public tag", 1, 1); | 722 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1000), ValueRepresentation_PatientName, "Declared public tag", 1, 1); |
678 | 723 |
679 Json::Value v; | 724 Json::Value v; |
680 const std::string sopClassUid = "1.2.840.10008.5.1.4.1.1.1"; // CR Image Storage: | 725 const std::string sopClassUid = "1.2.840.10008.5.1.4.1.1.1"; // CR Image Storage: |
681 | 726 |
682 { | 727 { |