[Paraview] PassData() question

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Wed Oct 6 09:18:02 EDT 2010


I may be totally missing the point here, but the two cylinder look
identical to me :). What am I supposed to be noticing?

Utkarsh

On Wed, Oct 6, 2010 at 9:12 AM, Fred Fred <stan1313 at hotmail.fr> wrote:
> Here it is.
>
>> Date: Wed, 6 Oct 2010 08:57:53 -0400
>> Subject: Re: [Paraview] PassData() question
>> From: utkarsh.ayachit at kitware.com
>> To: stan1313 at hotmail.fr
>> CC: paraview at paraview.org
>>
>> Can you post screenshots with the modified shading so that we can compare?
>>
>> Thanks
>> Utkarsh
>>
>> On Wed, Oct 6, 2010 at 8:47 AM, Fred Fred <stan1313 at hotmail.fr> wrote:
>> > 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;
>> > }
>> >
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the ParaView Wiki at:
>> > http://paraview.org/Wiki/ParaView
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.paraview.org/mailman/listinfo/paraview
>> >
>> >
>


More information about the ParaView mailing list