- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Using SOFA › [SOLVED] reversing the direction of mesh normals and changing their color
Tagged: 64_bits, Linux_ubuntu, SOFA_1806
Hi,
I hope every body is fine. In the runSofa window, the vertex normals of a volumetric model are showing inside the volume. Is there any way I can reverse their direction for a better representation?
How can I change their color to make them visible in white background?
Best wishes,
Zahra
Hi @zahra
Yes please look at the option flipNormals in MeshLoaders and in TetrahedronSetGeometryAlgorithms. But it depends on the code. Let me know if it works for you.
The color of the normals depends on which class draws them. If the OglModel does, you can have a look at OglModel.cpp (line 577), color is white. Same for TriangleModel (CollisionModel). Only the TriangleSetGeometryAlgorithms (line 2493) changes the color depending on the orientation. I hope this helps.
Best,
Hugo
Dear Hugo,
Setting the option “flipNormals” in MeshLoaders and TetrahedronSetGeometryAlgorithms and TriangleSetGeometryAlgorithms to 1 didn’t change the direction of normals. What do you mean that it depends on the code?
As an example, here is my code and mesh files:
https://gist.github.com/zbounik/c2c78c87de97d7ad0d7b1cc983d72f6d
Thank you for your guidance in advance,
Zahra
Hi @zahra
What I meant is that depending on which component does the flip of normals, different functions will be called (Loader, GeometryAlgorithms). Usually loaders can do it, but it’s always better to give as input of a MeshLoader a mesh with the good orientation.
As said above, some loaders have this flipNormals option working (VTK, Obj for instance). But the Gmsh does not. I will make a pull-request in this direction. It will be available in a few days in the master branch of SOFA.
Best,
Hugo
Dear Hugo,
Thank you for your kind explanation. I’m looking forward for the working flipNormals Gmsh loader. Meanwhile I will try to use Obj loader for the representation of Normals.
Best,
Zahra
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.