changeset 11:12e36b1b84f3

testing with dcmtk
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 30 Apr 2022 11:26:21 +0200
parents 8eb050609cb0
children 8747857b539e
files CMakeLists.txt Sources/UnitTestsSources/UnitTestsMain.cpp
diffstat 2 files changed, 49 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Tue Apr 26 12:05:13 2022 +0200
+++ b/CMakeLists.txt	Sat Apr 30 11:26:21 2022 +0200
@@ -76,9 +76,17 @@
   set(ENABLE_GOOGLE_TEST ON)
   set(ENABLE_ZLIB ON)
 
-  set(ENABLE_DCMTK OFF)   # Could be set to "ON" for debugging
-  set(ENABLE_PNG OFF)     # Could be set to "ON" for debugging
-  set(ENABLE_LOCALE OFF)  # Disable support for locales (notably in Boost)
+  if (OFF)
+    # Enable DCMTK for testing on raw DICOM files
+    set(ENABLE_DCMTK ON)
+    set(ENABLE_PNG ON)
+    set(ENABLE_LOCALE ON)
+  else()
+    set(ENABLE_DCMTK OFF)
+    set(ENABLE_PNG OFF)
+    set(ENABLE_LOCALE OFF)
+  endif()
+   
   set(ENABLE_MODULE_JOBS OFF CACHE INTERNAL "")
 
   include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkConfiguration.cmake)
@@ -147,6 +155,11 @@
   ${ORTHANC_CORE_SOURCES}
   )
 
+if (ENABLE_DCMTK)
+  link_libraries(${DCMTK_LIBRARIES})
+  list(APPEND NEURO_SOURCES ${ORTHANC_DICOM_SOURCES})
+endif()
+
 
 add_custom_target(
   AutogeneratedTarget
--- a/Sources/UnitTestsSources/UnitTestsMain.cpp	Tue Apr 26 12:05:13 2022 +0200
+++ b/Sources/UnitTestsSources/UnitTestsMain.cpp	Sat Apr 30 11:26:21 2022 +0200
@@ -22,6 +22,39 @@
 #include <Logging.h>
 
 
+#if ORTHANC_ENABLE_DCMTK == 1
+#  include "../Framework/InputDicomInstance.h"
+#  include <DicomParsing/ParsedDicomFile.h>
+#  include <SystemToolbox.h>
+
+TEST(Dcmtk, DumpCSAHeader)
+{
+  std::string s;
+  Orthanc::SystemToolbox::ReadFile(s, "49210406");
+  
+  Orthanc::ParsedDicomFile dicom(s);
+
+  Neuro::InputDicomInstance instance(dicom);
+
+  std::list<std::string> tags;
+  instance.GetCSAHeader().ListTags(tags);
+
+  for (std::list<std::string>::const_iterator it = tags.begin(); it != tags.end(); ++it)
+  {
+    const Neuro::CSATag& tag = instance.GetCSAHeader().GetTag(*it);
+    
+    printf("[%s] (%d) = ", it->c_str(), tag.GetSize());
+    for (size_t i = 0; i < tag.GetSize(); i++)
+    {
+      printf("[%s] ", tag.GetStringValue(i).c_str());
+    }
+    
+    printf("\n");
+  }
+}
+#endif
+
+
 int main(int argc, char **argv)
 {
   Orthanc::Logging::Initialize();