changeset 1931:00f123df5de3

added more tolerance wrt. bad values of the Pixel Spacing (0028,0030) tag
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 31 Mar 2022 13:34:24 +0200
parents 82024e1f304f
children b54fc67b3f92
files Applications/StoneWebViewer/NEWS OrthancStone/Sources/Toolbox/GeometryToolbox.cpp
diffstat 2 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/NEWS	Fri Mar 25 16:56:10 2022 +0100
+++ b/Applications/StoneWebViewer/NEWS	Thu Mar 31 13:34:24 2022 +0200
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* More tolerance wrt. bad values of the Pixel Spacing (0028,0030) tag
+
 
 Version 2.3 (2022-03-24)
 ========================
--- a/OrthancStone/Sources/Toolbox/GeometryToolbox.cpp	Fri Mar 25 16:56:10 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/GeometryToolbox.cpp	Thu Mar 31 13:34:24 2022 +0200
@@ -311,22 +311,15 @@
     {
       Vector v;
 
-      if (LinearAlgebra::ParseVector(v, dicom, Orthanc::DICOM_TAG_PIXEL_SPACING))
+      if (LinearAlgebra::ParseVector(v, dicom, Orthanc::DICOM_TAG_PIXEL_SPACING) &&
+          v.size() >= 2 &&
+          v[0] > 0 &&
+          v[1] > 0)
       {
-        if (v.size() != 2 ||
-            v[0] <= 0 ||
-            v[1] <= 0)
-        {
-          LOG(ERROR) << "Bad value for PixelSpacing tag";
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
-        }
-        else
-        {
-          // WARNING: X/Y are swapped (Y comes first)
-          spacingX = v[1];
-          spacingY = v[0];
-          return true;
-        }
+        // WARNING: X/Y are swapped (Y comes first)
+        spacingX = v[1];
+        spacingY = v[0];
+        return true;
       }
       else
       {