[Paraview-developers] establish client connection to pvserver from C++
Peter Vogt
vogtpeter5 at gmail.com
Thu Apr 21 09:57:38 EDT 2016
Thank you, Utkarsh,
the time for writing our last posts has overlapped. I had fixed the missing
UpdateVTKObjects() call in between, and I think the only missing step is to
add the sphere's representation to the view proxy.
But how do I add it to the Representations "property"? Neither
vtkSMViewProxy nor vtkSMRenderViewProxy have a method like
GetRepresentations() or InsertRepresentation(). Getting this final step
right will certainly help me understand the programming principle.
If the vtkSMParaViewPipleineControllerWithRendering is the recommended way
of remotely rendering objects, I'll definitely appreciate an example using
this class, if it doesn't cost you too much time.
Thanks
Peter
On Thu, Apr 21, 2016 at 3:42 PM, Utkarsh Ayachit <
utkarsh.ayachit at kitware.com> wrote:
> Peter,
>
> After a proxy is created or after any of its properties are changed,
> one must call "vtkSMProxy::UpdateVTKObject()" to push the changes made
> locally to the server or the underlying VTK objects. Try putting a
> call to this method the NewProxy(...) calls. You're also missing
> adding the Sphere source's representation to the View proxy's
> "Representations" property. Other option is to use the
> vtkSMParaViewPipleineControllerWithRendering.
>
> Give me a few hours, and I can put together an example that uses the
> controller to create a view and show something in it to get you
> started.
>
> Utkarsh
>
>
>
> On Thu, Apr 21, 2016 at 8:49 AM, 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/7b868b74/attachment.html>
More information about the Paraview-developers
mailing list