[Paraview] PassData() question

Fred Fred stan1313 at hotmail.fr
Wed Oct 6 08:47:52 EDT 2010


Hello,
I was just showing to my students how to write a very basic filter, for them to concentrate on the different steps rather than on the algorithm itself but... my example did not work!
The filter was supposed just to withdraw the X components of the normal of a PolyData and the students were asked to show a cylinder before and after the filter so as to compare the shading.
Looking at the code of the PassData() function, it seems that it really copies everything but when I apply my filter, the shading is modified both in the output and the input.
So where is the problem and how should I do it?

int vtkPbPassData::RequestData(
  vtkInformation *vtkNotUsed(request),
  vtkInformationVector **inputVector,
  vtkInformationVector *outputVector)
{
  // get the info objects
  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
  vtkInformation *outInfo = outputVector->GetInformationObject(0);

  // get the input and output
  vtkPolyData *input = vtkPolyData::SafeDownCast(
    inInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkPolyData *output = vtkPolyData::SafeDownCast(
    outInfo->Get(vtkDataObject::DATA_OBJECT()));

  // pass all associated data to output dataset
  output->CopyStructure(input);
  output->GetPointData()->PassData(input->GetPointData());
  output->GetFieldData()->PassData(input->GetFieldData());

  // modify the normals
  vtkPointData *pd = output->GetPointData();
  if (pd ==NULL) {
    vtkErrorMacro(<<"No point data");
    return 1;
  }
  vtkFloatArray *norms = (vtkFloatArray *)pd->GetNormals();
  if (norms == NULL) {
    vtkErrorMacro(<<"Normals must be defined for this filter to work");
    return 1;
  }
  float *coords = norms->GetPointer(0);

  for (int i=0 ; i<output->GetNumberOfPoints() ; i++,coords+=3)
    *coords = 0;

  return 1;
}

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20101006/e5c0c18b/attachment-0001.htm>


More information about the ParaView mailing list