[vtkusers] Multiple input data in custom vtkPolydataFilter
David Gobbi
david.gobbi at gmail.com
Wed Jun 27 14:41:06 EDT 2018
Hi Ben,
The filter has to be set up the same way regardless of whether you
intend to use SetInputConnection() or SetInputData(). After all,
SetInputData() always calls SetInputConnection() under the hood.
So the example that you linked is the way to go.
It looks like you want the second input to be optional. Since the
port exists whether or not an input has been connected to it, what
you need to do is check whether someone has connected an input
to the port. This works regardless of whether the connection was
done with SetInputConnection() or with SetInputData():
if (this->GetNumberOfInputConnections(1) != 0) { ... }
The filter itself must set the second port as "optional" when it sets
up the properties of the ports:
int vtkMyMultiInputFilter::FillInputPortInformation(int port,
vtkInformation* info)
{
if (port == 0)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
}
else if (port == 1)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), true);
}
return 1;
}
- David
On Wed, Jun 27, 2018 at 10:59 AM, BBerco <bebe0705 at colorado.edu> wrote:
> Hello all,
> I'm working on a filter that produces luminosity curves from shape models.
> I'm trying to extend its capability to the case of multiple-body systems,
> for instance that of a binary asteroid featuring a primary around which
> orbits a secondary object.
>
> To this end, I would need to allow my filter (inheriting from
> vtkPolyDataAlgorithm) to take in multiple polydata inputs (one for each
> body, with the first one being the primary, the second one the secondary
> (if
> any),...).
>
> I naively tried
> *
> myfilter-> SetInputData(0,primary_polydata)
> myfilter-> SetInputData(1,secondary_polydata)
> *
>
> but the method which I think should return the number of inputs
> (GetNumberOfInputPorts()) still returns 1. Obviously I'm being confused
> between the number of inputs and the number of input ports.
>
> This example
> <https://www.vtk.org/Wiki/VTK/Examples/Cxx/Developers/MultipleInputPorts>
>
> presents another approach that is not as flexible as I would like because
> it
> relies on* SetInputConnection* and not * SetInputData*.
>
> Any advice?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180627/f3aeb382/attachment.html>
More information about the vtkusers
mailing list