How to extract the correctly oriented normal on a face at one point. : GeomLProp_SLProps & TopoDS_Iterator

Hello,

What I am currently doing is the following:

BRepAdaptor_Surface surface1(face);
auto dir1 = surface.Face();
GeomLProp_SLProps props1(surface.Surface().Surface(), midPoint.X(), midPoint.Y(), 1, 1e-6);
gp_Vec normal1 = props1.Normal();

The returned normal is not oriented correctly (I am expecting it to always being point outside because this is a closed shell)

Reversing the normal using the face.Orientation() does not help (my faces are all TopAbs_REVERSED).

I had the impression I did not get the correct orientation of the face so I tried with

TopoDS_Iterator iterator to iterate over all elements in the body
TopoDS_Iterator iterator(_shape.Oriented (TopAbs_FORWARD),true,true);

But I am still not able to figure out the way to correctly get the normal for the face.

Any idea ?

Mark

Dmitrii Pasukhin's picture

Hello, the main hidden limitation for any BRepAdaptor is ignore orientation of the input objects. It is recommended to check only force forward objects. And process orientation of BRepAdaptor classes in external code by yourself. For example in you case, you need to process the face and its surface as forward and revert the normal in case if orientation is not same. (Please be careful with points on surface in that moment). And additionally, please check the surface is not null, some faces can contains only mesh with no surface (if you have no check before or limits on your input).

Best regards, Dmitrii.