Commit 7b2f7264 authored by Laurent Belcour's avatar Laurent Belcour

Working MERL reader, need a selective exporter

parent 0748f951
......@@ -18,8 +18,8 @@ class data
// Acces to data
// virtual bool get(int i, double& x, double& y, double& t) const = 0 ;
virtual const vec& get(int i) const = 0 ;
virtual const vec& operator[](int i) const = 0 ;
virtual vec get(int i) const = 0 ;
virtual vec operator[](int i) const = 0 ;
// Get data size, e.g. the number of samples to fit
virtual int size() const = 0 ;
......
......@@ -96,10 +96,12 @@ data* plugins_manager::get_data() const
{
if(_datas.empty())
{
std::cout << "<<DEBUG>> using vertical segment data loader" << std::endl ;
return new vertical_segment() ;
}
else
{
std::cout << "<<DEBUG>> using \"" << _datas.begin()->first << "\" data loader" << std::endl ;
return _datas.begin()->second ;
}
}
......@@ -134,10 +136,12 @@ data* plugins_manager::get_data(const std::string& n) const
{
if(_datas.count(n) == 0)
{
std::cout << "<<DEBUG>> using vertical segment data loader" << std::endl ;
return new vertical_segment() ;
}
else
{
std::cout << "<<DEBUG>> using \"" << n << "\" data loader" << std::endl ;
return _datas.at(n) ;
}
}
......
......@@ -25,7 +25,7 @@ class rational_function : public QObject, public function
// Overload the function operator
virtual vec value(const vec& x) const ;
virtual vec operator()(const vec& x) const { return value(x) ; }
virtual vec operator()(const vec& x) const { return value(x) ; }
// Get the p_i and q_j function
virtual double p(const vec& x, int i) const ;
......
......@@ -165,11 +165,11 @@ void vertical_segment::get(int i, vec& yl, vec& yu) const
}
}
const vec& vertical_segment::operator[](int i) const
vec vertical_segment::operator[](int i) const
{
return _data[i] ;
}
const vec& vertical_segment::get(int i) const
vec vertical_segment::get(int i) const
{
return _data[i] ;
}
......
......@@ -20,9 +20,9 @@ class vertical_segment : public data
// Acces to data
virtual bool get(int i, double& x, double& yl, double& yu) const ;
virtual const vec& get(int i) const ;
virtual vec get(int i) const ;
virtual void get(int i, vec& yl, vec& yu) const ;
virtual const vec& operator[](int i) const ;
virtual vec operator[](int i) const ;
// Get data size
virtual int size() const ;
......
......@@ -259,13 +259,14 @@ void data_merl::load(const std::string& filename, const arguments& args)
}
// Acces to data
const vec& data_merl::get(int i) const
vec data_merl::get(int i) const
{
int phid_ind = i % BRDF_SAMPLING_RES_PHI_D*BRDF_SAMPLING_RES_THETA_D / 2;
int phid_ind = i % (BRDF_SAMPLING_RES_PHI_D / 2);
int thed_ind = (i / (BRDF_SAMPLING_RES_PHI_D / 2)) % BRDF_SAMPLING_RES_THETA_D ;
int theh_ind = (i / (BRDF_SAMPLING_RES_PHI_D / 2 * BRDF_SAMPLING_RES_THETA_D))
% BRDF_SAMPLING_RES_THETA_H ;
vec res(6) ;
res[0] = phid_ind * M_PI / (BRDF_SAMPLING_RES_PHI_D / 2);
res[1] = thed_ind * 0.5 * M_PI / (BRDF_SAMPLING_RES_THETA_D);
......@@ -273,8 +274,9 @@ const vec& data_merl::get(int i) const
res[3] = brdf[i] * RED_SCALE;
res[4] = brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D/2] * GREEN_SCALE;
res[5] = brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D] * BLUE_SCALE;
return res ;
}
const vec& data_merl::operator[](int i) const
vec data_merl::operator[](int i) const
{
return get(i) ;
}
......
......@@ -18,8 +18,8 @@ class data_merl : public QObject, public data
virtual void load(const std::string& filename, const arguments& args) ;
// Acces to data
virtual const vec& get(int i) const ;
virtual const vec& operator[](int i) const ;
virtual vec get(int i) const ;
virtual vec operator[](int i) const ;
// Get data size, e.g. the number of samples to fit
virtual int size() const ;
......
......@@ -35,19 +35,8 @@ int main(int argc, char** argv)
return 1 ;
}
function* f = NULL;
if(args.is_defined("func"))
{
std::cout << "<<INFO>> Using plugin function \"" << args["func"] << "\"" << std::endl ;
f = manager.get_function(args["func"]) ;
}
else
{
f = manager.get_function() ;
}
data* d = NULL ;
d = manager.get_data() ;
d = manager.get_data(args["loader"]) ;
d->load(args["input"]);
// Create output file
......@@ -55,6 +44,7 @@ int main(int argc, char** argv)
if(d != NULL)
{
std::cout << "<<INFO>> will export " << d->size() << " elements" << std::endl ;
for(int i=0; i<d->size(); ++i)
{
vec v = d->get(i) ;
......
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