This file is indexed.

/usr/include/OTB-6.4/otbRCC8GraphFileWriter.txx is in libotb-dev 6.4.0+dfsg-1.

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
/*
 * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
 *
 * This file is part of Orfeo Toolbox
 *
 *     https://www.orfeo-toolbox.org/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef otbRCC8GraphFileWriter_txx
#define otbRCC8GraphFileWriter_txx

#include "otbRCC8GraphFileWriter.h"
#include "otbRCC8VertexIterator.h"
#include "otbRCC8EdgeIterator.h"
#include "otbMacro.h"
#include <fstream>

namespace otb
{
/**
 * Constructor
 */
template <class TInputGraph>
RCC8GraphFileWriter<TInputGraph>
::RCC8GraphFileWriter()
{
  this->SetNumberOfRequiredInputs(1);
  m_FileName = "";
}
/**
 * Destructor
 */
template <class TInputGraph>
RCC8GraphFileWriter<TInputGraph>
::~RCC8GraphFileWriter()
{
}
/**
 * Set the input graph.
 * \param graph The graph to write.
 */
template <class TInputGraph>
void
RCC8GraphFileWriter<TInputGraph>
::SetInput(const InputGraphType * graph)
{
  this->itk::ProcessObject::SetNthInput(0, const_cast<TInputGraph *>(graph));
}
/**
 * Get the input graph.
 * \return The input graph pointer.
 */
template <class TInputGraph>
typename RCC8GraphFileWriter<TInputGraph>
::InputGraphPointerType
RCC8GraphFileWriter<TInputGraph>
::GetInput(void)
{
  return static_cast<TInputGraph*>(this->itk::ProcessObject::GetInput(0));
}
/**
 * Update method.
 * (Call the Write() method).
 */
template <class TInputGraph>
void
RCC8GraphFileWriter<TInputGraph>
::Update(void)
{
  this->Write();
}
/**
 * Write Method.
 * Performs checkings and invoke GenerateData().
 */
template <class TInputGraph>
void
RCC8GraphFileWriter<TInputGraph>
::Write(void)
{
  InputGraphType * input = this->GetInput();

  itkDebugMacro(<< "Writing a RCC8Graph file");

  // Make sure input is available
  if (input == ITK_NULLPTR)
    {
    itkExceptionMacro(<< "No input to writer!");
    }

  // Make sure that we can write the file given the name
  //
  if (m_FileName == "")
    {
    itkExceptionMacro(<< "No filename was specified");
    }

  // Pipeline updating sequence
  input->UpdateOutputInformation();
  input->PropagateRequestedRegion();
  input->UpdateOutputData();
  // GenerateData (actually write file)
  this->GenerateData();
}
/**
 * Main computation method.
 */
template <class TInputGraph>
void
RCC8GraphFileWriter<TInputGraph>
::GenerateData()
{
  otbMsgDevMacro(<< "RCC8GraphFileWriter: GenerateData call");
  // input graph pointer
  InputGraphPointerType input = this->GetInput();

  // iterators typedefs
  typedef otb::RCC8VertexIterator<InputGraphType> VertexIteratorType;
  typedef otb::RCC8EdgeIterator<InputGraphType>   EdgeIteratorType;

  // Output file stream
  std::ofstream out;

  // open the outputfile
  out.open(m_FileName.c_str(), std::ios::out);

  // Test if the file has been opened correctly
  if (!out)
    {
    RCC8GraphFileWriterException e(__FILE__, __LINE__);
    std::ostringstream msg;
    msg << " Could not create IO object for file ";
    msg << m_FileName << "." << std::endl;
    e.SetDescription(msg.str().c_str());
    throw e;
    return;
    }

  // Start writing the graph to file
  out << "digraph G {" << std::endl;

  // For each vertex in the graph
  VertexIteratorType vIt(input);
  for (vIt.GoToBegin(); !vIt.IsAtEnd(); ++vIt)
    {
    this->WriteVertex(out, vIt.GetIndex(), vIt.Get());
    }

  // For each edge in the graph
  EdgeIteratorType eIt(input);
  for (eIt.GoToBegin(); !eIt.IsAtEnd(); ++eIt)
    {
    this->WriteEdge(out, eIt.GetSourceIndex(),
                    eIt.GetTargetIndex(),
                    eIt.GetValue());
    }

  // Ends the graph writing
  out << "}" << std::endl;

  // Close the file
  out.close();
}
/**
 * Write an edge to file.
 * \param of The output file stream.
 * \param source The index of the source vertex.
 * \param target The index of the target vertex.
 * \param value  The value of the edge.
 */
template <class TInputGraph>
void
RCC8GraphFileWriter<TInputGraph>
::WriteEdge(std::ofstream& of, VertexDescriptorType source,
            VertexDescriptorType target, RCC8ValueType value)
{
  otbMsgDevMacro(<< "RCC8GraphFileWriter: WriteEdge call: " << source << " " << target << " " << value);
  of << source << " -> " << target << " ";
  of << "[Value=\"" << value << "\"];";
  of << std::endl;
}
/**
 * Write a vertex to file.
 * \param of The output file stream.
 * \param index The index of the edge to write.
 * \param vertex The pointer to the vertex object.
 */
template <class TInputGraph>
void
RCC8GraphFileWriter<TInputGraph>
::WriteVertex(std::ofstream& of, VertexDescriptorType index,
              VertexPointerType vertex)
{
  typedef typename VertexType::AttributesMapType AttributesMapType;
  typedef typename AttributesMapType::iterator   IteratorType;
  AttributesMapType attr = vertex->GetAttributesMap();
  otbMsgDevMacro(<< "RCC8GraphFileWriter: WriteVertex call: " << index);
  of << index << " [";
  IteratorType it = attr.begin();
  while (it != attr.end())
    {
    of << (*it).first << "=\"";
    of << (*it).second << "\"";
    ++it;
    if (it == attr.end())
      {
      of << "];" << std::endl;
      }
    else
      {
      of << ",";
      }
    }
}
/**
 * PrintSelf method
 */
template <class TInputGraph>
void
RCC8GraphFileWriter<TInputGraph>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
  Superclass::PrintSelf(os, indent);
}
} // namespace otb
#endif