Commit ed9208f3 authored by Ludovic Courtès's avatar Ludovic Courtès

core: plugin-manager takes function parameters upfront.

parent 3738bfdf
......@@ -218,8 +218,7 @@ function* plugins_manager::load_function(const std::string& filename)
parameters params(dim.first, dim.second, param_in, param_out);
// Create the function from the command line
function* f = get_function(args);
f->setParametrization(params);
function* f = get_function(args, params);
// FIXME: Since the above is not quite the same as calling 'setDimY' (which
// is virtual), also call it from here. TODO: Remove it ASAP.
......@@ -238,7 +237,8 @@ function* plugins_manager::load_function(const std::string& filename)
//! Get an instance of the function selected based on the name <em>n</em>.
//! Return NULL if none exists.
function* plugins_manager::get_function(const arguments& args)
function* plugins_manager::get_function(const arguments& args,
const parameters& params)
{
#ifdef DEBUG
std::cout << __FILE__ << " " << __LINE__ << std::endl;
......@@ -250,7 +250,7 @@ function* plugins_manager::get_function(const arguments& args)
#ifdef DEBUG
std::cout << "<<DEBUG>> no function plugin specified, returning a rational function" << std::endl;
#endif
return new rational_function();
return new rational_function(params);
}
// The function to be returned.
......@@ -289,7 +289,7 @@ function* plugins_manager::get_function(const arguments& args)
arguments temp_args = arguments::create_arguments(n);
//Recursive call
function* f = get_function(temp_args);
function* f = get_function(temp_args, params);
nonlinear_function *nl_f = dynamic_cast<nonlinear_function*>(f);
if(nl_f == NULL)
{
......@@ -327,7 +327,7 @@ function* plugins_manager::get_function(const arguments& args)
else
{
std::cerr << "<<ERROR>> no function provider found in file \"" << filename << "\"" << std::endl;
return new rational_function() ;
return new rational_function(params) ;
}
}
......@@ -375,8 +375,10 @@ function* plugins_manager::get_function(const arguments& args)
std::cout << __FILE__ << " " << __LINE__ << std::endl;
std::cout << " n = " << n << std::endl;
#endif
nonlinear_function* func_fres = dynamic_cast<nonlinear_function*>(get_function(arguments::create_arguments(n)));
nonlinear_function* func_fres =
dynamic_cast<nonlinear_function*>(get_function(arguments::create_arguments(n),
params));
if(func_fres != NULL)
{
bool const fresnel_is_fixed = (args.is_defined("fixed-fresnel")) ? (true) : (false);
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2015 CNRS
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2016 Inria
This file is part of ALTA.
......@@ -17,6 +17,7 @@
#include "args.h"
#include "function.h"
#include "data.h"
#include "params.h"
#include "fitter.h"
#include "args.h"
#include "clustering.h"
......@@ -42,7 +43,8 @@ class plugins_manager
//! \details
//! This function attemps to load the shared object file specified in the
//! <code>--func filename</code>.
static function* get_function(const arguments& args) ;
static function* get_function(const arguments& args,
const parameters& params);
//! \brief load a function from the ALTA input file.
static function* load_function(const std::string& filename);
......
......@@ -145,14 +145,16 @@ bool rational_fitter_parallel::fit_data(const ptr<data>& dat, ptr<function>& fit
ptr<rational_function> rk(NULL);
#pragma omp critical (args)
{
rk = dynamic_pointer_cast<rational_function>(ptr<function>(plugins_manager::get_function(args)));
rk = dynamic_pointer_cast<rational_function>(
ptr<function>(plugins_manager::get_function(args,
r->parametrization())));
}
if(!rk)
{
std::cerr << "<<ERROR>> unable to obtain a rational function from the plugins manager" << std::endl;
throw;
}
rk->setParametrization(r->parametrization());
rk->setMin(r->min()) ;
rk->setMax(r->max()) ;
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014, 2015 Inria
Copyright (C) 2013, 2014, 2015, 2016 Inria
This file is part of ALTA.
......@@ -114,8 +114,8 @@ int main(int argc, char** argv)
fit->set_parameters(args) ;
ptr<function> f = ptr<function>(plugins_manager::get_function(args));
ptr<data> d = ptr<data>(plugins_manager::get_data(args["data"], args));
ptr<function> f = ptr<function>(plugins_manager::get_function(args, d->parametrization()));
try
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment