
Thu, 07/27/2023 - 13:58
I used the below code to calculate the projection of a point to a face:
============== code ================
gp_Pnt point(x, y, z);
Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(topoFace));
GeomAPI_ProjectPointOnSurf projection(point, surface, 1e-10);
Standard_Integer num = projection.NbPoints();
Standard_Real D = projection.LowerDistance();
gp_Pnt projPoint = projection.Point(1);
============== code ================
I thought it would be a failure as the original point is outside the face boundary. I mean, the point is not hovering right above the face and I guessed the projection couldn't be done.
However, it did yield a projected point on the face plane, which lies outside the face though.
You can see it from the attached the screenshot.
Is it possible for me to know when the projection exceeds the face boundary?
Thanks a lot.
Thu, 07/27/2023 - 23:13
When you get a surface from the face you actually get the whole surface that does not know anything about face bounds. What you need is to classify the projected 2D point regards the face using the algorithm like BRepClass_FClass2d.
Tue, 08/01/2023 - 05:28
Thank you, Mikhail. It works!