[Paraview-developers] How to implement an identity filter ?

houssen houssen at ipgp.fr
Wed Jul 15 04:13:25 EDT 2015


Yes, myFilter inherits from vtkAlgorithm and re-implements only 
FillInputPortInformation, FillOutputPortInformation, ProcessRequest as 
described below.

Le 2015-07-15 7:21, Mathieu Westphal a écrit :
> Du you inherit from vtkPolydataAlgorithm ? You should inherit from
> vtkAlgorithm .
>
> On 14 Jul 2015 23:40, "houssen" <houssen at ipgp.fr [5]> wrote:
>
>> How to write an identity filter ? (1 input port, 1 output port,
>> output = input whatever input may be)
>>
>> I need to write a custom filter. I am used to VTK "from outside"
>> (creating/handling vtk pipelines/scene/object from a main program)
>> that is basically without the need to understand all internal VTK
>> mechanics (except the SetInputConnection concept). I am not yet
> used
>> to VTK internal mechanics that is necessary for writing a ParaView
>> plugin.
>>
>> I need my filter to do "complex" stuffs. As I couldn't make it
>> work, I simplified as much as possible to obtain finally an
> identity
>> filter (!) : this is still not working. I feel I still miss
>> something from VTK internal mechanics.
>>
>> As far as I understand, in the constructor, I need :
>> myFilter::myFilter () { SetNumberOfInputPorts  ( 1 );
>> SetNumberOfOutputPorts ( 1 ); }
>>
>> So then I need to implement the FillXXXPortInformation :
>> int myFilter::FillInputPortInformation ( int vtkNotUsed ( iPort ),
>> vtkInformation * ipInfo )
>> {
>>   if ( ipInfo ) ipInfo -> Set (
>> vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE (), "vtkDataObject" ); //
>> Filter allowed data types
>>   return 1;
>> }
>> int myFilter::FillOutputPortInformation ( int vtkNotUsed ( iPort
>> ), vtkInformation * ipInfo )
>> {
>>   if ( ipInfo ) ipInfo -> Set ( vtkDataObject::DATA_TYPE_NAME (),
>> "vtkDataObject" ); // Output data type to be created
>>   return 1;
>> }
>>
>> So, now I only need to implement the ProcessRequest gateway:
>> int myFilter::ProcessRequest ( vtkInformation * ipRequest,
>> vtkInformationVector ** ipInputVector, vtkInformationVector *
>> opOutputVector )
>> {
>>   if ( ipRequest && ipRequest -> Has (
>> vtkDemandDrivenPipeline::REQUEST_DATA () ) )
>>     if ( ipInputVector && opOutputVector ) opOutputVector =
>> ipInputVector[0];
>>    return Superclass::ProcessRequest ( ipRequest, ipInputVector,
>> opOutputVector );
>> }
>>
>> I believed that I would be the only steps to proceed to get an
>> identity filter. When I use my identity filter in Paraview, I get
>> errors like :
>> ERROR: In
>>
> 
> /.../ParaView-v4.3.1-source/VTK/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx,
>> line 810
>> vtkPVPostFilterExecutive : Input for connection index 0 on input
>> port index 0 for algorithm vtkPVPostFilter(0x16d0ec0) is of type
>> vtkDataObject, but a vtkPolyData is required.
>>
>> Some logic is still missing here : could somebody explain me what
>> and why ?
>>
>> Thanks,
>>
>> Franck
>>
>> _______________________________________________
>> Powered by www.kitware.com [1]
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html [2]
>>
>> Search the list archives at:
>> http://markmail.org/search/?q=Paraview-developers [3]
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview-developers [4]
>
>
> Links:
> ------
> [1] http://www.kitware.com
> [2] http://www.kitware.com/opensource/opensource.html
> [3] http://markmail.org/search/?q=Paraview-developers
> [4] http://public.kitware.com/mailman/listinfo/paraview-developers
> [5] mailto:houssen at ipgp.fr



More information about the Paraview-developers mailing list