[vtkusers] removing vtkAlgorithm-object from visualisation-pipeline

Jens G. jens-devel at gmx.de
Tue Apr 4 08:49:34 EDT 2006


Hi
I managed to fix the problem like this:
(But this only supports algorithms with one input and one output. Does anybody 
has a function for multiple inputs and outputs, which does all the checkings?

bool removeAlgorithm( vtkAlgorithm* algorithm )
{
/*	           _________ 
	 ___	  |         |      ____
	|In1| --> |algorithm| --> |Out1|
                  |_________| 
*/
	vtkInformation* fromInfo	=
		algorithm->GetExecutive()->GetInputInformation(0,0);
	vtkInformation* toInfo		= 
		algorithm->GetExecutive()->GetOutputInformation(0);
	vtkExecutive* fromExec 	= 
		fromInfo->GetExecutive( vtkExecutive::PRODUCER() );
	vtkExecutive** toExecs	= 
		toInfo->GetExecutives( vtkExecutive::CONSUMERS() );

	vtkAlgorithm* fromObj = fromExec->GetAlgorithm();
	vtkAlgorithm* toObj	= toExecs[0]->GetAlgorithm();

	toObj->RemoveInputConnection( algorithm->GetOutputPort(0) );
	toObj->SetInputConnection( fromObj->GetOutputPort() );

	algorithm->RemoveAllInputs();
	algorithm->Delete();
} 

Am Dienstag, 4. April 2006 11:58 schrieb Jens G.:
> Hi vtk-fans
>
> How can I get the input and output vtkAlgorithm-objects of a
> vtkAlgorithm-object ? I try to write an easy function for removing
> vtkAlgorithm-objects from a visualisation-pipeline like the following. But
> inputObj and outputObj is always null.
>
> 	Greetings
> 		Jens
>
> ////////////////////////////////////////////////////////////////
> ////	removing a vtkAlgorithm-obj form its
> ////    visualisation pipeline.
> ////////////////////////////////////////////////////////////////
> bool removeAlgorithm( vtkAlgorithm* algo )
> {
> 	vtkInformation* inputInfo = algo->GetInputPortInformation(0);
> 	vtkInformation* outputInfo = algo->GetOutputPortInformation(0);
>
> 	// get the input- and output-vtkAlgorithm of algo
> 	vtkAlgorithm inputObj = vtkAlgorithm::SafeDownCast(
>                                             outputInfo->Get(
>                                              
> vtkDataObject::DATA_OBJECT())); vtkAlgorithm outputObj =
> vtkAlgorithm::SafeDownCast(
>                                             inputInfo->Get(
>                                              
> vtkDataObject::DATA_OBJECT()));
>
> 	// rechain the algorithms
> 	if(inputObj && outputObj) {
> 		inputObj->RemoveAllInputs();
> 		inputObj->SetInputConnection( outputObj->GetOutputPort() );
> 		alog->Delete();
> 		return true;
> 	}
> 	return false;
> }



More information about the vtkusers mailing list