如何解决使用pybind参数从C ++调用python函数
我有一个抽象类,用于通过在模拟点上计算一些数据来配置模拟。每种模拟都需要不同的配置,因此对于我从抽象类派生并随意配置的每种模拟。
class BlendingField
{
double blending(const Point_3 &point) = 0;
};
class BlendingForSim1
{
double blending(const Point_3 &point) final {
return 0;
}
};
...
为避免为如此琐碎的任务创建不同的子类,我考虑过使用Python
在Python中
def blending(point):
return point[0] + point[1] + point[2] // for example
在C ++中
class PythongBlending
{
double blending(const Point_3 &point) {
py::scoped_interpreter guard{}
// How should I call blending function in the script?
}
std::string m_pythonFile;
};
我一直在阅读pybind文档,但找不到如何传递参数或执行脚本的特定功能的方法。在C ++调用中应该包含什么内容?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。