}
// -------------------------------------------------------------------------
-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 );
}
// -------------------------------------------------------------------------
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 )
ProcessObject* f = this->GetFilter( name );
if( f == NULL )
{
- itkGenericExceptionMacro(
+ itkGenericExceptionMacro(
"cpPlugins::Workspace: Vertex \"" << name << "\" is not a filter."
);