21 #ifndef otbMaskMuParserFilter_hxx
22 #define otbMaskMuParserFilter_hxx
28 #include "itkImageRegionIterator.h"
29 #include "itkNumericTraits.h"
35 template <
class TInputImage,
class TOutputImage,
class TFunction>
40 m_ThreadUnderflow.SetSize(1);
41 m_ThreadOverflow.SetSize(1);
46 template <
class TInputImage,
class TOutputImage,
class TFunction>
51 template <
class TInputImage,
class TOutputImage,
class TFunction>
54 Superclass::PrintSelf(os, indent);
56 os << indent <<
"Expression: " << m_Expression << std::endl;
59 template <
class TInputImage,
class TOutputImage,
class TFunction>
62 if (m_Expression != expression)
63 m_Expression = expression;
67 template <
class TInputImage,
class TOutputImage,
class TFunction>
73 template <
class TInputImage,
class TOutputImage,
class TFunction>
76 std::vector<std::string> varList;
78 tempFunctor->SetExpression(m_Expression);
83 functor(this->GetInput()->GetPixel(this->GetInput()->GetBufferedRegion().GetIndex()));
85 catch (itk::ExceptionObject& err)
87 itkDebugMacro(<< err);
90 const std::map<std::string, double*>& varMap = functor.GetVar();
91 std::map<std::string, double*>::const_iterator it;
92 for (it = varMap.begin(); it != varMap.end(); ++it)
94 varList.push_back(it->first);
100 template <
class TInputImage,
class TOutputImage,
class TFunction>
104 tempFunctor->SetExpression(m_Expression);
110 functor(this->GetInput()->GetPixel(this->GetInput()->GetBufferedRegion().GetIndex()));
112 catch (itk::ExceptionObject& err)
114 itkDebugMacro(<< err);
117 return functor.GetFunList();
120 template <
class TInputImage,
class TOutputImage,
class TFunction>
124 checkFunctor->SetExpression(m_Expression);
130 functor(this->GetInput()->GetPixel(this->GetInput()->GetBufferedRegion().GetIndex()));
132 catch (itk::ExceptionObject& err)
134 itkDebugMacro(<< err);
143 template <
class TInputImage,
class TOutputImage,
class TFunction>
147 typename std::vector<FunctorPointer>::iterator itFunctor;
148 unsigned int nbThreads = this->GetNumberOfThreads();
149 unsigned int thread_index;
150 std::ostringstream varName;
153 m_ThreadUnderflow.SetSize(nbThreads);
154 m_ThreadUnderflow.Fill(0);
155 m_ThreadOverflow.SetSize(nbThreads);
156 m_ThreadOverflow.Fill(0);
157 m_VFunctor.resize(nbThreads);
159 for (itFunctor = m_VFunctor.begin(); itFunctor < m_VFunctor.end(); itFunctor++)
160 *itFunctor = FunctorType::New();
162 for (thread_index = 0; thread_index < nbThreads; thread_index++)
164 m_VFunctor.at(thread_index)->SetExpression(m_Expression);
168 template <
class TInputImage,
class TOutputImage,
class TFunction>
170 itk::ThreadIdType threadId)
180 this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
183 itk::ImageRegionConstIterator<TInputImage> inputIt(inputPtr, inputRegionForThread);
184 itk::ImageRegionIterator<TOutputImage> outputIt(outputPtr, outputRegionForThread);
186 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
189 outputIt.GoToBegin();
193 while (!inputIt.IsAtEnd())
195 outputIt.Set(functor(inputIt.Get()));
198 progress.CompletedPixel();
202 template <
class TInputImage,
class TOutputImage,
class TFunction>