[Paraview] Send an array from client to server

Biddiscombe, John A. biddisco at cscs.ch
Sat Sep 19 16:38:04 EDT 2015


I made some progress, but have not solved the problem.
The stream insertion from the gui generates 3 params, type size and the
array itself.
The cxx client server wrapper expects a size and a pointer, 2 params (+the
two for the objected etc)
The wrapper needs to be tricked into producing code for a
vtkClientServerStreamDataArg<int> object which exists during wrapping, but
not in normal code.
So adding 

#define VTK_WRAPPING_CXX
#include "vtkClientServerStream.h"


And later 

void SetSelectedGIds(int Ids[]);
//BTX
  void SetSelectedGIds(vtkClientServerStreamDataArg<int> &temp0);
//ETX

With the appropriate cxx function to extract the array, does work in that
it tricks the wrapper code into calling the function with the
client/server int array, but there are two problems

1) the pointer from the arg object is always NULL
2) we don’t know the size as the clientserverwrapperarg object doesn’t
store it, it only uses it during the constructor to allocate space then
passes the raw pointer on via the type T pointer. I can add this to the
wrapper class and then get the size (if I can find out and fix why the
pointer is always NULL).

I don’t really believe it should be this hard to pass an int pointer with
a known length from client to server, o I’d welcome any info that
simplifies this.

Thanks

JB




On 18/09/15 23:50, "ParaView on behalf of Biddiscombe, John A."
<paraview-bounces at paraview.org on behalf of biddisco at cscs.ch> wrote:

>Utkarsh
>
>Apologies, I didn’t get  chance to try this properly until now, When I
>call this 
>
>vtkClientServerStream stream;
>  stream << vtkClientServerStream::Invoke
>    << VTKOBJECT(proxy)
>    << "SetSelectedGIds"
>  << numValues;
>  stream.InsertArray(data, numValues);
>  stream << vtkClientServerStream::End;
>
>Inside my client server generated wrapper is this code
>
>if (!strcmp("SetSelectedGIds",method) && msg.GetNumberOfArguments(0) == 4)
>    {
>    int      temp0;
>    vtkClientServerStreamDataArg<int    > temp1(msg, 0, 3);
>    if(msg.GetArgument(0, 2, &temp0) &&
>      temp1)
>      {
>      op->SetSelectedGIds(temp0,temp1);
>      return 1;
>      }
>    }
>
>Which is generated from
>
>
>  void SetSelectedGIds(int N, const int *Ids);
>
>But when I step though the received message, the msg parameter only has
>GetNumberOfArguments == 3
>
>
>If I adjust the client server wrapped code to accept 3 args instead of 4,
>then the numValues looks correct, but the pointer is wrong.
>
>Q1 : why does the message only have 3 params when the wrapper wants 4
>Q2 : What should I change? I guess that something else needs to be
>inserted into the stream, but after having a poke round, I couldn’t guess
>what.
>
>Thanks
>
>JB
>
>
>
>
>On 17/09/15 16:47, "Utkarsh Ayachit" <utkarsh.ayachit at kitware.com> wrote:
>
>>(hit `send` prematurely, ignore previous email)
>>
>>How big is the array? For 100s of values, I'd say IntVectorProperty is
>>still reasonable. Any other approach will mean that those values are
>>not going to get saved in state files and such. For a one off push to
>>server side for values you don't care to be saved in state files, you
>>can directly call API using the vtkClientServerStream on the proxy as
>>follows:
>>
>>  vtkClientServerStream stream;
>>  stream << vtkClientServerStream::Invoke
>>              << VTKOBJECT(proxy)
>>               << SetValues
>>               << maxValues;
>>stream.InsertArray(values, maxValues);
>>stream << vtkClientServerStream::End;
>>
>>proxy->GetSession()->ExecuteStream(proxy->GetLocation(), stream);
>>
>>Assuming a server-side API of `void SetValues(int count, int* values);`.
>>
>>(please confirm the API, but this is pretty close to what it would look
>>like)
>>
>>Utkarsh
>>
>>
>>> On Thu, Sep 17, 2015 at 6:22 AM, Biddiscombe, John A.
>>><biddisco at cscs.ch> wrote:
>>>>
>>>> I’m afraid I’ve forgotten how to write plugins for paraview and I have
>>>>a simple-ish question :
>>>>
>>>>
>>>>
>>>> I’ve got a vtkUnsignedIntArray in my custom panel and I’d like to set
>>>>it as a property on a reader,
>>>>
>>>> the reader has a member
>>>>
>>>> vtkSetObjectMacro(SelectedGIDs)
>>>>
>>>>
>>>>
>>>> and in the panel I’ve generated a list of IDs, but I cannot recall how
>>>>I’m supposed to set them as the proxyproperty for the source.
>>>>
>>>>
>>>>
>>>> Is there an example (I do remember that I don’t want to use an
>>>>IntVectorProperty, but pass a whole array as a proxy property)
>>>>
>>>>
>>>>
>>>> (I’m considering using a vtkSelection, but the GIDs are not the same
>>>>as the cell Ids, so I wanted to try a direct array method first)
>>>>
>>>>
>>>>
>>>> thanks
>>>>
>>>>
>>>>
>>>> JB
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> John Biddiscombe,                        email:biddisco @.at.@ cscs.ch
>>>>
>>>> http://www.cscs.ch/
>>>>
>>>> CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
>>>>
>>>> Via Trevano 131, 6900 Lugano, Switzerland   | Fax:  +41 (91) 610.82.82
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/paraview
>>>>
>>>
>
>_______________________________________________
>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
>
>Search the list archives at: http://markmail.org/search/?q=ParaView
>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/paraview



More information about the ParaView mailing list