Commit 866ed4b4 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Removing Qt dependency for QCoreApplication in all softs

parent 32fdd498
......@@ -7,6 +7,16 @@
#include <cstring>
#include <algorithm>
#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
#else
#include <sys/times.h>
#include <sys/types.h>
#include <limits.h>
#include <unistd.h>
#endif
#ifdef OLD
/*! \brief A core implementation of a vector of double.
* \ingroup core
......
......@@ -29,13 +29,17 @@ vec ward_function::value(const vec& x) const
for(int i=0; i<dimY(); ++i)
{
const double hx_ax = h[0]/_ax[i];
const double hy_ay = h[1]/_ay[i];
const double ax = _ax[i];
const double ay = _ay[i];
const double hx_ax = h[0]/ax;
const double hy_ay = h[1]/ay;
const double exponent = (hx_ax*hx_ax + hy_ay*hy_ay) / (h[2]*h[2]);
if(x[2]*x[5] > 0.0)
{
res[i] = (_ks[i] / (4.0 * M_PI * _ax[i] * _ay[i] * sqrt(x[2]*x[5]))) * std::exp(- exponent);
res[i] = (_ks[i] / (4.0 * M_PI * ax * ay * sqrt(x[2]*x[5]))) * std::exp(- exponent);
}
else
{
......@@ -71,7 +75,7 @@ vec ward_function::parameters() const
{
res[i*3 + 0] = _ks[i];
res[i*3 + 1] = _ax[i];
res[i*3 + 2] = _ay[i];
res[i*3 + 2] = _ay[i];
}
return res;
}
......@@ -97,7 +101,7 @@ void ward_function::setParameters(const vec& p)
{
_ks[i] = p[i*3 + 0];
_ax[i] = p[i*3 + 1];
_ay[i] = p[i*3 + 2];
_ay[i] = p[i*3 + 2];
}
}
......@@ -116,19 +120,22 @@ vec ward_function::parametersJacobian(const vec& x) const
{
if(i == j && x[2]*x[5]>0.0)
{
const double hx_ax = h[0]/_ax[i];
const double hy_ay = h[1]/_ay[i];
const double ax = _ax[i];
const double ay = _ay[i];
const double hx_ax = h[0]/ax;
const double hy_ay = h[1]/ay;
const double gauss = exp(-(hx_ax*hx_ax + hy_ay*hy_ay) / (h[2]*h[2]));
const double fact = 1.0 / (4.0*M_PI*_ax[i]*_ay[i]*sqrt(x[2]*x[5]));
const double fact = 1.0 / (4.0*M_PI*ax*ay*sqrt(x[2]*x[5]));
// df / dk_s
jac[i*nbParameters() + j*3+0] = fact * gauss;
// df / da_x
jac[i*nbParameters() + j*3+1] = _ks[i] * fact * (1.0/_ax[i]) * (((2.0*h[0]*hx_ax) / h[2]) * gauss - 1);
jac[i*nbParameters() + j*3+1] = _ks[i] * fact * (1.0/ax) * (((2.0*h[0]*hx_ax) / h[2]) * gauss - 1);
// df / da_y
jac[i*nbParameters() + j*3+2] = _ks[i] * fact * (1.0/_ay[i]) * (((2.0*h[1]*hy_ay) / h[2]) * gauss - 1);
jac[i*nbParameters() + j*3+2] = _ks[i] * fact * (1.0/ay) * (((2.0*h[1]*hy_ay) / h[2]) * gauss - 1);
}
else
{
......@@ -150,6 +157,12 @@ void ward_function::bootstrap(const data* d, const arguments& args)
_ax[i] = 1.0;
_ay[i] = 1.0;
}
// Check if the fit should be done on an istropic lobe or not.
if(args.is_defined("isotropic"))
{
isotropic = true;
}
}
//! Load function specific files
......@@ -199,7 +212,7 @@ void ward_function::save_call(std::ostream& out, const arguments& args) const
{
out << "Ks " << _ks[i] << std::endl;
out << "ax " << _ax[i] << std::endl;
out << "ay " << _ay[i] << std::endl;
out << "ay " << _ay[i] << std::endl;
}
out << std::endl;
......@@ -240,11 +253,10 @@ void ward_function::save_body(std::ostream& out, const arguments& args) const
{
out << "vec3 ward(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, vec3 ks, vec3 ax, vec3 ay)" << std::endl;
out << "{" << std::endl;
out << "\tvec3 H = normalize(L + V);" << std::endl;
out << "\tvec3 hax = dot(H,X) / ax;" << std::endl;
out << "\tvec3 hay = dot(H,Y) / ay;" << std::endl;
out << "\tfloat hn = dot(H,N);" << std::endl;
out << "\tvec3 H = normalize(L + V);" << std::endl;
out << "\tvec3 hax = dot(H,X) / ax;" << std::endl;
out << "\tvec3 hay = dot(H,Y) / ay;" << std::endl;
out << "\tfloat hn = dot(H,N);" << std::endl;
out << "\treturn (ks / (4 * " << M_PI << " * ax*ay * sqrt(dot(L,N)*dot(V,N)))) * exp(-(hax*hax + hay*hay)/(hn*hn));" << std::endl;
out << "}" << std::endl;
}
......
......@@ -31,7 +31,8 @@ class ward_function : public nonlinear_function
public: // methods
ward_function()
{
{
isotropic = false;
setParametrization(params::CARTESIAN);
setDimX(6);
}
......@@ -80,5 +81,8 @@ class ward_function : public nonlinear_function
private: // data
vec _ks, _ax, _ay; // Lobes data
//! Allows to set the lobe to be isotropic or not
bool isotropic;
} ;
......@@ -2,10 +2,6 @@
#include <core/function.h>
#include <core/plugins_manager.h>
#include <QCoreApplication>
#include <QDir>
#include <QTime>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -15,7 +11,6 @@
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
arguments args(argc, argv) ;
if(! args.is_defined("input")) {
......
......@@ -5,8 +5,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QApplication>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -17,11 +15,8 @@
int main(int argc, char** argv)
{
QApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
if(args.is_defined("help")) {
std::cout << "<<HELP>> brdf2data --input brdf.file --func importer.so --output data.file --data exporter.so" << std::endl ;
std::cout << " - input, output, func, data are mandatory parameters" << std::endl ;
......@@ -48,10 +43,10 @@ int main(int argc, char** argv)
*/
// Import data
data* d = NULL ;
d = manager.get_data(args["data"]) ;
d = plugins_manager::get_data(args["data"]) ;
function* f = NULL;
f = manager.get_function(args["input"]);
f = plugins_manager::get_function(args["input"]);
// Modify function or data to provide coherent
// interfaces
......
......@@ -4,8 +4,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QCoreApplication>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -15,11 +13,8 @@
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
if(args.is_defined("help"))
{
std::cout << "<<HELP>> brdf2gnuplot --input brdf.file --output gnuplot.file --func function.lib --data data.file" << std::endl ;
......@@ -38,14 +33,14 @@ int main(int argc, char** argv)
}
// Load a function file
function* f = manager.get_function(args["input"]) ;
function* f = plugins_manager::get_function(args["input"]) ;
// Load a data file
data* d = NULL ;
if(args.is_defined("data"))
{
std::cout << "<<INFO>> Using data \"" << args["data"] << "\"" << std::endl ;
d = manager.get_data() ;
d = plugins_manager::get_data() ;
d->load(args["data"]) ;
}
......
......@@ -5,8 +5,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QApplication>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -17,11 +15,8 @@
int main(int argc, char** argv)
{
QApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
if(args.is_defined("help")) {
std::cout << "<<HELP>> data2moments --input data.file --output gnuplot.file --function loader.so" << std::endl ;
std::cout << " - input, output and data are mandatory parameters" << std::endl ;
......@@ -43,7 +38,7 @@ int main(int argc, char** argv)
// Import data
function* f = NULL ;
f = manager.get_function(args["input"]) ;
f = plugins_manager::get_function(args["input"]) ;
// Create output file
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
......
......@@ -4,10 +4,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QPluginLoader>
#include <QtPlugin>
#include <QCoreApplication>
#include <QDir>
#include <QTime>
#include <iostream>
......@@ -19,14 +15,12 @@
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
fitter* fit = manager.get_fitter(args["fitter"]) ;
fitter* fit = plugins_manager::get_fitter(args["fitter"]) ;
if(fit == NULL)
{
fit = manager.get_fitter() ;
fit = plugins_manager::get_fitter() ;
}
if(args.is_defined("available_params"))
......@@ -87,15 +81,11 @@ int main(int argc, char** argv)
std::cout << "<<INFO>> L2 distance to data = " << L2 << std::endl;
std::cout << "<<INFO>> Linf distance to data = " << Linf << std::endl;
/*
std::stringstream append; // Append informations to the export
if(args.is_defined("export-append")) {
append << args["export-append"];
}
append << "#L2 " << L2 << std::endl;
append << "#LINF " << Linf ;
args.update("export-append", append.str());
*/
// Export the L2 and Linf values to the command line
std::stringstream L2string, Linfstring;
L2string << L2; Linfstring << Linf;
args.update("L2", L2string.str());
args.update("Linf", Linfstring.str());
f->save(args["output"], args) ;
return 0;
......
......@@ -5,8 +5,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QCoreApplication>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -17,10 +15,7 @@
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
arguments args(argc, argv) ;
if(args.is_defined("help")) {
std::cout << "<<HELP>> data2diff --input data.file --output gnuplot.file --data loader.so --param RUSIN_TH_PH_TD_PD --partial 0" << std::endl ;
......@@ -49,7 +44,7 @@ int main(int argc, char** argv)
// Import data
data* d = NULL ;
d = manager.get_data(args["data"]) ;
d = plugins_manager::get_data(args["data"]) ;
d->load(args["input"]);
// Create output file
......@@ -67,7 +62,7 @@ int main(int argc, char** argv)
}
// Get the output data object
data* out_d = manager.get_data(args["data"]);
data* out_d = plugins_manager::get_data(args["data"]);
if(d != NULL)
{
......
......@@ -4,8 +4,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QApplication>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -16,11 +14,8 @@
int main(int argc, char** argv)
{
QApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
if(args.is_defined("help")) {
std::cout << "<<HELP>> data2gnuplot --input data.file --output gnuplot.file --loader loader.so" << std::endl ;
std::cout << " - input and output are mandatory parameters" << std::endl ;
......@@ -37,7 +32,7 @@ int main(int argc, char** argv)
}
data* d = NULL ;
d = manager.get_data(args["loader"]) ;
d = plugins_manager::get_data(args["loader"]) ;
d->load(args["input"]);
// Create output file
......
......@@ -5,8 +5,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QApplication>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -17,11 +15,8 @@
int main(int argc, char** argv)
{
QApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
if(args.is_defined("help")) {
std::cout << "<<HELP>> data2moments --input data.file --output gnuplot.file --data loader.so" << std::endl ;
std::cout << " - input, output and data are mandatory parameters" << std::endl ;
......@@ -43,7 +38,7 @@ int main(int argc, char** argv)
// Import data
data* d = NULL ;
d = manager.get_data(args["data"]) ;
d = plugins_manager::get_data(args["data"]) ;
d->load(args["input"]);
// Create output file
......
......@@ -4,12 +4,6 @@
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QPluginLoader>
#include <QtPlugin>
#include <QCoreApplication>
#include <QDir>
#include <QTime>
#include <iostream>
#include <vector>
#include <iostream>
......@@ -28,10 +22,6 @@ int parametrization_tests();
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv, false);
arguments args(argc, argv) ;
plugins_manager manager(args) ;
int nb_tests_failed = 0;
......
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