Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

Commit 5b3c85b0 authored by Laurent Belcour's avatar Laurent Belcour

Forgot to commit changes last week.

parent a67873eb
......@@ -6,6 +6,21 @@
<h2>Input file format</h2>
For a text data file with <em>n</em> data entries where the input domain has <em>N</em> dimensions and a <em>input_param</em> parametrization and the output domain has <em>P</em> dimensions and a <em>output_param</em> parametrization, our file format is the following:
\verbatim
#DIM N P
#PARAM_IN %input_param%
#PARAM_OUT %output_param%
#VS [0|1|2] (P times)
x_{1,1} ... x_{1,N} y_{1,1} ... y_{1,P}
...
x_{i,1} ... x_{i,N} y_{i,1} ... y_{i,P}
...
x_{n,1} ... x_{n,N} y_{n,1} ... y_{n,P}
\endverbatim
Vertical segments are not defined if VS is 0. For a VS of 1, each sample as a radius associated for the associated dimension. If VS is 2, each sample has a min and max segment value for the associated dimension.
<h3> Parametrization format </h3>
......
......@@ -22,7 +22,15 @@ double function::L2_distance(const data* d) const
l2 += dist*dist;
}
return sqrt(l2)/(double)nb_points;
double factor = 1.0/(double)nb_points;
vec _min = d->min();
vec _max = d->max();
for(int i=0; i<d->dimX(); ++i)
{
factor *= _max[i]-_min[i];
}
return sqrt(l2)*factor;
}
//! \brief Linf norm to data.
......@@ -46,4 +54,4 @@ double function::Linf_distance(const data* d) const
}
return linf;
}
\ No newline at end of file
}
......@@ -42,7 +42,7 @@ class function
//! \details
//! Can be used to set the diffuse component of the function for
//! example.
virtual void boostrap(const data* d, const arguments& args) {}
virtual void bootstrap(const data* d, const arguments& args) {}
//! \brief Save the current function to a specific file type, args can
//! be used to differenciate the type of export.
......
......@@ -211,6 +211,7 @@ params::input params::parse_input(const std::string& txt)
}
}
std::cout << "<<ERROR>> the input parametrization in unknown" << std::endl;
return params::UNKNOWN_INPUT;
}
......
......@@ -9,6 +9,8 @@
#include <cmath>
#include <cassert>
#define RELATIVE_ERROR
void vertical_segment::load(const std::string& filename)
{
arguments args ;
......@@ -138,7 +140,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
#endif
}
}
// If data is not in the interval of fit
bool is_in = true ;
for(int i=0; i<dimX(); ++i)
......
#include "function.h"
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <limits>
......@@ -109,13 +110,6 @@ vec lafortune_function::value(const vec& x, const vec& p) const
return res;
}
//! Load function specific files
void lafortune_function::load(const std::string& filename)
{
std::cerr << "Not implemented " << __FILE__ << ":" << __LINE__ << std::endl;
throw;
}
// Set the number of lobes of the Lafortune BRDF
void lafortune_function::setNbLobes(int N)
{
......@@ -273,7 +267,7 @@ vec lafortune_function::parametersJacobian(const vec& x) const
return jac;
}
void lafortune_function::boostrap(const data* d, const arguments& args)
void lafortune_function::bootstrap(const data* d, const arguments& args)
{
// Check the arguments for the number of lobes
this->setNbLobes(args.get_int("lobes", 1));
......@@ -336,28 +330,77 @@ std::ofstream& type_affectation(std::ofstream& out, const std::string& name, con
}
//! Load function specific files
void lafortune_function::load(const std::string& filename)
{
std::ifstream file(filename.c_str()) ;
if(!file.is_open())
{
std::cerr << "<<ERROR>> unable to open file \"" << filename << "\"" << std::endl ;
throw ;
}
_nX = 0 ; _nY = 0 ;
_n = 0;
double x, y, dy ;
while(file.peek() == '#')
{
std::string line ;
std::getline(file, line) ;
std::stringstream linestream(line) ;
linestream.ignore(1) ;
std::string comment ;
linestream >> comment ;
if(comment == std::string("DIM"))
{
linestream >> _nX >> _nY ;
}
else if(comment == std::string("NB_LOBES"))
{
linestream >> _n ;
}
}
setNbLobes(_n);
for(int n=0; n<_n; ++n)
{
std::cout << (char)file.peek() << std::endl;
for(int i=0; i<_nY; ++i)
{
file >> _C[(n*_nY + i)*3 + 0] >> _C[(n*_nY + i)*3 + 1] >> _C[(n*_nY + i)*3 + 2];
}
}
}
void lafortune_function::save(const std::string& filename) const
{
std::ofstream file(filename.c_str(), std::ios_base::trunc);
file << "#DIM " << _nX << " " << _nY << std::endl ;
std::ofstream file(filename.c_str(), std::ios_base::trunc);
file << "#DIM " << _nX << " " << _nY << std::endl ;
file << "#NB_LOBES " << _n << std::endl ;
for(int n=0; n<_n; ++n)
{
file << "#Lobe number " << n << std::endl;
file << "#Cx Cy Cz" << std::endl;
for(int i=0; i<_nY; ++i)
{
file << _C[(n*_nY + i)*3 + 0] << _C[(n*_nY + i)*3 + 2] << _C[(n*_nY + i)*3 + 1] << std::endl;
}
file << std::endl;
file << "#N" << std::endl;
for(int i=0; i<_nY; ++i)
{
file << _N[i] << std::endl;
}
file << std::endl;
}
for(int n=0; n<_n; ++n)
{
file << "#Lobe number " << n << std::endl;
file << "#Cx Cy Cz" << std::endl;
for(int i=0; i<_nY; ++i)
{
file << _C[(n*_nY + i)*3 + 0] << " " << _C[(n*_nY + i)*3 + 2] << " " << _C[(n*_nY + i)*3 + 1] << std::endl;
}
file << std::endl;
file << "#N" << std::endl;
for(int i=0; i<_nY; ++i)
{
file << _N[i] << std::endl;
}
file << std::endl;
}
}
......@@ -389,6 +432,20 @@ void lafortune_function::save_brdfexplorer(const std::string& filename,
file << "{" << std::endl;
if(_nY == 1)
{
file << " ";
type_definition(file, _nY) << " D = kd;" << std::endl << std::endl;
for(int n=0; n<_n; ++n)
{
file << " // Lobe number " << n+1 << std::endl;
file << " n = " << _N[n] << "; " << std::endl;
file << " Cx = " << _C[0*_n + n] << "; " << std::endl;
file << " Cy = " << _C[1*_n + n] << "; " << std::endl;
file << " Cz = " << _C[2*_n + n] << "; " << std::endl;
file << " D += pow(max(Cx * L.x * V.x + Cy * L.y * V.y + Cz * L.z * V.z, ";
type_definition(file, _nY) << "(0.0)), n);" << std::endl;
file << std::endl;
}
}
else
{
......
......@@ -13,7 +13,7 @@
#include <core/args.h>
#include <core/common.h>
#define ADAPT_TO_PARAM
//#define ADAPT_TO_PARAM
//#define FIT_DIFFUSE
/*! \brief A lafortune lobe class. It is provided for testing with the nonlinear
......@@ -43,7 +43,7 @@ class lafortune_function : public nonlinear_function, public QObject
virtual void load(const std::string& filename) ;
//! \brief Boostrap the function by defining the diffuse term
virtual void boostrap(const data* d, const arguments& args);
virtual void bootstrap(const data* d, const arguments& args);
//! \brief Number of parameters to this non-linear function
virtual int nbParameters() const ;
......
......@@ -137,7 +137,7 @@ vec phong_function::parametersJacobian(const vec& x) const
}
void phong_function::boostrap(const data* d, const arguments& args)
void phong_function::bootstrap(const data* d, const arguments& args)
{
vec x0 = d->get(0);
......
......@@ -51,7 +51,7 @@ class phong_function : public nonlinear_function, public QObject
//! \brief Boostrap the function by defining the diffuse term
virtual void boostrap(const data* d, const arguments& args);
virtual void bootstrap(const data* d, const arguments& args);
//! \brief Load function specific files
virtual void load(const std::string& filename) ;
......
......@@ -125,14 +125,14 @@ bool nonlinear_fitter_eigen::fit_data(const data* d, function* fit, const argume
fit->setMin(d->min()) ;
fit->setMax(d->max()) ;
// Convert the function and boostrap it with the data
// Convert the function and bootstrap it with the data
if(dynamic_cast<nonlinear_function*>(fit) == NULL)
{
std::cerr << "<<ERROR>> the function is not a non-linear function" << std::endl;
return false;
}
nonlinear_function* nf = dynamic_cast<nonlinear_function*>(fit);
nf->boostrap(d, args);
nf->bootstrap(d, args);
#ifndef DEBUG
std::cout << "<<DEBUG>> number of parameters: " << nf->nbParameters() << std::endl;
......
......@@ -24,6 +24,11 @@ function* rational_fitter_matlab::provide_function() const
return new rational_function() ;
}
ALTA_DLL_EXPORT fitter* provide_fitter()
{
return new rational_fitter_matlab();
}
rational_fitter_matlab::rational_fitter_matlab() : QObject()
{
}
......
......@@ -21,6 +21,7 @@ int main(int argc, char** argv)
if(k == 1)
{
f << "#DIM 1 1" << std::endl ;
f << "#PARAM_IN COS_TH" << std::endl;
for(int i=0; i<nbx; ++i)
{
const float x = i / (float)nbx ;
......@@ -32,6 +33,7 @@ int main(int argc, char** argv)
else if(k == 2)
{
f << "#DIM 1 1" << std::endl ;
f << "#PARAM_IN COS_TH" << std::endl;
for(int i=0; i<nbx; ++i)
{
const float x = i / (float)nbx ;
......
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