]> Creatis software - gdcm.git/commitdiff
* src/gdcmDictSet.h : set the default output to the os variable
authorregrain <regrain>
Thu, 13 Jan 2005 16:35:36 +0000 (16:35 +0000)
committerregrain <regrain>
Thu, 13 Jan 2005 16:35:36 +0000 (16:35 +0000)
   * src/gdcmDictEntry.[h|cxx] : add the Print method
   * gdcmPython/demo/ : add a new test
   -- BeNours

ChangeLog
gdcmPython/CMakeLists.txt
gdcmPython/demo/CMakeLists.txt
gdcmPython/demo/PrintDict.py.in [new file with mode: 0644]
src/gdcmDictEntry.cxx
src/gdcmDictEntry.h
src/gdcmDictSet.h

index 0f5443bd3bf4b6e702aca19bb9f73007dbd746d1..724cba702a90d32ceeab703b4a4978297392b7f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-01-13 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * src/gdcmDictSet.h : set the default output to the os variable
+   * src/gdcmDictEntry.[h|cxx] : add the Print method
+   * gdcmPython/demo/ : add a new test
+
 2005-01-13 Jean-Pierre Roux <jpr@creatis.univ-lyon1.fr>
    * merging of Test/PrintDicomDir and Test/TestDicomDir
        * removal of now redundant Test/PrintDicomDir
index 91fe9c0d8f001076e61de018fc94765fd5443ec6..ded39cb18359689a8afc2bcfdfe96d6b57f16edb 100644 (file)
@@ -134,26 +134,6 @@ ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
     ${EXE_DIR}/${CMAKE_CFG_INTDIR}/_gdcm${CMAKE_SHARED_LIBRARY_SUFFIX}
     )
 
-  # Remove temporary (lib)pygdcm(.so .dll) library:
-#  ADD_CUSTOM_COMMAND(
-#    TARGET pygdcm
-#    POST_BUILD
-#    COMMAND ${CMAKE_COMMAND}
-#    ARGS -E remove ${LIB_DIR}/${CMAKE_CFG_INTDIR}/${LIB_NAME}
-#  )
-
-  # where are library stored ?
-#  SET(GDCM_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
-#  ADD_CUSTOM_COMMAND(
-#    TARGET pygdcm
-#    POST_BUILD
-#    COMMAND ${CMAKE_COMMAND}
-#    ARGS -E copy
-#      ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${MY_LIB_NAME}${CMAKE_SHLIB_SUFFIX}
-#      ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/vtkXY.pvm
-#    TARGET vtkXY
-#  )
-
 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)   
 
 
index 25428d4e40ae96858589fc80cd87fb63e24288d0..6cc554568017ff9bbddefab43c5d9a3248925bc8 100644 (file)
@@ -16,6 +16,9 @@ FIND_PROGRAM(PYTHON_EXECUTABLE
 MARK_AS_ADVANCED(PYTHON_EXECUTABLE)
 
 IF(PYTHON_EXECUTABLE)
+  ADD_TEST(Python-PrintDict ${PYTHON_EXECUTABLE}
+    ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintDict.py
+    )
   ADD_TEST(Python-PrintHeader ${PYTHON_EXECUTABLE}
     ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintHeader.py
     )
@@ -40,3 +43,7 @@ CONFIGURE_FILE(
     ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintDicomDir.py
 )
 
+CONFIGURE_FILE(
+    ${GDCM_SOURCE_DIR}/gdcmPython/demo/PrintDict.py.in
+    ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintDict.py
+)
diff --git a/gdcmPython/demo/PrintDict.py.in b/gdcmPython/demo/PrintDict.py.in
new file mode 100644 (file)
index 0000000..4a1eb84
--- /dev/null
@@ -0,0 +1,49 @@
+import sys
+import os
+
+sys.path.append('${GDCM_BINARY_DIR}')
+if os.name == 'posix':
+   sys.path.append('${GDCM_BINARY_DIR}/bin')
+else:
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Release')
+   sys.path.append('${GDCM_BINARY_DIR}/bin/Debug')
+
+from gdcmPython.core import *
+
+print "#####################################################################"
+# Print the DictSet
+dicts=gdcm.Global.GetDicts()
+if(not isinstance(dicts,gdcm.DictSet)):
+       raise RuntimeError,"The DictSet hasn't the good type (%s)" % type(dicts)
+print "DictSet content :"
+dicts.Print()
+
+print "#####################################################################"
+# Print the Dict (public)
+pubDict=dicts.GetDefaultPubDict()
+if(not isinstance(pubDict,gdcm.Dict)):
+       raise RuntimeError,"The public Dict hasn't the good type (%s)" % type(dict)
+print "Public Dict content :"
+pubDict.Print()
+
+print "#####################################################################"
+# Print the DictEntry (0010|0020)
+ENTRY_GR = 0x10
+ENTRY_EL = 0x20
+entry=pubDict.GetDictEntry(ENTRY_GR,ENTRY_EL)
+if(not isinstance(entry,gdcm.DictEntry)):
+       raise RuntimeError,"The entry (%04x|%04x) hasn't the good type (%s)" % \
+             (ENTRY_GR,ENTRY_EL,type(entry))
+print "Entry (%04x|%04x) content :" % (ENTRY_GR,ENTRY_EL)
+entry.Print()
+
+# Print the DictEntry (0010|0010)
+ENTRY_GR = 0x10
+ENTRY_EL = 0x10
+entry=pubDict.GetDictEntry(ENTRY_GR,ENTRY_EL)
+if(not isinstance(entry,gdcm.DictEntry)):
+       raise RuntimeError,"The entry (%04x|%04x) hasn't the good type (%s)" % \
+             (ENTRY_GR,ENTRY_EL,type(entry))
+print "Entry (%04x|%04x) content :" % (ENTRY_GR,ENTRY_EL)
+entry.Print()
+
index 886dd48912aa37898cb6854c3471e91d4ffe4d53..a4bb7060bcdb5a1a0c98042ccc1392e6abb2a88e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/10 17:17:52 $
-  Version:   $Revision: 1.38 $
+  Date:      $Date: 2005/01/13 16:35:37 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,6 +20,9 @@
 #include "gdcmDebug.h"
 #include "gdcmUtil.h"
 
+#include <iomanip> // for std::ios::left, ...
+#include <fstream>
+
 namespace gdcm 
 {
 
@@ -49,6 +52,27 @@ DictEntry::DictEntry(uint16_t group, uint16_t element,
 
 //-----------------------------------------------------------------------------
 // Print
+void DictEntry::Print(std::ostream &os)
+{
+   std::string vr;
+   std::ostringstream s;
+
+   vr = GetVR();
+   if(vr==GDCM_UNKNOWN)
+      vr="  ";
+
+   s << DictEntry::TranslateToKey(GetGroup(),GetElement()); 
+   s << " [" << vr  << "] ";
+
+   if (PrintLevel >= 1)
+   {
+      s.setf(std::ios::left);
+      s << std::setw(66-GetName().length()) << " ";
+   }
+
+   s << "[" << GetName()<< "]";
+   os << s.str();
+}
 
 //-----------------------------------------------------------------------------
 // Public
index 1658bb493753a40015cd8f7f5f6a36b1cd0f1ebc..89a85c0c704cff8a5490dc9b5d85eb1e90f833cf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/11 15:15:38 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2005/01/13 16:35:37 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -46,8 +46,13 @@ public:
              TagName const &vm     = GDCM_UNKNOWN,
              TagName const &name   = GDCM_UNKNOWN);
 
+// Print
+   void Print(std::ostream &os = std::cout);
+
+// Key creation
    static TagKey TranslateToKey(uint16_t group, uint16_t element);
 
+// Content of DictEntry
    void SetVR(TagName const &vr);
    void SetVM(TagName const &vm);
 
index cb891b82fbda8c1471a2e5e799e20ed2aff48691..54c8b0fcc97b457a1c5cc790a22ab67474c8f658 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/11 15:15:38 $
-  Version:   $Revision: 1.34 $
+  Date:      $Date: 2005/01/13 16:35:37 $
+  Version:   $Revision: 1.35 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -44,7 +44,7 @@ public:
    DictSet();
    ~DictSet();
 
-   void Print(std::ostream &os);
+   void Print(std::ostream &os = std::cout);
 
    // Probabely useless !
    //EntryNamesList *GetPubDictEntryNames();