Commit 8c90c23b authored by Ludovic Courtès's avatar Ludovic Courtès

core: 'plugins_manager::load' passes arguments to 'load_data_from_text'.

Fixes a regression introduced in d9ce986b whereby filtering arguments
were no longer passed to 'load_data_from_text'.

Reported by Romain Pacanowski.
parent 588b3d38
......@@ -153,12 +153,9 @@ static void read_confidence_interval(std::istream& input,
}
alta::data* alta::load_data_from_text(std::istream& input,
const alta::arguments& header)
const alta::arguments& header,
const alta::arguments& args)
{
// FIXME: Eventually reinstate support for extra arguments when loading a
// file.
static alta::arguments args;
vec min, max ;
vec ymin, ymax;
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2013, 2014, 2015, 2016 Inria
Copyright (C) 2013, 2014, 2015, 2016, 2017 Inria
This file is part of ALTA.
......@@ -25,9 +25,12 @@ namespace alta
void save_data_as_binary(std::ostream& out, const alta::data& data);
// Return the data read from INPUT in ALTA's native text format.
// Return the data read from INPUT in ALTA's native text format. Read
// extra parsing parameters from ARGS. XXX: ARGS is currently used for
// extra filtering, which should really happen elsewhere.
data* load_data_from_text(std::istream& input,
const alta::arguments& header);
const alta::arguments& header,
const alta::arguments& args = alta::arguments());
// Return the data read from the binary-formatted stream IN.
data* load_data_from_binary(std::istream& in, const alta::arguments& header);
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2014, 2015 CNRS
Copyright (C) 2013, 2014, 2015, 2016 Inria
Copyright (C) 2013, 2014, 2015, 2016, 2017 Inria
This file is part of ALTA.
......@@ -486,8 +486,7 @@ ptr<data> plugins_manager::load_data(const std::string& type, std::istream& inpu
if (header["FORMAT"] == "binary") {
result = ptr<data>(load_data_from_binary(input, header));
} else {
// FIXME: ARGS is currently ignored.
result = ptr<data>(load_data_from_text(input, header));
result = ptr<data>(load_data_from_text(input, header, args));
}
}
else
......
......@@ -91,6 +91,38 @@ static void test_simple_load_from_text()
TEST_ASSERT(view.col(3) == Eigen::Vector3d(3., 7., 11.));
}
// Try loading a simple example from a text-format stream, with extra
// filtering arguments.
static void test_simple_load_from_text_filtering()
{
static const char example[] = "\
#DIM 1 3f\n\
#VS 0\n\
#PARAM_IN COS_TH\n\
#PARAM_OUT RGB_COLOR\n\
0 1 2 3\n\
1 4 5 6\n\
2 7 8 9\n\
3 10 11 12\n\
4 7 7 7\n";
std::istringstream input(example);
// Filter out elements that are not within those boundaries.
arguments args =
{ { "ymin", "4" }, { "ymax", "10" }, { "max", "3" } };
auto data = dynamic_pointer_cast<vertical_segment>(
plugins_manager::load_data("vertical_segment", input, args));
TEST_ASSERT(data != NULL);
// There should be only 2 elements left after filtering.
TEST_ASSERT(data->size() == 2);
TEST_ASSERT(data->get(0) == Eigen::Vector4d(1., 4., 5., 6.));
TEST_ASSERT(data->get(1) == Eigen::Vector4d(2., 7., 8., 9.));
}
// Files that are automatically deleted upon destruction.
class temporary_file
{
......@@ -170,8 +202,9 @@ int main(int argc, char** argv)
input_file = data_dir + "/" + data_file;
}
// Simple test first.
// Simple tests first.
test_simple_load_from_text();
test_simple_load_from_text_filtering();
// Try a sequence of loads and saves.
try
......
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