[Paraview-developers] establish client connection to pvserver from C++
Peter Vogt
vogtpeter5 at gmail.com
Thu Apr 21 08:49:12 EDT 2016
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/e09bad6b/attachment.html>
More information about the Paraview-developers
mailing list