Commit f45c930e authored by Julien Michel's avatar Julien Michel
Browse files

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

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