Attention une mise à jour du serveur va être effectuée le vendredi 16 avril entre 12h et 12h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 9be5ff93 authored by Laurent Belcour's avatar Laurent Belcour

Got a working MERL data exporter and updated the data2diff to export

a new data object instead of gnuplot
parent 5caa362f
......@@ -25,7 +25,7 @@ class data
virtual void load(const std::string& filename, const arguments& args) = 0 ;
// Save the data to a file
virtual void save(const std::string& filename)
virtual void save(const std::string& filename) const
{
std::ofstream file(filename.c_str(), std::ios_base::trunc);
file << "#DIM " << _nX << " " << _nY << std::endl;
......
......@@ -34,6 +34,13 @@
#ifdef WIN32
#define M_PI 3.1415926535897932384626433832795
#endif
data_merl::data_merl()
{
const int n = BRDF_SAMPLING_RES_PHI_D/2 * BRDF_SAMPLING_RES_THETA_D * BRDF_SAMPLING_RES_THETA_H;
brdf = (double*) malloc (sizeof(double)*3*n);
}
// cross product of two vectors
void cross_product (double* v1, double* v2, double* out)
{
......@@ -232,7 +239,6 @@ bool read_brdf(const char *filename, double* &brdf)
return false;
}
brdf = (double*) malloc (sizeof(double)*3*n);
fread(brdf, sizeof(double), 3*n, f);
fclose(f);
......@@ -258,6 +264,23 @@ void data_merl::load(const std::string& filename, const arguments& args)
}
}
void data_merl::save(const std::string& filename) const
{
FILE *f = fopen(filename.c_str(), "wb");
int dims[3];
dims[0] = BRDF_SAMPLING_RES_PHI_D/2;
dims[1] = BRDF_SAMPLING_RES_THETA_D;
dims[2] = BRDF_SAMPLING_RES_THETA_H;
const int n = dims[0]*dims[1]*dims[2];
fwrite(dims, sizeof(int), 3, f);
fwrite(brdf, sizeof(double), 3*n, f);
fclose(f);
}
// Acces to data
vec data_merl::get(int i) const
{
......
......@@ -13,9 +13,13 @@ class data_merl : public QObject, public data
public: // methods
data_merl();
// Load data from a file
virtual void load(const std::string& filename) ;
virtual void load(const std::string& filename, const arguments& args) ;
virtual void save(const std::string& filename) const ;
// Acces to data
virtual vec get(int i) const ;
......
......@@ -10,7 +10,7 @@ SUBDIRS = \
rational_function_chebychev \
# rational_fitter_matlab \
# rational_fitter_dca \
nonlinear_levenberg_eigen \
# nonlinear_levenberg_eigen \
nonlinear_function_phong \
nonlinear_function_lafortune \
data_merl \
......
......@@ -66,6 +66,9 @@ int main(int argc, char** argv)
dim = p_idx;
}
// Get the output data object
data* out_d = manager.get_data(args["data"]);
if(d != NULL)
{
float dt = 0.01;
......@@ -74,7 +77,7 @@ int main(int argc, char** argv)
{
// Copy the input vector
vec x = d->get(i);
vec dx = x;
vec out_x = x;
// Convert input to required param
params::convert(&x[0], d->parametrization(), p_in, &tempParam[0]);
......@@ -93,7 +96,14 @@ int main(int argc, char** argv)
V[0] = tempCart[3]; V[1] = tempCart[4]; V[2] = tempCart[5];
vec y2 = d->value(L, V);
// Compute the diff vector
for(int j=0; j<d->dimY(); ++j)
out_x[d->dimX() + j] = (y1[j]-y2[j])/(2.0*dt);
// Store it into the output data object
out_d->set(out_x);
/*
// Print the input vector
for(int j=0; j<d->dimX(); ++j)
file << x[j] << "\t";
......@@ -103,8 +113,11 @@ int main(int argc, char** argv)
file << (y1[j]-y2[j])/(2.0*dt) << "\t";
file << std::endl;
*/
}
out_d->save(args["output"]);
file.close();
}
else
......
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