Normal vector of a Face or Surface

Hi again!

How can I easily calculate the direction of the normal to a TopoDS_Face or Geom_Surface?

Rob Bachrach's picture

Look at GeomLProp_SLProps::Normal. This requires you to set the location at which you require the normal using U,V parameters on the surface. You can use BRep_Tool::Surface to get the surface for a face and BRepTools::UVBounds to get the parametric limits on the surface.

Udo's picture

Thank you!

Here is the result:
TopoDS_Face aCurrentFace = [..];
Standard_Real umin, umax, vmin, vmax;
BRepTools::UVBounds(aCurrentFace,umin, umax, vmin, vmax);
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aCurrentFace);
GeomLProp_SLProps props(aSurface, umin, vmin,1, 0.01);
gp_Dir normal = props.Normal();

merve's picture

does one surface have only one vector?
i think planes have only one vector?
am i wrong?

jelle's picture

yes a single vector

merve's picture

but a surface can be something like this
http://t3.gstatic.com/images?q=tbn:ANd9GcTZmX6H8E2ZAKCdS2o2HOIZ_rCC8iDiJ...

am i wrong, am i wrong with the concept of "surface"?

a surface like the one at the pic has lots of tangent planes, thus surface should have lots of normals?

merve's picture

http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Surface_normal....

one surface must have a set of normals, must have one normal for its every point.

jelle's picture

there is an infinity of normals on a brep / nurbs surface, since the set of possible points is endless.
the wiki image is that of a mesh, which is a discrete representation of a surface, hence with finite normals.
so its a little confusing.
as mentioned before, you can lookup the normals of the surface for every u,v position.
really easy...

merve's picture

thanks