Loading...
Searching...
No Matches
py_fresnel.h
Go to the documentation of this file.
1#ifndef _BBM_PYTHON_FRESNEL_H_
2#define _BBM_PYTHON_FRESNEL_H_
3
4#include "core/ior.h"
5
6/************************************************************************/
7/*! \file py_fresnel.h
8 \brief Export ior::ior and ior::reflectance to pyton
9*************************************************************************/
10
11namespace bbm {
12 namespace python {
13
14 /********************************************************************/
15 /*! \brief Define a python interface for ior::ior and ior::reflectance
16 given a value type T.
17
18 \tparam T = value type of ior or reflectance
19
20 ********************************************************************/
21 template<typename T>
22 void fresnel(py::module& m, const std::string& prefix = "")
23 {
24 py::class_<ior::ior<T>>(m, (prefix + "Ior").c_str())
25 .def(py::init<const remove_diff_t<T>&>())
26 .def(py::init<const ior::reflectance<T>&>())
27 .def("__str__", [](const ior::ior<T>& ior) { return bbm::toString(ior); });
28
29 py::class_<ior::reflectance<T>>(m, (prefix + "Reflectance").c_str())
30 .def(py::init<const remove_diff_t<T>&>())
31 .def(py::init<const ior::ior<T>&>())
32 .def("__str__", [](const ior::reflectance<T>& refl) { return bbm::toString(refl); });
33
34 py::implicitly_convertible<remove_diff_t<T>, ior::ior<T>>();
35 py::implicitly_convertible<ior::reflectance<T>, ior::ior<T>>();
36 py::implicitly_convertible<remove_diff_t<T>, ior::reflectance<T>>();
37 py::implicitly_convertible<ior::ior<T>, ior::reflectance<T>>();
38
39 }
40
41 /********************************************************************/
42 /*! \brief Define a python interface for ior::complex given a value type T.
43
44 \tparam T = value type for ior::complex
45
46 *********************************************************************/
47 template<typename T>
48 void complex_fresnel(py::module& m, const std::string& prefix = "")
49 {
50 py::class_<ior::complex_ior<T>>(m, (prefix + "ComplexIor").c_str())
51 .def(py::init<const remove_diff_t<T>&>())
52 .def(py::init<const remove_diff_t<T>&, const remove_diff_t<T>&>())
53 .def(py::init<const ior::ior<T>&>())
54 .def(py::init<const vec2d<T>&>())
55 .def("__str__", [](const ior::complex_ior<T>& ior) { return bbm::toString(ior); });
56
57 py::implicitly_convertible<ior::ior<T>, ior::complex_ior<T>>();
58 py::implicitly_convertible<remove_diff_t<T>, ior::complex_ior<T>>();
59 py::implicitly_convertible<vec2d<T>, ior::complex_ior<T>>();
60 }
61
62 } // end python namespace
63} // end bbm namespace
64
65#endif /* _BBM_PYTHON_FRESNEL_H_ */
Defines 'ior' and 'reflectance' types.
void fresnel(py::module &m, const std::string &prefix="")
Define a python interface for ior::ior and ior::reflectance given a value type T.
Definition: py_fresnel.h:22
void complex_fresnel(py::module &m, const std::string &prefix="")
Define a python interface for ior::complex given a value type T.
Definition: py_fresnel.h:48
Definition: aggregatebsdf.h:29
std::string toString(const T &)
toString alias
Definition: stringconvert.h:594
Base declaration of attribute; further specialized below.
Definition: attribute.h:26