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

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

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

Samples & Tools

 

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

Adv. Components

Related pages

About Distance between a plant and a line

Tomac's picture
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);
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

Tomac'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