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 c91d4db6 authored by Ludovic Courtès's avatar Ludovic Courtès

core: Use 'plugins_manager::load_data' everywhere.

parent abd62711
......@@ -57,22 +57,6 @@ class data
virtual void load(std::istream& input,
const arguments& args = arguments()) = 0;
// Load data from an input file.
void load(const std::string& file,
const arguments& args = arguments())
{
std::ifstream stream;
// Raise an exception when 'open' fails, and open in binary mode to
// placate Windows.
stream.exceptions(std::ios::failbit);
stream.open(file.c_str(), std::ifstream::binary);
stream.exceptions(std::ios::goodbit);
load(stream, args);
stream.close(); // FIXME: make it auto-close
}
// Save the data to a file
virtual void save(const std::string& filename) const;
......
......@@ -70,15 +70,13 @@ int main(int argc, char** argv)
}
// Get the associated data object and load the file is any
ptr<data> d = plugins_manager::get_data(args["data"], args) ;
if(args.is_defined("data-file"))
{
try
{
d->load(args["data-file"]);
}
CATCH_FILE_IO_ERROR(args["data-file"]);
ptr<data> d;
try
{
d = plugins_manager::load_data(args["data-file"], args["data"], args);
}
CATCH_FILE_IO_ERROR(args["data-file"]);
// Get the output object. In the case where it is not a VS file, we use
// the load object.
......
......@@ -80,22 +80,13 @@ int main(int argc, char** argv)
// Load a data file
if(args.is_defined("data") || args.is_defined("data-file"))
{
ptr<data> d = plugins_manager::get_data(args["data"], args);
ptr<data> d;
// Load data file if the plugin manager created a plugin object.
if(d)
{
try
{
d->load(args["data-file"]);
}
CATCH_FILE_IO_ERROR (args["data-file"]);
}
else
{
std::cerr << "<<ERROR>> unable to load the data plugin" << std::endl;
return EXIT_FAILURE;
}
try
{
d = plugins_manager::load_data(args["data-file"], args["data"], args);
}
CATCH_FILE_IO_ERROR (args["data-file"]);
// Create output file now that we are sure that needed data are loaded
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
......
......@@ -114,11 +114,10 @@ int main(int argc, char** argv)
fit->set_parameters(args) ;
ptr<data> d = ptr<data>(plugins_manager::get_data(args["data"], args));
ptr<data> d;
try
{
d->load(args["input"], args);
d = plugins_manager::load_data(args["input"], args["data"], args);
}
CATCH_FILE_IO_ERROR(args["input"]);
......
......@@ -112,10 +112,11 @@ int main(int argc, char** argv)
// Import data
ptr<data> d_in = plugins_manager::get_data(args["in-data"], args) ;
ptr<data> d_in;
try
{
d_in->load(args["input"], args);
d_in = plugins_manager::load_data(args["input"], args["in-data"], args) ;
}
CATCH_FILE_IO_ERROR(args["input"]);
......
......@@ -81,17 +81,16 @@ int main(int argc, char** argv)
// Import data
ptr<data> d = NULL ;
d = plugins_manager::get_data(args["data"], args) ;
try
{
d = plugins_manager::load_data(args["input"], args["data"], args) ;
}
CATCH_FILE_IO_ERROR(args["input"]);
if(dynamic_pointer_cast<vertical_segment>(d)) {
std::cerr << "<<ERROR>> this data object is not interpolant." << std::endl;
return 1;
}
try
{
d->load(args["input"]);
}
CATCH_FILE_IO_ERROR(args["input"]);
// Create output file
std::ofstream file(args["output"].c_str(), std::ios_base::trunc);
......
......@@ -504,10 +504,15 @@ int main(int argc, char* argv[])
}
std::cout << "<<INFO>> Loading data ..." << std::endl;
ptr<data> input = plugins_manager::get_data(args["in-data"]);
ptr<data> input;
//ptr<data> input = plugins_manager::get_data("vertical_segment");
input->load(args["input"], args);
try
{
input = plugins_manager::load_data(args["input"], args["in-data"]);
}
CATCH_FILE_IO_ERROR (args["input"]);
if(!input) {
std::cout << "<<ERROR>> Could not load data file \'" << args["input"]
<< "\'" << std::endl;
......@@ -515,8 +520,14 @@ int main(int argc, char* argv[])
}
// Load a function file representing the BRDF
ptr<data> ref = plugins_manager::get_data(args["ref-data"]) ;
ref->load(args["ref"]);
ptr<data> ref;
try
{
ref = plugins_manager::load_data(args["ref"], args["ref-data"]);
}
CATCH_FILE_IO_ERROR (args["ref"]);
if(!ref) {
std::cout << "<<ERROR>> Could not load data file \'" << args["ref"]
<< "\'" << std::endl;
......
......@@ -466,15 +466,14 @@ main(int argc, char* argv[])
}
std::cout << "<<INFO>> Loading data ..." << std::endl;
ptr<vertical_segment> vs_data = ptr<vertical_segment>(new vertical_segment());
//ptr<data> vs_data = plugins_manager::get_data("vertical_segment");
ptr<data> vs_data;
timer t;
try
{
t.start();
ptr<data> data = vs_data;
data->load(args["input"], args);
vs_data = plugins_manager::load_data(args["input"],
"vertical_segment", args);
t.stop();
}
catch(...)
......@@ -499,16 +498,13 @@ main(int argc, char* argv[])
std::cout << "<<INFO>> BRDF File Loaded. Starting to compute statistics ... " << std::endl;
//Conversion
ptr<data> generic_data = dynamic_pointer_cast<data>( vs_data );
vertical_segment* conv_vs = NULL;
bool conversion_necessary = true;
std::cout << "<<INFO>> Converting data to function parametrization if needed" << std::endl;
t.start();
convertDataToFunctionParam( generic_data, brdf, conversion_necessary, conv_vs );
convertDataToFunctionParam( vs_data, brdf, conversion_necessary, conv_vs );
t.stop();
std::cout << "<<INFO>> Data converted in " << t << std::endl;
t.reset();
......@@ -521,7 +517,7 @@ main(int argc, char* argv[])
}
else
{
converted_data = generic_data;
converted_data = vs_data;
}
//Here we go new way and faster because we evaluate the function just once
......@@ -686,14 +682,14 @@ main(int argc, char* argv[])
//Comparisons with the norm methods provided in function.cpp
t.start();
double const L2 = brdf->L2_distance( generic_data ) ;
double const L2 = brdf->L2_distance( vs_data ) ;
t.stop();
std::cout << "<<INFO>> L2, (computed from function) distance to data = " << L2
<< " (computed in " << t << ")" << std::endl;
t.reset();
t.start();
double const Linf = brdf->Linf_distance( generic_data );
double const Linf = brdf->Linf_distance( vs_data );
t.stop();
std::cout << "<<INFO>> Linf distance to data = " << Linf
<< " (computed in " << t << ")" << std::endl;
......
......@@ -118,11 +118,17 @@ int main(int argc, char** argv)
try
{
std::ifstream input;
input.open(input_file);
// Use the standard load/save methods.
((data&)sample1).load(input_file);
((data&)sample1).load(input);
sample1.save(temp_file1);
((data&)sample2).load(temp_file1);
std::ifstream temp1;
temp1.open(temp_file1);
((data&)sample2).load(temp1);
sample2.save(temp_file2);
// Now use the binary output format.
......@@ -132,7 +138,9 @@ int main(int argc, char** argv)
out.close();
// This should automatically load using the binary format loader.
((data&)sample3).load(temp_file3);
std::ifstream temp3;
temp3.open(temp_file3);
((data&)sample3).load(temp3);
}
CATCH_FILE_IO_ERROR(input_file);
......
......@@ -44,8 +44,7 @@ int main(int argc, char *argv[])
input_file = data_dir + "/" + data_file;
}
auto data = ptr<alta::data>(new vertical_segment());
data->load(input_file);
auto data = plugins_manager::load_data(input_file, "vertical_segment");
for (auto&& fitter_name: fitters) {
auto function = plugins_manager::get_function("nonlinear_function_diffuse",
......
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