# creating a 3d curve from a (2d) curve on surface

Hi all and thanks for the answers in this forum.

I have a bounded Geom2d_Curve on a Geom_Surface and I need to create the corresponding (3d) Geom_Curve.
Now I am using ShapeFix_Edge::FixAddCurve3d(), but I discovered that it has no specialization on the type of surface and curve, it always uses an approximation algorithm.
E.g., given a horizontal line segment in the domain of a cylinder, it does not create a Geom_Circle, but an approximate Geom_BSplineCurve!
Is there any other function with specialized treatment of planes, cylinders, etc. ?

Thanks a lot.
Mauro

try this and let me know if it does produce a canonical shape.... i would use an adaptor afterwards to check if its a circle or ellipse or straight line,etc .

this is how you wrap a 2d curve onto a surface, the equivalent of the rhino command applyuvcurve, or the CATIA fold curve(except this only works on a developable surface).

gp_Ax2 xoy2 = gp::XOY();
gp_Ax3 xoy3(xoy2);
gp_Pln xypln(xoy3);

Handle_Geom_Surface mysurf = (... your surface...)
TopoDS_Shape curshape = (... your 2d curve as a topods_shape ...)
double aFP, aLP;
TopoDS_Edge intedge = TopoDS::Edge(curshape);

BRepLib::BuildCurves3d(intedge);

Handle_Geom2d_Curve the2dcurve;
aCurve = BRep_Tool::Curve(intedge, aFP, aLP);
the2dcurve = GeomAPI::To2d(aCurve,xypln);

TopoDS_Edge aEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(the2dcurve , mysurf);
BRepLib::BuildCurves3d(aEdge1OnSurf1);
TopoDS_Edge &edge3d = TopoDS::Edge(aEdge1OnSurf1);
TopoDS_Shape theShape = edge3d;

Best,

AlexP

Thank you, Alex.
I am sorry for replying so late, but I received no authomatic message in my mailbox.

I have looked inside BRepLib::BuildCurves3d() and it seems to me that it always creates a B-Spline surface, except when the surface is a plane.

I also do not understand the aim of your code after
BRepLib::BuildCurves3d(intedge);

Thanks again.
Mauro