From 9c72b9ee8d584f4fd5729f496b7927fec8f55e4e Mon Sep 17 00:00:00 2001 From: Robert Twyman Date: Fri, 9 Oct 2020 16:25:26 +0100 Subject: [PATCH 1/3] Generate prior factory This isn't working... --- src/swig/stir.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/swig/stir.i b/src/swig/stir.i index b727d6805..30c92702a 100644 --- a/src/swig/stir.i +++ b/src/swig/stir.i @@ -1579,6 +1579,10 @@ namespace stir { #undef elemT #endif +%newobject *::get_prior_ptr; +%factory(stir::GeneralisedPrior *stir::GeneralisedObjectiveFunction::get_prior_ptr, stir::QuadraticPrior, stir::PLSPrior, stir::RelativeDifferencePrior); +//%factory(stir::GeneralisedPrior *stir::GeneralisedObjectiveFunction< TargetT >::get_prior_ptr, stir::QuadraticPrior, stir::PLSPrior, stir::RelativeDifferencePrior); + %include "stir/recon_buildblock/GeneralisedObjectiveFunction.h" %include "stir/recon_buildblock/GeneralisedObjectiveFunction.h" %include "stir/recon_buildblock/PoissonLogLikelihoodWithLinearModelForMean.h" From c6fbe6f14f96ea58b2606bb6ee8deb77f3b13ffc Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Sun, 18 Oct 2020 00:04:14 +0000 Subject: [PATCH 2/3] [SWIG] sort-out factory for get_prior tell SWIG about the prior hierarchy such that get_prior() returns instances of the actual prior (not just the base class) --- src/swig/stir.i | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/swig/stir.i b/src/swig/stir.i index 30c92702a..ef9e0e73e 100644 --- a/src/swig/stir.i +++ b/src/swig/stir.i @@ -472,6 +472,7 @@ #endif %include "attribute.i" +%include "factory.i" %init %{ #if defined(SWIGPYTHON) @@ -1575,14 +1576,24 @@ namespace stir { %shared_ptr(stir::FBP2DReconstruction); %shared_ptr(stir::FBP3DRPReconstruction); +// tell SWIG to convert the return of get_prior_ptr etc to the appropriate object +/* This currently fails, so is still commented out + +%newobject *::get_objective_function; +%factory( + stir::GeneralisedObjectiveFunction& stir::IterativeReconstruction::get_objective_function, + %arg(stir::PoissonLogLikelihoodWithLinearModelForMeanAndProjData)); +*/ +%newobject *::get_prior_ptr; +%factory(stir::GeneralisedPrior *stir::GeneralisedObjectiveFunction< TargetT >::get_prior_ptr, + stir::QuadraticPrior, + stir::PLSPrior, + stir::RelativeDifferencePrior); + #undef TargetT #undef elemT #endif -%newobject *::get_prior_ptr; -%factory(stir::GeneralisedPrior *stir::GeneralisedObjectiveFunction::get_prior_ptr, stir::QuadraticPrior, stir::PLSPrior, stir::RelativeDifferencePrior); -//%factory(stir::GeneralisedPrior *stir::GeneralisedObjectiveFunction< TargetT >::get_prior_ptr, stir::QuadraticPrior, stir::PLSPrior, stir::RelativeDifferencePrior); - %include "stir/recon_buildblock/GeneralisedObjectiveFunction.h" %include "stir/recon_buildblock/GeneralisedObjectiveFunction.h" %include "stir/recon_buildblock/PoissonLogLikelihoodWithLinearModelForMean.h" From fd15a8b7ae410643d945a7b8d02741e0a7bb5891 Mon Sep 17 00:00:00 2001 From: Robert Twyman Date: Tue, 20 Oct 2020 18:09:39 +0100 Subject: [PATCH 3/3] Clean up comments [ci skip] --- src/swig/stir.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/swig/stir.i b/src/swig/stir.i index ef9e0e73e..441c89425 100644 --- a/src/swig/stir.i +++ b/src/swig/stir.i @@ -1576,14 +1576,14 @@ namespace stir { %shared_ptr(stir::FBP2DReconstruction); %shared_ptr(stir::FBP3DRPReconstruction); -// tell SWIG to convert the return of get_prior_ptr etc to the appropriate object /* This currently fails, so is still commented out - %newobject *::get_objective_function; %factory( stir::GeneralisedObjectiveFunction& stir::IterativeReconstruction::get_objective_function, %arg(stir::PoissonLogLikelihoodWithLinearModelForMeanAndProjData)); -*/ +*/ + +// tell SWIG to convert the return of get_prior_ptr etc to the appropriate object %newobject *::get_prior_ptr; %factory(stir::GeneralisedPrior *stir::GeneralisedObjectiveFunction< TargetT >::get_prior_ptr, stir::QuadraticPrior,