Commit e9791b19 authored by Laurent Belcour's avatar Laurent Belcour

Debugging the brdf2data and brdf2gnuplot programs

parent 3bd27e30
......@@ -58,8 +58,7 @@ int main(int argc, char** argv)
}
// Get the associated data object and load the file is any
ptr<data> d = NULL ;
d = plugins_manager::get_data(args["data"]) ;
ptr<data> d = plugins_manager::get_data(args["data"]) ;
if(args.is_defined("data-file"))
{
d->load(args["data-file"]);
......@@ -67,14 +66,9 @@ int main(int argc, char** argv)
// Get the output object. In the case where it is not a VS file, we use
// the load object.
ptr<data> d_out = NULL;
if(!dynamic_pointer_cast<vertical_segment>(d))
ptr<data> d_out = plugins_manager::get_data(args["data"]);
if(dynamic_pointer_cast<vertical_segment>(d))
{
d_out = d;
}
else
{
d_out = ptr<data>(new vertical_segment());
d_out->setDimX(d->dimX());
d_out->setDimY(d->dimY());
d_out->setParametrization(d->input_parametrization());
......
......@@ -67,13 +67,19 @@ int main(int argc, char** argv)
// Load a data file
ptr<data> d = NULL ;
if(args.is_defined("data") || args.is_defined("in-data"))
{
d = plugins_manager::get_data(args["data"]);
if(dynamic_pointer_cast<vertical_segment>(d))
ptr<data> d = plugins_manager::get_data(args["data"]);
// Load data file if the plugin manager created a plugin object.
if(d)
{
d->load(args["data-file"]);
}
else
{
d->load(args["in-data"]);
std::cerr << "<<ERROR>> unable to load the data plugin" << std::endl;
return 1;
}
// Print the distance to the data to check if it correspond to the value
......@@ -97,67 +103,60 @@ int main(int argc, char** argv)
linear_plot = true;
}
if(d)
{
for(int i=0; i<d->size(); ++i)
for(int i=0; i<d->size(); ++i)
{
vec v = d->get(i) ;
vec x(f->dimX());
// Convert the data to the function's input space.
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
vec v = d->get(i) ;
vec x(f->dimX());
// Convert the data to the function's input space.
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&x[0], &v[0], f->dimX()*sizeof(double));
}
else
{
params::convert(&v[0], d->input_parametrization(), f->input_parametrization(), &x[0]);
}
// Evaluate the function. I can add the cosine term to the BRDF
// value.
double costerm = 1.0;
if(cos_plot)
{
double cart[6];
params::convert(&x[0], f->input_parametrization(), params::CARTESIAN, cart);
costerm = cart[5]*cart[2];
}
vec y2 = costerm * f->value(x) ;
memcpy(&x[0], &v[0], f->dimX()*sizeof(double));
}
else
{
params::convert(&v[0], d->input_parametrization(), f->input_parametrization(), &x[0]);
}
// Evaluate the function. I can add the cosine term to the BRDF
// value.
double costerm = 1.0;
if(cos_plot)
{
double cart[6];
params::convert(&x[0], f->input_parametrization(), params::CARTESIAN, cart);
costerm = cart[5]*cart[2];
}
vec y2 = costerm * f->value(x) ;
if(!linear_plot)
if(!linear_plot)
{
for(int u=0; u<d->dimX(); ++u)
file << v[u] << "\t" ;
}
else
{
file << i << "\t" ;
}
for(int u=0; u<d->dimY(); ++u)
{
if(plot_error)
{
for(int u=0; u<d->dimX(); ++u)
file << v[u] << "\t" ;
file << (v[d->dimX() + u] - y2[u]) << "\t" ;
}
else
else if(linear_plot)
{
file << i << "\t" ;
file << (v[d->dimX() + u] - y2[u])/v[d->dimX()+u] << "\t" ;
}
for(int u=0; u<d->dimY(); ++u)
else
{
if(plot_error)
{
file << (v[d->dimX() + u] - y2[u]) << "\t" ;
}
else if(linear_plot)
{
file << (v[d->dimX() + u] - y2[u])/v[d->dimX()+u] << "\t" ;
}
else
{
file << y2[u] << "\t" ;
}
file << y2[u] << "\t" ;
}
file << std::endl ;
}
}
else
{
std::cerr << "<<ERROR>> data argument is incorrectly defined" << std::endl ;
file << std::endl ;
}
}
else if(args.is_defined("polar-plot"))
......
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