Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 937d3f49 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Updating the interface of rational fitters. This is not a clean REV. ALTA will not compile.

parent 4544fba8
......@@ -30,7 +30,7 @@ rational_fitter_cgal::~rational_fitter_cgal()
{
}
bool rational_fitter_cgal::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_cgal::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
......
......@@ -24,7 +24,7 @@ class rational_fitter_cgal : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......
......@@ -19,7 +19,7 @@ ALTA_DLL_EXPORT fitter* provide_fitter()
return new rational_fitter_dca();
}
data* rational_fitter_dca::provide_data() const
ptr<data> rational_fitter_dca::provide_data() const
{
return new vertical_segment() ;
}
......@@ -36,7 +36,7 @@ rational_fitter_dca::~rational_fitter_dca()
{
}
bool rational_fitter_dca::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_dca::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
......@@ -85,7 +85,7 @@ void rational_fitter_dca::set_parameters(const arguments& args)
{
}
double distance(const rational_function* f, const data* d)
double distance(const rational_function* f, const ptr<data> d)
{
double distance = 0.0;
for(int i=0; i<d->size(); ++i)
......@@ -107,7 +107,7 @@ double distance(const rational_function* f, const data* d)
}
// Bootstrap the DCA algorithm with an already done fit
void rational_fitter_dca::bootstrap(const data* d, int& np, int& nq, rational_function* fit, double& delta, const arguments& args)
void rational_fitter_dca::bootstrap(const ptr<data> d, int& np, int& nq, rational_function* fit, double& delta, const arguments& args)
{
if(args.is_defined("bootstrap"))
......@@ -146,7 +146,7 @@ void rational_fitter_dca::bootstrap(const data* d, int& np, int& nq, rational_fu
// np and nq are the degree of the RP to fit to the data
// y is the dimension to fit on the y-data (e.g. R, G or B for RGB signals)
// the function return a ration BRDF function and a boolean
bool rational_fitter_dca::fit_data(const data* d, rational_function* r, const arguments& args)
bool rational_fitter_dca::fit_data(const ptr<data> d, rational_function* r, const arguments& args)
{
int np, nq;
......
......@@ -32,7 +32,7 @@ class rational_fitter_dca : public QObject, public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......@@ -40,19 +40,19 @@ class rational_fitter_dca : public QObject, public fitter
// Obtain associated data and functions
//
virtual data* provide_data() const ;
virtual ptr<data> provide_data() const ;
virtual function* provide_function() const ;
protected: // function
// Fitting a data object using np elements in the numerator and nq
// elements in the denominator
virtual bool fit_data(const data* d, rational_function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, rational_function* fit, const arguments& args) ;
//! \brief Bootstrap the DCA algorithm with an already fitted function. It will
//! load the the rational function object from a text file defined in the argument
//! --bootstrap %filename%.
void bootstrap(const data* d, int& np, int& nq, rational_function* fit, double& delta,
void bootstrap(const ptr<data> d, int& np, int& nq, rational_function* fit, double& delta,
const arguments& args) ;
protected: // data
......
......@@ -24,16 +24,16 @@ rational_fitter_eigen::~rational_fitter_eigen()
{
}
bool rational_fitter_eigen::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_eigen::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
ptr<vertical_segment> d = dynamic_pointer_cast<vertical_segment>(dat) ;
if(r == NULL)
{
std::cerr << "<<ERROR>> not passing the correct function object to the fitter" << std::endl ;
return false ;
}
if(d == NULL)
if(!d)
{
std::cerr << "<<ERROR>> not passing the correct data object to the fitter" << std::endl ;
return false ;
......@@ -74,7 +74,7 @@ void rational_fitter_eigen::set_parameters(const arguments& args)
_nq = args.get_float("nq", 10) ;
}
bool rational_fitter_eigen::fit_data(const vertical_segment* d, int np, int nq, rational_function* r)
bool rational_fitter_eigen::fit_data(const ptr<vertical_segment> d, int np, int nq, rational_function* r)
{
// For each output dimension (color channel for BRDFs) perform
// a separate fit on the y-1D rational function.
......@@ -94,7 +94,7 @@ bool rational_fitter_eigen::fit_data(const vertical_segment* d, int np, int nq,
// np and nq are the degree of the RP to fit to the data
// y is the dimension to fit on the y-data (e.g. R, G or B for RGB signals)
// the function return a ration BRDF function and a boolean
bool rational_fitter_eigen::fit_data(const vertical_segment* d, int np, int nq, int ny, rational_function_1d* r)
bool rational_fitter_eigen::fit_data(const ptr<vertical_segment> d, int np, int nq, int ny, rational_function_1d* r)
{
// Each constraint (fitting interval or point
// add another dimension to the constraint
......
......@@ -25,7 +25,7 @@ class rational_fitter_eigen : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......@@ -35,8 +35,8 @@ class rational_fitter_eigen : public fitter
// Fitting a data object using np elements in the numerator and nq
// elements in the denominator
virtual bool fit_data(const vertical_segment* d, int np, int nq, rational_function* fit) ;
virtual bool fit_data(const vertical_segment* dat, int np, int nq, int ny, rational_function_1d* fit) ;
virtual bool fit_data(const ptr<vertical_segment> d, int np, int nq, rational_function* fit) ;
virtual bool fit_data(const ptr<vertical_segment> dat, int np, int nq, int ny, rational_function_1d* fit) ;
protected: // data
......
......@@ -17,7 +17,7 @@ ALTA_DLL_EXPORT fitter* provide_fitter()
return new rational_fitter_leastsquare();
}
data* rational_fitter_leastsquare::provide_data() const
ptr<data> rational_fitter_leastsquare::provide_data() const
{
return new vertical_segment() ;
}
......@@ -34,11 +34,11 @@ rational_fitter_leastsquare::~rational_fitter_leastsquare()
{
}
bool rational_fitter_leastsquare::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_leastsquare::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
if(r == NULL || d == NULL)
const ptr<vertical_segment> d = dynamic_pointer_cast<vertical_segment>(dat) ;
if(r == NULL || !d)
{
std::cerr << "<<ERROR>> not passing the correct class to the fitter" << std::endl ;
return false ;
......@@ -80,7 +80,7 @@ void rational_fitter_leastsquare::set_parameters(const arguments& args)
_max_iter = args.get_float("max-iter", 1) ;
}
bool rational_fitter_leastsquare::fit_data(const vertical_segment* d, int np, int nq, rational_function* r)
bool rational_fitter_leastsquare::fit_data(const ptr<vertical_segment>& d, int np, int nq, rational_function* r)
{
// For each output dimension (color channel for BRDFs) perform
// a separate fit on the y-1D rational function.
......@@ -101,7 +101,7 @@ bool rational_fitter_leastsquare::fit_data(const vertical_segment* d, int np, in
// np and nq are the degree of the RP to fit to the data
// y is the dimension to fit on the y-data (e.g. R, G or B for RGB signals)
// the function return a ration BRDF function and a boolean
bool rational_fitter_leastsquare::fit_data(const vertical_segment* d, int np, int nq, int ny, rational_function_1d* r)
bool rational_fitter_leastsquare::fit_data(const ptr<vertical_segment>& d, int np, int nq, int ny, rational_function_1d* r)
{
using namespace Eigen;
......
......@@ -21,7 +21,7 @@ class rational_fitter_leastsquare : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......@@ -29,15 +29,15 @@ class rational_fitter_leastsquare : public fitter
// Obtain associated data and functions
//
virtual data* provide_data() const ;
virtual ptr<data> provide_data() const ;
virtual function* provide_function() const ;
protected: // function
// Fitting a data object using np elements in the numerator and nq
// elements in the denominator
virtual bool fit_data(const vertical_segment* d, int np, int nq, rational_function* fit) ;
virtual bool fit_data(const vertical_segment* dat, int np, int nq, int ny, rational_function_1d* fit) ;
virtual bool fit_data(const ptr<vertical_segment>& d, int np, int nq, rational_function* fit) ;
virtual bool fit_data(const ptr<vertical_segment>& dat, int np, int nq, int ny, rational_function_1d* fit) ;
protected: // data
......
......@@ -34,7 +34,7 @@ rational_fitter_matlab::~rational_fitter_matlab()
engClose(ep);
}
bool rational_fitter_matlab::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_matlab::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
......
......@@ -25,7 +25,7 @@ class rational_fitter_matlab : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......
......@@ -32,7 +32,7 @@ rational_fitter_parallel::~rational_fitter_parallel()
{
}
bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_parallel::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
if(r == NULL)
......@@ -41,13 +41,13 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar
return false ;
}
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
if(d == NULL)
ptr<vertical_segment> d = dynamic_pointer_cast<vertical_segment>(dat) ;
if(!d)
{
std::cerr << "<<WARNING>> automatic convertion of the data object to vertical_segment," << std::endl;
std::cerr << "<<WARNING>> we advise you to perform convertion with a separate command." << std::endl;
vertical_segment* vs = new vertical_segment();
ptr<vertical_segment> vs(new vertical_segment());
for(int i=0; i<dat->size(); ++i)
{
const vec x = dat->get(i);
......@@ -115,7 +115,7 @@ bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const ar
// Allocate a rational function and set it to the correct size, dimensions
// and parametrizations.
rational_function* rk = NULL;
rational_function* rk = NULL;
#pragma omp critical (args)
{
rk = dynamic_cast<rational_function*>(plugins_manager::get_function(args));
......@@ -201,7 +201,7 @@ void rational_fitter_parallel::set_parameters(const arguments&)
}
bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int nq,
bool rational_fitter_parallel::fit_data(const ptr<vertical_segment>& d, int np, int nq,
rational_function* r, const arguments &args,
double& delta, double& linf_dist, double& l2_dist)
{
......@@ -220,8 +220,8 @@ bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int n
rf->update(p, q);
}
linf_dist = r->Linf_distance(d);
l2_dist = r->L2_distance(d);
linf_dist = r->Linf_distance(dynamic_pointer_cast<data>(d));
l2_dist = r->L2_distance(dynamic_pointer_cast<data>(d));
return true ;
}
......@@ -230,7 +230,7 @@ bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int n
// np and nq are the degree of the RP to fit to the data
// y is the dimension to fit on the y-data (e.g. R, G or B for RGB signals)
// the function returns a rational BRDF function and a boolean
bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int nq, int ny,
bool rational_fitter_parallel::fit_data(const ptr<vertical_segment>& d, int np, int nq, int ny,
rational_function_1d* r, const arguments& args,
vec& p, vec& q, double& delta)
{
......@@ -295,7 +295,7 @@ bool rational_fitter_parallel::fit_data(const vertical_segment* d, int np, int n
}
void rational_fitter_parallel::get_constraint(int i, int np, int nq, int ny,
const vertical_segment* data,
const ptr<vertical_segment>& data,
const rational_function_1d* func,
vec& cu, vec& cl)
{
......
......@@ -48,7 +48,7 @@ class rational_fitter_parallel : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......@@ -58,10 +58,10 @@ class rational_fitter_parallel : public fitter
// Fitting a data object using np elements in the numerator and nq
// elements in the denominator
virtual bool fit_data(const vertical_segment* d, int np, int nq,
virtual bool fit_data(const ptr<vertical_segment>& d, int np, int nq,
rational_function* fit, const arguments &args,
double& delta, double& linf_dist,double& l2_dist) ;
virtual bool fit_data(const vertical_segment* dat, int np, int nq,
virtual bool fit_data(const ptr<vertical_segment>& dat, int np, int nq,
int ny, rational_function_1d* fit, const arguments& args,
vec& p, vec& q, double& delta) ;
......@@ -71,7 +71,7 @@ class rational_fitter_parallel : public fitter
//! corresponding to the lower constraint and the upper constraint
//! of the vertical segment.
virtual void get_constraint(int i, int np, int nq, int ny,
const vertical_segment* data,
const ptr<vertical_segment>& data,
const rational_function_1d* func,
vec& cu, vec& cl);
......
......@@ -32,7 +32,7 @@ rational_fitter_parallel::~rational_fitter_parallel()
{
}
bool rational_fitter_parallel::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_parallel::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
if(r == NULL)
......
......@@ -48,7 +48,7 @@ class rational_fitter_parallel : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......
......@@ -53,7 +53,7 @@ rational_fitter_parsec_one::~rational_fitter_parsec_one()
dague_fini(&dague);
}
bool rational_fitter_parsec_one::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_parsec_one::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
......
......@@ -29,7 +29,7 @@ class rational_fitter_parsec_one : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......
......@@ -29,11 +29,11 @@ rational_fitter_quadprog::~rational_fitter_quadprog()
{
}
bool rational_fitter_quadprog::fit_data(const data* dat, function* fit, const arguments &args)
bool rational_fitter_quadprog::fit_data(const ptr<data> dat, function* fit, const arguments &args)
{
rational_function* r = dynamic_cast<rational_function*>(fit) ;
const vertical_segment* d = dynamic_cast<const vertical_segment*>(dat) ;
if(r == NULL || d == NULL)
const ptr<vertical_segment>& d = dynamic_pointer_cast<vertical_segment>(dat) ;
if(r == NULL || !d)
{
std::cerr << "<<ERROR>> not passing the correct class to the fitter" << std::endl ;
return false ;
......@@ -102,7 +102,7 @@ void rational_fitter_quadprog::set_parameters(const arguments& args)
}
bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int nq, rational_function* r)
bool rational_fitter_quadprog::fit_data(const ptr<vertical_segment>& d, int np, int nq, rational_function* r)
{
// For each output dimension (color channel for BRDFs) perform
// a separate fit on the y-1D rational function.
......@@ -124,7 +124,7 @@ bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int n
// np and nq are the degree of the RP to fit to the data
// y is the dimension to fit on the y-data (e.g. R, G or B for RGB signals)
// the function return a ration BRDF function and a boolean
bool rational_fitter_quadprog::fit_data(const vertical_segment* d, int np, int nq, int ny, rational_function_1d* r)
bool rational_fitter_quadprog::fit_data(const ptr<vertical_segment>& d, int np, int nq, int ny, rational_function_1d* r)
{
// Size of the problem
const int N = np+nq ;
......
......@@ -25,7 +25,7 @@ class rational_fitter_quadprog : public fitter
// Fitting a data object
//
virtual bool fit_data(const data* d, function* fit, const arguments& args) ;
virtual bool fit_data(const ptr<data> d, function* fit, const arguments& args) ;
// Provide user parameters to the fitter
//
......@@ -37,8 +37,8 @@ class rational_fitter_quadprog : public fitter
// Fitting a data object using np elements in the numerator and nq
// elements in the denominator
virtual bool fit_data(const vertical_segment* d, int np, int nq, rational_function* fit) ;
virtual bool fit_data(const vertical_segment* dat, int np, int nq, int ny, rational_function_1d* fit) ;
virtual bool fit_data(const ptr<vertical_segment>& d, int np, int nq, rational_function* fit) ;
virtual bool fit_data(const ptr<vertical_segment>& dat, int np, int nq, int ny, rational_function_1d* fit) ;
// min and Max usable np and nq values for the fitting
int _max_np, _max_nq ;
......
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