[vtkusers] vtkWeb - sending data to the client

Sebastien Jourdain sebastien.jourdain at kitware.com
Fri Oct 7 17:27:15 EDT 2016


We do that all the time, so yes, vtk/paraview web can handle it.

Just need to create a new RPC method that will build the structure the
client expect based on its request.

Here is a ParaView example which should apply to VTK if you ignore the
ParaView proxy magic (self.reader.GetClientSideObject())

    @exportRpc("my.super.app.get.table")
    def getTable(self):
        from vtk.util.numpy_support import vtk_to_numpy
        returnValue = {}
        dataTable = self.reader.GetClientSideObject().GetOutputDataObject(0)
        count = dataTable.GetNumberOfColumns()
        for idx in range(count):
            array = dataTable.GetColumn(idx)
            if SUPPORTED_TYPES[VTK_DATA_TYPES[array.GetDataType()]]:
                npArray = vtk_to_numpy(array)
                returnValue[array.GetName()] = [ i.item() for i in npArray ]
            else:
                returnValue[array.GetName()] = [ array.GetValue(i) for i in
xrange(array.GetNumberOfValues()) ]
        return returnValue

with that for our constant settings for filtering arrays we don't want to
get on the client side.

VTK_DATA_TYPES = [ 'void',            # 0
                   'bit',             # 1
                   'char',            # 2
                   'unsigned_char',   # 3
                   'short',           # 4
                   'unsigned_short',  # 5
                   'int',             # 6
                   'unsigned_int',    # 7
                   'long',            # 8
                   'unsigned_long',   # 9
                   'float',           # 10
                   'double',          # 11
                   'id_type',         # 12
                   'unspecified',     # 13
                   'unspecified',     # 14
                   'signed_char' ]    # 15

SUPPORTED_TYPES = { 'void': False,
                   'bit': False,
                   'char': True,
                   'unsigned_char': True,
                   'short': True,
                   'unsigned_short': True,
                   'int': True,
                   'unsigned_int': True,
                   'long': True,
                   'unsigned_long': True,
                   'float': True,
                   'double': True,
                   'id_type': True,
                   'unspecified': False,
                   'unspecified': False,
                   'signed_char': True }

On Fri, Oct 7, 2016 at 3:09 PM, Dan Lipsa <dan.lipsa at kitware.com> wrote:

> Hi Seb and all,
> One of the features we want to implement in our application is the ability
> to render plots on the client (in certain cases) using alternate means such
> as plotly.
>
> For this we need to send data = a numpy or numpy masked array = to the
> client. Is there any capability in vtkWeb or do you have any advise on how
> to do that?
>
> Thanks,
> Dan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161007/503333b7/attachment.html>


More information about the vtkusers mailing list