| 224 | } |
| 225 | |
| 226 | void mitk::PythonContext::BindImage(Image* image, const std::string& varName) |
| 227 | { |
| 228 | py::gil_scoped_acquire gil; |
| 229 | |
| 230 | if (image == nullptr) |
| 231 | { |
| 232 | m_Impl->Dictionary[py::str(varName)] = py::none(); |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | try |
| 237 | { |
| 238 | m_Impl->Dictionary[py::str(varName)] = py::cast(image, py::return_value_policy::reference); |
| 239 | } |
| 240 | catch (const py::error_already_set& e) |
| 241 | { |
| 242 | mitkThrow() << "Could not bind image to Python variable \"" << varName << "\": " << e.what(); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | bool mitk::PythonContext::HasVariable(const std::string &varName) |
| 247 | { |