Reading normals of triangles from STL

Greetings,

I'm currently reading an stl file with:

RWStl::ReadAscii(OSD_Path(stlfilepath.c_str()));

In my Stl file, each facet is described by three poitns and a normal:

facet normal 0.000000e+00 -0.000000e+00 -1.000000e+00
   outer loop
     vertex 3.838308e-02 4.185656e-04 -9.486067e-02
     vertex 3.838923e-02 4.216301e-04 -9.486067e-02
     vertex 3.837746e-02 3.022011e-04 -9.486067e-02
   endloop
 endfacet

This file was also exported by OpenCascade.

How could I read the normals of each facet too?

Kirill Gavrilov's picture

Normals in STL file are meaningless in most cases - either they just define normal to triangle
(which can be trivially computed from triangle nodes) or haven't written at all (some STL exporters write zeros here).
I wouldn't rely on this information in STL file.
 

Pranav's picture

The normals can be trivially computed of course but, my problem is to distinguish between the inside and outside of the geometry. Thus, if the normals are facing outwards (by export from OpenCascade) or inwards, I could use that information. I'm currently using OCCT 7.2.0. Is there a way I could compute that information ?

Best Regards,
Pranav

PG's picture

Loop through the vertices and normals of each triangle in domain 

of the STL mesh using StlMesh_Explorer class and its functions. 

Kirill Gavrilov's picture

> of the STL mesh using StlMesh_Explorer class and its functions. 
These are not part of Open CASCADE Technology since OCCT 7.2.0.