Commit 4458a373 authored by Laurent Belcour's avatar Laurent Belcour

Some correction to the diffuse and to the gnuplot exporter

parent 3c8186c0
......@@ -43,7 +43,7 @@ void diffuse_function::load(std::istream &in)
// Checking for the comment line #FUNC nonlinear_function_diffuse
std::string token;
in >> token;
if(token != "FUNC") { std::cerr << "<<ERROR>> parsing the stream. The #FUNC is not the next line defined." << std::endl; }
if(token != "#FUNC") { std::cerr << "<<ERROR>> parsing the stream. The #FUNC is not the next line defined." << std::endl; }
in >> token;
if(token != "nonlinear_function_diffuse") { std::cerr << "<<ERROR>> parsing the stream. function name is not the next token." << std::endl; }
......@@ -55,12 +55,17 @@ void diffuse_function::load(std::istream &in)
}
}
void diffuse_function::save_alta(const std::string& filename, const arguments& args) const
void diffuse_function::save_call(std::ostream& out, const arguments& args) const
{
NOT_IMPLEMENTED();
out << "#FUNC nonlinear_function_diffuse" << std::endl ;
for(int i=0; i<dimY(); ++i)
{
out << "kd " << _kd[i] << std::endl;
}
out << std::endl;
}
//! Number of parameters to this non-linear function
int diffuse_function::nbParameters() const
{
......
......@@ -27,7 +27,8 @@ class diffuse_function : public nonlinear_function
virtual void bootstrap(const data* d, const arguments& args);
//! \brief Load function specific files
virtual void load(std::istream& in) ;
virtual void load(std::istream& in) ;
virtual void save_call(std::ostream& out, const arguments& args) const;
//! \brief Number of parameters to this non-linear function
virtual int nbParameters() const ;
......@@ -48,10 +49,6 @@ class diffuse_function : public nonlinear_function
_kd.resize(nY);
}
protected: // methods
virtual void save_alta(const std::string& filename, const arguments& args) const;
private: // data
vec _kd;
......
......@@ -20,22 +20,27 @@ int main(int argc, char** argv)
plugins_manager manager(args) ;
if(args.is_defined("help")) {
if(args.is_defined("help"))
{
std::cout << "<<HELP>> brdf2gnuplot --input brdf.file --output gnuplot.file --func function.lib --data data.file" << std::endl ;
std::cout << " - input, output and data are mandatory parameters" << std::endl ;
}
if(! args.is_defined("input")) {
if(! args.is_defined("input"))
{
std::cerr << "<<ERROR>> the input filename is not defined" << std::endl ;
return 1 ;
}
if(! args.is_defined("output")) {
if(! args.is_defined("output"))
{
std::cerr << "<<ERROR>> the output filename is not defined" << std::endl ;
return 1 ;
}
function* f = manager.get_function(args["input"]) ;
// Load a function file
function* f = manager.get_function(args["input"]) ;
// Load a data file
data* d = NULL ;
if(args.is_defined("data"))
{
......@@ -44,23 +49,30 @@ int main(int argc, char** argv)
d->load(args["data"]) ;
}
// If the function loaded has no parametrization (for example a diffuse
// function), the function will take the parametrization of the data
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
manager.check_compatibility(d, f, args);
}
bool plot_error = false ;
bool linear_plot = false;
bool linear_plot = false;
if(args.is_defined("error"))
{
std::cout << "<<INFO>> Exporting an error plot" << std::endl;
plot_error = true ;
}
else if(args.is_defined("linear_error"))
{
std::cout << "<<INFO>> Exporting linear error plot" << std::endl;
linear_plot = true;
}
else if(args.is_defined("linear_error"))
{
std::cout << "<<INFO>> Exporting linear error plot" << std::endl;
linear_plot = true;
}
// Create output file
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
if(d != NULL)
if(d != NULL)
{
for(int i=0; i<d->size(); ++i)
{
......
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