diff Framework/Radiography/RadiographyMaskLayer.cpp @ 1201:ab958fd99b07

RadiographyScene fixes
author Alain Mazy <alain@mazy.be>
date Fri, 29 Nov 2019 16:21:24 +0100
parents a5f2a6b04a31
children 69177b10e2b9
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyMaskLayer.cpp	Thu Nov 28 18:28:15 2019 +0100
+++ b/Framework/Radiography/RadiographyMaskLayer.cpp	Fri Nov 29 16:21:24 2019 +0100
@@ -112,15 +112,19 @@
 
       Orthanc::Image tmp(Orthanc::PixelFormat_Grayscale8, buffer.GetWidth(), buffer.GetHeight(), false);
 
-      t.Apply(tmp, cropped, ImageInterpolation_Nearest, true /* clear */);
 
       unsigned int x1, y1, x2, y2;
-      OrthancStone::GetProjectiveTransformExtent(x1, y1, x2, y2,
-                                                 t.GetHomogeneousMatrix(),
-                                                 cropped.GetWidth(),
-                                                 cropped.GetHeight(),
-                                                 buffer.GetWidth(),
-                                                 buffer.GetHeight());
+      if (!OrthancStone::GetProjectiveTransformExtent(x1, y1, x2, y2,
+                                                      t.GetHomogeneousMatrix(),
+                                                      cropped.GetWidth(),
+                                                      cropped.GetHeight(),
+                                                      buffer.GetWidth(),
+                                                      buffer.GetHeight()))
+      {
+        return;  // layer is outside the buffer
+      }
+
+      t.Apply(tmp, cropped, ImageInterpolation_Nearest, true /* clear */);
 
       // we have observed vertical lines at the image border (probably due to bilinear filtering of the DICOM image when it is not aligned with the buffer pixels)
       // -> draw the mask one line further on each side