Commit a328f39a authored by Rashad Kanavath's avatar Rashad Kanavath

SWIG: check a simply dynamic_cast before using castImageFilter (issue with numpy.float and float)

parent 001d7b6f
......@@ -183,18 +183,25 @@ template <class TInputImage, class TOutputImage>
TOutputImage*
InputImageParameter::SimpleCastImage()
{
TInputImage* realInputImage = dynamic_cast<TInputImage*>(m_Image.GetPointer());
if ( dynamic_cast<TOutputImage*> (m_Image.GetPointer()) )
{
return dynamic_cast<TOutputImage*> (m_Image.GetPointer());
}
else
{
TInputImage* realInputImage = dynamic_cast<TInputImage*>(m_Image.GetPointer());
typedef itk::CastImageFilter<TInputImage, TOutputImage> CasterType;
typename CasterType::Pointer caster = CasterType::New();
typedef itk::CastImageFilter<TInputImage, TOutputImage> CasterType;
typename CasterType::Pointer caster = CasterType::New();
caster->SetInput(realInputImage);
caster->UpdateOutputInformation();
caster->SetInput(realInputImage);
caster->UpdateOutputInformation();
m_Image = caster->GetOutput();
m_Caster = caster;
m_Image = caster->GetOutput();
m_Caster = caster;
return caster->GetOutput();
return caster->GetOutput();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment