Commit 7f0c908a authored by Laurent Belcour's avatar Laurent Belcour

Adding a tool to convert a .function into a gnuplot file

parent 98488744
#include "plugins_manager.h"
#include "rational_function.h"
#include "vertical_segment.h"
#include <QCoreApplication>
#include <QPluginLoader>
......@@ -83,7 +85,7 @@ function* plugins_manager::get_function() const
{
if(_functions.empty())
{
return NULL ;
return new rational_function() ;
}
else
{
......@@ -94,7 +96,7 @@ data* plugins_manager::get_data() const
{
if(_datas.empty())
{
return NULL ;
return new vertical_segment() ;
}
else
{
......@@ -121,7 +123,7 @@ function* plugins_manager::get_function(const std::string& n) const
{
if(_functions.count(n) == 0)
{
return NULL ;
return new rational_function() ;
}
else
{
......@@ -132,7 +134,7 @@ data* plugins_manager::get_data(const std::string& n) const
{
if(_datas.count(n) == 0)
{
return NULL ;
return new vertical_segment() ;
}
else
{
......
CONFIG += qt
INCLUDEPATH += ../../
DESTDIR = ../../build
SOURCES += main.cpp
LIBS += -L../../build -lcore
#include <core/args.h>
#include <core/data.h>
#include <core/function.h>
#include <core/fitter.h>
#include <core/plugins_manager.h>
#include <QApplication>
#include <iostream>
#include <vector>
#include <iostream>
#include <fstream>
#include <limits>
#include <cstdlib>
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>> 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")) {
std::cerr << "<<ERROR>> the input filename is not defined" << std::endl ;
return 1 ;
}
if(! args.is_defined("output")) {
std::cerr << "<<ERROR>> the output filename is not defined" << std::endl ;
return 1 ;
}
function* f = NULL;
if(args.is_defined("func"))
{
std::cout << "<<INFO>> Using plugin function \"" << args["func"] << "\"" << std::endl ;
f = manager.get_function(args["func"]) ;
}
else
{
f = manager.get_function() ;
}
data* d = NULL ;
if(args.is_defined("data"))
{
std::cout << "<<INFO>> Using data \"" << args["data"] << "\"" << std::endl ;
d = manager.get_data() ;
d->load(args["data"]) ;
}
// Load the BRDF
f->load(args["input"]);
// Create output file
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
if(d != NULL)
{
for(int i=0; i<d->size(); ++i)
{
vec v = d->get(i) ;
vec y2 = f->value(v) ;
for(int u=0; u<d->dimX(); ++u)
file << v[u] << "\t" ;
for(int u=0; u<d->dimY(); ++u)
file << y2[u] << "\t" ;
file << std::endl ;
}
}
else
{
std::cerr << "<<ERROR>> --data is not defined" << std::endl ;
}
return 0 ;
}
TEMPLATE = subdirs
SUBDIRS = generate_data \
plugin_loader \
# rational_1d
brdf2gnuplot
TEMPLATE = subdirs
SUBDIRS = core \
plugins \
tests
softs
plugins.depends = core
tests.depends = core
tests.depends = plugins
softs.depends = core
softs.depends = plugins
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