Nektar++
Static Public Member Functions | List of all members
vtkObjectPointer_to_python< T > Struct Template Reference

#include <VtkWrapper.hpp>

Static Public Member Functions

static PyObject * convert (const T &p)
 

Detailed Description

template<class T>
struct vtkObjectPointer_to_python< T >

Definition at line 46 of file VtkWrapper.hpp.

Member Function Documentation

◆ convert()

template<class T >
static PyObject * vtkObjectPointer_to_python< T >::convert ( const T &  p)
inlinestatic

Definition at line 48 of file VtkWrapper.hpp.

49 {
50 if (p == NULL)
51 {
52 return py::incref(Py_None);
53 }
54 std::ostringstream oss;
55 oss << (vtkObjectBase *)p; // here don't get address
56 std::string address_str = oss.str();
57
58 try
59 {
60 py::object obj = py::import("vtkmodules.vtkCommonCore")
61 .attr("vtkObjectBase")(address_str);
62 return py::incref(obj.ptr());
63 }
64 catch (py::error_already_set &)
65 {
66 // Clear error to avoid potential failure to catch error in
67 // next try-catch block.
68 PyErr_Clear();
69 }
70
71 try
72 {
73 py::object obj =
74 py::import("vtk").attr("vtkObjectBase")(address_str);
75 return py::incref(obj.ptr());
76 }
77 catch (py::error_already_set &)
78 {
80 throw NekError("Unable to import VTK.");
81 }
82
83 return py::incref(py::object().ptr());
84 }
Nektar::ErrorUtil::NekError NekError

References CellMLToNektar.cellml_metadata::p.