]> Creatis software - clitk.git/commitdiff
avoid segfault when adding ROI to image w/o trafo
authorDavid Boersma <david.boersma@medaustron.at>
Fri, 9 Mar 2018 14:11:26 +0000 (15:11 +0100)
committerDavid Boersma <david.boersma@medaustron.at>
Fri, 9 Mar 2018 14:34:27 +0000 (15:34 +0100)
we got segfaults with VV when doing the following
1. start VV
2. select CT image set (DICOM)
3. open ROI from DICOM

The segfault happened right after we had selected the names of the ROIs to be selected from the RS.* file.

After compiling VV as a "Debug" build and running the above steps in gdb, the
backtrace showed that the crash was caused in line 125 of
vvBinaryImageOverlayActor.cxx.  Apparently our CT image was represented without
any transformation at that point in the code, while the code assumed that there
would always be a transformation.

If it is DICOM-wise or VTK-wise legal for an image to have an empty vector of
transformations, then I think that my fix is sufficient.

If you think that it is anomalous that this vector was empty in our case, then
I think more work is needed. For instance, if this situation could really only
happen if the input data is somehow corrupt, then the user should get an
informative error message about that, and maybe VV just terminates after that
in a more controlled way. Or maybe VV should just provide identity trafo to
images that have an empty trafo vector. Or, less likely, maybe the image did
have a trafo but VV somehow manages to lose it? In all these cases this PR is
insufficient. I can't tell myself, because I am not an image expert. :-)

vv/vvBinaryImageOverlayActor.cxx

index 061bdb8ff6387d1a73c9253138970def5f71db31..7da2edcc78da26165e33293b35ff6792bd3b4e71 100644 (file)
@@ -122,7 +122,9 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
 
     vtkSmartPointer<vtkTransform> mConcatenatedFusionTransform = vtkSmartPointer<vtkTransform>::New();
     mConcatenatedFusionTransform->Identity();
-    mConcatenatedFusionTransform->Concatenate(mImage->GetTransform()[0]);
+    if (!mImage->GetTransform().empty()){
+      mConcatenatedFusionTransform->Concatenate(mImage->GetTransform()[0]);
+    }
     mConcatenatedFusionTransform->Concatenate(mSlicer->GetSlicingTransform());
     mFusionReslice->SetResliceAxes(mConcatenatedFusionTransform->GetMatrix());
     if (mImage->IsTimeSequence()) {