Accessing from python a C++ function that takes a pointer

Viewed 53

I am trying to use a function that requires a pointer to a class.

I get the following error

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

G4TesselledSolid has a function G4bool AddFacet (G4VFacet *aFacet)

G4TriansularFacet class definition has class G4TriangularFacet : public G4VFacet

My Boost class definition looks like

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

My Pythons looks like tessellate = G4TessellatedSolid() tessellate.AddFacet(face)

1 Answers

Thanks for reference was able to resolve by adding bases to definition

 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)
   ;
Related