[Paraview-developers] establish client connection to pvserver from C++

Peter Vogt vogtpeter5 at gmail.com
Thu Apr 21 09:40:22 EDT 2016


One more update, after calling view->UpdateVTKObjects() and
view->MakeRenderWindowInteractor(), the example below runs without errors.
But still, the sphere source is not visible, only the grey background. What
is missing to show the sphere in the view?

#include "vtkInitializationHelper.h"
#include "vtkProcessModule.h"
#include "vtkPVOptions.h"
#include "vtkSMProxyManager.h"
#include "vtkSMSession.h"
#include "vtkSMSessionClient.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkSMSourceProxy.h"
#include "vtkSMProperty.h"
#include "vtkSMRenderViewProxy.h"

#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"

int main(int argc, char* argv[])
{
  // Initialization
  vtkPVOptions* options = vtkPVOptions::New();
  vtkInitializationHelper::Initialize(argc, argv,
                                      vtkProcessModule::PROCESS_CLIENT,
                                      options);

  vtkSMSessionClient* session = vtkSMSessionClient::New();
  vtkProcessModule::GetProcessModule()->RegisterSession(session);
  session->Connect(options->GetServerURL());
  cout<<"Connected to: "<<options->GetServerURL()<<endl;

  vtkSMSessionProxyManager *pxm = session->GetSessionProxyManager();
  vtkSMProxy *sphere = pxm->NewProxy("sources", "SphereSource");
  cout<<"SphereSource created."<<endl;
  vtkSMRenderViewProxy* view=(vtkSMRenderViewProxy*)pxm->NewProxy("views",
"RenderView");
  bool ok=view->MakeRenderWindowInteractor(false);
  cout<<"RenderView created. "<<ok<<endl;
  vtkSMRepresentationProxy*
repr=view->CreateDefaultRepresentation(sphere,0);
  view->UpdateVTKObjects();
  cout<<"DefaultRepresentation created."<<endl;

//Alternative 2:
/*
  view->ResetCamera(); //no crash, but only background visible.
  view->StillRender(); while(1);
*/

//Alternative 3:

  view->InteractiveRender();
  view->GetInteractor()->Initialize();
  view->GetInteractor()->Start();

  //TODO: clean up stuff
}

On Thu, Apr 21, 2016 at 2:49 PM, Peter Vogt <vogtpeter5 at gmail.com> wrote:

> Hello again,
> thanks to your help, I was able to establish a connection to a pvserver
> and create a SphereSource proxy. Now I cannot figure out how to view the
> rendered scene on the client.
>
> My attempt, "TestConnection.cxx", is attached below. I have tried three
> alternatives, which I have marked in the code:
> Alternative 1 calls "view->StillRender()", which shows the greyish
> background, maybe because the sphere is outside the viewport?
> Alternative 2 calls "view->ResetCamera()" before the StillRender(), but
> ResetCamera crashes with the following output:
> >ERROR: In
> /opt/ParaView-v5.0.1-source/ParaViewCore/ServerImplementation/Core/vtkPVSessionCoreInterpreterHelper.cxx,
> line 63
> >vtkPVSessionCoreInterpreterHelper (0x976950): No vtkSIProxy for id : 257
> >
> >ERROR: In
> /opt/ParaView-v5.0.1-source/ParaViewCore/ServerImplementation/Core/vtkPVSessionCore.cxx,
> line 390
> >vtkPVSessionCore (0x8ca480): Wrapper function not found for class "(vtk
> object is NULL)".
> >while processing
> >Message 0 = Invoke
> >  Argument 0 = stream_value {
> >    Message 0 = Invoke
> >      Argument 0 = id_value {1}
> >      Argument 1 = string_value {GetVTKObject}
> >      Argument 2 = uint32_value {257}
> >    }
> >  Argument 1 = string_value {ResetCamera}
> >
> >
> >ERROR: In
> /opt/ParaView-v5.0.1-source/ParaViewCore/ServerImplementation/Core/vtkPVSessionCore.cxx,
> line 391
> >vtkPVSessionCore (0x8ca480): Aborting execution for debugging purposes.
> >
> >############ ABORT #############
> >Wrong tag but don't know how to handle it... 188971
> >Aborted (core dumped)
> Alternative 3 tries to show an interactive RenderWindow, but crashes,
> because view->GetInteractor() returns NULL.
>
> Apparently I am missing some important step. Can somebody point out how to
> modify the example (below) in order to render the sphere source visible?
>
> Thank you
> Peter
>
> TestConnection.cxx:
>
> #include "vtkInitializationHelper.h"
> #include "vtkProcessModule.h"
> #include "vtkPVOptions.h"
> #include "vtkSMProxyManager.h"
> #include "vtkSMSession.h"
> #include "vtkSMSessionClient.h"
> #include "vtkSMSessionProxyManager.h"
> #include "vtkSMSourceProxy.h"
> #include "vtkSMProperty.h"
> #include "vtkSMRenderViewProxy.h"
>
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
>
> int main(int argc, char* argv[])
> {
>   // Initialization
>   vtkPVOptions* options = vtkPVOptions::New();
>   vtkInitializationHelper::Initialize(argc, argv,
>                                       vtkProcessModule::PROCESS_CLIENT,
>                                       options);
>
>   vtkSMSessionClient* session = vtkSMSessionClient::New();
>   vtkProcessModule::GetProcessModule()->RegisterSession(session);
>   session->Connect(options->GetServerURL());
>   cout<<"Connected to: "<<options->GetServerURL()<<endl;
>
>   vtkSMSessionProxyManager *pxm = session->GetSessionProxyManager();
>   vtkSMProxy *sphere = pxm->NewProxy("sources", "SphereSource");
>   cout<<"SphereSource created."<<endl;
>   vtkSMRenderViewProxy* view=(vtkSMRenderViewProxy*)pxm->NewProxy("views",
> "RenderView");
>   cout<<"RenderView created."<<endl;
>   vtkSMRepresentationProxy*
> repr=view->CreateDefaultRepresentation(sphere,0);
>   cout<<"DefaultRepresentation created."<<endl;
>
> //Alternative 1:
>   view->StillRender(); while(1); //no crash, but only background visible.
>
> //Alternative 2:
> /*
>   view->ResetCamera(); //crash here
>   view->StillRender(); while(1);
> */
>
> //Alternative 3:
> /*
>   view->InteractiveRender();
>   view->GetInteractor()->Initialize(); //crash here, because
> view->GetInteractor()==NULL
>   view->GetInteractor()->Start();
> */
>   //TODO: clean up stuff
> }
>
> On Wed, Apr 20, 2016 at 5:26 PM, Utkarsh Ayachit <
> utkarsh.ayachit at kitware.com> wrote:
>
>> > Thank you, but we need a pure C++ solution. There is plenty of
>> information
>> > how this is done with python scripting, but I can't find anything for
>> C++.
>> > I really need nothing more than a minimal example.
>>
>> Peter, look at TestComparativeAnimationCueProxy.cxx[1] file in the
>> ParaView source. It demonstrates how the initialization needs to
>> happen. If you have further questions on how to use anything specific
>> in this application, feel free to holler :).
>>
>> [1]
>> https://gitlab.kitware.com/paraview/paraview/blob/master/ParaViewCore/ServerManager/Default/Testing/Cxx/TestComparativeAnimationCueProxy.cxx
>>
>> Utkarsh
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20160421/549bc1e5/attachment-0001.html>


More information about the Paraview-developers mailing list