Skip to content

Commit

Permalink
12431 - stop ExtractSliceFilter crash when sliceBounds out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
MattClarkson committed Jul 5, 2012
1 parent c855ded commit 3976cb3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Core/Code/Algorithms/mitkExtractSliceFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,26 +324,30 @@ void mitk::ExtractSliceFilter::GenerateData(){
/*========== BEGIN setup extent of the slice ==========*/
int xMin, xMax, yMin, yMax;

bool successfullyClipped = false;
vtkFloatingPointType sliceBounds[6];

if(m_WorldGeometry->GetReferenceGeometry()){


for ( int i = 0; i < 6; ++i )
{
sliceBounds[i] = 0.0;
}
this->GetClippedPlaneBounds( m_WorldGeometry->GetReferenceGeometry(), planeGeometry, sliceBounds );

successfullyClipped = this->GetClippedPlaneBounds( m_WorldGeometry->GetReferenceGeometry(), planeGeometry, sliceBounds );
}
if (m_WorldGeometry->GetReferenceGeometry() && successfullyClipped)
{
// Calculate output extent (integer values)
xMin = static_cast< int >( sliceBounds[0] / m_OutPutSpacing[0] + 0.5 );
xMax = static_cast< int >( sliceBounds[1] / m_OutPutSpacing[0] + 0.5 );
yMin = static_cast< int >( sliceBounds[2] / m_OutPutSpacing[1] + 0.5 );
yMax = static_cast< int >( sliceBounds[3] / m_OutPutSpacing[1] + 0.5 );

}else
}
else
{
// If no reference geometry is available, we also don't know about the
// maximum plane size;
// If no reference geometry is available, or we couldn't clip
// we also don't know about the maximum plane size;
xMin = yMin = 0;
xMax = static_cast< int >( extent[0]);
yMax = static_cast< int >( extent[1]);
Expand Down

0 comments on commit 3976cb3

Please sign in to comment.