OTB  9.0.0
Orfeo Toolbox
otbMaskMuParserFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 
23 #ifndef otbMaskMuParserFilter_h
24 #define otbMaskMuParserFilter_h
25 
26 
27 #include "itkProgressReporter.h"
28 #include <string>
29 #include <vector>
30 
31 #include "itkArray.h"
32 
33 
34 #include "otbMaskMuParserFunctor.h"
35 
36 #include "itkImageToImageFilter.h"
37 #include "itkImageRegionIteratorWithIndex.h"
38 
39 namespace otb
40 {
72 template <class TInputImage, class TOutputImage, class TFunction = Functor::MaskMuParserFunctor<typename TInputImage::PixelType>>
73 class ITK_EXPORT MaskMuParserFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
74 {
75 public:
78  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
79  typedef itk::SmartPointer<Self> Pointer;
80  typedef itk::SmartPointer<const Self> ConstPointer;
81 
83  itkNewMacro(Self);
84  ;
85 
87  itkTypeMacro(MaskMuParserFilter, itk::ImageToImageFilter);
88  ;
90 
92  typedef TInputImage InputImageType;
93  typedef typename InputImageType::RegionType InputImageRegionType;
94  typedef typename InputImageType::PixelType PixelType;
95  typedef typename InputImageType::IndexType IndexType;
96  typedef typename InputImageType::Pointer InputImagePointer;
97  typedef typename InputImageType::ConstPointer InputImageConstPointer;
98  typedef TOutputImage OutputImageType;
99  typedef typename OutputImageType::RegionType OutputImageRegionType;
100 
101  typedef typename OutputImageType::Pointer OutputImagePointer;
102  typedef TFunction FunctorType;
103  typedef typename FunctorType::Pointer FunctorPointer;
104 
106 
108  void SetExpression(const std::string expression);
109 
111  bool CheckExpression();
112 
114  std::string GetExpression() const;
115 
116  std::vector<std::string> GetVar();
117 
118  Parser::FunctionMapType GetFunList();
119 
120 protected:
122  ~MaskMuParserFilter() override;
123  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
124 
125  void BeforeThreadedGenerateData() override;
126  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) override;
127  void AfterThreadedGenerateData() override;
128 
129 private:
130  MaskMuParserFilter(const Self&) = delete;
131  void operator=(const Self&) = delete;
132 
133  std::vector<FunctorPointer> m_VFunctor;
134  std::string m_Expression;
137  itk::Array<long> m_ThreadUnderflow;
138  itk::Array<long> m_ThreadOverflow;
139 };
140 
141 } // end namespace otb
142 
143 #ifndef OTB_MANUAL_INSTANTIATION
144 #include "otbMaskMuParserFilter.hxx"
145 #endif
146 
147 #endif
otb::MaskMuParserFilter::m_OverflowCount
long m_OverflowCount
Definition: otbMaskMuParserFilter.h:136
otb::MaskMuParserFilter::m_ThreadOverflow
itk::Array< long > m_ThreadOverflow
Definition: otbMaskMuParserFilter.h:138
otb::MaskMuParserFilter::FunctorPointer
FunctorType::Pointer FunctorPointer
Definition: otbMaskMuParserFilter.h:103
otb::MaskMuParserFilter::PixelType
InputImageType::PixelType PixelType
Definition: otbMaskMuParserFilter.h:94
otb::MaskMuParserFilter::m_UnderflowCount
long m_UnderflowCount
Definition: otbMaskMuParserFilter.h:135
otb::Parser::FunctionMapType
std::map< std::string, int > FunctionMapType
Definition: otbParser.h:64
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MaskMuParserFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbMaskMuParserFilter.h:98
otb::MaskMuParserFilter::Superclass
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Definition: otbMaskMuParserFilter.h:78
otb::MaskMuParserFilter::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbMaskMuParserFilter.h:93
otbMaskMuParserFunctor.h
otb::MaskMuParserFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbMaskMuParserFilter.h:99
otb::MaskMuParserFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbMaskMuParserFilter.h:101
otb::MaskMuParserFilter::InputImageConstPointer
InputImageType::ConstPointer InputImageConstPointer
Definition: otbMaskMuParserFilter.h:97
otb::MaskMuParserFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMaskMuParserFilter.h:80
otb::MaskMuParserFilter::IndexType
InputImageType::IndexType IndexType
Definition: otbMaskMuParserFilter.h:95
otb::MaskMuParserFilter::m_Expression
std::string m_Expression
Definition: otbMaskMuParserFilter.h:134
otb::MaskMuParserFilter::InputImageType
TInputImage InputImageType
Definition: otbMaskMuParserFilter.h:87
otb::MaskMuParserFilter::m_ThreadUnderflow
itk::Array< long > m_ThreadUnderflow
Definition: otbMaskMuParserFilter.h:137
otb::MaskMuParserFilter::FunctorType
TFunction FunctorType
Definition: otbMaskMuParserFilter.h:102
otb::MaskMuParserFilter::InputImagePointer
InputImageType::Pointer InputImagePointer
Definition: otbMaskMuParserFilter.h:96
otb::MaskMuParserFilter::m_VFunctor
std::vector< FunctorPointer > m_VFunctor
Definition: otbMaskMuParserFilter.h:133
otb::MaskMuParserFilter
Definition: otbMaskMuParserFilter.h:73
otb::MaskMuParserFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMaskMuParserFilter.h:79
otbMaskMuParserFilter.hxx
otb::MaskMuParserFilter::MaskMuParserFilterType
MaskMuParserFilter< InputImageType, OutputImageType, FunctorType > MaskMuParserFilterType
Definition: otbMaskMuParserFilter.h:105
otb::MaskMuParserFilter::Self
MaskMuParserFilter Self
Definition: otbMaskMuParserFilter.h:77