For all issues regarding the Forums use, please, refer to the Forum Rules.

### Our Solutions

Need professional assistance?
Consider our:

Need to speed up your development?
Have a look at our:

Need some functionality extending standard OCCT capabilities?
Check out our:

# About Distance between a plant and a line

Forums:

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);
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£¡

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

Sergey£¬

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);
gp_Pln thePln2 = theAdaptSurf2.Plane();
Standard_Real distance = thePln2.Distance(point1);
return distance;
////////////////////

thanks a lot