OTB  6.7.0
Orfeo Toolbox
otbStreamingImageVirtualWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbStreamingImageVirtualWriter_h
22 #define otbStreamingImageVirtualWriter_h
23 
24 #include "itkMacro.h"
25 #include "itkImageToImageFilter.h"
26 #include "otbStreamingManager.h"
27 #include "itkFastMutexLock.h"
28 
29 namespace otb
30 {
31 
59 template <class TInputImage >
60 class ITK_EXPORT StreamingImageVirtualWriter : public itk::ImageToImageFilter<TInputImage, TInputImage>
61 {
62 public:
68 
70  itkNewMacro(Self);
71 
74 
76  typedef TInputImage InputImageType;
77  typedef typename InputImageType::Pointer InputImagePointer;
78  typedef typename InputImageType::RegionType InputImageRegionType;
79  typedef typename InputImageType::PixelType InputImagePixelType;
80 
84 
86  itkStaticConstMacro(InputImageDimension, unsigned int,
87  InputImageType::ImageDimension);
88 
92  {
93  return m_StreamingManager;
94  }
95 
98  void SetStreamingManager(StreamingManagerType* streamingManager)
99  {
100  m_StreamingManager = streamingManager;
101  }
102 
105  void SetNumberOfDivisionsStrippedStreaming(unsigned int nbDivisions);
106 
109  void SetNumberOfDivisionsTiledStreaming(unsigned int nbDivisions);
110 
113  void SetNumberOfLinesStrippedStreaming(unsigned int nbLinesPerStrip);
114 
120  void SetAutomaticStrippedStreaming(unsigned int availableRAM = 0, double bias = 1.0);
121 
124  void SetTileDimensionTiledStreaming(unsigned int tileDimension);
125 
132  void SetAutomaticTiledStreaming(unsigned int availableRAM = 0, double bias = 1.0);
133 
140  void SetAutomaticAdaptativeStreaming(unsigned int availableRAM = 0, double bias = 1.0);
141 
144  void Update() override;
145 
147  const bool & GetAbortGenerateData() const override;
148 
149  void SetAbortGenerateData(const bool val) override;
150 
151 protected:
153 
154  ~StreamingImageVirtualWriter() override;
155 
156  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
157 
158  void GenerateData(void) override;
159 
160  void GenerateInputRequestedRegion(void) override;
161 
162 private:
164  void operator =(const StreamingImageVirtualWriter&) = delete;
165 
167  {
168  if (typeid(event) != typeid(itk::ProgressEvent))
169  {
170  return;
171  }
172 
173  itk::ProcessObject* processObject = dynamic_cast<itk::ProcessObject*>(object);
174  if (processObject)
175  {
176  m_DivisionProgress = processObject->GetProgress();
177  }
178 
179  this->UpdateFilterProgress();
180  }
181 
183  {
184  this->UpdateProgress( (m_DivisionProgress + m_CurrentDivision) / m_NumberOfDivisions );
185  }
186 
187  unsigned int m_NumberOfDivisions;
188  unsigned int m_CurrentDivision;
190 
192 
194  unsigned long m_ObserverID;
195 
198 };
199 
200 } // end namespace otb
201 
202 #ifndef OTB_MANUAL_INSTANTIATION
204 #endif
205 
206 #endif
void ObserveSourceFilterProgress(itk::Object *object, const itk::EventObject &event)
virtual const float & GetProgress() const
itk::ImageToImageFilter< TInputImage, TInputImage > Superclass
StreamingManager< InputImageType > StreamingManagerType
This class handles the streaming process used in the writers implementation.
void SetStreamingManager(StreamingManagerType *streamingManager)
itk::SmartPointer< const Self > ConstPointer
StreamingManagerType * GetStreamingManager(void)
This class acts like a StreamingImageFileWriter, but without actually writing data to the disk...
StreamingManagerType::Pointer StreamingManagerPointerType