Commit 78e0785f authored by Laurent Belcour's avatar Laurent Belcour

[Fix] Enable loading EXR file in the UTIA plugin. I had to change the way the...

[Fix] Enable loading EXR file in the UTIA plugin. I had to change the way the arguments are passed to the plugin during plugin creation.
parent 450a9db4
......@@ -43,6 +43,7 @@ class arguments
arguments()
{
}
arguments(const arguments& args) : _map(args._map) {}
arguments(std::initializer_list<pair_type> lst)
: _map(lst)
{
......@@ -517,7 +518,7 @@ class arguments
}
private: // data
protected: // data
std::map<std::string, std::string> _map ;
......
......@@ -506,12 +506,19 @@ ptr<data> plugins_manager::load_data(const std::string& file,
{
std::ifstream stream;
// Create a temporary `arguments` object to pass information data
// to the newly created plugin. Some arguments are provided
// through the soft command. Here we only force the filename to
// be located at item "filename"
arguments n_args(args);
n_args.update("filename", file);
// 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);
ptr<data> result = load_data(type, stream, args);
ptr<data> result = load_data(type, stream, n_args);
stream.close(); // FIXME: make it auto-close
return result;
......
......@@ -320,14 +320,37 @@ ALTA_DLL_EXPORT data* load_data(std::istream& input, const arguments& args)
} else
#endif
UTIA* result = new UTIA(alta::parameters(4, 3,
params::SPHERICAL_TL_PL_TV_PV,
params::RGB_COLOR));
int count = result->planes * result->nti * result->npi
* result->ntv * result->npv;
input.read((char*)result->Bd, count*sizeof(double));
std::cout << "<<INFO>> Successfully read BRDF" << std::endl;
// Check the filename extension and perform the adequate loading depending
// if it is an EXR file or a binary file.
std::string filename = args["filename"];
if(filename.substr(filename.find_last_of(".") + 1) == "exr") {
// EXR data reading
double *temp; int W, H;
t_EXR_IO<double>::LoadEXR(input, W, H, temp);
// Data copy
for(int i=0; i<H; ++i)
for(int j=0; j<W; ++j){
int indexUTIA = i*W+j;
int indexEXR = (H-i-1)*W+j;
result->Bd[indexUTIA + 0*N_PER_PLANE] = temp[3*indexEXR + 0];
result->Bd[indexUTIA + 1*N_PER_PLANE] = temp[3*indexEXR + 1];
result->Bd[indexUTIA + 2*N_PER_PLANE] = temp[3*indexEXR + 2];
}
delete[] temp;
std::cout << "<<INFO>> Successfully read EXR BRDF file" << std::endl;
} else {
int count = result->planes * result->nti * result->npi
* result->ntv * result->npv;
input.read((char*)result->Bd, count*sizeof(double));
std::cout << "<<INFO>> Successfully read binary BRDF file" << std::endl;
}
return result;
}
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