<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hello,<br>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!<br>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.<br>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.<br>So where is the problem and how should I do it?<br><br>int vtkPbPassData::RequestData(<br> vtkInformation *vtkNotUsed(request),<br> vtkInformationVector **inputVector,<br> vtkInformationVector *outputVector)<br>{<br> // get the info objects<br> vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);<br> vtkInformation *outInfo = outputVector->GetInformationObject(0);<br><br> // get the input and output<br> vtkPolyData *input = vtkPolyData::SafeDownCast(<br> inInfo->Get(vtkDataObject::DATA_OBJECT()));<br> vtkPolyData *output = vtkPolyData::SafeDownCast(<br> outInfo->Get(vtkDataObject::DATA_OBJECT()));<br><br> // pass all associated data to output dataset<br> output->CopyStructure(input);<br> output->GetPointData()->PassData(input->GetPointData());<br> output->GetFieldData()->PassData(input->GetFieldData());<br><br> // modify the normals<br> vtkPointData *pd = output->GetPointData();<br> if (pd ==NULL) {<br> vtkErrorMacro(<<"No point data");<br> return 1;<br> }<br> vtkFloatArray *norms = (vtkFloatArray *)pd->GetNormals();<br> if (norms == NULL) {<br> vtkErrorMacro(<<"Normals must be defined for this filter to work");<br> return 1;<br> }<br> float *coords = norms->GetPointer(0);<br><br> for (int i=0 ; i<output->GetNumberOfPoints() ; i++,coords+=3)<br> *coords = 0;<br><br> return 1;<br>}<br><br>                                            </body>
</html>