Handle(Geom2d_BSplineCurve) to TopoDS_Edge

Good afternoon,

I have a quick question. Is it possible to convert a "Handle(Geom2d_BSplineCurve) bSpline" to a TopoDS_Edge?

I tried the following:

gp_Pln plane(gp::XOY());
Handle(Geom_Surface) flatSurface = new Geom_Plane(plane);
TopoDS_Edge newEdge = BRepBuilderAPI_MakeEdge(bSpline, flatSurface);

But the resulting edge is always Null.

Am I missing something?

Thanks in advance,

Martijn

gkv311 n's picture

Valid TopoDS_Edge should have 3D curve representation. You may build such curve from 2d curve using tool GeomLib::BuildCurve3d() for instance.

The code snippet based on StdPrs_BRepFont::to3d():

bool to3d (const Handle(Geom2d_Curve)& theCurve2d, const GeomAbs_Shape theContinuity, Handle(Geom_Curve)& theCurve3d)
{
  gp_Pln plane(gp::XOY());
  Handle(Geom_Surface) flatSurface = new Geom_Plane(plane);
  Handle(Adaptor3d_Surface) aSurfAdaptor = new GeomAdaptor_Surface(flatSurface);

  Handle(Geom2dAdaptor_Curve) aCurve2dAdaptor = new Geom2dAdaptor_Curve(theCurve2d);

  Adaptor3d_CurveOnSurface aCurveOnSurf;
  aCurveOnSurf.Load (aSurfAdaptor);
  aCurveOnSurf.Load (aCurve2dAdaptor);

  double aPrecision = Precision::Confusion();
  double aMaxDeviation = 0.0;
  double anAverDeviation = 0.0;
  GeomLib::BuildCurve3d (aPrecision, aCurveOnSurf,
                         aCurve2dAdaptor.FirstParameter(), aCurve2dAdaptor.LastParameter(),
                         theCurve3d, aMaxDeviation, anAverDeviation, theContinuity);
  return !theCurve3d.IsNull();
}
martijn db's picture

Thank you very much, it works!

Martijn

Attachments: