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

houssen houssen at ipgp.fr
Sun Jul 19 16:54:29 EDT 2015


Finally working ! Thanks !
I guess my mistake was to do the shallow copy in RequestDataObject, not 
in RequestData.

Franck

Le 2015-07-19 21:25, Joachim Pouderoux a écrit :
> Franck,
>
> What do you do in RequestData()? You are supposed to shallow copy
> input to the output, right?
>
> Joachim
>
> JOACHIM POUDEROUX
>
>> _PhD, Technical Expert_
>
> 2015-07-19 19:53 GMT+02:00 houssen <houssen at ipgp.fr [35]>:
>
>> Still get the zero filter ?!... Don't understand !? If somebody has
>> an idea ?... Something to check ? Verify ? Track ? Something
> missing
>> ? Add tag in xml ? Missing rendering call ?
>>
>> Now, I derive from vtkDataObjectAlgorithm, I re-implement only
>> RequestDataObject. I tried without success to create a new instance
>> (from pInputObj) to pass to pOutputInfo (with and without using
>> DeepCopy) : finally I tried to pass directly pInputObj. In the GUI,
>> in the information tab, I get the expected type but zero point /
>> cell. When I delete the filter, the initial data are still here
> (tab
>> info indicates non zero number of points / cells) but the 3D
>> viewpoint is empty : can this be a clue of some problem ?
>>
>> Franck
>>
>> int myFilter::RequestDataObject ( vtkInformation * ipRequest,
>> vtkInformationVector ** ipInputVector, vtkInformationVector *
>> opOutputVector )
>> {
>>   if ( !ipRequest ) return 0;
>>
>>   vtkInformation * pInputInfo = ( ipInputVector ) ?
>> ipInputVector[0] -> GetInformationObject ( 0 )            :
>> NULL;
>>   vtkDataObject  * pInputObj  = ( pInputInfo    ) ?
>> pInputInfo       -> Get ( vtkDataObject::DATA_OBJECT () ) :
>> NULL;
>>   if ( pInputObj )
>>   {
>>     vtkInformation * pOutputInfo = ( opOutputVector ) ?
>> opOutputVector -> GetInformationObject ( 0 )            :
>> NULL;
>>     vtkDataObject  * pOutputObj  = ( pOutputInfo    ) ?
>> pOutputInfo    -> Get ( vtkDataObject::DATA_OBJECT () ) : NULL;
>>     if ( !pOutputObj )
>>     {
>>       _OutputDataType = pInputObj -> GetClassName (); // For
>> later call to FillOutputPortInformation
>>       pOutputInfo -> Set ( vtkDataObject::DATA_OBJECT (),
>> pInputObj );
>>       return 1;
>>     }
>>   }
>>   return 0;
>> }
>>
>> int myFilter::FillOutputPortInformation ( int iPort,
>> vtkInformation * ipInfo )
>> {
>>   if ( ipInfo ) ipInfo -> Set ( vtkDataObject::DATA_TYPE_NAME (),
>> _OutputDataType.c_str () ); // Output data type to create (called
>> after ProcessRequest)
>>   return 1;
>> }
>>
>> Le 2015-07-15 23:49, houssen a écrit :
>>
>>> Shawn, Joachim, thanks.
>>> After a quick look at the code, if I got you right, on a
>>> REQUEST_DATA_OBJECT request, I still need to create a new
>>> instance of
>>> the input and to set it as the DATA_OBJECT of the vtkInfo of the
>>> output. I still have to test this, but, I got the idea !
>>>
>>> Franck
>>>
>>> Le 2015-07-15 15:47, Shawn Waldon a écrit :
>>>
>>>> You might want to take a look at inheriting from
>>>> vtkPassInputTypeAlgorithm[1] if you want the output type to be
>>>> the
>>>> same as the input type.  It already implements
>>>> RequestDataObject the
>>>> way that I think Joachim is suggesting.
>>>>
>>>> HTH,
>>>> Shawn
>>>>
>>>> [1]:
>>>>
>>>>
>>>>
>>>
>>
> 
> http://www.vtk.org/doc/nightly/html/classvtkPassInputTypeAlgorithm.html
>>>> [14]
>>>> [14]
>>>>
>>>> On Wed, Jul 15, 2015 at 7:27 AM, Joachim Pouderoux
>>>> <joachim.pouderoux at kitware.com [15] [15]> wrote:
>>>>
>>>>> Franck,
>>>>>
>>>>> You will have to override the RequestDataObject() method in
>>>>> order
>>>>> to make your filter generic. This method is the one called
>>>>> to
>>>>> generate the output data object.
>>>>> Take a look at vtkGenerateIndexArray.cxx for instance, I
>>>>> think you
>>>>> can just copy it in your class (which should be derivated
>>>>> from
>>>>> vtkDataObjectAlgorithm).
>>>>>
>>>>> Best,
>>>>>
>>>>> JOACHIM POUDEROUX
>>>>>
>>>>>> _PhD, Technical Expert_
>>>>>
>>>>> 2015-07-15 11:57 GMT+02:00 houssen <houssen at ipgp.fr [1]
>>>>> [9]>:
>>>>>
>>>>>> Seems that it is not possible to filter on vtkDataObject
>>>>>> type.
>>>>>> But with less generic types (like vtkUnstrucutredGrid for
>>>>>> instance), the myFilter works : no error occur, but,
>>>>>> viewpoint
>>>>>> ends up to be empty. I get "zero" instead of "identity" :
>>>>>> why ?!
>>>>>>
>>>>>> Franck
>>>>>>
>>>>>> Le 2015-07-14 23:38, houssen a écrit :
>>>>>>
>>>>>>> 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 [2] [1]
>>>>>>>
>>>>>>> Visit other Kitware open-source projects at
>>>>>>> http://www.kitware.com/opensource/opensource.html [3]
>>>>>>> [2]
>>>>>>>
>>>>>>> Search the list archives at:
>>>>>>> http://markmail.org/search/?q=Paraview-developers [4]
>>>>>>> [3]
>>>>>>>
>>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>>>>>> [5]
>>>>>>> [4]
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com [6] [5]
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html [7] [6]
>>>>>>
>>>>>> Search the list archives at:
>>>>>> http://markmail.org/search/?q=Paraview-developers [8] [7]
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>
>>>>>>
>>>>>
>>>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>>>>> [9]
>>>>>> [8]
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com [10] [10]
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html [11] [11]
>>>>>
>>>>> Search the list archives at:
>>>>> http://markmail.org/search/?q=Paraview-developers [12] [12]
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>>
>>>>>
>>>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>>>> [13]
>>>>> [13]
>>>>
>>>> Links:
>>>> ------
>>>> [1] http://www.kitware.com [16]
>>>> [2] http://www.kitware.com/opensource/opensource.html [17]
>>>> [3] http://markmail.org/search/?q=Paraview-developers [18]
>>>> [4]
>>>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>>> [19]
>>>> [5] http://www.kitware.com [20]
>>>> [6] http://www.kitware.com/opensource/opensource.html [21]
>>>> [7] http://markmail.org/search/?q=Paraview-developers [22]
>>>> [8]
>>>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>>> [23]
>>>> [9] mailto:houssen at ipgp.fr [24]
>>>> [10] http://www.kitware.com [25]
>>>> [11] http://www.kitware.com/opensource/opensource.html [26]
>>>> [12] http://markmail.org/search/?q=Paraview-developers [27]
>>>> [13]
>>>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>>> [28]
>>>> [14]
>>>>
>>>
>>
> 
> http://www.vtk.org/doc/nightly/html/classvtkPassInputTypeAlgorithm.html
>>>> [29]
>>>> [15] mailto:joachim.pouderoux at kitware.com [30]
>>
>> _______________________________________________
>> Powered by www.kitware.com [31]
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html [32]
>>
>> Search the list archives at:
>> http://markmail.org/search/?q=Paraview-developers [33]
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview-developers
>> [34]
>
>
>
> Links:
> ------
> [1] mailto:houssen at ipgp.fr
> [2] http://www.kitware.com
> [3] http://www.kitware.com/opensource/opensource.html
> [4] http://markmail.org/search/?q=Paraview-developers
> [5] http://public.kitware.com/mailman/listinfo/paraview-developers
> [6] http://www.kitware.com
> [7] http://www.kitware.com/opensource/opensource.html
> [8] http://markmail.org/search/?q=Paraview-developers
> [9] http://public.kitware.com/mailman/listinfo/paraview-developers
> [10] http://www.kitware.com
> [11] http://www.kitware.com/opensource/opensource.html
> [12] http://markmail.org/search/?q=Paraview-developers
> [13] http://public.kitware.com/mailman/listinfo/paraview-developers
> [14] 
> http://www.vtk.org/doc/nightly/html/classvtkPassInputTypeAlgorithm.html
> [15] mailto:joachim.pouderoux at kitware.com
> [16] http://www.kitware.com
> [17] http://www.kitware.com/opensource/opensource.html
> [18] http://markmail.org/search/?q=Paraview-developers
> [19] http://public.kitware.com/mailman/listinfo/paraview-developers
> [20] http://www.kitware.com
> [21] http://www.kitware.com/opensource/opensource.html
> [22] http://markmail.org/search/?q=Paraview-developers
> [23] http://public.kitware.com/mailman/listinfo/paraview-developers
> [24] mailto:houssen at ipgp.fr
> [25] http://www.kitware.com
> [26] http://www.kitware.com/opensource/opensource.html
> [27] http://markmail.org/search/?q=Paraview-developers
> [28] http://public.kitware.com/mailman/listinfo/paraview-developers
> [29] 
> http://www.vtk.org/doc/nightly/html/classvtkPassInputTypeAlgorithm.html
> [30] mailto:joachim.pouderoux at kitware.com
> [31] http://www.kitware.com
> [32] http://www.kitware.com/opensource/opensource.html
> [33] http://markmail.org/search/?q=Paraview-developers
> [34] http://public.kitware.com/mailman/listinfo/paraview-developers
> [35] mailto:houssen at ipgp.fr



More information about the Paraview-developers mailing list