This file is indexed.

/usr/include/OTB-5.8/otbLabelObjectToPolygonFunctor.h is in libotb-dev 5.8.0+dfsg-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


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


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef otbLabelObjectToPolygonFunctor_h
#define otbLabelObjectToPolygonFunctor_h

#include <vector>

//TODO change this include  have to define from what inherate this class
#include "otbPolyLineParametricPathWithValue.h" //for vcl_abs

#include "itkPoint.h"
#include "itkIndex.h"

namespace otb
{

namespace Functor
{

/** \class LabelObjectToPolygonFunctor
 *  \brief This class vectorizes a LabelObject to a Polygon.
 *
 * The algorithm follows a finite states machine described in the
 * following paper:
 *
 * "An algorithm for the rapid computation of boundaries of run-length
 * encoded regions", Francis K. H. Queck, in Pattern Recognition 33
 * (2000), p 1637-1649.
 *
 * Lines in the RLE are first sorted in lexicographical order (to
 * ensure ordered RLE), and the finite states machine tracks the edge
 * following 8 canonical states given by the configuration of two
 * consecutive raws of lines.
 *
 * Iterations are done until convergence which is guaranteed to
 * happen.
 *
 * Please be aware that this functor is not thread-safe.
 *
 *
 * \ingroup OTBLabelMap
 */
template <class TLabelObject, class TPolygon>
class LabelObjectToPolygonFunctor
{
public:
  /** Template parameters typedefs */
  typedef TLabelObject                                LabelObjectType;
  /** Const iterator over LabelObject lines */
  typedef typename LabelObjectType::ConstLineIterator  ConstLineIteratorType;

  typedef typename LabelObjectType::LineType          LineType;
  typedef typename LineType::IndexType                IndexType;
  typedef TPolygon                                    PolygonType;
  typedef typename PolygonType::Pointer               PolygonPointerType;
  typedef typename PolygonType::VertexType            VertexType;
  typedef itk::Point<double, 2>                       PointType;
  typedef itk::Vector<double, 2>                      SpacingType;
  typedef itk::Index<2>                               RegionIndexType;

  /**
   * \param labelObject the label object to vectorize
   * \return The vectorized label object as a polygon.
   */
  inline PolygonType * operator ()(LabelObjectType * labelObject);

  /** Get  name of class. */
  const char * GetNameOfClass()
    {
      return "LabelObjectToPolygonFunctor";
    }

  /** Set the start index of the underlying image */
  void SetStartIndex(const RegionIndexType& index)
  {
    m_StartIndex = index;
  }
  /** Get the start index */
  const RegionIndexType& GetStartIndex() const
  {
    return m_StartIndex;
  }
  /** Set the origin of the underlying image */
  void SetOrigin(const PointType& origin)
  {
    m_Origin = origin;
  }
  /** Get the origin */
  const PointType& GetOrigin() const
  {
    return m_Origin;
  }
  /** Set the spacing of the underlying image */
  void SetSpacing(const SpacingType& spacing)
  {
    m_Spacing = spacing;
  }
  /** Get the spacing */
  const SpacingType& GetSpacing() const
  {
    return m_Spacing;
  }

  /** Constructor */
  LabelObjectToPolygonFunctor() : m_Polygon(ITK_NULLPTR),
    m_CurrentState(UP_LEFT),
    m_PositionFlag(LEFT_END),
    m_StartingPoint(),
    m_CurrentPoint(),
    m_CurrentRun(),
    m_CurrentLine(0),
    m_Solution(),
    m_LineOffset(0),
    m_StartIndex(),
    m_Origin(),
    m_Spacing(1.)
  {
    m_StartingPoint.Fill(0);
    m_CurrentPoint.Fill(0);
    m_CurrentRun.Fill(0);
    m_StartIndex.Fill(0);
    m_Origin.Fill(0);
}

  /** Destructor */
  virtual ~LabelObjectToPolygonFunctor(){}

private:
  /// Internal structures
  typedef std::vector<LineType>        RunsPerLineType;
  typedef std::vector<RunsPerLineType> RunsPerLineVectorType;
  typedef std::vector<IndexType>       IndexVectorType;

  /// Internal enums
  enum StateType {UP_LEFT, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT};
  enum PositionFlagType {LEFT_END, RIGHT_END};

  /// Compare two line in the lexicographical order
  static bool LexicographicalLineCompare(const LineType&  l1, const LineType& l2);

  /// Check if the given run index (index in line, line) is valid
  inline bool IsRunIndexValid(const IndexType& index) const;

  /// Check if the point lies within the range of the line
  inline IndexType Within(const IndexType& point, unsigned int line) const;

  /// Return the left-end of the run
  inline IndexType LeftEnd(const IndexType& runIndex) const;

  /// Return the right-end of the run
  inline IndexType RightEnd(const IndexType& runIndex) const;

  /** Return the right-most run whose left end lies within the range of
   * the given run.
   */
  inline IndexType RightMostLeftEndInside(unsigned int line, const IndexType& point, const IndexType& run) const;

  /** Return the left-most run whose right end lies within the range of
   * the given run.
   */
  inline IndexType LeftMostRightEndInside(unsigned int line, const IndexType& point, const IndexType& run) const;

  /// Walk left to update the finite states machine.
  inline void WalkLeft(unsigned int line,
                       const IndexType& startPoint,
                       const IndexType& endPoint,
                       PolygonType * polygon,
                       const StateType state);

  /// Walk right to update the finite states machine.
  inline void WalkRight(unsigned int line,
                        const IndexType& startPoint,
                        const IndexType& endPoint,
                        PolygonType * polygon,
                        const StateType state);

  // Apply origin and spacing
  VertexType IndexToPoint(const VertexType& index) const;

  PolygonPointerType m_Polygon;

  // Internal structure to store runs
  RunsPerLineVectorType m_InternalDataSet;

  /// The current state
  StateType m_CurrentState;
  /// The position flag
  PositionFlagType m_PositionFlag;

  // The starting point for vectorization
  IndexType m_StartingPoint;

  /// The current point for vectorization
  IndexType m_CurrentPoint;

  /// The current run for vectorization
  IndexType m_CurrentRun;

  /// The current line for vectorization
  int m_CurrentLine;

  /// The vector of vectorized boundaries
  IndexVectorType m_Solution;

  /// The line offset from start of the region
  unsigned int m_LineOffset;

  // The following will be used for coordinate transform
  RegionIndexType m_StartIndex;
  PointType       m_Origin;
  SpacingType     m_Spacing;

}; // end class LabelObjectToPolygonFunctor

} // end namespace Functor

} // end namespace otb

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

#endif