Commit 92313844 authored by Laurent Belcour's avatar Laurent Belcour

The min and max arguments can be vectors now

parent 52fb76f9
......@@ -27,13 +27,19 @@ class arguments
if(temp.compare(0, 2, "--") == 0)
{
key = temp.substr(2, temp.size()-2) ;
if(i+1 < argc)
int j = i+1;
while(j < argc)
{
std::string next(argv[i+1]) ;
std::string next(argv[j]) ;
if(next.compare(0, 2, "--") != 0)
{
data = next ;
data.append(next) ;
}
else
{
break ;
}
++j;
}
}
_map.insert(std::pair<std::string, std::string>(key, data)) ;
......@@ -79,34 +85,43 @@ class arguments
else
return default_value ;
}
vec get_vec(const std::string& key, float default_value) const
vec get_vec(const std::string& key, int size, float default_value = 0.0f) const
{
vec res;
vec res(size);
if(_map.count(key) > 0)
{
std::string s = _map.at(key);
if(s[0] == '\[') // Is an array of type [a, b, c]
{
int i = 0;
size_t pos = 0;
size_t pos = 1;
while(pos != std::string::npos)
{
size_t ppos = s.find(",", pos);
size_t ppos = s.find(',', pos);
if(ppos != std::string::npos)
{
std::cout << s.substr(pos, ppos) << std::endl ;
res[i] = atof(s.substr(pos, ppos).c_str());
pos = ppos+1;
++i;
}
else
{
res[i] = atof(s.substr(pos, ppos-1).c_str());
pos = ppos;
++i;
}
}
std::cout << std::endl ;
return res;
}
}
float val = get_float(key, default_value);
res.push_back(default_value);
for(int i=0; i<size; ++i)
{
res[i] = val;
}
return res;
}
......
......@@ -23,9 +23,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
throw ;
}
double min, max ;
min = args.get_float("min", -std::numeric_limits<double>::max()) ;
max = args.get_float("max", std::numeric_limits<double>::max()) ;
vec min, max ;
_nX = 0 ; _nY = 0 ;
std::vector<int> vs ; int current_vs = 0 ;
......@@ -57,6 +55,10 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
_min.resize(dimX()) ;
_max.resize(dimX()) ;
min = args.get_vec("min", _nX, -std::numeric_limits<double>::max()) ;
max = args.get_vec("max", _nX, std::numeric_limits<double>::max()) ;
for(int k=0; k<dimX(); ++k)
{
_min[k] = std::numeric_limits<double>::max() ;
......@@ -115,7 +117,7 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
bool is_in = true ;
for(int i=0; i<dimX(); ++i)
{
if(v[i] < min || v[i] > max)
if(v[i] < min[i] || v[i] > max[i])
{
is_in = false ;
}
......
......@@ -53,6 +53,13 @@ int main(int argc, char** argv)
d->load(args["data"]) ;
}
bool plot_error = false ;
if(args.is_defined("error"))
{
std::cout << "<<INFO>> Exporting an error plot" << std::endl;
plot_error = true ;
}
// Load the BRDF
f->load(args["input"]);
......@@ -70,7 +77,13 @@ int main(int argc, char** argv)
file << v[u] << "\t" ;
for(int u=0; u<d->dimY(); ++u)
file << y2[u] << "\t" ;
{
if(plot_error) {
file << y2[u] << "\t" ;
} else {
file << (v[d->dimX() + u] - y2[u])/v[d->dimX()+u] << "\t" ;
}
}
file << std::endl ;
}
......
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