Convert Geom_Curve to Geom2d_Curve

Hi,
I have a Geom_Curve which is DownCasted from an Object and I'm sure the curve lying on the surface. My code as following:
TanShape = Handle(AIS_Shape)::DownCast(myCurrentIC->Current())->Shape();
TanEdge=TopoDS::Edge(TanShape);
Handle(Geom2d_Curve) actCurve;
BRep_ListIteratorOfListOfCurveRepresentation itcr((*((Handle(BRep_TEdge)*)&TanEdge.TShape()))->ChangeCurves());
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
if (cr->IsCurve3D())
{
TanCurve=GC->Curve3D();
Tan2dCurve=GeomProjLib::Curve2d(TanCurve,FaceSur);

First=Tan2dCurve->FirstParameter();
}

I check the data for TanCurve and FaceSur and they are ok, but in the debug mode, I check the value of the entity for "Tan2dCurve" and it is 0xfefd0000 and vfpter is "CXX0030: Error: expression cannot be evaluated".

Who can help me, whether the problem come from the bug of "GeomProjLib" or I can't use the function for the 3D Curve which has already lied on the surface?

Sincerely,
Angel

Sharjith Naramparambath's picture

Hi Angel,
I think the GeomAPI::To2d() and the GeomAPI::To3d() may help you.
Try it out. Best luck.

Sharjith N.

François Lauzon's picture

Hi Angel,
if you are sure your edge is lying on the face, you might want to try extracting the 2d pcurve from the edge instead of iterating on the curve representation, try using BRep_Tool::CurveOnSurface(TanEdge, TanFace,First,Last), it will return you a Geom2d_Curve which is not null if the TanEdge really hold a pcurve lying on your TopoDS_Face TanFace.

Good Luck,
Francois.