diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.h b/Modules/IO/ImageIO/include/otbImageFileWriter.h index b7bc6499b089a47cf7c75822523e56fb9cf819e0..93cee428aa69190559540530c799a80fb2e5d92f 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.h @@ -207,6 +207,9 @@ protected: /** Does the real work. */ void GenerateData(void) ITK_OVERRIDE; + /** Prepare the streaming and write the output information on disk */ + void GenerateOutputInformation(void) override; + private: ImageFileWriter(const ImageFileWriter &); //purposely not implemented void operator =(const ImageFileWriter&); //purposely not implemented diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.txx b/Modules/IO/ImageIO/include/otbImageFileWriter.txx index b1472291f1ae216f302757ad00b69bfd161b3630..820d945241effbe66d7354ea6550e386eed0bb7a 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.txx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.txx @@ -268,13 +268,11 @@ ImageFileWriter<TInputImage> return static_cast<const InputImageType*>(this->ProcessObject::GetInput(0)); } -/** - * Update method : update output information of input and write to file - */ +/** Prepare everything and call m_ImageIO.WriteInformation() */ template<class TInputImage> void ImageFileWriter<TInputImage> -::Update() +::GenerateOutputInformation(void) { // Update output information on input image InputImagePointer inputPtr = @@ -393,14 +391,6 @@ ImageFileWriter<TInputImage> } } - this->SetAbortGenerateData(0); - this->SetProgress(0.0); - - /** - * Tell all Observers that the filter is starting - */ - this->InvokeEvent(itk::StartEvent()); - /** Prepare ImageIO : create ImageFactory */ if (m_FileName == "") @@ -479,7 +469,6 @@ ImageFileWriter<TInputImage> /** * Grab the input */ - inputPtr->UpdateOutputInformation(); InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); /** Parse region size modes */ @@ -544,12 +533,6 @@ ImageFileWriter<TInputImage> m_NumberOfDivisions = m_StreamingManager->GetNumberOfSplits(); otbMsgDebugMacro(<< "Number Of Stream Divisions : " << m_NumberOfDivisions); - /** - * Loop over the number of pieces, execute the upstream pipeline on each - * piece, and copy the results into the output image. - */ - InputImageRegionType streamRegion; - // // Setup the ImageIO with information from inputPtr // @@ -588,12 +571,33 @@ ImageFileWriter<TInputImage> m_ImageIO->SetFileName(m_FileName.c_str()); m_ImageIO->WriteImageInformation(); +} +/** + * Update method : update output information of input and write to file + */ +template<class TInputImage> +void +ImageFileWriter<TInputImage> +::Update() +{ + this->UpdateOutputInformation(); + + this->SetAbortGenerateData(0); + this->SetProgress(0.0); + + /** + * Tell all Observers that the filter is starting + */ + this->InvokeEvent(itk::StartEvent()); + this->UpdateProgress(0); m_CurrentDivision = 0; m_DivisionProgress = 0; // Get the source process object + InputImagePointer inputPtr = + const_cast<InputImageType *>(this->GetInput()); itk::ProcessObject* source = inputPtr->GetSource(); m_IsObserving = false; m_ObserverID = 0; @@ -615,6 +619,12 @@ ImageFileWriter<TInputImage> itkWarningMacro(<< "Could not get the source process object. Progress report might be buggy"); } + /** + * Loop over the number of pieces, execute the upstream pipeline on each + * piece, and copy the results into the output image. + */ + InputImageRegionType streamRegion; + for (m_CurrentDivision = 0; m_CurrentDivision < m_NumberOfDivisions && !this->GetAbortGenerateData(); m_CurrentDivision++, m_DivisionProgress = 0, this->UpdateFilterProgress())