From 52abf31e3700ba4675b6d9b3263787418cefc790 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@c-s.fr>
Date: Mon, 11 Dec 2006 10:21:56 +0000
Subject: [PATCH] =?UTF-8?q?Ajout=20du=20support=20des=20it=C3=A9rateur=20d?=
 =?UTF-8?q?'arr=C3=AAtes=20incidentes=20et=20sortantes,=20tests=20associ?=
 =?UTF-8?q?=C3=A9s=20ajout=C3=A9s=20au=20test=20RCC8Graph.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Code/SpatialReasoning/otbRCC8EdgeIterator.h   |   2 +-
 Code/SpatialReasoning/otbRCC8EdgeIterator.txx |   5 +-
 Code/SpatialReasoning/otbRCC8InEdgeIterator.h | 124 +++++++++++
 .../otbRCC8InEdgeIterator.txx                 | 192 ++++++++++++++++++
 .../SpatialReasoning/otbRCC8OutEdgeIterator.h | 124 +++++++++++
 .../otbRCC8OutEdgeIterator.txx                | 192 ++++++++++++++++++
 .../Code/SpatialReasoning/otbRCC8Graph.cxx    |  32 +++
 7 files changed, 669 insertions(+), 2 deletions(-)
 create mode 100644 Code/SpatialReasoning/otbRCC8InEdgeIterator.h
 create mode 100644 Code/SpatialReasoning/otbRCC8InEdgeIterator.txx
 create mode 100644 Code/SpatialReasoning/otbRCC8OutEdgeIterator.h
 create mode 100644 Code/SpatialReasoning/otbRCC8OutEdgeIterator.txx

diff --git a/Code/SpatialReasoning/otbRCC8EdgeIterator.h b/Code/SpatialReasoning/otbRCC8EdgeIterator.h
index 7eb617d835..9ea0f5b50c 100644
--- a/Code/SpatialReasoning/otbRCC8EdgeIterator.h
+++ b/Code/SpatialReasoning/otbRCC8EdgeIterator.h
@@ -24,7 +24,7 @@ namespace otb
 {
 /**
  * \class EdgeIterator
- * \brief Iterates on the graph vertices
+ * \brief Iterates on the graph edges.
  */
 template <class TGraph>
 class RCC8EdgeIterator 
diff --git a/Code/SpatialReasoning/otbRCC8EdgeIterator.txx b/Code/SpatialReasoning/otbRCC8EdgeIterator.txx
index 922ec0947b..486a6a07e9 100644
--- a/Code/SpatialReasoning/otbRCC8EdgeIterator.txx
+++ b/Code/SpatialReasoning/otbRCC8EdgeIterator.txx
@@ -48,7 +48,10 @@ namespace otb
     m_Graph=graph;
     tie(m_Iter,m_End)=edges(*m_Graph->GetGraph());
   }
-  
+  /**
+   * Get the current edge value.
+   * \return The value of the current edge pointed by the iterator.
+   */
   template <class TGraph>
   typename  RCC8EdgeIterator<TGraph>
   ::RCC8ValueType 
diff --git a/Code/SpatialReasoning/otbRCC8InEdgeIterator.h b/Code/SpatialReasoning/otbRCC8InEdgeIterator.h
new file mode 100644
index 0000000000..48583650c9
--- /dev/null
+++ b/Code/SpatialReasoning/otbRCC8InEdgeIterator.h
@@ -0,0 +1,124 @@
+/*=========================================================================
+
+  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 _otbRCC8InEdgeIterator_h
+#define _otbRCC8InEdgeIterator_h
+
+#include "otbRCC8Graph.h"
+
+namespace otb
+{
+/**
+ * \class EdgeIterator
+ * \brief Iterates on the graph in edges from a vertex.
+ */
+template <class TGraph>
+class RCC8InEdgeIterator 
+{
+ public:
+  /** self typedef */
+  typedef RCC8InEdgeIterator Self;
+
+  /** Graph typedef */
+  typedef TGraph GraphType;
+  typedef typename GraphType::InternalGraphType InternalGraphType;
+  typedef typename GraphType::Pointer GraphPointerType;
+  typedef typename GraphType::EdgePointerType EdgePointerType;
+  typedef typename GraphType::VertexPointerType VertexPointerType;
+  typedef typename GraphType::VertexDescriptorType VertexDescriptorType;
+  typedef typename GraphType::RCC8ValueType RCC8ValueType;
+  /** typedef of the internal iterator */
+  typedef typename boost::graph_traits<InternalGraphType>::in_edge_iterator InternalIteratorType;
+  /** Typedef of the index map */
+  typedef typename boost::property_map<InternalGraphType, boost::vertex_index_t>::type IndexMapType;
+
+  /** Constructor */
+  RCC8InEdgeIterator();  
+   /** Copy constructor */
+   RCC8InEdgeIterator(const Self& iter);
+   /**  Constructor with input graph */
+   RCC8InEdgeIterator(VertexDescriptorType vertex,GraphType * graph);
+  /**
+   * Get the current edge value.
+   * \return The value of the current edge pointed by the iterator.
+   */
+  RCC8ValueType GetValue(void);
+ /**
+   * Return the source vertex of the current edge.
+   * \return The source edge.
+   */
+  VertexPointerType GetSourceVertex(void);
+  /**
+   * Return the source vertex index of the current edge.
+   * \return The souce vertex index.
+   */
+  VertexDescriptorType GetSourceIndex(void); 
+   /** 
+    * Return true if the iterator is at the end.
+    * \return True if the iterator is at the end.
+    */
+   bool IsAtEnd(void);
+   /**
+    * Go to the beginning.
+    */
+   void GoToBegin(void);
+  /**
+   * Increment.
+   */
+  Self& operator++();
+  /**
+   * Decrement.
+   */
+  Self& operator--();
+  /**
+   * Add
+   */
+  Self& operator+(int i);
+
+  /**
+   * Remove
+   */
+  Self& operator-(int i);
+  /**
+   * Difference comparison operator.
+   */
+  bool operator!=(const Self& it);
+  /**
+   * Equality comparison operator.
+   */
+  bool operator==(const Self& it);
+  /**
+   * Instantiation operator.
+   */
+  Self& operator=(const Self& it);
+ private:
+  // End
+  InternalIteratorType m_End;
+  // Internal iterator.
+  InternalIteratorType m_Iter;
+  // Input graph pointer
+  GraphPointerType m_Graph;
+  // Target vertex index
+  VertexDescriptorType m_VertexIndex;
+};
+} // End namespace otb
+
+#ifndef OTB_MANUAL_INSTANTIATION
+#include "otbRCC8InEdgeIterator.txx"
+#endif
+
+#endif
diff --git a/Code/SpatialReasoning/otbRCC8InEdgeIterator.txx b/Code/SpatialReasoning/otbRCC8InEdgeIterator.txx
new file mode 100644
index 0000000000..8180a704b4
--- /dev/null
+++ b/Code/SpatialReasoning/otbRCC8InEdgeIterator.txx
@@ -0,0 +1,192 @@
+/*=========================================================================
+
+  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 _otbRCC8InEdgeIterator_txx
+#define _otbRCC8InEdgeIterator_txx
+
+#include "otbRCC8InEdgeIterator.h"
+
+namespace otb
+{
+ /** Constructor */
+  template <class TGraph>
+  RCC8InEdgeIterator<TGraph>
+  ::RCC8InEdgeIterator()
+  {}
+  /**
+   * Copy operator.
+   */
+  template <class TGraph>
+  RCC8InEdgeIterator<TGraph>
+  ::RCC8InEdgeIterator(const Self& iter)
+  {
+    m_Iter=iter.m_Iter;
+    m_Graph=iter.m_Graph;
+    m_VertexIndex = iter.m_VertexIndex;
+    m_End=iter.m_End;
+  }
+  /**  
+   *Constructor with input graph 
+   */
+  template <class TGraph>
+  RCC8InEdgeIterator<TGraph>
+  ::RCC8InEdgeIterator(VertexDescriptorType vertex,TGraph * graph) 
+  {
+    m_Graph=graph;
+    m_VertexIndex=vertex;
+    tie(m_Iter,m_End)=in_edges(vertex,*m_Graph->GetGraph());
+  }
+  /**
+   * Get the current edge value.
+   * \return The value of the current edge pointed by the iterator.
+   */
+  template <class TGraph>
+  typename  RCC8InEdgeIterator<TGraph>
+  ::RCC8ValueType 
+  RCC8InEdgeIterator<TGraph>
+  ::GetValue(void)
+  {
+    return (*m_Graph->GetGraph())[*m_Iter]->GetValue();
+  }
+  /**
+   * Return the source vertex of the current edge.
+   * \return The source edge.
+   */
+  template <class TGraph>
+  typename  RCC8InEdgeIterator<TGraph>
+  ::VertexPointerType 
+  RCC8InEdgeIterator<TGraph>
+  ::GetSourceVertex(void)
+  {
+    return (*m_Graph->GetGraph())[source(*m_Iter,(*m_Graph->GetGraph()))]; 
+  }
+  /**
+   * Return the source vertex index of the current edge.
+   * \return The souce vertex index.
+   */
+  template <class TGraph>
+  typename  RCC8InEdgeIterator<TGraph>
+  ::VertexDescriptorType 
+  RCC8InEdgeIterator<TGraph>
+  ::GetSourceIndex(void)
+  {
+    IndexMapType index = get(boost::vertex_index, (*m_Graph->GetGraph()));
+    return index[source(*m_Iter,(*m_Graph->GetGraph()))]; 
+  }
+  /** 
+   * Return true if the iterator is at the end.
+   * \return True if the iterator is at the end.
+   */
+  template <class TGraph>
+  bool
+  RCC8InEdgeIterator<TGraph>
+  ::IsAtEnd(void)
+  {
+    return (m_Iter==m_End);
+  }
+  /**
+   * Go to the beginning.
+   */
+  template <class TGraph>
+  void 
+  RCC8InEdgeIterator<TGraph>
+  ::GoToBegin(void)
+  {
+    tie(m_Iter,m_End)=in_edges(m_VertexIndex,*m_Graph->GetGraph());
+  }
+  /**
+   * Increment.
+   */
+  template <class TGraph>
+  typename RCC8InEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8InEdgeIterator<TGraph>
+  ::operator++()
+  { 
+    ++m_Iter;
+    return *this;
+  }
+  /**
+   * Decrement.
+   */
+  template <class TGraph>
+  typename RCC8InEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8InEdgeIterator<TGraph>
+  ::operator--()
+  {
+    --m_Iter;
+    return *this;
+  } 
+  /**
+   * Add
+   */
+  template <class TGraph>
+  typename RCC8InEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8InEdgeIterator<TGraph>
+  ::operator+(int i)
+  {
+    m_Iter=m_Iter+i;
+    return *this;
+  }
+  /**
+   * Remove
+   */
+  template <class TGraph>
+  typename RCC8InEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8InEdgeIterator<TGraph>
+  ::operator-(int i)
+  {
+    m_Iter=m_Iter-i;
+    return *this;
+  }
+  /**
+   * Difference comparison operator.
+   */
+  template <class TGraph>
+  bool 
+  RCC8InEdgeIterator<TGraph>
+  ::operator!=(const Self& iter)
+  {
+    return (m_Iter != iter.m_Iter);
+  }
+  /**
+   * Equality comparison operator.
+   */
+  template <class TGraph>
+  bool 
+  RCC8InEdgeIterator<TGraph>
+  ::operator==(const Self& iter)
+  {
+    return (m_Iter == iter.m_Iter);
+  }
+  /**
+   * Instantiation operator.
+   */
+  template <class TGraph>
+  typename RCC8InEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8InEdgeIterator<TGraph>
+  ::operator=(const Self& iter)
+  {
+    m_Iter = iter.m_Iter;
+    return *this;
+  }
+} // End namespace otb
+#endif
diff --git a/Code/SpatialReasoning/otbRCC8OutEdgeIterator.h b/Code/SpatialReasoning/otbRCC8OutEdgeIterator.h
new file mode 100644
index 0000000000..c6df3469c2
--- /dev/null
+++ b/Code/SpatialReasoning/otbRCC8OutEdgeIterator.h
@@ -0,0 +1,124 @@
+/*=========================================================================
+
+  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 _otbRCC8OutEdgeIterator_h
+#define _otbRCC8OutEdgeIterator_h
+
+#include "otbRCC8Graph.h"
+
+namespace otb
+{
+/**
+ * \class EdgeIterator
+ * \brief Iterates on the graph out edges from a vertex.
+ */
+template <class TGraph>
+class RCC8OutEdgeIterator 
+{
+ public:
+  /** self typedef */
+  typedef RCC8OutEdgeIterator Self;
+
+  /** Graph typedef */
+  typedef TGraph GraphType;
+  typedef typename GraphType::InternalGraphType InternalGraphType;
+  typedef typename GraphType::Pointer GraphPointerType;
+  typedef typename GraphType::EdgePointerType EdgePointerType;
+  typedef typename GraphType::VertexPointerType VertexPointerType;
+  typedef typename GraphType::VertexDescriptorType VertexDescriptorType;
+  typedef typename GraphType::RCC8ValueType RCC8ValueType;
+  /** typedef of the internal iterator */
+  typedef typename boost::graph_traits<InternalGraphType>::out_edge_iterator InternalIteratorType;
+  /** Typedef of the index map */
+  typedef typename boost::property_map<InternalGraphType, boost::vertex_index_t>::type IndexMapType;
+
+  /** Constructor */
+  RCC8OutEdgeIterator();  
+   /** Copy constructor */
+   RCC8OutEdgeIterator(const Self& iter);
+   /**  Constructor with input graph */
+   RCC8OutEdgeIterator(VertexDescriptorType vertex,TGraph * graph);
+  /**
+   * Get the current edge value.
+   * \return The value of the current edge pointed by the iterator.
+   */
+  RCC8ValueType GetValue(void);
+  /**
+   * Return the target vertex of the current edge.
+   * \return The target vertex.
+   */
+  VertexPointerType GetTargetVertex(void);
+  /**
+   * Return the target vertex index of the current edge.
+   * \return The target vertex index.
+   */
+  VertexDescriptorType GetTargetIndex(void);
+ 
+   /** 
+    * Return true if the iterator is at the end.
+    * \return True if the iterator is at the end.
+    */
+   bool IsAtEnd(void);
+   /**
+    * Go to the beginning.
+    */
+   void GoToBegin(void);
+  /**
+   * Increment.
+   */
+  Self& operator++();
+  /**
+   * Decrement.
+   */
+  Self& operator--();
+  /**
+   * Add
+   */
+  Self& operator+(int i);
+  /**
+   * Remove
+   */
+  Self& operator-(int i);
+  /**
+   * Difference comparison operator.
+   */
+  bool operator!=(const Self& it);
+  /**
+   * Equality comparison operator.
+   */
+  bool operator==(const Self& it);
+  /**
+   * Instantiation operator.
+   */
+  Self& operator=(const Self& it);
+ private:
+  // End
+  InternalIteratorType m_End;
+  // Internal iterator.
+  InternalIteratorType m_Iter;
+  // Input graph pointer
+  GraphPointerType m_Graph;
+  // source vertex descriptor
+  VertexDescriptorType m_VertexIndex;
+};
+} // End namespace otb
+
+#ifndef OTB_MANUAL_INSTANTIATION
+#include "otbRCC8OutEdgeIterator.txx"
+#endif
+
+#endif
diff --git a/Code/SpatialReasoning/otbRCC8OutEdgeIterator.txx b/Code/SpatialReasoning/otbRCC8OutEdgeIterator.txx
new file mode 100644
index 0000000000..576b5c6a5b
--- /dev/null
+++ b/Code/SpatialReasoning/otbRCC8OutEdgeIterator.txx
@@ -0,0 +1,192 @@
+/*=========================================================================
+
+  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 _otbRCC8OutEdgeIterator_txx
+#define _otbRCC8OutEdgeIterator_txx
+
+#include "otbRCC8OutEdgeIterator.h"
+
+namespace otb
+{
+ /** Constructor */
+  template <class TGraph>
+  RCC8OutEdgeIterator<TGraph>
+  ::RCC8OutEdgeIterator()
+  {}
+  /**
+   * Copy operator.
+   */
+  template <class TGraph>
+  RCC8OutEdgeIterator<TGraph>
+  ::RCC8OutEdgeIterator(const Self& iter)
+  {
+    m_Iter=iter.m_Iter;
+    m_Graph=iter.m_Graph;
+    m_VertexIndex = iter.m_VertexIndex;
+    m_End=iter.m_End;
+  }
+  /**  
+   *Constructor with input graph 
+   */
+  template <class TGraph>
+  RCC8OutEdgeIterator<TGraph>
+  ::RCC8OutEdgeIterator(VertexDescriptorType vertex,TGraph * graph) 
+  {
+    m_Graph=graph;
+    m_VertexIndex = vertex;
+    tie(m_Iter,m_End)=out_edges(vertex,*m_Graph->GetGraph());
+  }
+  /**
+   * Get the current edge value.
+   * \return The value of the current edge pointed by the iterator.
+   */
+  template <class TGraph>
+  typename  RCC8OutEdgeIterator<TGraph>
+  ::RCC8ValueType 
+  RCC8OutEdgeIterator<TGraph>
+  ::GetValue(void)
+  {
+    return (*m_Graph->GetGraph())[*m_Iter]->GetValue();
+  }
+  /**
+   * Return the target vertex of the current edge.
+   * \return The target vertex.
+   */
+  template <class TGraph>
+  typename  RCC8OutEdgeIterator<TGraph>
+  ::VertexPointerType 
+  RCC8OutEdgeIterator<TGraph>
+  ::GetTargetVertex(void)
+  {
+    return (*m_Graph->GetGraph())[target(*m_Iter,(*m_Graph->GetGraph()))];    
+  }
+  /**
+   * Return the target vertex index of the current edge.
+   * \return The target vertex index.
+   */
+  template <class TGraph>
+  typename  RCC8OutEdgeIterator<TGraph>
+  ::VertexDescriptorType 
+  RCC8OutEdgeIterator<TGraph>
+  ::GetTargetIndex(void)
+  {
+    IndexMapType index = get(boost::vertex_index,(*m_Graph->GetGraph()));
+    return index[target(*m_Iter,(*m_Graph->GetGraph()))];    
+  }
+  /** 
+   * Return true if the iterator is at the end.
+   * \return True if the iterator is at the end.
+   */
+  template <class TGraph>
+  bool
+  RCC8OutEdgeIterator<TGraph>
+  ::IsAtEnd(void)
+  {
+    return (m_Iter==m_End);
+  }
+  /**
+   * Go to the beginning.
+   */
+  template <class TGraph>
+  void 
+  RCC8OutEdgeIterator<TGraph>
+  ::GoToBegin(void)
+  {
+    tie(m_Iter,m_End)=out_edges(m_VertexIndex,*m_Graph->GetGraph());
+  }
+  /**
+   * Increment.
+   */
+  template <class TGraph>
+  typename RCC8OutEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8OutEdgeIterator<TGraph>
+  ::operator++()
+  { 
+    ++m_Iter;
+    return *this;
+  }
+  /**
+   * Decrement.
+   */
+  template <class TGraph>
+  typename RCC8OutEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8OutEdgeIterator<TGraph>
+  ::operator--()
+  {
+    --m_Iter;
+    return *this;
+  } 
+  /**
+   * Add
+   */
+  template <class TGraph>
+  typename RCC8OutEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8OutEdgeIterator<TGraph>
+  ::operator+(int i)
+  {
+    m_Iter=m_Iter+i;
+    return *this;
+  }
+  /**
+   * Remove
+   */
+  template <class TGraph>
+  typename RCC8OutEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8OutEdgeIterator<TGraph>
+  ::operator-(int i)
+  {
+    m_Iter=m_Iter-i;
+    return *this;
+  }
+  /**
+   * Difference comparison operator.
+   */
+  template <class TGraph>
+  bool 
+  RCC8OutEdgeIterator<TGraph>
+  ::operator!=(const Self& iter)
+  {
+    return (m_Iter != iter.m_Iter);
+  }
+  /**
+   * Equality comparison operator.
+   */
+  template <class TGraph>
+  bool 
+  RCC8OutEdgeIterator<TGraph>
+  ::operator==(const Self& iter)
+  {
+    return (m_Iter == iter.m_Iter);
+  }
+  /**
+   * Instantiation operator.
+   */
+  template <class TGraph>
+  typename RCC8OutEdgeIterator<TGraph> 
+  ::Self& 
+  RCC8OutEdgeIterator<TGraph>
+  ::operator=(const Self& iter)
+  {
+    m_Iter = iter.m_Iter;
+    return *this;
+  }
+} // End namespace otb
+#endif
diff --git a/Testing/Code/SpatialReasoning/otbRCC8Graph.cxx b/Testing/Code/SpatialReasoning/otbRCC8Graph.cxx
index 1541cb4fdc..9098579996 100644
--- a/Testing/Code/SpatialReasoning/otbRCC8Graph.cxx
+++ b/Testing/Code/SpatialReasoning/otbRCC8Graph.cxx
@@ -20,6 +20,8 @@ PURPOSE.  See the above copyright notices for more information.
 #include "otbRCC8VertexBase.h"
 #include "otbRCC8VertexIterator.h"
 #include "otbRCC8EdgeIterator.h"
+#include "otbRCC8InEdgeIterator.h"
+#include "otbRCC8OutEdgeIterator.h"
 
 void fail(bool test, char * reason)
 {
@@ -41,6 +43,8 @@ int otbRCC8Graph(int argc, char* argv[])
       typedef RCC8GraphType::EdgeType EdgeType;
       typedef otb::RCC8VertexIterator<RCC8GraphType> VertexIteratorType;
       typedef otb::RCC8EdgeIterator<RCC8GraphType>   EdgeIteratorType;
+      typedef otb::RCC8InEdgeIterator<RCC8GraphType> InEdgeIteratorType;
+      typedef otb::RCC8OutEdgeIterator<RCC8GraphType> OutEdgeIteratorType;
     
       // Instantiation
       RCC8GraphType::Pointer rcc8Graph = RCC8GraphType::New();
@@ -125,6 +129,34 @@ int otbRCC8Graph(int argc, char* argv[])
 	      fail(true,"Edge iterator out of bound."); 
 	    }
 	}
+
+      // Adding vertices and edges to test the in and out iterators
+      VertexType::Pointer vertex4 = VertexType::New();
+      VertexType::Pointer vertex5 = VertexType::New();
+      vertex4->SetSegmentationImageIndex(3);
+      vertex4->SetObjectLabelInImage(3);
+      vertex5->SetSegmentationImageIndex(4);
+      vertex5->SetObjectLabelInImage(4);
+      rcc8Graph->SetVertex(3,vertex4);
+      rcc8Graph->SetVertex(4,vertex5);
+      rcc8Graph->AddEdge(3,1,otb::OTB_RCC8_NTPP);
+      rcc8Graph->AddEdge(1,4,otb::OTB_RCC8_PO);
+      
+      // Testing the in edge iterator
+      int vertexIndex=1;
+      InEdgeIteratorType inEdgeIt(vertexIndex,rcc8Graph);
+      for(inEdgeIt.GoToBegin();!inEdgeIt.IsAtEnd();++inEdgeIt)
+	{
+	  fail(!((inEdgeIt.GetSourceIndex()==0)||(inEdgeIt.GetSourceIndex()==3)),
+	       "!((inEdgeIt.GetSourceIndex()==0)||(inEdgeIt.GetSourceIndex()==3))");
+	}
+      // Testing the out edge iterator
+      OutEdgeIteratorType outEdgeIt(vertexIndex,rcc8Graph);
+      for(outEdgeIt.GoToBegin();!outEdgeIt.IsAtEnd();++outEdgeIt)
+	{
+	  fail(!((inEdgeIt.GetSourceIndex()==0)||(inEdgeIt.GetSourceIndex()==3)),
+	       "!((inEdgeIt.GetSourceIndex()==2)||(inEdgeIt.GetSourceIndex()==4))");
+	}
     }
   catch( itk::ExceptionObject & err ) 
     { 
-- 
GitLab