<p dir="ltr">Du you inherit from vtkPolydataAlgorithm ? You should inherit from vtkAlgorithm .<br>
</p>
<div class="gmail_quote">On 14 Jul 2015 23:40, "houssen" <<a href="mailto:houssen@ipgp.fr">houssen@ipgp.fr</a>> wrote:<br type="attribution"><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, output = input whatever input may be)<br>
<br>
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.<br>
<br>
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.<br>
<br>
As far as I understand, in the constructor, I need :<br>
myFilter::myFilter () { SetNumberOfInputPorts  ( 1 ); SetNumberOfOutputPorts ( 1 ); }<br>
<br>
So then I need to implement the FillXXXPortInformation :<br>
int myFilter::FillInputPortInformation ( int vtkNotUsed ( iPort ), vtkInformation * ipInfo )<br>
{<br>
  if ( ipInfo ) ipInfo -> Set ( vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE (), "vtkDataObject" ); // Filter allowed data types<br>
  return 1;<br>
}<br>
int myFilter::FillOutputPortInformation ( int vtkNotUsed ( iPort ), vtkInformation * ipInfo )<br>
{<br>
  if ( ipInfo ) ipInfo -> Set ( vtkDataObject::DATA_TYPE_NAME (), "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, vtkInformationVector ** ipInputVector, vtkInformationVector * opOutputVector )<br>
{<br>
  if ( ipRequest && ipRequest -> Has ( vtkDemandDrivenPipeline::REQUEST_DATA () ) )<br>
    if ( ipInputVector && opOutputVector ) opOutputVector = ipInputVector[0];<br>
   return Superclass::ProcessRequest ( ipRequest, ipInputVector, opOutputVector );<br>
}<br>
<br>
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 :<br>
ERROR: In /.../ParaView-v4.3.1-source/VTK/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 810<br>
vtkPVPostFilterExecutive : Input for connection index 0 on input port index 0 for algorithm vtkPVPostFilter(0x16d0ec0) is of type 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 <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>
</blockquote></div>