18 #ifndef __otbRCC8GraphFileWriter_txx
19 #define __otbRCC8GraphFileWriter_txx
32 template <
class TInputGraph>
36 this->SetNumberOfRequiredInputs(1);
42 template <
class TInputGraph>
51 template <
class TInputGraph>
62 template <
class TInputGraph>
64 ::InputGraphPointerType
74 template <
class TInputGraph>
85 template <
class TInputGraph>
92 itkDebugMacro(<<
"Writing a RCC8Graph file");
97 itkExceptionMacro(<<
"No input to writer!");
102 if (m_FileName ==
"")
104 itkExceptionMacro(<<
"No filename was specified");
108 input->UpdateOutputInformation();
109 input->PropagateRequestedRegion();
110 input->UpdateOutputData();
112 this->GenerateData();
117 template <
class TInputGraph>
134 out.open(m_FileName.c_str(), std::ios::out);
140 std::ostringstream msg;
141 msg <<
" Could not create IO object for file ";
142 msg << m_FileName <<
"." << std::endl;
149 out <<
"digraph G {" << std::endl;
152 VertexIteratorType vIt(input);
153 for (vIt.GoToBegin(); !vIt.IsAtEnd(); ++vIt)
155 this->WriteVertex(out, vIt.GetIndex(), vIt.Get());
159 EdgeIteratorType eIt(input);
160 for (eIt.GoToBegin(); !eIt.IsAtEnd(); ++eIt)
162 this->WriteEdge(out, eIt.GetSourceIndex(),
163 eIt.GetTargetIndex(),
168 out <<
"}" << std::endl;
180 template <
class TInputGraph>
186 otbMsgDevMacro(<<
"RCC8GraphFileWriter: WriteEdge call: " << source <<
" " << target <<
" " << value);
187 of << source <<
" -> " << target <<
" ";
188 of <<
"[Value=\"" << value <<
"\"];";
197 template <
class TInputGraph>
204 typedef typename AttributesMapType::iterator IteratorType;
205 AttributesMapType attr = vertex->GetAttributesMap();
206 otbMsgDevMacro(<<
"RCC8GraphFileWriter: WriteVertex call: " << index);
208 IteratorType it = attr.begin();
209 while (it != attr.end())
211 of << (*it).first <<
"=\"";
212 of << (*it).second <<
"\"";
214 if (it == attr.end())
216 of <<
"];" << std::endl;
227 template <
class TInputGraph>
232 Superclass::PrintSelf(os, indent);