Convert IGES to NURBS

Hello,

I am trying to use Open CASCADE to convert a IGES file to a NURBS representation. From what I understand, I have to use the IGESControl_Reader and somehow get a GESGeom_BSplineSurface, from where I can extract the parameters I need.

The problem I have is that I'm not sure how to call the IGESToBRep_BasicSurface::TransferBSplineSurface function. I want to convert the whole shape I have in the file, so this is what I'm doing now:

IGESControl_Reader reader;
IFSelect_ReturnStatus stat = reader.ReadFile("model.IGS");

Standard_Integer trans_roots = reader.TransferRoots();
Standard_Integer nbs = reader.NbShapes();

TopoDS_Shape shape = reader.OneShape();

auto basic_surface = new IGESToBRep_BasicSurface();
auto bspline = basic_surface->TransferBSplineSurface(shape);

Of course, that doesn't even compile because the type of shape is not what the TransferBSplineSurface function expects.

I have also tried with getting entities in the following way:

auto entities_handler = reader.GiveList("xst-model-roots");
auto entities = entities_handler.get();

auto bspline = x->TransferBSplineSurface(entities[0]);

But still doesn't work.

Any ideas on how can I make it work?

Thanks!