[Paraview-developers] How to obtain pqPipelineSource from vtkObject?
Hillier, Michael (NRCan/RNCan)
michael.hillier at canada.ca
Fri Jan 22 18:07:54 EST 2016
Hi Utkarsh,
Thanks for your reply. I am not too surprised that how I was implementing was not how things are expected. I did manage to get what I had to work via another mechanism:
vtkSMProxyManager *proxyManager = vtkSMProxyManager::GetProxyManager();
vtkSMSessionProxyManager *sessionProxyManager = proxyManager->GetActiveSessionProxyManager();
// Create a vtkTrivalProducer and set its output to be the poly data
vtkSmartPointer<vtkSMSourceProxy> producer;
producer.TakeReference(vtkSMSourceProxy::SafeDownCast(sessionProxyManager->NewProxy("sources","PVTrivialProducer")));
vtkNew<vtkSMParaViewPipelineController> Controller;
Controller->PreInitializeProxy(producer);
vtkObjectBase *clientSideObject = producer->GetClientSideObject();
vtkPVTrivialProducer *realProducer = vtkPVTrivialProducer::SafeDownCast(clientSideObject);
realProducer->SetOutput(pdata);
Controller->PostInitializeProxy(producer);
Controller->RegisterPipelineProxy(producer,"test_pipe");
producer->UpdateVTKObjects();
Would creating a subclass of vtkPolyDataAlgorithm simply this? Would it make it more efficient? I try to re implement this way so that I do things the right way.
Thanks
Michael
-----Original Message-----
From: Utkarsh Ayachit [mailto:utkarsh.ayachit at kitware.com]
Sent: Friday, January 22, 2016 3:39 PM
To: Hillier, Michael (NRCan/RNCan)
Cc: paraview-developers at paraview.org
Subject: Re: [Paraview-developers] How to obtain pqPipelineSource from vtkObject?
Michael,
This isn't how things are expected to work in ParaView. I'd suggest instead of creating a vtkXMLPolyDataReader directly in your plugin and setting the binary string on it, create a new vtkPolyDataAlgorithm subclass that in its RequestData() method obtains the vtp file from the database and then sets it on an internal vtkXMLPolyDataReader and then executes it and passes the data out.
Now you can create a plugin for this new vtkPolyDataAlgorithm and then available for the application to use/create like other data source proxies like readers or sphere source etc.
Utkarsh
On Tue, Jan 19, 2016 at 4:20 PM, Hillier, Michael (NRCan/RNCan) <michael.hillier at canada.ca> wrote:
> I am having trouble figuring out how to get a pqPipelineSource from a
> vtkObject (specifically a vtkPolyData) so that I can view those
> objects in paraview from my plugin. Here is my code
>
>
>
>
>
> vtkSmartPointer<vtkXMLPolyDataReader> reader =
> vtkSmartPointer<vtkXMLPolyDataReader>::New();
>
> std::string binary_string; // I get this from a database which stores
> contents of a binary .vtp file
>
> reader->SetInputString(binary_string);
>
> reader->ReadFromInputStringOn();
>
> reader->Update();
>
>
>
> pqApplicationCore *core = pqApplicationCore::instance();
>
> pqDisplayPolicy *displayPolicy = core->getDisplayPolicy();
>
> pqView *view = pqActiveObjects::instance().activeView();
>
>
>
> pqPipelineSource* source = ??? // want to obtain from
> vtkObject/vtkPolyData somehow (vtkPolyData * pdata =
> reader->GetOutput());
>
> vtkSMProxy *sourceProxy = source->getProxy();
>
> sourceProxy->UpdateVTKObjects();
>
> displayPolicy->setRepresentationVisibility(source->getOutputPort(0),vi
> displayPolicy->ew,true);
>
>
>
>
>
> Any help much appreciated.
>
>
>
> Michael
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at:
> http://markmail.org/search/?q=Paraview-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview-developers
>
More information about the Paraview-developers
mailing list