changeset 1956:fc16ee04e71b

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 06 Apr 2016 14:22:48 +0200
parents ed77a9aea3f6
children b10a165e0e36
files OrthancServer/Internals/DicomFrameIndex.cpp OrthancServer/Internals/DicomFrameIndex.h OrthancServer/ParsedDicomFile.cpp
diffstat 3 files changed, 21 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Internals/DicomFrameIndex.cpp	Wed Apr 06 08:41:47 2016 +0200
+++ b/OrthancServer/Internals/DicomFrameIndex.cpp	Wed Apr 06 14:22:48 2016 +0200
@@ -319,21 +319,21 @@
 
 
 
-  bool DicomFrameIndex::IsVideo(const DcmDataset& dataset)
+  bool DicomFrameIndex::IsVideo(DcmFileFormat& dicom)
   {
-    if (dataset.getOriginalXfer() == EXS_MPEG2MainProfileAtMainLevel ||
-        dataset.getOriginalXfer() == EXS_MPEG2MainProfileAtHighLevel)
+    if (dicom.getDataset()->getOriginalXfer() == EXS_MPEG2MainProfileAtMainLevel ||
+        dicom.getDataset()->getOriginalXfer() == EXS_MPEG2MainProfileAtHighLevel)
     {
       return true;
     }        
 
 #if DCMTK_VERSION_NUMBER > 360
     // New transfer syntaxes introduced in the DICOM standard after DCMTK 3.6.0
-    if (dataset.getOriginalXfer() == EXS_MPEG4HighProfileLevel4_1 ||
-        dataset.getOriginalXfer() == EXS_MPEG4BDcompatibleHighProfileLevel4_1 ||
-        dataset.getOriginalXfer() == EXS_MPEG4HighProfileLevel4_2_For2DVideo ||
-        dataset.getOriginalXfer() == EXS_MPEG4HighProfileLevel4_2_For3DVideo ||
-        dataset.getOriginalXfer() == EXS_MPEG4StereoHighProfileLevel4_2)
+    if (dicom.getDataset()->getOriginalXfer() == EXS_MPEG4HighProfileLevel4_1 ||
+        dicom.getDataset()->getOriginalXfer() == EXS_MPEG4BDcompatibleHighProfileLevel4_1 ||
+        dicom.getDataset()->getOriginalXfer() == EXS_MPEG4HighProfileLevel4_2_For2DVideo ||
+        dicom.getDataset()->getOriginalXfer() == EXS_MPEG4HighProfileLevel4_2_For3DVideo ||
+        dicom.getDataset()->getOriginalXfer() == EXS_MPEG4StereoHighProfileLevel4_2)
     {
       return true;
     }        
@@ -343,16 +343,16 @@
   }
 
 
-  unsigned int DicomFrameIndex::GetFramesCount(DcmDataset& dataset)
+  unsigned int DicomFrameIndex::GetFramesCount(DcmFileFormat& dicom)
   {
     // Assume 1 frame for video transfer syntaxes
-    if (IsVideo(dataset))
+    if (IsVideo(dicom))
     {
       return 1;
     }        
 
     const char* tmp = NULL;
-    if (!dataset.findAndGetString(DCM_NumberOfFrames, tmp).good() ||
+    if (!dicom.getDataset()->findAndGetString(DCM_NumberOfFrames, tmp).good() ||
         tmp == NULL)
     {
       return 1;
@@ -378,15 +378,17 @@
   }
 
 
-  DicomFrameIndex::DicomFrameIndex(DcmDataset& dataset)
+  DicomFrameIndex::DicomFrameIndex(DcmFileFormat& dicom)
   {
-    countFrames_ = GetFramesCount(dataset);
+    countFrames_ = GetFramesCount(dicom);
     if (countFrames_ == 0)
     {
       // The image has no frame. No index is to be built.
       return;
     }
 
+    DcmDataset& dataset = *dicom.getDataset();
+
     // Test whether this image is composed of a sequence of fragments
     DcmPixelSequence* pixelSequence = FromDcmtkBridge::GetPixelSequence(dataset);
     if (pixelSequence != NULL)
--- a/OrthancServer/Internals/DicomFrameIndex.h	Wed Apr 06 08:41:47 2016 +0200
+++ b/OrthancServer/Internals/DicomFrameIndex.h	Wed Apr 06 14:22:48 2016 +0200
@@ -33,6 +33,7 @@
 #pragma once
 
 #include <dcmtk/dcmdata/dcdatset.h>
+#include <dcmtk/dcmdata/dcfilefo.h>
 #include <vector>
 #include <stdint.h>
 #include <boost/noncopyable.hpp>
@@ -62,7 +63,7 @@
     unsigned int           countFrames_;
 
   public:
-    DicomFrameIndex(DcmDataset& dataset);
+    DicomFrameIndex(DcmFileFormat& dicom);
 
     unsigned int GetFramesCount() const
     {
@@ -72,8 +73,8 @@
     void GetRawFrame(std::string& frame,
                      unsigned int index) const;
 
-    static bool IsVideo(const DcmDataset& dataset);
+    static bool IsVideo(DcmFileFormat& dicom);
 
-    static unsigned int GetFramesCount(DcmDataset& dataset);
+    static unsigned int GetFramesCount(DcmFileFormat& dicom);
   };
 }
--- a/OrthancServer/ParsedDicomFile.cpp	Wed Apr 06 08:41:47 2016 +0200
+++ b/OrthancServer/ParsedDicomFile.cpp	Wed Apr 06 14:22:48 2016 +0200
@@ -1234,7 +1234,7 @@
   {
     if (pimpl_->frameIndex_.get() == NULL)
     {
-      pimpl_->frameIndex_.reset(new DicomFrameIndex(*pimpl_->file_->getDataset()));
+      pimpl_->frameIndex_.reset(new DicomFrameIndex(*pimpl_->file_));
     }
 
     pimpl_->frameIndex_->GetRawFrame(target, frameId);
@@ -1265,6 +1265,6 @@
 
   unsigned int ParsedDicomFile::GetFramesCount() const
   {
-    return DicomFrameIndex::GetFramesCount(*pimpl_->file_->getDataset());
+    return DicomFrameIndex::GetFramesCount(*pimpl_->file_);
   }
 }