Wed, 02/04/2015 - 16:56
Hello everyone, I try to use the class Adaptor3d_CurveOnSurface to obtain a mapping curve from a 2d curve which is in the parametric domian to a 3d curve which is on the surface.
so the code I written is 按时following:
void TestCurveOnSurface()
{
TopoDS_Shape aShape;
ShapeFromIges(aShape);
Handle(Geom_Surface) aGeomSurface;
SurfaceFromTopo(aShape,aGeomSurface);
GeomAdaptor_Surface aGeomAdapt(aGeomSurface);
Handle(GeomAdaptor_GHSurface) aHGeomAdapt = new GeomAdaptor_GHSurface(aGeomAdapt);
gp_Ax2d anAx2(gp_Pnt2d(10.,10.),gp_Dir2d(1.,0.));
Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(anAx2,5);
Geom2dAdaptor_Curve aCircleAdapt(aCircle);
Handle(Geom2dAdaptor_HCurve) aHCircleAdapt = new Geom2dAdaptor_HCurve(aCircleAdapt);
Adaptor3d_CurveOnSurface aCurveOnSurfaceAdapt(aHCircleAdapt,aHGeomAdapt);
GeomAbs_CurveType aType = aCurveOnSurfaceAdapt.GetType();//the type is GeomAbs_OtherCurve
Handle(Geom_BSplineCurve) aNURBSCurve = aCurveOnSurfaceAdapt.BSpline();//throw an error,no such an object
TopoDS_Edge aTopoNURBSCurve = BRepBuilderAPI_MakeEdge(aNURBSCurve);
Handle(AIS_Shape) anAISNURBSCurve = new AIS_Shape(aTopoNURBSCurve);
myAISContext->Display(anAISNURBSCurve );
}
void ShapeFromIges(TopoDS_Shape& aShape)
{
CFileDialog dlg(TRUE);
if (IDOK != dlg.DoModal())
{
return;
}
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
IGESControl_Reader reader;
Standard_Integer status = reader.ReadFile(aFileName.ToCString());
if (status != IFSelect_RetDone)
{
return;
}
reader.TransferRoots();
aShape = reader.OneShape();
}
void SurfaceFromTopo(TopoDS_Shape& aShape,Handle(Geom_Surface)& aGeomSurface)
{
BRepAdaptor_Surface surface(TopoDS::Face(aShape));
const GeomAdaptor_Surface& geomAdapSurf = surface.Surface();
aGeomSurface = geomAdapSurf.Surface();
}
I also tried to draw the point on the curve,using the method aCurveOnSurfaceAdapt.Value(U); it worked, so I just have no idea how to get the curve.
Thank you!