[Gmsh] Extract mesh info from C++ API classes

David Bernstein david at terafrac.org
Tue Feb 11 17:24:42 CET 2014

Hi Andrea, I wrote some code for the open source project I’m working on that does this, you can find it at


Look in src/gmsh.cpp at the function MakeFrom2DGmshGModel starting on line 195.  If you have any questions please email me and I’ll try to answer them.


On Feb 11, 2014, at 2:38 AM, Sacconi, Andrea <a.sacconi11 at imperial.ac.uk> wrote:

> Hi all GMSH users,
> I would like to ask you a quick question about the usage of the API C++ classes to extract the connectivity of the mesh, once it has been created.
> The setting is a planar mesh of triangles. I managed to create the GModel, passing lines, planar surface and physical entities. So far, so good.
> The problem is, how can I extract how many triangles I have got and their vertices? It seems a silly question, but I am really confused about all the methods I found. What is the method to traverse only the elements and extract their vertices?
> For example, what is the difference between GVertex and MVertex? Same questions for the other geometrical objects ...
> In general, I need to pass the connectivity information to the C++ code I am writing for my thesis simulations.
> Any help would be much appreciated!
> Kind regards,
> Andrea
> __________________________________________________________
> Andrea Sacconi
> PhD student, Applied Mathematics
> AMMP Section, Department of Mathematics, Imperial College London,
> London SW7 2AZ, UK
> a.sacconi11 at imperial.ac.uk
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh