From e9791b1952eaf75bfd79def66785434e6963a7d3 Mon Sep 17 00:00:00 2001 From: Laurent Belcour Date: Fri, 6 Jun 2014 10:58:13 -0400 Subject: [PATCH] Debugging the brdf2data and brdf2gnuplot programs --- sources/softs/brdf2data/main.cpp | 12 +-- sources/softs/brdf2gnuplot/main.cpp | 109 ++++++++++++++-------------- 2 files changed, 57 insertions(+), 64 deletions(-) diff --git a/sources/softs/brdf2data/main.cpp b/sources/softs/brdf2data/main.cpp index a2af1a8..a2d00b6 100644 --- a/sources/softs/brdf2data/main.cpp +++ b/sources/softs/brdf2data/main.cpp @@ -58,8 +58,7 @@ int main(int argc, char** argv) } // Get the associated data object and load the file is any - ptr d = NULL ; - d = plugins_manager::get_data(args["data"]) ; + ptr 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 d_out = NULL; - if(!dynamic_pointer_cast(d)) + ptr d_out = plugins_manager::get_data(args["data"]); + if(dynamic_pointer_cast(d)) { - d_out = d; - } - else - { - d_out = ptr(new vertical_segment()); d_out->setDimX(d->dimX()); d_out->setDimY(d->dimY()); d_out->setParametrization(d->input_parametrization()); diff --git a/sources/softs/brdf2gnuplot/main.cpp b/sources/softs/brdf2gnuplot/main.cpp index 08a4420..5b83f7f 100644 --- a/sources/softs/brdf2gnuplot/main.cpp +++ b/sources/softs/brdf2gnuplot/main.cpp @@ -67,13 +67,19 @@ int main(int argc, char** argv) // Load a data file - ptr d = NULL ; if(args.is_defined("data") || args.is_defined("in-data")) { - d = plugins_manager::get_data(args["data"]); - if(dynamic_pointer_cast(d)) + ptr 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 << "<> 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; isize(); ++i) + for(int i=0; isize(); ++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; udimX(); ++u) + file << v[u] << "\t" ; + } + else + { + file << i << "\t" ; + } + + for(int u=0; udimY(); ++u) + { + if(plot_error) { - for(int u=0; udimX(); ++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; udimY(); ++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 << "<> data argument is incorrectly defined" << std::endl ; + + file << std::endl ; } } else if(args.is_defined("polar-plot")) -- GitLab