Commit 4b89bdbf by Laurent Belcour

### Adding test suite for Lafortune

parent 7bef7190
 ... ... @@ -82,7 +82,7 @@ void params::to_cartesian(const double* invec, params::input intype, break; case params::RUSIN_TH_TD: half_to_cartesian(invec[0], 0.0, invec[1], 0.5*M_PI, outvec); half_to_cartesian(invec[0], 0.0, invec[1], 0.0, outvec); break; // 3D Parametrization ... ...
 ... ... @@ -167,8 +167,8 @@ class params //! \todo investigate here, the rotation along N should be //1 of phi_h not theta_h ! rotate_normal(out, phi_h); rotate_binormal(out, theta_h); rotate_normal(out, phi_h); // Compute the out vector from the in vector and the half // vector. ... ... @@ -211,8 +211,8 @@ class params const double cost = cos(theta); const double sint = sin(theta); vec[0] = cost * vec[0] - sint * vec[2]; vec[2] = sint * vec[0] + cost * vec[2]; vec[1] = cost * vec[1] - sint * vec[2]; vec[2] = sint * vec[1] + cost * vec[2]; } static void print_input_params(); ... ...
 ... ... @@ -55,8 +55,6 @@ vec lafortune_function::value(const vec& x) const const double d = Cx*dx + Cy*dy + Cz*dz; if(d > 0.0) res[i] += pow(d, N); else res[i] += 0.0; } } ... ... @@ -102,8 +100,6 @@ vec lafortune_function::value(const vec& x, const vec& p) const const double d = Cx*dx + Cy*dy + Cz*dz; if(d > 0.0) res[i] += pow(d, N); else res[i] += 0.0; } } ... ...
 #! /bin/sh ## Params function="--func ./build/libnonlinear_function_lafortune.so" fitter="--fitter ./build/libnonlinear_levenberg_eigen.so" test_generated=1 test_alta=0 mkdir tests ## Test with generated data ## if [ \$test_generated -eq 1 ]; then min_test=7; max_test=8 for i in `seq \$min_test \$max_test` do ./build/generate_data --f \$i mv input.gnuplot tests/input_\$i.gnuplot ./build/data2brdf --input tests/input_\$i.gnuplot --output tests/output_lafortune_\$i.lafortune \${function} \${fitter} \${fitter_args} > tests/output_lafortune_\$i.out if [ \$? -eq 0 ]; then echo "Test number \$i passed" #./build/brdf2gnuplot --input tests/output_lafortune_\$i.lafortune \$function --data tests/input_\$i.gnuplot --output tests/output_lafortune_\$i.gnuplot > /dev/null else echo "Test number \$i failed" fi done fi ## Test with ALTA internal data ## if [ \$test_alta -eq 1 ]; then ./build/data2brdf --input ../data/2d/matusik_merl/beige-fabric-double-cc-cos-th-td-90deg.dat --output tests/beige.lafortune \${function} \${fitter} \${fitter_args} > tests/beige_lafortune.out if [ \$? -eq 0 ]; then echo "Test beige matusik passed" ./build/brdf2gnuplot --input tests/beige.lafortune \$function --data ../data/2d/matusik_merl/beige-fabric-double-cc-cos-th-td-90deg.dat --output tests/beige_lafortune.gnuplot > /dev/null else echo "Test beige matusik failed" fi fi
 ... ... @@ -79,29 +79,29 @@ int main(int argc, char** argv) vec v = d->get(i) ; vec y2 = f->value(v) ; if(!linear_plot) { for(int u=0; udimX(); ++u) file << v[u] << "\t" ; } else { file << i << "\t" ; } 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) { file << (v[d->dimX() + u] - y2[u])/v[d->dimX()+u] << "\t" ; } else if(linear_plot) { file << (v[d->dimX() + u] - y2[u])/v[d->dimX()+u] << "\t" ; } else { file << y2[u] << "\t" ; if(plot_error) { file << (v[d->dimX() + u] - y2[u])/v[d->dimX()+u] << "\t" ; } else if(linear_plot) { file << (v[d->dimX() + u] - y2[u])/v[d->dimX()+u] << "\t" ; } else { file << y2[u] << "\t" ; } } ... ...
 ... ... @@ -5,7 +5,7 @@ #include #include #include #include #include #include ... ... @@ -17,7 +17,7 @@ int main(int argc, char** argv) { QApplication app(argc, argv, false); QCoreApplication app(argc, argv, false); arguments args(argc, argv) ; plugins_manager manager(args) ; ... ...
 ... ... @@ -10,7 +10,7 @@ int main(int argc, char** argv) std::ofstream f("input.gnuplot") ; arguments args(argc, argv); std::cout.precision(10); std::cout.precision(10); int nbx = 100; int nby = 100; ... ... @@ -24,30 +24,30 @@ int main(int argc, char** argv) if(k == 1) { f << "#DIM 1 1" << std::endl ; f << "#PARAM_IN UNKNOWN" << std::endl; //f << "#VS 2" << std::endl; f << "#PARAM_IN UNKNOWN" << std::endl; //f << "#VS 2" << std::endl; for(int i=0; i 0.0) { const double z = std::pow(cos, n) ; f << in_r[0] << "\t" << in_r[1] << "\t" << z << std::endl ; } else { f << in_r[0] << "\t" << in_r[1] << "\t" << 0.0 << std::endl ; } } } } // Lafortune fitting // Triple lobe (0.86, 0.77, 18.6), (-0.41, 0.018, 2.58), (-1.03, 0.7, 63.8) else if(k == 8) { f << "#DIM 2 1" << std::endl ; f << "#PARAM_IN RUSIN_TH_TD" << std::endl; for(int i=0; i<=90; ++i) { for(int j=0; j<=90; ++j) { double in_r[2], in_c[6]; in_r[0] = M_PI * 0.5 * i / (double)90 ; in_r[1] = M_PI * 0.5 * j / (double)90 ; params::convert(in_r, params::RUSIN_TH_TD, params::CARTESIAN, in_c); const double Cx[3] = {0.86, -0.410, -1.03}; const double Cz[3] = {0.77, 0.018, 0.70}; const double n[3] = {18.6, 2.580, 63.8}; double z = 0.0; for(int k=0; k<3; ++k) { const double cos = Cx[k] * (in_c[0]*in_c[3] + in_c[1]*in_c[4]) + Cz[k]*in_c[2]*in_c[5]; if(cos > 0.0) { z += std::pow(cos, n[k]) ; } } f << in_r[0] << "\t" << in_r[1] << "\t" << z << std::endl ; } } } // Lafortune fitting // Single lobe (0.86, 0.77, 18.6) else if(k == 7) { f << "#DIM 2 1" << std::endl ; f << "#PARAM_IN RUSIN_TH_TD" << std::endl; for(int i=0; i 0.0) { const double z = std::pow(cos, n) ; f << in_r[0] << "\t" << in_r[1] << "\t" << z << std::endl ; } } } } // Lafortune fitting // Triple lobe (0.86, 0.77, 18.6), (-0.41, 0.018, 2.58), (-1.03, 0.7, 63.8) else if(k == 8) { f << "#DIM 2 1" << std::endl ; f << "#PARAM_IN RUSIN_TH_TD" << std::endl; for(int i=0; i 0.0) { z += std::pow(cos, n[k]) ; } } f << in_r[0] << "\t" << in_r[1] << "\t" << z << std::endl ; } } } return 0 ; }
 ... ... @@ -6,4 +6,5 @@ SUBDIRS = generate_data \ data2gnuplot \ data2diff \ data2moments \ tests \ # fourieranalysis
 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define EPSILON 1.0E-10 int main(int argc, char** argv) { QCoreApplication app(argc, argv, false); arguments args(argc, argv) ; plugins_manager manager(args) ; int nb_tests_failed = 0; // Parametrization tests // // Evaluation tests // std::cout << "<> " << nb_tests_failed << " tests failed" << std::endl; return nb_tests_failed; }
 CONFIG += qt \ console DESTDIR = ../../build INCLUDEPATH += ../../ ../../libs/rational_1d \ SOURCES += main.cpp LIBS += -L../../build -lcore unix{ PRE_TARGETDEPS += ../../build/libcore.a }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!