[Gmsh] Not all mesh elements are being drawn using API

phillip mobley phillipmobley2 at gmail.com
Mon Jan 8 04:48:57 CET 2018


Hello all,

I have a version of gmsh (3.0.4) almost fully integrated into my
applciation. I have the source code directly in the project and I am not
using gmsh as a library/

Anyways, I am not sure if I discovered a bug in the source code or if I am
doing something incorrectly. Either way, I would like to get to the bottom
of this. After I generate a mesh, I call this
function(p_meshModel->indexMeshVertices(true);) in order to index all of
the mesh indicies to prepare the model for me to access the mesh elements.

I need to access this data so that I can display the final mesh onto the
screen for the user to see. I am doing this rather simply since I am
working with OPENGL. Once the mesh is generated and indexed, I access the
mesh elements by the tags. I have pasted the code snippet that I use to
access the mesh elements

        p_modelMesh->getEntities(entityList, 4);

        glBegin(GL_LINES);
            int numOfElements = 0;
            for(unsigned int i = 0; i < entityList.size(); i++)
            {
                int temp = entityList[i]->getNumMeshElements();
                for(unsigned int j = 0; j <
entityList[i]->getNumMeshElements(); j++)
                {
                    numOfElements++;
                    int test =
entityList[i]->getMeshElement(j)->getNumVertices() - 1;
                    for(unsigned int k = 0; k <
entityList[i]->getMeshElement(j)->getNumVertices() - 1; k++)
                    {

glVertex2d(entityList[i]->getMeshElement(j)->getVertex(k)->x(),
entityList[i]->getMeshElement(j)->getVertex(k)->y());

glVertex2d(entityList[i]->getMeshElement(j)->getVertex(k + 1)->x(),
entityList[i]->getMeshElement(j)->getVertex(k + 1)->y());
                    }
                }
            }

Now, the error that I am seeing is that not all of the mesh elements are
drawn on the screen. However, if I were the export the mesh as a VTK file,
all of the mesh elements are exported properly.

So I was wondering, what is the proper method for accessing the mesh
elements for drawing on the screen? Is what I have correct and I discovered
a bug in the code (If so, I can help with properly recording it with
examples and what not). Or, is there a more robust method that I should be
using?

Thank you and any help will be appricated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20180107/ab2c02d3/attachment.html>


More information about the gmsh mailing list