I have some C++ code that generates meshes from step files and then analyses these meshes for visibility of the faces from different viewing directions. I currently use CGAL but I would like to switch over to using gmsh for my meshing. The problem I'm encountering is that gmsh doesn't mesh flat cylindrical faces well, it makes some of the faces indented, which messes up my visibility analysis.

I've looked at the gmsh docs and played around with its settings but I've not been able to fix this. The step file I'm using is: io1-cm-214.stp.

The part using my old meshing library: enter image description here

The part using gmsh, showing the strange indented cylindrical faces in the central hole of the part: The failing faces in the central hole of this part.

Any help would be appreciated.


1 Answer 1


I think you need to know that when you discretize a volume by using tetrahedral meshes, you will get just an approximation of your perfect surfaces because of triangulation.

You started with STEP file format, which is NOT a mesh format, but it's a CAD format. The difference between CAD formats and mesh formats is that CAD formats like STEP, IGES, SAT, etc. shows the topology of your manifolds and if you create a cylinder for example in SolidWorks or CATIA, which I assume you used these softwares or at least similar ones to create your STEP file, they show you a perfect cylinder without imperfection, such as the ones that you see here.

On the other hand, mesh formats like STL, MSH, VTP, etc. approximate manifolds by tiny triangles (or for volumes by tiny tetrahedrals but you see just the triangles at the surface). As a result, no matter how you refine your mesh size, always there would be some tiny or minuscule imperfections there. At some point, the renderer may not show it to you, which I would put some example at the end, but you need to know that still those imperfections caused by approximating a surface by tiny triangles are there.

Now, let's look at some simple example of cylinder. I would create a cylinder in ParaView but changing the resolution I could make it appear so smooth to you but the imperfections, no matter how tiny, still are there:

First imperfect cylinder created by ParaView:

enter image description here

Now, let's increase the resolution and see what would happen here:

enter image description here

See, for a higher resolution, you barely can notice the imperfections but still they are there.

So conclusion: If you think that imperfections that you see are harmful for your further processes like simulations probably, you need to refine your mesh to get a better approximation of your surfaces.

  • $\begingroup$ Great, thanks for your detailed answer and explanation it's very helpful. I'll add some more refinement to my mesh. $\endgroup$ Oct 22, 2019 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.