Browse Source

ADD: DICOM Demo SCU client showing how to use DCMTK's DcmSCU class.

Just a simple client showing how to use the "new" DcmSCU class that
comes with DCMTK's dcmnet module. So far the program just issues
a C-ECHO to an SCP specified via hostname and port number. May be
expanded later for further API demonstration.
Michi Onken 15 years ago
parent
commit
9e2cfc451b

+ 59 - 0
Applications/ctkDICOMDemoSCU/CMakeLists.txt

@@ -0,0 +1,59 @@
+PROJECT(ctkDICOMDemoSCU)
+
+#
+# 3rd party dependencies
+#
+
+FIND_PACKAGE(DCMTK)
+IF(NOT DCMTK_FOUND)
+  MESSAGE(FATAL_ERROR "error: DCMTK package is required to build ${PROJECT_NAME}")
+ENDIF()
+
+#
+# See CTK/CMake/ctkMacroBuildLib.cmake for details
+#
+
+# Additional directories to include
+SET(KIT_include_directories
+  ${DCMTK_INCLUDE_DIR}
+  )
+  
+# Source files
+SET(KIT_SRCS
+  ctkDICOMDemoSCU.cpp
+  )
+
+# Headers that should run through moc
+SET(KIT_MOC_SRCS
+  
+  )
+
+# UI files
+SET(KIT_UI_FORMS
+)
+
+# Resources
+SET(KIT_resources
+  )
+
+# Target libraries - See CMake/ctkMacroGetTargetLibraries.cmake
+# The following macro will read the target libraries from the file 'target_libraries.cmake'
+ctkMacroGetTargetLibraries(KIT_target_libraries)
+
+ctkMacroBuildApp(
+  NAME ${PROJECT_NAME}
+  INCLUDE_DIRECTORIES ${KIT_include_directories}
+  SRCS ${KIT_SRCS}
+  MOC_SRCS ${KIT_MOC_SRCS}
+  UI_FORMS ${KIT_UI_FORMS}
+  TARGET_LIBRARIES ${KIT_target_libraries}
+  RESOURCES ${KIT_resources}
+  )
+
+# Plugins
+#ADD_SUBDIRECTORY(Plugins)
+
+# Testing
+IF(BUILD_TESTING)
+#  ADD_SUBDIRECTORY(Testing)
+ENDIF(BUILD_TESTING)

+ 84 - 0
Applications/ctkDICOMDemoSCU/ctkDICOMDemoSCU.cpp

@@ -0,0 +1,84 @@
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+#include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
+#include "dcmtk/dcmnet/scu.h"
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+#include <fstream>
+
+void print_usage()
+{
+  std::cerr << "Usage: \n";
+  std::cerr << "  ctkDICOMDemoSCU peer port\n";
+  std::cerr << "     Issues ECHO request to the given host and given port.\n"; 
+  return;
+}
+
+int main(int argc, char** argv)
+{
+  // Check whether host and port are given
+  if (argc < 3)
+  {
+    print_usage();
+    return 2;
+  } 
+  
+  std::string host = argv[1];
+  unsigned int port = atoi(argv[2]);
+  
+  // Setup SCU
+  DcmSCU scu;
+  scu.setPeerHostName(host);
+  scu.setPeerPort(port);
+  OFString verificationSOP = UID_VerificationSOPClass;
+  OFList<OFString> ts;
+  ts.push_back(UID_LittleEndianExplicitTransferSyntax);
+  ts.push_back(UID_BigEndianExplicitTransferSyntax);  
+  ts.push_back(UID_LittleEndianImplicitTransferSyntax);
+  scu.addPresentationContext(verificationSOP, ts);
+  OFCondition result = scu.initNetwork();
+  if (result.bad())
+  {
+    std::cerr << "Error setting up SCU: " << result.text() << "\n";
+    return 2;
+  }
+  
+  // Negotiate association
+  result = scu.negotiateAssociation();
+  if (result.bad())
+  {
+    std::cerr << "Error negotiating association: " << result.text() << "\n";
+    return 2;
+  }
+  
+  // Issue ECHO request and let scu find presentation context itself (0)
+  result = scu.sendECHORequest(0);
+  if (result.bad())
+  { 
+    std::cerr << "Error issuing ECHO request or received rejecting response: " << result.text() << "\n";
+    return 2;
+  }
+  std::cout << "Successfully sent DICOM Echo to host " << argv[1] << " on port " << argv[2] << "\n";
+  return 0;
+  
+}

+ 9 - 0
Applications/ctkDICOMDemoSCU/target_libraries.cmake

@@ -0,0 +1,9 @@
+#
+# See CMake/ctkMacroGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK application.
+# 
+
+SET(target_libraries
+   DCMTK_LIBRARIES
+  )

+ 1 - 0
CMakeLists.txt

@@ -283,6 +283,7 @@ SET(CTK_APPLICATIONS
   ctkPluginBrowser:OFF
   ctkDICOM:OFF
   ctkDICOMIndexer:OFF
+  ctkDICOMDemoSCU:OFF
   )
   
 #-----------------------------------------------------------------------------