normals at vertices

I have a shell (connected faces).
I need to compute normals(say gp_Dir) at each of the vertices.
Any piece of code which is optimized for performance too.


- PG

Francesco Argese's picture


have you resolved the problem?

I also need to compute normals at each of the vertices from triangulation.

I have tried in these ways without great results:
1) Using method HasNormals of Poly_Triangulation class:
Handle(Poly_Triangulation) aTri = BRep_Tool::Triangulation(static_cast(face), aLocation);
if( aTri.IsNull() )
std::cout << "Error tessellating!!!" << std::endl;
return false;
for(int i = 1; i < aTri->Normals().Length()+1; i=i+3)

aTri->HasNormals() give me always false. Is there a manner to force OpenCascade to calculate normals? Is it enabled only for some cad formats? I'm working with iges at the moment.

2) Following another post on this forum [1] i have tried to calculate normals (one for every triangle) but some normals seems reversed and reversing all when orientation is TopAbs_REVERSED doesn't resolve the problem (see attachment).

3) Has someone any suggestion to do the same thing using other functions? For example using (u, v) surface representation utilities [2]?

4) I think that presentation module of OpenCascade must calculate these normals somewhere. Could you give me some hints on how to find some pieces of code doing this?

Thanks in advance.

Francesco Argese


Francesco Argese's picture

Hi all,

I have resolved my problem adapting this code (found in [1]) to my needs:

* Compute normal of vertex on a surface

void ComputeNormal(const BRepAdaptor_Surface& SF,
gp_Pnt& V1,
gp_Pnt2d& V1_2d,
gp_Vec &Normal)
gp_Vec T1,T2;
// Compute normal
Normal = T1.Crossed(T2);
Standard_Real x = Normal.Magnitude();
if (x > 1.e-10)
else {
cout << "Null normal"<< endl;

* Add a vertex with normal for strip algo

void AddVertex(int N1,
const BRepAdaptor_Surface& SF,
const TColgp_Array1OfPnt& Nodes,
const TColgp_Array1OfPnt2d& UVNodes,
Standard_Boolean identity,
gp_Trsf myTransf)
gp_Pnt V1 = Nodes(N1);
if(!identity) V1.Transform(myTransf);
gp_Vec Normal(0,0,0);
gp_Pnt2d P = UVNodes(N1);
// Here normal is correcly computed

It works well! :-)

Francesco Argese