From 460be60a4ee465504796e7bb4698baeb4436ab77 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@orfeo-toolbox.org> Date: Wed, 27 Mar 2013 14:07:55 +0100 Subject: [PATCH] ENH: crop user defined box region with the LargestPossibleRegion --- Code/IO/otbImageFileWriter.txx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Code/IO/otbImageFileWriter.txx b/Code/IO/otbImageFileWriter.txx index 09aa007278..02e62b106e 100644 --- a/Code/IO/otbImageFileWriter.txx +++ b/Code/IO/otbImageFileWriter.txx @@ -478,6 +478,20 @@ ImageFileWriter<TInputImage> { inputRegion = m_FilenameHelper->GetBox(); otbMsgDevMacro(<< "inputRegion " << inputRegion); + + if (!inputRegion.Crop(inputPtr->GetLargestPossibleRegion())) + { + // Couldn't crop the region (requested region is outside the largest + // possible region). Throw an exception. + + // build an exception + itk::InvalidRequestedRegionError e(__FILE__, __LINE__); + e.SetLocation(ITK_LOCATION); + e.SetDescription("Requested box region is (at least partially) outside the largest possible region."); + e.SetDataObject(inputPtr); + throw e; + } + otbMsgDevMacro(<< "inputRegion " << inputRegion); } /** -- GitLab