Create displayable shape from Geom_BezierSurface

I am trying to figure out how to create a displayable shape (eg, AIS_Shape) from a Bezier surface but cannot seem to determine the right sequence.  Here is my code snippet of the surface creation:

    Handle(Geom_BezierCurve) bc3 = new Geom_BezierCurve(pntArray3,whtArray3);
    Handle(GeomFill_BezierCurves) bcFill = new GeomFill_BezierCurves(bc1, bc2, bc3, GeomFill_CurvedStyle);
    Handle(Geom_BezierSurface) bzSurf = bcFill->Surface();
This throws no errors. At this point I would have thought that some form of BRepBuilderAPI_MakeFace() would work to give me a face:
 TopoDS_Face bzFace = BRepBuilderAPI_MakeFace(bzSurf);
 TopoDS_Face bzFace = BRepBuilderAPI_MakeFace(bzSurf,1E-07);

But I get an error regarding no candidate constructor.  Any pointer?  Am I missing something obvious?


Walter Rhoden's picture

So I finally sorted out the problem or at least the solution.  The errors were likely due to incorrect combinations of pointers and references.  I'm still not completely clear on some of this as the errors can sometimes be pretty obscure and I am still a c/c++ novice.  Regardless, this code works to give be a displayable face.  If anyone has suggestions on how to make this better, please comment.  Thanks.

    // Bezier surface attempt from three bezier curves
    // Arrays of points and weights for each curve
    TColgp_Array1OfPnt pntArray1(1,3);
    pntArray1.SetValue(1,gp_Pnt(2.0, 0.0, 4.1231056));
    pntArray1.SetValue(2,gp_Pnt(1.1094, 2.496151, 4.1231056));
    pntArray1.SetValue(3,gp_Pnt(0.0, 3.0, 4.1231056));
    TColStd_Array1OfReal whtArray1(1,3);
    Handle(Geom_BezierCurve) bc1 = new Geom_BezierCurve(pntArray1,whtArray1);
    TColgp_Array1OfPnt pntArray2(1,3);
    pntArray2.SetValue(1,gp_Pnt(0.0, 3.0, 4.1231056));
    pntArray2.SetValue(2,gp_Pnt(1.0, 0.0, 1.722964));
    pntArray2.SetValue(3,gp_Pnt(0.0, 0.0, 1.0));
    TColStd_Array1OfReal whtArray2(1,3);
    Handle(Geom_BezierCurve) bc2 = new Geom_BezierCurve(pntArray2,whtArray2);
    TColgp_Array1OfPnt pntArray3(1,3);
    pntArray3.SetValue(1,gp_Pnt(0.0, 0.0, 1.0));
    pntArray3.SetValue(2,gp_Pnt(1.0, 0.94846, 0.0));
    pntArray3.SetValue(3,gp_Pnt(2.0, 0.0, 4.1231056));
    TColStd_Array1OfReal whtArray3(1,3);
    Handle(Geom_BezierCurve) bc3 = new Geom_BezierCurve(pntArray3,whtArray3);
   GeomFill_BezierCurves bcFill;
   bcFill.Init(bc1, bc2, bc3, GeomFill_CurvedStyle);
    TopoDS_Face bzFace = BRepBuilderAPI_MakeFace(bcFill.Surface(), 1e-6);
    Handle(AIS_Shape) bzShape = new AIS_Shape(bzFace);