Loading...
Searching...
No Matches
Classes | Functions
bbm::python Namespace Reference

Classes

struct  interpreter
 Python interpreter with BBM module imported. More...
 
struct  py_cast
 Default casting. More...
 
struct  py_cast< TARGET >
 specialization for bbm::attribute More...
 

Functions

template<typename RET_TYPE , typename CONF = get_config<RET_TYPE>>
requires concepts::config<CONF>
RET_TYPE capture (const std::string &prog)
 Helper function to execute a python string and capture the output.
 
template<typename CONF >
requires concepts::config<CONF>
void execute (const std::string &prog)
 Helper function to execute a python string and ignore the output.
 
template<typename ARGS >
requires is_args_v<ARGS>
auto py_args_to_bbm_args (py::args &args, py::kwargs &kwargs)
 Create a bbm::arg from py:args and py::kwargs.
 
template<typename OBJ_TYPE >
requires concepts::constructor<OBJ_TYPE>
OBJ_TYPE create_object (py::args &args, py::kwargs &kwargs)
 Construct an object with a valid 'constructor_args_t' based on python args and kwargs.
 
template<typename ARGS , bool TYPE = false>
requires is_args_v<ARGS>
std::string args_to_string (void)
 Provide a human readable string of an bbm::args type.
 
template<typename BSDFMODEL >
requires concepts::bsdfmodel<BSDFMODEL> && concepts::constructor<BSDFMODEL>
void def_bsdf (py::module &m)
 export a BSDF model to Python
 
template<typename T >
void fresnel (py::module &m, const std::string &prefix="")
 Define a python interface for ior::ior and ior::reflectance given a value type T.
 
template<typename T >
void complex_fresnel (py::module &m, const std::string &prefix="")
 Define a python interface for ior::complex given a value type T.
 

Function Documentation

◆ args_to_string()

std::string args_to_string ( void  )

Provide a human readable string of an bbm::args type.

Prints the name and default value of the bbm::arg, and optinally the type if TYPE is set to true.

◆ capture()

RET_TYPE capture ( const std::string &  prog)

Helper function to execute a python string and capture the output.

Template Parameters
RET_TYPE= type of the return value (must be specified manually)
CONF= config of the bbm python lib.
Parameters
prog= string of python program to run

◆ complex_fresnel()

void complex_fresnel ( py::module &  m,
const std::string &  prefix = "" 
)

Define a python interface for ior::complex given a value type T.

Template Parameters
T= value type for ior::complex

◆ create_object()

OBJ_TYPE create_object ( py::args &  args,
py::kwargs &  kwargs 
)
inline

Construct an object with a valid 'constructor_args_t' based on python args and kwargs.

Template Parameters
OBJ_TYPE= object type to create
Parameters
args= list of python arguments (copied to the first N attributes)
kwargs= list of keyword arguments

Attempt to create an object with with 'OBJ_TYPE' from py::args and py::kwargs when 'constructor_ars_t' exists (i.e., bbm/constructor.h was used to declare a constructor).

◆ def_bsdf()

void def_bsdf ( py::module &  m)

export a BSDF model to Python

Template Parameters
BSDFMODEL= BSDF model to export
Parameters
m= python module

Creates a bsdf_ptr wrapper for a BSDF model, and exports it to the python module 'm' with 'name'. Using a trampoline function to set the attributes instead of direcly defining the attributes and default values, otherwise there might be issues with embedding the module more than once for certain types of default values (e.g., numpy).

◆ execute()

void execute ( const std::string &  prog)

Helper function to execute a python string and ignore the output.

Template Parameters
CONF= config of the bbm python lib
Parameters
prog= string of python program to run

◆ fresnel()

void fresnel ( py::module &  m,
const std::string &  prefix = "" 
)

Define a python interface for ior::ior and ior::reflectance given a value type T.

Template Parameters
T= value type of ior or reflectance

◆ py_args_to_bbm_args()

auto py_args_to_bbm_args ( py::args &  args,
py::kwargs &  kwargs 
)
inline

Create a bbm::arg from py:args and py::kwargs.

Template Parameters
ARGS= bbm::args type to create and fill
Parameters
args= list of python arguments
kwargs= list of keyword arguments