Filters with non-optional ports ?


I am looking for vtkAlgorithm derived classes in VTK that requires two or more non-optional inputs ?

Any recommendations ?

At this stage of my VTK study, I am not after repeatable inputs yet.


In a vtkAlgorithm you can override the FillInputPortInformation function to set port info like types, optional, required, etc. Here’s one with two input ports with types & one being optional.

In the header.

MyFilterSubclass() { SetNumberOfInputPorts(2); }
int FillInputPortInformation(int port, vtkInformation* info)

Later in the source

int MyFilterSubclass::FillInputPortInformation(int port, vtkInformation* info)
	if (port == 0)
		info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkPolyData");
		return 1;
	else if (port == 1)
		info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkImageData");
		info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1); // true
		return 1;
	return 0;

I am not trying to write a new class, I want to find out if there are classes in the VTK source example that already requires 2 or more non-optional ports.