I am trying to use OpenCascade to build a mesh (OpenMesh) from an IGES-file.
My first try was to mesh the imported shape with BRepMesh_IncrementalMesh or BRepMesh_Discret.
In both triangulations there were wrong normals.
I dont see any errors in OpenCascade, but when I export the mesh to OpenMesh, it sais there are complex edges.
This means there are edges that have 3 neighbouring faces.
In my second attempt I wrote an STL-File with StlAPI_Writer and imported the stlfile to OpenMesh with the included stl-reader.
The effect was the same. I guess StlAPI_Writer uses the triangulation created by BRepMesh.
I dont really know what is wrong here.
Searching this forum I noticed there are many problems with normals in triangulations from IGES files, so I guess this is the problem.
Does anyone know how to fix the wrong normals?
Best regards,
Matthias
Matthias Teich
2008/03/13 11:19
I forgot to mention that I already use shapehealing to sew faces.
Everything seems to be fine when I use STEP files instead.
Matthias Teich
2008/03/13 11:23
Oh, fine was exaggerated. Lets say its better :(
Zettler
2008/03/13 11:40
Hi Matthias,
check the Face Orientation. If the Orientation is different between different faces then also the normals of the mesh you generate will point to the wrong side.
I did quite a lot of mesh stuff with OCC and this was the way I used to solve that problems.
Take care,
dvdjimmy
Matthias Teich
2008/03/13 14:34
Hello,
thanks for your answer.
Can you elaborate a bit on this?
and then I check its orientation with
if(F.Orientation() = TopAbs_REVERSED )
//add vertices counterclockwise to the Openmesh Datastructure
else
//add vertices clockwise
Then Openmesh calculates the normal by itself.
Do you mean I should set the orientation of each face to either Reversed or Forward?
Best Regards,
Matthias
Matthias Teich
2008/03/13 14:55
I just tried it, the normals are also messed up when all TopoDS_faces have the same orientation :(
Zettler
2008/03/13 15:04
You can invert them to a specific direction if a certain treshold value is reached. For example if 60% of the normals show in one direction you can use this direction as the "guiding" direction and invert all the other triangle normals as well.
Before we do it like that we check the orientation agains 0,0,1 and then decide to which direction we invert the normals.
dvdjimmy
Matthias Teich
2008/03/16 17:57
I played a bit with the triangulation of OpenCascade and I came to the conclusion that the normals are not the problem.
I am not sure if this is your problem, but you are not accounting for the face location in your triangulation. It is possible that 2 faces share the same triangulation but one is a transformed version of the other. Your points need to be transformed as well:
thanks for your hint.
I just modified my code in the way you proposed.
The problem seems to be somewhere else, nothing changed :(
Now I use Netgen as a mesh generator, but nevertheless it would be interesting to know why the code did not work.
So if anyone has an idea..please let me know.