Commit 693a66cf authored by Ludovic Courtès's avatar Ludovic Courtès

core: 'provide_function' function takes a 'parameters' object.

parent 2e78561d
......@@ -126,8 +126,8 @@ class function
}
// TODO: Deprecate, then remove these two methods.
virtual void setDimX(int x);
virtual void setDimY(int y);
virtual void setDimX(int x) ALTA_DEPRECATED;
virtual void setDimY(int y) ALTA_DEPRECATED;
protected:
// Input and output parametrization
......
......@@ -322,7 +322,7 @@ function* plugins_manager::get_function(const arguments& args,
std::cout << "<<DEBUG>> using function provider in file \"" << filename << "\"" << std::endl;
#endif
func = myFunction();
func = myFunction(params);
}
else
{
......@@ -420,7 +420,8 @@ function* plugins_manager::get_function(const arguments& args,
}
ptr<function> plugins_manager::get_function(const std::string& n)
ptr<function> plugins_manager::get_function(const std::string& n,
const parameters& params)
{
if(n.empty())
{
......@@ -436,7 +437,7 @@ ptr<function> plugins_manager::get_function(const std::string& n)
#ifdef DEBUG
std::cout << "<<DEBUG>> using function provider in file \"" << n << "\"" << std::endl;
#endif
return ptr<function>(myFunc());
return ptr<function>(myFunc(params));
}
else
{
......
......@@ -50,7 +50,8 @@ class plugins_manager
static function* load_function(const std::string& filename);
//! \brief load a function from the ALTA input file.
static ptr<function> get_function(const std::string& n);
static ptr<function> get_function(const std::string& n,
const parameters& params);
//! \brief get an instance of the data that is defined in the plugin with
//! filename n. Return null if no one exist.
......@@ -77,7 +78,7 @@ class plugins_manager
private: //data
// Object provider prototypes
typedef function* (*FunctionPrototype)();
typedef function* (*FunctionPrototype)(const parameters&);
typedef fitter* (*FitterPrototype)();
typedef data* (*DataPrototype)(const arguments&);
};
......
......@@ -21,15 +21,13 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
{
return new schlick();
return new schlick(params);
}
schlick::schlick():
// XXX: Partial parametrization.
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN, params::UNKNOWN_OUTPUT))
schlick::schlick(const alta::parameters& params):
nonlinear_function(params.set_input(6, params::CARTESIAN))
{
}
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2016 Inria
This file is part of ALTA.
......@@ -15,7 +15,9 @@
#include <string>
// Interface
#include <core/params.h>
#include <core/function.h>
#include <core/params.h>
#include <core/data.h>
#include <core/fitter.h>
#include <core/args.h>
......@@ -29,8 +31,7 @@ class schlick : public nonlinear_function
public: // methods
// Constructor
schlick();
schlick(const alta::parameters& params);
//! \brief Load function specific files
virtual bool load(std::istream& in) ;
......@@ -74,5 +75,8 @@ class schlick : public nonlinear_function
//! Unidimensional Fresnel reflectance at theta = 0
vec R;
// Constructor
schlick() {};
} ;
......@@ -21,15 +21,13 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
{
return new retro_schlick();
return new retro_schlick(params);
}
retro_schlick::retro_schlick():
// XXX: Partial parametrization.
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN, params::UNKNOWN_OUTPUT))
retro_schlick::retro_schlick(const alta::parameters& params):
nonlinear_function(params.set_input(6, params::CARTESIAN))
{
}
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2016 Inria
This file is part of ALTA.
......@@ -15,6 +15,7 @@
#include <string>
// Interface
#include <core/params.h>
#include <core/function.h>
#include <core/data.h>
#include <core/fitter.h>
......@@ -29,8 +30,7 @@ class retro_schlick : public nonlinear_function
public: // methods
//! \brief Constructor
retro_schlick();
retro_schlick(const alta::parameters& params);
//! \brief Load function specific files
virtual bool load(std::istream& in) ;
......@@ -74,5 +74,6 @@ class retro_schlick : public nonlinear_function
//! Unidimensional Fresnel reflectance at theta = 0
vec R;
retro_schlick();
} ;
......@@ -21,9 +21,14 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
{
return new schlick_fresnel(params);
}
schlick_fresnel::schlick_fresnel(const alta::parameters& params)
: nonlinear_function(params)
{
return new schlick_fresnel();
}
//! Load function specific files
......
......@@ -33,11 +33,7 @@ class schlick_fresnel : public nonlinear_function
public: // methods
schlick_fresnel():
// XXX: Partial parametrization.
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN, params::UNKNOWN_OUTPUT))
{}
schlick_fresnel(const alta::parameters& params);
//! \brief Load function specific files
virtual bool load(std::istream& in) ;
......@@ -83,5 +79,7 @@ class schlick_fresnel : public nonlinear_function
//! Fresnel reflectance at theta = 0
vec R;
schlick_fresnel() {};
} ;
......@@ -22,9 +22,9 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
{
return new abc_function();
return new abc_function(params);
}
// Overload the function operator
......
......@@ -48,9 +48,8 @@ class abc_function : public nonlinear_function
public: // methods
abc_function():
nonlinear_function(alta::parameters(1, 0,
params::COS_TH, params::UNKNOWN_OUTPUT))
abc_function(const alta::parameters& params)
: nonlinear_function(params)
{}
// Overload the function operator
......@@ -91,5 +90,7 @@ class abc_function : public nonlinear_function
private: // data
vec _a, _b, _c; // Lobes data
abc_function() {};
} ;
......@@ -22,11 +22,17 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
{
return new beckmann_function();
return new beckmann_function(params);
}
beckmann_function::beckmann_function(const alta::parameters& params)
: nonlinear_function(params.set_input(6, params::CARTESIAN))
{
}
vec beckmann_function::G(const vec& x) const
{
//TODO : RP: REMOVE THIS CODE BECAUSE IT IS NEVER CALLED ?
......
......@@ -38,12 +38,7 @@ class beckmann_function : public nonlinear_function
public: // methods
beckmann_function():
// XXX: Partial initialization.
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN,
params::UNKNOWN_OUTPUT))
{}
beckmann_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -87,5 +82,7 @@ class beckmann_function : public nonlinear_function
vec _ks; //Specular coefficients. One per color/wavelength
vec _a; // Roughness parameters. One per color/wavelength
beckmann_function();
} ;
......@@ -21,11 +21,16 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new blinn_function();
return new blinn_function(params);
}
blinn_function::blinn_function(const alta::parameters& params)
: nonlinear_function(params.set_input(1, params::COS_TH))
{}
// Overload the function operator
vec blinn_function::operator()(const vec& x) const
{
......
......@@ -42,10 +42,7 @@ class blinn_function : public nonlinear_function
public: // methods
blinn_function():
nonlinear_function(alta::parameters(1, 1, params::COS_TH,
params::UNKNOWN_OUTPUT))
{}
blinn_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -97,5 +94,7 @@ class blinn_function : public nonlinear_function
//! \brief The blinn lobe parameters
vec _ks, _N;
blinn_function() {};
} ;
......@@ -21,15 +21,14 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new diffuse_function();
return new diffuse_function(params);
}
diffuse_function::diffuse_function()
: _kd( vec::Zero( _parameters.dimY() ) ),
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN, params::UNKNOWN_OUTPUT))
diffuse_function::diffuse_function(const alta::parameters& params)
: nonlinear_function(params.set_input(6, params::CARTESIAN)),
_kd( vec::Zero(params.dimY()))
{
}
......
......@@ -42,7 +42,7 @@ class diffuse_function : public nonlinear_function
// Set the input parametrization to CARTESIAN to reduce the number
// of transformations in a compound object.
diffuse_function();
diffuse_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -80,5 +80,7 @@ class diffuse_function : public nonlinear_function
private: // data
vec _kd;
diffuse_function() {};
} ;
......@@ -21,11 +21,16 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new isotropic_lafortune_function();
return new isotropic_lafortune_function(params);
}
isotropic_lafortune_function::isotropic_lafortune_function(const alta::parameters& params):
nonlinear_function(params.set_input(6, params::CARTESIAN)),
_n(1)
{}
// Overload the function operator
vec isotropic_lafortune_function::operator()(const vec& x) const
{
......
......@@ -61,11 +61,7 @@ class isotropic_lafortune_function : public nonlinear_function
public: // methods
isotropic_lafortune_function():
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN, params::UNKNOWN_OUTPUT)),
_n(1)
{}
isotropic_lafortune_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -117,6 +113,8 @@ class isotropic_lafortune_function : public nonlinear_function
N = _N[n*_parameters.dimY() + c];
}
isotropic_lafortune_function() {};
private: // data
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2016 Inria
This file is part of ALTA.
......@@ -22,9 +22,9 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
{
return new lafortune_function();
return new lafortune_function(params);
}
// Overload the function operator
......
......@@ -22,11 +22,18 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new beckmann_function();
return new beckmann_function(params);
}
beckmann_function::beckmann_function(const alta::parameters& params)
: nonlinear_function(params.set_input(6, params::CARTESIAN)),
_use_back_param(true)
{
}
// Overload the function operator
vec beckmann_function::operator()(const vec& x) const
{
......
......@@ -41,12 +41,7 @@ class beckmann_function : public nonlinear_function
public: // methods
beckmann_function():
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN,
params::UNKNOWN_OUTPUT)),
_use_back_param(true)
{}
beckmann_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -87,5 +82,7 @@ class beckmann_function : public nonlinear_function
vec _ks, _a; // Lobes data
bool _use_back_param;
beckmann_function() {};
} ;
......@@ -21,9 +21,14 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new retroblinn_function(params);
}
retroblinn_function::retroblinn_function(const alta::parameters &params)
: nonlinear_function(params)
{
return new retroblinn_function();
}
// Overload the function operator
......
......@@ -36,6 +36,8 @@ class retroblinn_function : public nonlinear_function
public: // methods
retroblinn_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
virtual vec value(const vec& x) const ;
......@@ -89,5 +91,7 @@ class retroblinn_function : public nonlinear_function
//! \brief The retroblinn lobe data
vec _ks, _N;
retroblinn_function() {};
} ;
......@@ -22,11 +22,17 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new yoo_function();
return new yoo_function(params);
}
yoo_function::yoo_function(const alta::parameters& params)
: nonlinear_function(params.set_input(6, params::CARTESIAN))
{
}
// Overload the function operator
vec yoo_function::operator()(const vec& x) const
{
......
......@@ -44,11 +44,7 @@ class yoo_function : public nonlinear_function
public: // methods
yoo_function():
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN,
params::UNKNOWN_OUTPUT))
{}
yoo_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -88,5 +84,7 @@ class yoo_function : public nonlinear_function
private: // data
vec _kr, _lt; // Lobes data
yoo_function() {};
} ;
......@@ -21,11 +21,16 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function()
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new shifted_gamma_function();
return new shifted_gamma_function(params);
}
shifted_gamma_function::shifted_gamma_function(const alta::parameters& params)
: nonlinear_function(params.set_input(6, params::CARTESIAN))
{}
// Overload the function operator
vec shifted_gamma_function::operator()(const vec& x) const
{
......
......@@ -28,11 +28,7 @@ class shifted_gamma_function : public nonlinear_function
{
public: // methods
shifted_gamma_function():
nonlinear_function(alta::parameters(6, 0,
params::CARTESIAN,
params::UNKNOWN_OUTPUT))
{}
shifted_gamma_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -111,6 +107,8 @@ class shifted_gamma_function : public nonlinear_function
//! Color parameters
vec rho_d, rho_s, alpha;
shifted_gamma_function() {};
} ;
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2016 Inria
This file is part of ALTA.
......@@ -22,9 +22,9 @@</