Commit 10076200 by Laurent Belcour

### Updating the interface of data to incorporate an index based set function.

parent ec2f94ea
 ... @@ -281,7 +281,7 @@ throw ... @@ -281,7 +281,7 @@ throw // Mathematical definition not provided on the Window plateform // Mathematical definition not provided on the Window plateform #ifdef _WIN32 #ifdef _WIN32 #define M_PI 3.14159265 #define M_PI 3.1415926535897932384626433832795 template bool isnan(T x) template bool isnan(T x) { { ... ...
 ... @@ -58,25 +58,19 @@ class data : public parametrized ... @@ -58,25 +58,19 @@ class data : public parametrized // Acces to data // Acces to data virtual vec get(int i) const = 0 ; virtual vec get(int i) const = 0 ; virtual vec operator[](int i) const = 0 ; virtual vec operator[](int i) const = 0 ; /* //! \brief Provide an evaluation of the data using interpolation. If //! \brief Provide an evaluation in a BRDF way of the data. //! the data object does not provide an interpolation mechanism, it //! //! should throw an exception. //! \details //! The input vector in (can have texture coordinate) and the output //! vector out are taken to grab a value and return it. The two vectors //! should be compliant with the size and parametrization of the data. virtual vec value(vec in, vec out) const = 0; */ //! \brief Provide an evaluation in a BRDF way of the data. //! //! //! \details //! \details //! The input vector must have the parametrization of the data. //! The input vector must have the parametrization of the data, and virtual vec value(vec in) const = 0; //! match the total dimension: dimX + dimY. virtual vec value(const vec& in) const = 0; //! \brief Put the sample inside the data //! \brief Put the sample inside the data virtual void set(vec x) = 0; virtual void set(const vec& x) = 0; virtual void set(int i, const vec& x) = 0; // Get data size, e.g. the number of samples to fit // Get data size, e.g. the number of samples to fit ... @@ -130,11 +124,7 @@ class data_params : public data ... @@ -130,11 +124,7 @@ class data_params : public data save(std::string("cluster.gnuplot")); save(std::string("cluster.gnuplot")); } } virtual vec value(vec, vec) const virtual vec value(const vec&) const { NOT_IMPLEMENTED(); } virtual vec value(vec) const { { NOT_IMPLEMENTED(); NOT_IMPLEMENTED(); } } ... @@ -163,11 +153,16 @@ class data_params : public data ... @@ -163,11 +153,16 @@ class data_params : public data } } //! \todo This should crash at execution. //! \todo This should crash at execution. virtual void set(vec x) virtual void set(const vec& x) { { this->set(x); this->set(x); } } virtual void set(int i, const vec& x) { this->set(i, x); } // Get data size, e.g. the number of samples to fit // Get data size, e.g. the number of samples to fit virtual int size() const virtual int size() const { { ... ...
 ... @@ -369,6 +369,12 @@ class params ... @@ -369,6 +369,12 @@ class params class parametrized class parametrized { { public: public: parametrized(params::input in_param, params::output out_param) { _in_param = in_param; _out_param = out_param; _nX = params::dimension(_in_param); _nY = params::dimension(_out_param); } parametrized() : _in_param(params::UNKNOWN_INPUT), parametrized() : _in_param(params::UNKNOWN_INPUT), _out_param(params::UNKNOWN_OUTPUT) { } _out_param(params::UNKNOWN_OUTPUT) { } ... ...
 ... @@ -286,12 +286,18 @@ vec vertical_segment::get(int i) const ... @@ -286,12 +286,18 @@ vec vertical_segment::get(int i) const //! \todo Check the vertical segment size and if the data //! \todo Check the vertical segment size and if the data //! is not already present. //! is not already present. void vertical_segment::set(vec x) void vertical_segment::set(const vec& x) { { // assert(x.size() == dimX() + dimY() || x.size() == dimX() + 3*dimY()); // assert(x.size() == dimX() + dimY() || x.size() == dimX() + 3*dimY()); _data.push_back(x); _data.push_back(x); } } void vertical_segment::set(int i, const vec& x) { // assert(x.size() == dimX() + dimY() || x.size() == dimX() + 3*dimY()); _data[i] = x; } int vertical_segment::size() const int vertical_segment::size() const { { return _data.size() ; return _data.size() ; ... ...
 ... @@ -90,18 +90,16 @@ class vertical_segment : public data ... @@ -90,18 +90,16 @@ class vertical_segment : public data // Acces to data // Acces to data virtual vec get(int i) const ; virtual vec get(int i) const ; virtual vec operator[](int i) const ; virtual vec operator[](int i) const; virtual vec value(vec, vec) const { virtual vec value(const vec&) const NOT_IMPLEMENTED(); } virtual vec value(vec) const { { NOT_IMPLEMENTED(); NOT_IMPLEMENTED(); } } //! \brief Put the sample inside the data //! \brief Put the sample inside the data virtual void set(vec x); virtual void set(const vec& x); virtual void set(int i, const vec& x); //! \brief Specific accessor to a vertical segment, this gives the //! \brief Specific accessor to a vertical segment, this gives the //! complete vector, plus the ordinate segment //! complete vector, plus the ordinate segment ... ...
 ... @@ -2,6 +2,7 @@ ... @@ -2,6 +2,7 @@ SConscript('data_merl/SConscript') SConscript('data_merl/SConscript') SConscript('data_brdf_slice/SConscript') SConscript('data_brdf_slice/SConscript') SConscript('data_interpolant/SConscript') SConscript('data_interpolant/SConscript') #SConscript('data_io/SConscript') # # Building nonlinear fitters # # Building nonlinear fitters SConscript('nonlinear_fitter_ceres/SConscript') SConscript('nonlinear_fitter_ceres/SConscript') ... @@ -31,6 +32,7 @@ SConscript('rational_fitter_leastsquare/SConscript') ... @@ -31,6 +32,7 @@ SConscript('rational_fitter_leastsquare/SConscript') SConscript('rational_fitter_quadprog/SConscript') SConscript('rational_fitter_quadprog/SConscript') SConscript('rational_fitter_parallel/SConscript') SConscript('rational_fitter_parallel/SConscript') SConscript('rational_fitter_matlab/SConscript') SConscript('rational_fitter_matlab/SConscript') SConscript('rational_fitters/SConscript') # # Building rational functions # # Building rational functions ... ...
 ... @@ -66,7 +66,7 @@ void data_astm::load(const std::string& filename, const arguments& args) ... @@ -66,7 +66,7 @@ void data_astm::load(const std::string& filename, const arguments& args) } } // Acces to data // Acces to data vec data_astm::get(int i) const vec& data_astm::get(int i) { { return _data[i]; return _data[i]; } } ... ...
 ... @@ -28,7 +28,7 @@ class data_astm : public QObject, public data ... @@ -28,7 +28,7 @@ class data_astm : public QObject, public data // Acces to data // Acces to data virtual vec get(int i) const ; virtual vec get(int i) const ; virtual vec operator[](int i) const ; virtual vec& operator[](int i) ; virtual vec value(vec in, vec out) const ; virtual vec value(vec in, vec out) const ; // Get data size, e.g. the number of samples to fit // Get data size, e.g. the number of samples to fit ... ...
 ... @@ -10,6 +10,10 @@ ... @@ -10,6 +10,10 @@ #ifndef EXR_IO_H_ #ifndef EXR_IO_H_ #define EXR_IO_H_ #define EXR_IO_H_ /* * Author: Cyril Soler */ #include #include ... ...
 ... @@ -78,7 +78,7 @@ vec data_brdf_slice::operator[](int i) const ... @@ -78,7 +78,7 @@ vec data_brdf_slice::operator[](int i) const } } //! \todo Test this function //! \todo Test this function void data_brdf_slice::set(vec x) void data_brdf_slice::set(const vec& x) { { assert(x.size() == 6); assert(x.size() == 6); assert(x[0] <= 0.5*M_PI && x[0] >= 0.0); assert(x[0] <= 0.5*M_PI && x[0] >= 0.0); ... @@ -93,13 +93,16 @@ void data_brdf_slice::set(vec x) ... @@ -93,13 +93,16 @@ void data_brdf_slice::set(vec x) _data[3*id + 1] = x[4]; _data[3*id + 1] = x[4]; _data[3*id + 2] = x[5]; _data[3*id + 2] = x[5]; } } void data_brdf_slice::set(int id, const vec& x) vec data_brdf_slice::value(vec, vec) const { { vec res(3); assert(x.size() == 3); return res; _data[3*id + 0] = x[0]; _data[3*id + 1] = x[1]; _data[3*id + 2] = x[2]; } } vec data_brdf_slice::value(vec x) const vec data_brdf_slice::value(const vec& x) const { { assert(x[0] <= 0.5*M_PI && x[0] >= 0.0); assert(x[0] <= 0.5*M_PI && x[0] >= 0.0); assert(x[1] <= 0.5*M_PI && x[1] >= 0.0); assert(x[1] <= 0.5*M_PI && x[1] >= 0.0); ... ...
 ... @@ -31,11 +31,11 @@ class data_brdf_slice : public data ... @@ -31,11 +31,11 @@ class data_brdf_slice : public data virtual vec get(int i) const ; virtual vec get(int i) const ; virtual vec operator[](int i) const ; virtual vec operator[](int i) const ; virtual vec value(vec in, vec out) const; virtual vec value(const vec& x) const; virtual vec value(vec x) const; // Set data // Set data virtual void set(vec x); virtual void set(int i, const vec& x); virtual void set(const vec& x); // Get data size, e.g. the number of samples to fit // Get data size, e.g. the number of samples to fit virtual int size() const ; virtual int size() const ; ... ...
 ... @@ -342,13 +342,13 @@ vec data_merl::get(int i) const ... @@ -342,13 +342,13 @@ vec data_merl::get(int i) const res[5] = brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D] * BLUE_SCALE; res[5] = brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D] * BLUE_SCALE; return res ; return res ; } } vec data_merl::operator[](int i) const vec data_merl::operator[](int i) const { { return get(i) ; return get(i) ; } } //! \todo Test this function //! \todo Test this function void data_merl::set(vec x) void data_merl::set(const vec& x) { { assert(x.size() == 6); assert(x.size() == 6); const int phid_ind = phi_diff_index(x[2]); const int phid_ind = phi_diff_index(x[2]); ... @@ -366,7 +366,15 @@ void data_merl::set(vec x) ... @@ -366,7 +366,15 @@ void data_merl::set(vec x) brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D] = x[5] / BLUE_SCALE; brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D] = x[5] / BLUE_SCALE; } } vec data_merl::value(vec in) const void data_merl::set(int i, const vec& x) { assert(x.size() == 3); brdf[i] = x[0] / RED_SCALE; brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D/2] = x[1] / GREEN_SCALE; brdf[i + BRDF_SAMPLING_RES_THETA_H*BRDF_SAMPLING_RES_THETA_D*BRDF_SAMPLING_RES_PHI_D] = x[2] / BLUE_SCALE; } vec data_merl::value(const vec& in) const { { double r, g, b; double r, g, b; lookup_brdf_val(brdf, in[0], in[1], in[2], r, g, b) ; lookup_brdf_val(brdf, in[0], in[1], in[2], r, g, b) ; ... ...
 ... @@ -27,13 +27,14 @@ class data_merl : public data ... @@ -27,13 +27,14 @@ class data_merl : public data virtual void save(const std::string& filename) const ; virtual void save(const std::string& filename) const ; // Acces to data // Acces to data virtual vec get(int i) const ; virtual vec get(int i) const; virtual vec operator[](int i) const ; virtual vec operator[](int i) const; virtual vec value(vec in) const; virtual vec value(const vec& in) const; // Set data // Set data virtual void set(vec x); virtual void set(int i, const vec& x); virtual void set(const vec& x); // Get data size, e.g. the number of samples to fit // Get data size, e.g. the number of samples to fit virtual int size() const ; virtual int size() const ; ... ...
 ... @@ -155,7 +155,7 @@ BOOST_PYTHON_MODULE(alta) ... @@ -155,7 +155,7 @@ BOOST_PYTHON_MODULE(alta) bp::class_, boost::noncopyable>("data", bp::no_init) bp::class_, boost::noncopyable>("data", bp::no_init) .def("size", &data::size) .def("size", &data::size) .def("get", &data::get) .def("get", &data::get) .def("set", &data::set) //.def("set", &data::set) .def("load", static_cast< void(data::*)(const std::string&)>(&data::load)) .def("load", static_cast< void(data::*)(const std::string&)>(&data::load)) .def("save", &data::save); .def("save", &data::save); bp::def("get_data", plugins_manager::get_data); bp::def("get_data", plugins_manager::get_data); ... ...
 ... @@ -4,4 +4,6 @@ SConscript('data2moments/SConscript') ... @@ -4,4 +4,6 @@ SConscript('data2moments/SConscript') SConscript('brdf2brdf/SConscript') SConscript('brdf2brdf/SConscript') SConscript('brdf2data/SConscript') SConscript('brdf2data/SConscript') SConscript('brdf2gnuplot/SConscript') SConscript('brdf2gnuplot/SConscript') \ No newline at end of file #SConscript('tests/SConscript')
 ... @@ -95,6 +95,11 @@ int main(int argc, char** argv) ... @@ -95,6 +95,11 @@ int main(int argc, char** argv) if(d && f != NULL) if(d && f != NULL) { { // Is the output data file already allocated and has the same size // than the training data ? const bool out_filled = d->size() == d_out->size(); const bool output_dif = args.is_defined("export-diff"); vec temp(f->dimX()); vec temp(f->dimX()); for(int i=0; isize(); ++i) for(int i=0; isize(); ++i) { { ... @@ -111,12 +116,17 @@ int main(int argc, char** argv) ... @@ -111,12 +116,17 @@ int main(int argc, char** argv) } } vec y = f->value(temp); vec y = f->value(temp); for(int j=0; jdimY(); ++j) for(int j=0; jdimY(); ++j) { { x[d->dimX() + j] = (output_dif) ? x[d->dimX() + j] - y[j] : y[j]; x[d->dimX() + j] = y[j]; } } d_out->set(x); // If the output data is already allocated and has the same size // than the training data, we do simple copy of the index elements. if(out_filled) { d_out->set(i, y); } else { d_out->set(x); } } } d_out->save(args["output"]); d_out->save(args["output"]); ... ...
 /* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions /* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions Copyright (C) 2013 Inria Copyright (C) 2013 Inria ... @@ -8,6 +9,29 @@ ... @@ -8,6 +9,29 @@ License, v. 2.0. If a copy of the MPL was not distributed with this License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include int main(int argc, char** argv) { spherical sphericalParam; isotropic_tl_tv isotropicParam; vec in(4); in[0] = 0.0; in[1] = 0.0; in[2] = 0.0; in[3] = 0.0; vec out(2); sphericalParam.convert_to(in, isotropicParam, out); return 0; } #ifdef OLD #include #include #include #include #include #include ... @@ -208,3 +232,5 @@ int parametrization_tests() ... @@ -208,3 +232,5 @@ int parametrization_tests() */ */ return nb_tests_failed; return nb_tests_failed; } } #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!