从Python访问一个带有Pin的C++函数

2024-04-20 03:36:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用一个需要指向类的指针的函数。你知道吗

我得到以下错误

<class 'Boost.Python.ArgumentError'>: Python argument types in
    G4TessellatedSolid.AddFacet(G4TessellatedSolid, G4TriangularFacet)
did not match C++ signature:
    AddFacet(G4TessellatedSolid {lvalue}, G4VFacet*)

G4TesselledSolid有一个函数 G4bool添加面(G4VFacet*aFacet)

G4TrianSuraFacet类定义 G4TriangularFacet类:公共G4VFacet

我的Boost类定义如下

class_<G4TessellatedSolid, G4TessellatedSolid*, boost::noncopyable>
         ("G4TessellatedSolid", "solid class")
 // ---
       .def("AddFacet",       &G4TessellatedSolid::AddFacet)
 // operators
       .def(self == self)
       ;

我的Python看起来像 镶嵌=G4TessellatedSolid() 镶嵌.AddFacet(脸)


Tags: 函数self定义def错误argumentclass指向
1条回答
网友
1楼 · 发布于 2024-04-20 03:36:17

感谢您的参考,我们可以通过在定义中添加基础来解决问题

 class_<G4VFacet, G4VFacet*, boost::noncopyable>
    ("G4VFacet", "solid class", no_init)
    //  -
    .def("SetVertex",      &G4TriangularFacet::SetVertex)

    // operators
    .def(self == self)
    ;

 class_<G4TriangularFacet, bases<G4VFacet> , boost::noncopyable>
   ("G4TriangularFacet", "solid class")
   //  -
   .def("SetVertex",      &G4TriangularFacet::SetVertex)

   // operators
   .def(self == self)
   ;

相关问题 更多 >