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();
}