otbImageToPointSetFilter.h 4 KB
Newer Older
Patrick Imbo's avatar
Patrick Imbo committed
1
2
/*=========================================================================

Patrick Imbo's avatar
nomsg    
Patrick Imbo committed
3
4
5
6
7
8
9
10
11
12
  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


13
14
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Patrick Imbo's avatar
nomsg    
Patrick Imbo committed
15
     PURPOSE.  See the above copyright notices for more information.
Patrick Imbo's avatar
Patrick Imbo committed
16
17
18
19
20
21
22
23
24
25
26

=========================================================================*/
#ifndef __otbImageToPointSetFilter_h
#define __otbImageToPointSetFilter_h

#include "otbPointSetSource.h"

namespace otb
{

/** \class ImageToPointSetFilter
27
 * \brief Base class to output PointSet data with image data as input
Patrick Imbo's avatar
Patrick Imbo committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 *
 * ImageToPointSetFilter is the base class for all process objects that output
 * Point Set data and require image data as input. Specifically, this class
 * defines the SetInput() method for defining the input to a filter.
 *
 * \ingroup ImageFilters
 */
template <class TInputImage, class TOutputPointSet>
class ITK_EXPORT ImageToPointSetFilter : public PointSetSource<TOutputPointSet>
{
public:
  /** Standard class typedefs. */
  typedef ImageToPointSetFilter            Self;
  typedef PointSetSource<TOutputPointSet>  Superclass;
  typedef itk::SmartPointer<Self>          Pointer;
  typedef itk::SmartPointer<const Self>    ConstPointer;

  /** Run-time type information (and related methods). */
  itkTypeMacro(ImageToPointSetFilter, PointSetSource);

  /** Some Image related typedefs. */
  typedef   TInputImage                             InputImageType;
  typedef   typename InputImageType::Pointer        InputImagePointer;
  typedef   typename InputImageType::ConstPointer   InputImageConstPointer;
52
53
54
  typedef   typename InputImageType::RegionType     InputImageRegionType;
  typedef   typename InputImageType::PixelType      InputImagePixelType;

Patrick Imbo's avatar
Patrick Imbo committed
55
56
57
  /** Some PointSet related typedefs. */
  typedef   typename Superclass::OutputPointSetType     OutputPointSetType;
  typedef   typename Superclass::OutputPointSetPointer  OutputPointSetPointer;
58
59
  typedef   typename Superclass::PointsContainerType    PointsContainerType;
  typedef   itk::ProcessObject                          ProcessObjectType;
Patrick Imbo's avatar
Patrick Imbo committed
60
61
62

  /** Set the input image of this process object.  */
  void SetInput(unsigned int idx, const InputImageType *input);
63
  void SetInput( const InputImageType *input);
Patrick Imbo's avatar
Patrick Imbo committed
64
65
66

  /** Get the input image of this process object.  */
  const InputImageType * GetInput(unsigned int idx);
67
  const InputImageType * GetInput();
Patrick Imbo's avatar
Patrick Imbo committed
68
69
70

  /** Prepare the output */
  void GenerateOutputInformation(void);
71

Patrick Imbo's avatar
Patrick Imbo committed
72
73
protected:
  ImageToPointSetFilter();
74
  virtual ~ImageToPointSetFilter() {};
Patrick Imbo's avatar
Patrick Imbo committed
75
  void PrintSelf(std::ostream& os, itk::Indent indent) const;
76

77
78
79
80
  virtual void GenerateData(void);

  /** Multi-threading implementation */

81
  typedef std::vector<typename OutputPointSetType::PointsContainer::Pointer> OutputPointsContainerForThreadType;
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

  virtual void BeforeThreadedGenerateData();

  virtual void AfterThreadedGenerateData();

  virtual int SplitRequestedRegion(int i, int num, InputImageRegionType& splitRegion);

  virtual void ThreadedGenerateData(const InputImageRegionType &inputRegionForThread, int threadId);

  /** Static function used as a "callback" by the MultiThreader.  The threading
   * library will call this routine for each thread, which will delegate the
   * control to ThreadedGenerateData(). */
  static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg );

  /** Internal structure used for passing image data into the threading library */
  struct ThreadStruct
  {
    Pointer Filter;
  };

102
  OutputPointsContainerForThreadType m_PointsContainerPerThread;
103
104
105

  /** End Multi-threading implementation */

Patrick Imbo's avatar
Patrick Imbo committed
106
107
108
109
110
111
112
113
114
115
116
117
118
private:
  ImageToPointSetFilter(const ImageToPointSetFilter&); //purposely not implemented
  void operator=(const ImageToPointSetFilter&); //purposely not implemented

};

} // end namespace otb

#ifndef OTB_MANUAL_INSTANTIATION
#include "otbImageToPointSetFilter.txx"
#endif

#endif