Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit bccc682f authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Adding the loading of ALTA file from the plugin manager

parent 0791b93a
...@@ -81,7 +81,7 @@ ALTA library assumes that all functions are exported using the following convent ...@@ -81,7 +81,7 @@ ALTA library assumes that all functions are exported using the following convent
Example of a .function file for a single Lafortune lobe without any diffuse: Example of a .function file for a single Lafortune lobe without any diffuse:
\verbatim \verbatim
#ALTA_HEADER_START #ALTA_HEADER_DATA
#CMD lafortune --nb_lobes 1 --isotrope #CMD lafortune --nb_lobes 1 --isotrope
#DIM 2 1 #DIM 2 1
#PARAM_IN ROMEIRO_TH_TD #PARAM_IN ROMEIRO_TH_TD
...@@ -98,7 +98,7 @@ For multiple BRDFs lobes (when you want to add a diffuse for example), you need ...@@ -98,7 +98,7 @@ For multiple BRDFs lobes (when you want to add a diffuse for example), you need
specify it into the command line. The different parameters are outputed sequentially specify it into the command line. The different parameters are outputed sequentially
into the file: into the file:
\verbatim \verbatim
#ALTA_HEADER_START #ALTA_HEADER_FUNC
#CMD [diffuse, lafortune --nb_lobes 1 --isotrope, phong --fresnel schlick] #CMD [diffuse, lafortune --nb_lobes 1 --isotrope, phong --fresnel schlick]
#DIM 2 3 #DIM 2 3
#PARAM_IN ROMEIRO_TH_TD #PARAM_IN ROMEIRO_TH_TD
......
...@@ -194,6 +194,64 @@ fitter* plugins_manager::get_fitter() ...@@ -194,6 +194,64 @@ fitter* plugins_manager::get_fitter()
#endif #endif
} }
//! \brief load a function from the ALTA input file.
function* plugins_manager::get_function(const std::string& filename)
{
std::ifstream file;
file.open(filename.c_str()) ;
if(!file.is_open())
{
std::cerr << "<<ERROR>> unable to open file \"" << filename << "\"" << std::endl ;
throw ;
}
// Parameters of the function object
int nX, nY;
arguments args;
// Test for the first line of the file. Should be a ALTA FUNC HEADER
std::string line ;
std::getline(file, line) ;
if(line != "#ALTA FUNC HEADER")
{
std::cerr << "<<ERROR>> this is not a function file" << std::endl;
}
// Parse the header for the function command line and the dimension
// of the function
while(line != "#ALTA HEADER END")
{
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("CMD"))
{
args = arguments::create_arguments(line.substr(4, std::string::npos));
}
}
// Create the function from the command line
function* f = get_function(args);
f->setDimX(nX);
f->setDimY(nY);
// Load the function part from the file object
//f->load(file);
return f;
}
//! Get an instance of the function selected based on the name <em>n</em>. //! Get an instance of the function selected based on the name <em>n</em>.
//! Return NULL if no one exist. //! Return NULL if no one exist.
function* plugins_manager::get_function(const arguments& args) function* plugins_manager::get_function(const arguments& args)
...@@ -219,18 +277,30 @@ function* plugins_manager::get_function(const arguments& args) ...@@ -219,18 +277,30 @@ function* plugins_manager::get_function(const arguments& args)
return NULL; return NULL;
} }
//! \todo create a <em>compound</em> class to store multiple //! create a <em>compound</em> class to store multiple
//! functions in it. //! functions in it.
compound_function* compound = new compound_function();
//! For each args_vec element, create a function object and add //! For each args_vec element, create a function object and add
//! it to the compound one. //! it to the compound one.
for(int i=0; i<args_vec.size(); ++i)
std::string n("--func "); {
n.append(args_vec[0]); std::string n("--func ");
func = get_function(arguments::create_arguments(n)); n.append(args_vec[i]);
//! return the compound class function* f = get_function(arguments::create_arguments(n));
if(dynamic_cast<nonlinear_function*>(f) == NULL)
{
std::cerr << "<<ERROR>> only non-linear function care compatible with a compound" << std::endl;
}
else
{
compound->push_back(dynamic_cast<nonlinear_function*>(f));
}
}
//! return the compound class
func = compound;
} }
else else
{ {
......
...@@ -46,7 +46,13 @@ class plugins_manager ...@@ -46,7 +46,13 @@ class plugins_manager
#ifdef USING_STATIC #ifdef USING_STATIC
static static
#endif #endif
function* get_function(const arguments& args) ; function* get_function(const arguments& args) ;
//! \brief load a function from the ALTA input file.
#ifdef USING_STATIC
static
#endif
function* get_function(const std::string& filename);
//! \brief get an instance of the data that is defined in the plugin with //! \brief get an instance of the data that is defined in the plugin with
//! filename n. Return null if no one exist. //! filename n. Return null if no one exist.
......
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