X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FWorkspace.cxx;fp=lib%2FcpPlugins%2FWorkspace.cxx;h=b3f6af70a41e280e55d49211b6499563748e120d;hb=b5417af22a8c30e05961789f4758c10e0cc1b926;hp=dd4ade8e7237fb4e3ad6482808a46ba27d66c29e;hpb=1eca6dc8780b7fda231cf03e7ec56c77549bf865;p=cpPlugins.git diff --git a/lib/cpPlugins/Workspace.cxx b/lib/cpPlugins/Workspace.cxx index dd4ade8..b3f6af7 100644 --- a/lib/cpPlugins/Workspace.cxx +++ b/lib/cpPlugins/Workspace.cxx @@ -172,9 +172,42 @@ RenameFilter( const std::string& old_name, const std::string& new_name ) } // ------------------------------------------------------------------------- -void cpPlugins::Workspace:: +bool cpPlugins::Workspace:: RemoveFilter( const std::string& name ) { + auto filter = this->GetFilter( name ); + if( filter != NULL ) + { + auto vIt = this->m_Graph->BeginVertices( ); + for( ; vIt != this->m_Graph->EndVertices( ); ++vIt ) + { + if( vIt->first != name ) + { + if( this->m_Graph->HasEdge( name, vIt->first ) ) + { + auto edges = this->m_Graph->GetEdges( name, vIt->first ); + auto other = this->GetFilter( vIt->first ); + for( auto eIt = edges.begin( ); eIt != edges.end( ); ++eIt ) + other->SetInput( eIt->first, ( DataObject* )( NULL ) ); + + } // fi + + if( this->m_Graph->HasEdge( vIt->first, name ) ) + { + auto edges = this->m_Graph->GetEdges( vIt->first, name ); + for( auto eIt = edges.begin( ); eIt != edges.end( ); ++eIt ) + filter->SetInput( eIt->first, ( DataObject* )( NULL ) ); + + } // fi + + } // fi + + } // rof + this->m_Graph->RemoveVertex( name ); + return( true ); + } + else + return( false ); } // ------------------------------------------------------------------------- @@ -306,6 +339,32 @@ Connect( const OutputPort& port, const std::string& exposed_port ) return( false ); } +// ------------------------------------------------------------------------- +bool cpPlugins::Workspace:: +Disconnect( + const std::string& orig_filter, const std::string& dest_filter, + const std::string& output_name, const std::string& input_name + ) +{ + // Get filters + ProcessObject* orig = this->GetFilter( orig_filter ); + ProcessObject* dest = this->GetFilter( dest_filter ); + if( orig == NULL || dest == NULL ) + return( false ); + + // Real disconnection + if( dest->SetInput( input_name, ( DataObject* )( NULL ) ) ) + { + this->m_Graph->RemoveEdge( + orig_filter, dest_filter, + TConnection( output_name, input_name ) + ); + return( true ); + } + else + return( false ); +} + // ------------------------------------------------------------------------- bool cpPlugins::Workspace:: Reduce( const std::string& name ) @@ -467,7 +526,7 @@ Execute( const std::string& name ) ProcessObject* f = this->GetFilter( name ); if( f == NULL ) { - itkGenericExceptionMacro( + itkGenericExceptionMacro( "cpPlugins::Workspace: Vertex \"" << name << "\" is not a filter." );