<div dir="ltr"><div><div>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.<br><br></div>HTH,<br></div>Shawn<br><br>[1]: <a href="http://www.vtk.org/doc/nightly/html/classvtkPassInputTypeAlgorithm.html">http://www.vtk.org/doc/nightly/html/classvtkPassInputTypeAlgorithm.html</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 15, 2015 at 7:27 AM, Joachim Pouderoux <span dir="ltr"><<a href="mailto:joachim.pouderoux@kitware.com" target="_blank">joachim.pouderoux@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Franck,<br><br></div>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.<br></div>Take a look at vtkGenerateIndexArray.cxx for instance, I think you can just copy it in your class (which should be derivated from vtkDataObjectAlgorithm).<br><br></div>Best,<br><div><div><br></div></div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><b>Joachim Pouderoux</b><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font size="1"><i>PhD, Technical Expert</i></font><br><b><font size="1"><a href="http://www.kitware.fr" target="_blank">Kitware SAS</a></font></b><br></blockquote>
</div></div></div><div><div class="h5">
<br><div class="gmail_quote">2015-07-15 11:57 GMT+02:00 houssen <span dir="ltr"><<a href="mailto:houssen@ipgp.fr" target="_blank">houssen@ipgp.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Seems that it is not possible to filter on vtkDataObject type.<br>
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 ?!<br>
<br>
Franck<div><div><br>
<br>
Le 2015-07-14 23:38, houssen a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How to write an identity filter ? (1 input port, 1 output port,<br>
output = input whatever input may be)<br>
<br>
I need to write a custom filter. I am used to VTK "from outside"<br>
(creating/handling vtk pipelines/scene/object from a main program)<br>
that is basically without the need to understand all internal VTK<br>
mechanics (except the SetInputConnection concept). I am not yet used<br>
to VTK internal mechanics that is necessary for writing a ParaView<br>
plugin.<br>
<br>
I need my filter to do "complex" stuffs. As I couldn't make it work,<br>
I simplified as much as possible to obtain finally an identity filter<br>
(!) : this is still not working. I feel I still miss something from<br>
VTK internal mechanics.<br>
<br>
As far as I understand, in the constructor, I need :<br>
myFilter::myFilter () { SetNumberOfInputPorts  ( 1 );<br>
SetNumberOfOutputPorts ( 1 ); }<br>
<br>
So then I need to implement the FillXXXPortInformation :<br>
int myFilter::FillInputPortInformation ( int vtkNotUsed ( iPort ),<br>
vtkInformation * ipInfo )<br>
{<br>
  if ( ipInfo ) ipInfo -> Set (<br>
vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE (), "vtkDataObject" ); //<br>
Filter allowed data types<br>
  return 1;<br>
}<br>
int myFilter::FillOutputPortInformation ( int vtkNotUsed ( iPort ),<br>
vtkInformation * ipInfo )<br>
{<br>
  if ( ipInfo ) ipInfo -> Set ( vtkDataObject::DATA_TYPE_NAME (),<br>
"vtkDataObject" ); // Output data type to be created<br>
  return 1;<br>
}<br>
<br>
So, now I only need to implement the ProcessRequest gateway:<br>
int myFilter::ProcessRequest ( vtkInformation * ipRequest,<br>
vtkInformationVector ** ipInputVector, vtkInformationVector *<br>
opOutputVector )<br>
{<br>
  if ( ipRequest && ipRequest -> Has (<br>
vtkDemandDrivenPipeline::REQUEST_DATA () ) )<br>
    if ( ipInputVector && opOutputVector ) opOutputVector = ipInputVector[0];<br>
   return Superclass::ProcessRequest ( ipRequest, ipInputVector,<br>
opOutputVector );<br>
}<br>
<br>
I believed that I would be the only steps to proceed to get an<br>
identity filter. When I use my identity filter in Paraview, I get<br>
errors like :<br>
ERROR: In<br>
<br>
/.../ParaView-v4.3.1-source/VTK/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx,<br>
line 810<br>
vtkPVPostFilterExecutive : Input for connection index 0 on input port<br>
index 0 for algorithm vtkPVPostFilter(0x16d0ec0) is of type<br>
vtkDataObject, but a vtkPolyData is required.<br>
<br>
Some logic is still missing here : could somebody explain me what and why ?<br>
<br>
Thanks,<br>
<br>
Franck<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Search the list archives at:<br>
<a href="http://markmail.org/search/?q=Paraview-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=Paraview-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview-developers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
</blockquote>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=Paraview-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=Paraview-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview-developers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
</div></div></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=Paraview-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=Paraview-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview-developers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
<br></blockquote></div><br></div>