]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Base/ImageSkeleton.hxx
...
[FrontAlgorithms.git] / lib / fpa / Base / ImageSkeleton.hxx
index 96257958d259d52dadf6c20b44bc6af0d4ea72e9..747d9ded94f46ec1782dade17403340b58b3e5fb 100644 (file)
@@ -11,9 +11,9 @@ AddBranch( const TVertex& a, const TVertex& b )
 
   // Check if the branch already exists
   bool found = false;
-  auto arIt = this->Get( ).find( a );
-  if( arIt != this->Get( ).end( ) )
-    found = ( arIt->second.find( b ) != arIt->second.end( ) );
+  auto aIt = this->Get( ).find( a );
+  if( aIt != this->Get( ).end( ) )
+    found = ( aIt->second.find( b ) != aIt->second.end( ) );
   if( found )
     return;
 
@@ -25,8 +25,24 @@ AddBranch( const TVertex& a, const TVertex& b )
 
   // Assign path vertices
   path->SetReferenceImage( this->m_MinimumSpanningTree );
-  this->Get( )[ a ][ b ] = path;
-  this->Modified( );
+
+  typedef typename TSkeleton::value_type _T1;
+  typedef typename TSkeletonRow::value_type _T2;
+
+  TSkeleton& sk = this->Get( );
+  auto sIt = sk.find( a );
+  if( sIt == sk.end( ) )
+  {
+    sIt = sk.insert( _T1( a, TSkeletonRow( ) ) ).first;
+    this->Modified( );
+
+  } // fi
+  if( sIt->second.find( b ) == sIt->second.end( ) )
+  {
+    sIt->second.insert( _T2( b, path ) );
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------