About Distance between a plant and a line

hi everyone £¬
i want to compute the distance between a plant and a line

/////////////////////////
gp_Ax1 axis = GetAxis(aface1);
gp_Lin line1=gp_Lin(axis);
TopLoc_Location loc;
Handle(Geom_Surface) theSurf2 = BRep_Tool::Surface(aface2, loc);
GeomAdaptor_Surface theAdaptSurf2(theSurf2);
gp_Pln thePln2 = theAdaptSurf2.Plane();
Standard_Real distance = thePln2.Distance(line1);
return distance;
/////////////////////////////

the proble is £¬the distance always return 0 £¡£¡

who can help me£¿
what is the problem£¿

thank you very much£¡

sergey zaritchny's picture

Hi,
Problems can be different.
Try to locate it.
1) visualize both (or dump coordinates of both) to check that they are not coincident
2) if you are friendly with Draw environment use, please, command , which reports distance between shapes. Or check the command implementation and use obtained knowledge in your own example.
Good luck
Sergey

ilovrene's picture

Sergey£¬
thank you for your advice.

i solved the problem

////////
gp_Ax1 axis = GetAxis(aface1);
//gp_Lin line1=gp_Lin(axis);
gp_Pnt point1=axis.Location();
TopLoc_Location loc;
Handle(Geom_Surface) theSurf2 = BRep_Tool::Surface(aface2, loc);
GeomAdaptor_Surface theAdaptSurf2(theSurf2);
gp_Pln thePln2 = theAdaptSurf2.Plane();
Standard_Real distance = thePln2.Distance(point1);
return distance;
////////////////////

thanks a lot