Commit f45c930e authored by Julien Michel's avatar Julien Michel

BUG: Avoid a cast that can fail if ImageBase* does not downcast to OutputImageType*

parent 61c5ef81
......@@ -117,21 +117,13 @@ void
OGRDataSourceToLabelImageFilter<TOutputImage>
::SetOutputParametersFromImage(const ImageBaseType * image)
{
if (dynamic_cast<const OutputImageType*>(image))
{
const OutputImageType * src = dynamic_cast<const OutputImageType*>(image);
this->SetOutputOrigin ( src->GetOrigin() );
this->SetOutputSpacing ( src->GetSpacing() );
//this->SetOutputStartIndex ( src->GetLargestPossibleRegion().GetIndex() );
this->SetOutputSize ( src->GetLargestPossibleRegion().GetSize() );
this->SetOutputProjectionRef(src->GetProjectionRef());
//this->SetOutputKeywordList(src->GetImageKeywordlist());
}
else
{
itkExceptionMacro(<< "Image can't be casted to output image type.");
}
this->SetOutputOrigin ( image->GetOrigin() );
this->SetOutputSpacing ( image->GetSpacing() );
this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() );
ImageMetadataInterfaceBase::Pointer imi = ImageMetadataInterfaceFactory::CreateIMI(image->GetMetaDataDictionary());
this->SetOutputProjectionRef(imi->GetProjectionRef());
}
template< class TOutputImage>
......
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