Skip to content
Snippets Groups Projects
Commit 226a87e2 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

BUG: improvement of the correction 22e36285f581

parent 480859f6
Branches
Tags
No related merge requests found
...@@ -43,9 +43,10 @@ void ...@@ -43,9 +43,10 @@ void
UnaryFunctorObjectListBooleanFilter<TInputList,TOutputList,TFunction> UnaryFunctorObjectListBooleanFilter<TInputList,TOutputList,TFunction>
::GenerateData(void) ::GenerateData(void)
{ {
this->AllocateOutputs();
InputListPointer inputPtr = this->GetInput(); InputListPointer inputPtr = this->GetInput();
OutputListPointer outputPtr = this->GetOutput(); OutputListPointer outputPtr = this->GetOutput();
outputPtr->Clear();//FIXME this should be probably be in a superclass in a method called before GenerateData()
itk::ProgressReporter progress(this, 0, inputPtr->Size()); itk::ProgressReporter progress(this, 0, inputPtr->Size());
......
...@@ -43,9 +43,10 @@ void ...@@ -43,9 +43,10 @@ void
UnaryFunctorObjectListFilter<TInputList,TOutputList,TFunction> UnaryFunctorObjectListFilter<TInputList,TOutputList,TFunction>
::GenerateData(void) ::GenerateData(void)
{ {
this->AllocateOutputs();
InputListPointer inputPtr = this->GetInput(); InputListPointer inputPtr = this->GetInput();
OutputListPointer outputPtr = this->GetOutput(); OutputListPointer outputPtr = this->GetOutput();
outputPtr->Clear();//FIXME this should be probably be in a superclass in a method called before GenerateData()
itk::ProgressReporter progress(this, 0, inputPtr->Size()); itk::ProgressReporter progress(this, 0, inputPtr->Size());
......
...@@ -25,7 +25,7 @@ PURPOSE. See the above copyright notices for more information. ...@@ -25,7 +25,7 @@ PURPOSE. See the above copyright notices for more information.
namespace otb namespace otb
{ {
/** \class ObjectList /** \class ObjectList
* \brief This class is a generic all-purpose wrapping around an std::vector<SmartPointer<ObjectType>>. * \brief This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
* *
* ObjectList stores SmartPointer to ObjectType in a std::vector data structure. It provides the same * ObjectList stores SmartPointer to ObjectType in a std::vector data structure. It provides the same
* methods and iterators interfaces. * methods and iterators interfaces.
......
...@@ -171,6 +171,9 @@ namespace otb ...@@ -171,6 +171,9 @@ namespace otb
/**PrintSelf method */ /**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** Ensure that the list are cleared before processing */
virtual void AllocateOutputs();
/** ObjectListSource can be implemented as a multithreaded filter. /** ObjectListSource can be implemented as a multithreaded filter.
* Therefore, this implementation provides a ThreadedGenerateData() routine * Therefore, this implementation provides a ThreadedGenerateData() routine
* which is called for each processing thread. The output image data is * which is called for each processing thread. The output image data is
...@@ -181,7 +184,7 @@ namespace otb ...@@ -181,7 +184,7 @@ namespace otb
* *
* \sa ImageToImageFilter::ThreadedGenerateData(), * \sa ImageToImageFilter::ThreadedGenerateData(),
* ImageToImageFilter::GenerateData() */ * ImageToImageFilter::GenerateData() */
void GenerateData(void); virtual void GenerateData(void);
private: private:
ObjectListSource(const Self&); //purposely not implemented ObjectListSource(const Self&); //purposely not implemented
......
...@@ -116,9 +116,25 @@ namespace otb ...@@ -116,9 +116,25 @@ namespace otb
output->Graft( graft ); output->Graft( graft );
} }
//----------------------------------------------------------------------------
template <class TOutputList>
void
ObjectListSource<TOutputList>
::AllocateOutputs()
{
OutputListPointer outputPtr;
// Allocate the output memory
for (unsigned int i=0; i < this->GetNumberOfOutputs(); i++)
{
outputPtr = this->GetOutput(i);
outputPtr->Clear();
}
}
/** /**
* GenerateData Performs the pixel-wise addition * GenerateData
*/ */
template <class TOutputList> template <class TOutputList>
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment