Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment