From 6bea13464981760795d38c8bf93587fa0bb8a4a0 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 7 Apr 2023 10:36:21 +0200 Subject: [PATCH] Factorisation --- src/SPV3D/SPV3D_Prs.cxx | 31 +++++++++++++++++++++++++++++-- src/SPV3D/SPV3D_Prs.h | 4 +++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index 4613be0c1..cf2e3a562 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -25,8 +25,16 @@ #include "SPV3D_Prs.h" -#include - +#include "vtkActor.h" +#include "vtkDataSet.h" +#include "vtkMapper.h" +#include "pqServer.h" +#include "pqApplicationCore.h" +#include "pqServerManagerModel.h" +#include "pqObjectBuilder.h" +#include "pqPipelineSource.h" +#include "vtkSMSourceProxy.h" +#include "vtkPVTrivialProducer.h" #include //--------------------------------------------------------- @@ -60,6 +68,25 @@ SPV3D_Prs *SPV3D_Prs::deepCopy() const return ret; } +void SPV3D_Prs::FillUsingActor(vtkActor *actor) const +{ + actor->GetMapper()->Update(); + vtkDataObject *ds = actor->GetMapper()->GetInput();//GetOutputDataObject(0); + vtkDataSet *ds2 = vtkDataSet::SafeDownCast(ds); + // + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + pqPipelineSource *mySourceProducer(builder->createSource("sources","PVTrivialProducer",serv)); + vtkSMProxy *producerBase = mySourceProducer->getProxy(); + vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase)); + vtkObjectBase *clientSideObject(producer->GetClientSideObject()); + vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject); + clientSideObjectCast->SetOutput(ds2); + mySourceProducer->updatePipeline(); + // + this->SetSourceProducer( mySourceProducer ); +} + SPV3D_Prs:: ~SPV3D_Prs() { DBG_FUN(); diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index 492555fa2..4ed52b0c3 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -22,7 +22,6 @@ #include "SPV3D.h" #include "SALOME_Prs.h" -class vtkActorCollection; class vtkActor; class pqPipelineSource; class pqDataRepresentation; @@ -57,8 +56,11 @@ public: SPV3D_Prs *deepCopy() const; + void FillUsingActor(vtkActor *actor) const; + void DisplayIn( SALOME_View* v ) const override; + void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; } void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); } -- 2.39.2