Commit a5ac60aa authored by Laurent Belcour's avatar Laurent Belcour

Need to debug ration fitter, it is not implementing the correct interface

parent 37a32f73
......@@ -2,6 +2,7 @@
#include "function.h"
#include "data.h"
#include "args.h"
#include <QtPlugin>
......@@ -19,6 +20,8 @@ class fitter
//
virtual bool fit_data(const data* d, function*& f) = 0 ;
virtual void set_parameters(const arguments& args) = 0 ;
} ;
Q_DECLARE_INTERFACE(fitter, "Fitter.Fitter")
......@@ -254,4 +254,4 @@ bool rational_1d_fitter_cgal::fit_data(const data* d, int np, int nq, function*&
}
}
Q_EXPORT_PLUGIN2(rational_plugin_cgal, rational_1d_fitter_cgal)
Q_EXPORT_PLUGIN2(rational_fitter_cgal, rational_1d_fitter_cgal)
......@@ -9,6 +9,10 @@
#include <QDir>
#include <iostream>
#include <vector>
#include <iostream>
#include <fstream>
#include <limits>
int main(int argc, char** argv)
{
......@@ -25,7 +29,7 @@ int main(int argc, char** argv)
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
if (plugin) {
if (plugin != nullptr) {
std::cout << "Loading plugin " << fileName.toStdString() << std::endl ;
if(dynamic_cast<function*>(plugin) != nullptr)
......@@ -49,8 +53,39 @@ int main(int argc, char** argv)
arguments args(argc, argv) ;
if(fitters.size() > 0 && datas.size() > 0 && functions.size() > 0)
{
fitters[0]->set_parameters(args) ;
function* f = functions[0] ;
data* d = datas[0] ;
bool is_fitted = fitters[0]->fit_data(d, f) ;
// Display the result
if(is_fitted)
{
std::cout << f << std::endl ;
//*
std::ofstream file(args["output"], std::ios_base::trunc);
const double dt = (d->max() - d->min()) / 100.0f ;
for(double x=d->min(); x<=d->max(); x+=dt)
{
file << x << "\t" << (*f)(x) << std::endl ;
}
//*/
}
else
{
std::cout << "<<ERROR>> unable to fit the data" << std::endl ;
}
}
else
{
std::cout << "<<ERROR>> not enough plugin defined" << std::endl ;
}
std::cout << "Done" << std::endl ;
return 0 ;
}
DEST_DIR = ../bin
CONFIG += debug plugin
QT +=
INCLUDEPATH += ../../ ../../libs/rational_1d /home/belcour/Sources/Eigen/include/eigen3
INCLUDEPATH += ../../ ../../plugins/rational_1d /home/belcour/Sources/Eigen/include/eigen3
SOURCES += main.cpp \
../../libs/rational_1d/rational_1d_fitter.cpp \
../../libs/rational_1d/rational_1d_fitter_cgal.cpp \
../../libs/rational_1d/rational_1d_fitter_eigen.cpp
../../plugins/rational_1d/rational_1d_fitter.cpp \
../../plugins/rational_1d/rational_1d_fitter_cgal.cpp \
../../plugins/rational_1d/rational_1d_fitter_eigen.cpp
QMAKE_CXXFLAGS += -std=c++11 -frounding-math
......
TEMPLATE = subdirs
SUBDIRS = generate_data \
plugin_loader \
rational_1d
# rational_1d
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