[Paraview] Accessing VTK data from a Paraview plugin

Miron Sadziak miron at will.brl.ntt.co.jp
Tue Feb 19 22:01:08 EST 2008


That looks very promising. Thank you. I have still a small problem - in
python it works nice but I cant manage to convert it to C++. The code
from Fetch function looks more or less like this:

gvd=rendering.ClientDeliveryRepresentationBase()
gvd.AddInput(input,"DONTCARE")
gvd.SetReductionType(1) #For me its vtkPolyData
gvd.UpdateVTKObjects()
gvd.Update()
return gvd.GetOutput()

In C++ I converted it into :

vtkSMClientDeliveryRepresentationProxy*
rep=vtkSMClientDeliveryRepresentationProxy::New(); //Thats probably not
right yet
rep->AddInput((vtkSMSourceProxy*)proxy, "DONTCARE");
rep->SetReductionType(1);
rep->UpdateVTKObjects();
rep->Update();
vtkPolyData* test=(vtkPolyData*)(rep->GetOutput());
cout << "ARRAYS " << test->GetPointData()->GetNumberOfArrays() << "\n";

//(proxy is of type vtkSMProxy* and represents the active source which
is of type vtkPolyData)

But it returns 0 as a number of arrays so the data has not been copied I
guess.
I suppose I should derive the ClientDeliveryRepresentation somehow from
gvd=rendering.ClientDeliveryRepresentationBase() but cant find a way to
do it. Im still new in Paraview and I dont understand yet well how the
representation system works.
Could you give me a small hint how to do it ?

Thank you.



David E DeMarle さんは書きました:
> You can use a ClientDeliveryRepresentation to copy the data from the
> server onto the client. See the Fetch module in paraview's python
> wrapped client interface for an example.
>
> On 2/19/08, Miron Sadziak <miron at will.brl.ntt.co.jp> wrote:
>   
>> Thank you for your reply. I think I shouldn't have used the word
>> "directly". What I want is just 'any' access to the point data of the
>> opened object. Even if I had to write both server and client plugin and
>> send data by properties calls it would be ok. But by now I cant find any
>> way to do it.
>>
>> Utkarsh Ayachit さんは書きました:
>>     
>>> As you have discovered, there is no direct access to the actual
>>> vtkDataObject on the client side. This is because paraview supports
>>> server configurations in which the data processing server may be in
>>> another process. In that case one cannot directly access the data on
>>> the client side, since the data is never delivered in its entirety to
>>> the client.
>>>
>>> Utkarsh
>>>
>>> Miron Sadziak wrote:
>>>       
>>>> Thank you for you help. I checked the filter plugin description and
>>>> the examples but I think thats not what I want. At least I cant
>>>> figure out how I can use it to read the raw data through the client.
>>>> The code I posted in the previous mail is already a part of a plugin
>>>> which shows a toolbar with buttons in Paraview client. Clicking on a
>>>> button should pop up a window with the point coordinates of all
>>>> points of the selected source. Thats the aim but now it only shows
>>>> the number of points and the vtk class name "vtkImageData". Since
>>>> these informations are already on the client there must be a simple
>>>> way to get also all the point coordinates/point data of that
>>>> vtkImageData class. How to do it ?
>>>>
>>>>
>>>> Mike Jackson さんは書きました:
>>>>         
>>>>> You probably want to write a Filter plugin for ParaView. Look on the
>>>>> Wiki for more information.
>>>>>
>>>>> Mike
>>>>>
>>>>> On Feb 18, 2008, at 8:16 PM, Miron Sadziak wrote:
>>>>>
>>>>>           
>>>>>> Hi
>>>>>>
>>>>>> I want to write a plugin for Paraview to manipulate the data Paraview
>>>>>> has opened.
>>>>>> It will be mostly ImageData or PolyData but I would like to understand
>>>>>> the general idea how to do it.
>>>>>> Im using C++ so the code i have figured out by now looks like that:
>>>>>>
>>>>>> #Getting the active source
>>>>>> pqApplicationCore* core = pqApplicationCore::instance();
>>>>>> pqServerManagerSelection sels =
>>>>>> *core->getSelectionModel()->selectedItems();
>>>>>> pqPipelineSource* source = 0;
>>>>>> pqServerManagerModelItem* item = 0;
>>>>>> pqServerManagerSelection::ConstIterator iter = sels.begin();
>>>>>> item = *iter;
>>>>>> source = dynamic_cast<pqPipelineSource*>(item);
>>>>>>
>>>>>> #Trying to access the data of the source.
>>>>>> #Here I can access data information only, not raw-data
>>>>>> vtkPVDataInformation*
>>>>>> datainfo=source->getOutputPort(0)->getDataInformation(true);
>>>>>> cout << "PointsNumber " << datainfo->GetNumberOfPoints() << "\n";
>>>>>> cout << "DataClassName " << datainfo->GetDataClassName() << "\n";
>>>>>>
>>>>>> It all works but its just data information.
>>>>>> I would like to access a function like GetData or GetDataArray to be
>>>>>> able to read the data contained in the VTK object. To read/write
>>>>>> directly from/to the data array. The problem is that I cant find a
>>>>>> suitable function in any of the classes like pqPipelineSource,
>>>>>> vtkPVDataInformation etc.
>>>>>> What should I do ?
>>>>>>
>>>>>> I would be thankful for any help,
>>>>>> Paraview user
>>>>>>
>>>>>>
>>>>>>             
>>>> _______________________________________________
>>>> ParaView mailing list
>>>> ParaView at paraview.org
>>>> http://www.paraview.org/mailman/listinfo/paraview
>>>>
>>>>         
>>>       
>> _______________________________________________
>> ParaView mailing list
>> ParaView at paraview.org
>> http://www.paraview.org/mailman/listinfo/paraview
>>
>>     
>
>   



More information about the ParaView mailing list